From 7076850699cd44fd7a63dcac61e43adbbc7dab25 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Thu, 20 Mar 2025 17:42:15 +0800 Subject: [PATCH 001/140] =?UTF-8?q?=E6=84=8F=E5=9B=BE=E6=8F=92=E4=BB=B6ini?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/Intent_Logger.ts | 94 ++++++ .../ets_ui/rollup-plugin-ets-typescript.ts | 13 +- compiler/src/parse_Intent.ts | 295 ++++++++++++++++++ compiler/src/pre_define.ts | 1 + compiler/src/process_ui_syntax.ts | 30 +- 5 files changed, 427 insertions(+), 6 deletions(-) create mode 100644 compiler/src/Intent_Logger.ts create mode 100644 compiler/src/parse_Intent.ts diff --git a/compiler/src/Intent_Logger.ts b/compiler/src/Intent_Logger.ts new file mode 100644 index 000000000..277b990aa --- /dev/null +++ b/compiler/src/Intent_Logger.ts @@ -0,0 +1,94 @@ +import {getLogger} from 'log4js'; + +type ErrorCode = string; +type ErrorDescription = string; + +/** + * 日志工厂类(用于创建标准化的 LogData) + */ +export class LogDataFactory { + static newInstance( + code: ErrorCode, + description: ErrorDescription, + details: string + ): LogData { + return new LogData(code, description, details); + } +} + +/** + * 日志数据实体类 + */ +class LogData { + code: string; + description: string; + cause: string; + constructor( + code: ErrorCode, + description: string, + cause: string = '' + ) { + this.code = code; + this.description = description; + this.cause = cause; + } + + toString(): string { + let errorString = `ERROR Code: ${this.code} ${this.description}\n`; + + if (this.cause) { + errorString += `Error Message: ${this.cause}`; + errorString += '\n\n'; + } + + return errorString; + } +} + +export class IntentLogger { + private static instance: IntentLogger; + private logger: Object = getLogger('ETS'); + static getInstance(): IntentLogger { + if (!IntentLogger.instance) { + IntentLogger.instance = new IntentLogger(); + } + return IntentLogger.instance; + } + + info(...args: string[]): void { + this.logger.info(...args); + } + + debug(...args: string[]): void { + this.logger.debug(...args); + } + + warn(...args: string[]): void { + this.logger.warn(...args); + } + + error(...args: string[]): void { + this.logger.error(...args); + } + + /** + * 处理结构化错误数据(适配原始 printError 方法) + * @param error LogData 实例或原始错误字符串 + */ + printError(error: LogData | string): void { + if (typeof error === 'string') { + this.logger.error(error); + } else { + this.logger.error(error.toString()); + } + } + + /** + * 处理致命错误(简化版直接抛出异常) + * @param error LogData 实例或错误字符串 + */ + printErrorAndExit(error: LogData | string): never { + const message = typeof error === 'string' ? error : error.toString(); + throw new Error(message); + } +} diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index e1c3280f9..a639596d0 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -91,6 +91,7 @@ import { checkHasKeepTs, resetKitImportLog } from '../../process_kit_import'; +import parseIntent from '../../parse_Intent'; import { resetProcessComponentMember } from '../../process_component_member'; import { collectReservedNameForObf, @@ -210,6 +211,12 @@ export function etsTransform() { } }, afterBuildEnd() { + const cacheSourceMapPath = path.join(projectConfig.aceProfilePath, 'test.json'); + fs.writeFile(cacheSourceMapPath, JSON.stringify(parseIntent.intentData, null, 2), 'utf-8', (err) => { + if (err) { + console.error('lmz fail'); + } + }); // Copy the cache files in the compileArkTS directory to the loader_out directory if (projectConfig.compileHar && !projectConfig.byteCodeHar) { for (let moduleInfoId of allModuleIds.keys()) { @@ -373,7 +380,7 @@ async function transform(code: string, id: string) { const result: ts.TranspileOutput = ts.transpileModule(newContent, { compilerOptions: compilerOptions, fileName: id, - transformers: { before: [processUISyntax(null)] } + transformers: { before: [processUISyntax(globalProgram.program)] } }); resetCollection(); @@ -454,7 +461,7 @@ async function transform(code: string, id: string) { tsProgram.emit(targetSourceFile, writeFile, undefined, undefined, { before: [ - processUISyntax(null, false, compilationTime, id), + processUISyntax(tsProgram, false, compilationTime, id), processKitImport(id, metaInfo, compilationTime, true, lazyImportOptions), collectReservedNameForObf(this.share.arkProjectConfig?.obfuscationMergedObConfig, shouldETSOrTSFileTransformToJSWithoutRemove(id, projectConfig, metaInfo)) @@ -470,7 +477,7 @@ async function transform(code: string, id: string) { undefined : targetSourceFile, undefined); transformResult = ts.transformNodes(emitResolver, tsProgram.getEmitHost?.(), ts.factory, tsProgram.getCompilerOptions(), [targetSourceFile], - [processUISyntax(null, false, compilationTime, id), + [processUISyntax(tsProgram, false, compilationTime, id), processKitImport(id, metaInfo, compilationTime, false, lazyImportOptions), collectReservedNameForObf(this.share.arkProjectConfig?.obfuscationMergedObConfig, shouldETSOrTSFileTransformToJSWithoutRemove(id, projectConfig, metaInfo))], false); diff --git a/compiler/src/parse_Intent.ts b/compiler/src/parse_Intent.ts new file mode 100644 index 000000000..e9678e097 --- /dev/null +++ b/compiler/src/parse_Intent.ts @@ -0,0 +1,295 @@ +import ts from 'typescript'; + +type StaticValue = string | number | boolean | null | undefined | StaticValue[] | { [key: string]: StaticValue }; + +interface Params { + decoratorFile : string; + decoratorClass : string; + decoratorType : string; + intentName: string; + domain: string; // 根据实际需求定义具体类型 + displayName : string; + displayDescription : string; + llmDescription : string; + uri : string; + params : object[]; +} + +const requiredFields: (keyof Params)[] = ['intentName', 'domain', 'uri', 'displayName']; +const allowedFields = new Set([ + 'decoratorFile', 'decoratorClass', 'decoratorType', 'intentName', + 'domain', 'displayName', 'displayDescription', 'llmDescription', 'uri', 'params' +]); + +class ParseIntent { + constructor() { + this.intentData = []; + } + checker: ts.TypeChecker; + intentData: any[]; + + handleIntent(node: ts.ClassDeclaration, checker: ts.TypeChecker, path : string) { + this.checker = checker; + node.modifiers.forEach(decorator => { + const originalDecortor: string = decorator.getText().replace(/\(.*\)$/, '').trim(); + if (originalDecortor === '@InsightIntentLinkDecorator') { + const expr = decorator.expression; + if (ts.isCallExpression(expr)) { // 判断是否为装饰器调用(如 @Intent()) + const args = expr.arguments; // 提取参数列表(如 ['aaa', 'bbb']) + const decoratorClass = node.name.text; + const decoratorType = "InsightIntentLinkDecorator"; + this.analyzeDecoratorArgs(args, path, decoratorClass, decoratorType); + } else { + console.error('非调用形式'); + } + } + }); + } + + /** + * 判断符号是否为编译期常量 + * @param symbol 要检查的符号 + * @param checker TypeScript 类型检查器 + */ + isSymbolConstant(symbol: ts.Symbol): boolean { + const declaration = symbol.valueDeclaration; + + // 1. 必须是 const 声明的变量 + if (!this.isConstVariable(declaration)) { + return false; + } + + // 2. 获取初始值表达式 + const varDecl = declaration as ts.VariableDeclaration; + const initializer = varDecl.initializer; + + // 3. 初始值必须是编译时可确定的常量表达式 + return initializer ? this.isConstantExpression(initializer) : false; + } + + /** + * 检查变量声明是否为 const 声明 + */ + isConstVariable(node: ts.Node | undefined): node is ts.VariableDeclaration { + if (!node || !ts.isVariableDeclaration(node)) { + return false; + } + + // 获取父级 VariableDeclarationList 的 const 标志 + const varList = node.parent; + return ts.isVariableDeclarationList(varList) && + (varList.flags & ts.NodeFlags.Const) !== 0; + } + + /** + * 递归验证表达式是否为常量 + */ + isConstantExpression(node: ts.Node): boolean { + // 字面量直接通过 + if (ts.isLiteralExpression(node)) { + return true; + } + + // 标识符(变量)需指向常量 + if (ts.isIdentifier(node)) { + const symbol = this.checker.getSymbolAtLocation(node); + return symbol ? this.isSymbolConstant(symbol) : false; + } + + // 数组字面量需所有元素为常量 + if (ts.isArrayLiteralExpression(node)) { + return node.elements.every(element => this.isConstantExpression(element)); + } + + // 5. 对象字面量需所有元素为常量 + if (ts.isObjectLiteralExpression(node)) { + return node.properties.every(property => { + // 处理普通属性赋值 (key: value) + if (ts.isPropertyAssignment(property)) { + // 检查属性名(如果是计算属性名需递归) + const nameIsConst = !ts.isComputedPropertyName(property.name); // 非计算属性名直接通过(如字符串、数字字面量)/ 不允许计算属性 + + // 检查属性值 + return nameIsConst && this.isConstantExpression(property.initializer); + } + + // 拒绝其他形式(如方法、getter/setter) + return false; + }); + } + + // 其他类型(如函数调用、动态表达式)直接拒绝 需要抛出编译错误方式参考@sendable,我们自己新建一个报错类 + return false; + } + + // -------------------------- + // 2. 校验必选参数是否缺失 + // -------------------------- + validateRequiredParameters( + node: ts.ObjectLiteralExpression, + requiredFields: (keyof Params)[] + ) { + // 从 AST 节点提取所有有效参数名 + const existingParams = new Set(); + + for (const prop of node.properties) { + if ( + ts.isPropertyAssignment(prop) && // 仅处理普通属性赋值 + ts.isIdentifier(prop.name) && // 仅处理标识符作为属性名 + allowedFields.has(prop.name.text) // 验证是否为合法参数名 + ) { + existingParams.add(prop.name.text as keyof Params); + } + } + + // 检查必选参数 + const missingFields = requiredFields.filter(f => !existingParams.has(f)); + if (missingFields.length > 0) { + throw Error(`[Error] 缺少必选参数: ${missingFields.join(', ')}\n + + 节点位置: ${node.getStart()}~${node.getEnd()}`).message; + } + } + +// -------------------------- +// 3. 校验参数类型 +// -------------------------- + validateParameterTypes( + node: ts.ObjectLiteralExpression, + typeValidators: Record boolean> + ) { + node.properties.forEach(prop => { + if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) return; + + const paramName = prop.name.text as keyof Params; + const validator = typeValidators[paramName]; + + if (validator && !validator(prop.initializer)) { + throw Error(`[Error] 参数类型错误: "${paramName}"`).message; + } + }); + } + + analyzeDecoratorArgs(args: ts.NodeArray, path : string, decoratorClass:string, decoratorType:string) { + args.forEach(arg => { + // 做参数检查 + const symbol = this.checker.getSymbolAtLocation(arg); + const declaration = symbol?.valueDeclaration; + this.validateRequiredParameters(declaration.initializer, requiredFields); + const res = this.parseStaticObject(arg); + let intentObj = {}; + Object.assign(intentObj, { + 'decoratorFile': path + }); + Object.assign(intentObj, { + 'decoratorClass': decoratorClass, + }); + Object.assign(intentObj, { + 'decoratorType': decoratorType + }) + Object.assign(intentObj, res) + this.intentData.push(res); + console.log(JSON.stringify(this.intentData, null, 2)); + }); + } + + parseStaticObject(node: ts.Node): StaticValue | undefined { + if (ts.isStringLiteral(node)) { + return node.text; + } + if (ts.isNumericLiteral(node)) { + return parseFloat(node.text); + } + if (node.kind === ts.SyntaxKind.TrueKeyword) { + return true; + } + if (node.kind === ts.SyntaxKind.FalseKeyword) { + return false; + } + if (node.kind === ts.SyntaxKind.NullKeyword) { + return null; + } + if (node.kind === ts.SyntaxKind.UndefinedKeyword) { + return undefined; + } + + // 参数是变量引用 + if (ts.isIdentifier(node)) { + const isStaic = this.isConstantExpression(node); + if (isStaic) { + const symbol = this.checker.getSymbolAtLocation(node); + const declaration = symbol?.valueDeclaration; + return this.parseStaticObject(declaration.initializer); + } + } + + // 处理数组 + if (ts.isArrayLiteralExpression(node)) { + return this.processArrayElements(node.elements); + } + + // 处理对象字面量 + if (ts.isObjectLiteralExpression(node)) { + return this.processObjectElements(node); + } + + return undefined; + } + + processObjectElements(elements: ts.ObjectLiteralExpression): { [key: string]: StaticValue } { + const obj: { [key: string]: StaticValue } = {}; + for (const prop of elements.properties) { + // 处理普通属性 + if (ts.isPropertyAssignment(prop)) { + const key = this.parsePropertyKey(prop.name); + const value = this.parseStaticObject(prop.initializer); + if (key !== undefined && value !== undefined) { + obj[key] = value; + } + } + + // 处理展开运算符 + if (ts.isSpreadAssignment(prop)) { + const spreadObj = this.parseStaticObject(prop.expression); + if (typeof spreadObj === 'object' && spreadObj !== null) { + Object.assign(obj, spreadObj); + } + } + } + return obj; + } + processArrayElements(elements: readonly ts.Node[]): StaticValue[] { + const parsedElements: StaticValue[] = []; + + elements.forEach((element) => { + if (ts.isSpreadElement(element)) { + const spreadValue = this.parseStaticObject(element.expression); + if (Array.isArray(spreadValue)) { + parsedElements.push(...spreadValue); + } + } else { + const value = this.parseStaticObject(element); + if (value !== undefined) { + parsedElements.push(value); + } + } + }); + + return parsedElements; + } + // 辅助函数:解析属性名 + parsePropertyKey(node: ts.PropertyName): string | undefined { + // 字面量属性名 (如 "key" 或 123) + if (ts.isLiteralExpression(node)) { + return node.text; + } + + // 标识符属性名 (如 key) + if (ts.isIdentifier(node)) { + return node.text; + } + + return undefined; + } +} + +export default new ParseIntent(); diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index b3d1a940d..9b2f1cf0d 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -85,6 +85,7 @@ export const COMPONENT_STYLES_DECORATOR: string = '@Styles'; export const COMPONENT_ANIMATABLE_EXTEND_DECORATOR: string = '@AnimatableExtend'; export const COMPONENT_CONCURRENT_DECORATOR: string = '@Concurrent'; export const COMPONENT_SENDABLE_DECORATOR: string = '@Sendable'; +export const COMPONENT_INTENT_DECORATOR:string = '@InsightIntentLinkDecorator'; export const CHECK_COMPONENT_EXTEND_DECORATOR: string = 'Extend'; export const STRUCT_CONTEXT_METHOD_DECORATORS: Set = new Set([COMPONENT_BUILDER_DECORATOR, COMPONENT_STYLES_DECORATOR, COMPONENT_LOCAL_BUILDER_DECORATOR]); diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 03f0093a6..777101de5 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -80,7 +80,8 @@ import { PAGE_FULL_PATH, LENGTH, PUV2_VIEW_BASE, - CONTEXT_STACK + CONTEXT_STACK, + COMPONENT_INTENT_DECORATOR } from './pre_define'; import { componentInfo, @@ -169,14 +170,18 @@ import { routerModuleType, routerBundleOrModule } from './process_module_package'; - +import parseIntent from './parse_Intent'; +import { getNormalizedOhmUrlByFilepath } from './ark_utils'; +import { + IntentLogger +} from './Intent_Logger'; export let transformLog: IFileLog = new createAstNodeUtils.FileLog(); export let contextGlobal: ts.TransformationContext; export let resourceFileName: string = ''; export const builderTypeParameter: { params: string[] } = { params: [] }; export function processUISyntax(program: ts.Program, ut = false, - compilationTime: CompilationTimeStatistics = null, filePath: string = ''): Function { + compilationTime: CompilationTimeStatistics = null, filePath: string = '', metaInfo: Object = {}): Function { let entryNodeKey: ts.Expression; return (context: ts.TransformationContext) => { contextGlobal = context; @@ -403,6 +408,25 @@ export function processUISyntax(program: ts.Program, ut = false, }); } } else if (ts.isClassDeclaration(node)) { + if (hasDecorator(node, COMPONENT_INTENT_DECORATOR)) { + const checker = program.getTypeChecker(); + const currentFile = filePath; // C:\Users\l00813716\DevEcoStudioProjects\MyApplication6\entry\src\main\ets\pages\Index.ets + const realpath = program.getCurrentDirectory(); + const relativePath = '.\\' + path.relative(realpath, currentFile); + const convertedPath = relativePath.replace(/\\+/g, '/'); + const pkgParams = { + pkgName: metaInfo.pkgName, + pkgPath: metaInfo.pkgPath + }; + const Logger = IntentLogger.getInstance(); + const recordName = getNormalizedOhmUrlByFilepath(convertedPath, projectConfig, Logger, pkgParams, filePath); + console.log(`recordName------${recordName}`); + parseIntent.handleIntent(node, checker, `@normalized:${recordName}`); + + // remove @Intent + node = processSendableClass(node); + } + if (hasDecorator(node, COMPONENT_SENDABLE_DECORATOR)) { if (projectConfig.compileHar && !projectConfig.useTsHar) { let warnMessage: string = 'If you use @Sendable in js har, an exception will occur during runtime.\n' + -- Gitee From 205255bbcfddd35fbcd4d11f4a65307981825e43 Mon Sep 17 00:00:00 2001 From: Yenan Date: Sun, 23 Mar 2025 20:26:37 +0800 Subject: [PATCH 002/140] yenan10@huawei.com Signed-off-by: Yenan --- compiler/src/log_message_collection.ts | 14 +- compiler/src/pre_define.ts | 7 + compiler/src/process_component_build.ts | 13 +- compiler/src/process_component_class.ts | 10 +- compiler/src/process_component_member.ts | 43 ++-- compiler/src/process_custom_component.ts | 90 ++++++-- compiler/src/process_struct_componentV2.ts | 10 +- compiler/src/process_ui_syntax.ts | 18 +- compiler/src/validate_ui_syntax.ts | 59 +++-- compiler/test/transform_ut_error.json | 244 ++++++++++----------- 10 files changed, 290 insertions(+), 218 deletions(-) diff --git a/compiler/src/log_message_collection.ts b/compiler/src/log_message_collection.ts index 00b2882ee..7765af6bc 100644 --- a/compiler/src/log_message_collection.ts +++ b/compiler/src/log_message_collection.ts @@ -89,7 +89,7 @@ function checkNestedComponents(parentComponentType: ParentType, isRecycleChild: if (parentComponentType === ParentType.NormalComponentV1 && isReuseV2Child) { log.push({ type: LogType.ERROR, - message: `A custom component decorated with @Component cannot contain child components decorated with @ReusableV2.`, + message: `A custom component decorated with '@Component' cannot contain child components decorated with '@ReusableV2'.`, pos: node.getStart(), code: '10905244' }); @@ -97,7 +97,7 @@ function checkNestedComponents(parentComponentType: ParentType, isRecycleChild: if (parentComponentType === ParentType.ReuseComponentV1 && isReuseV2Child) { log.push({ type: LogType.ERROR, - message: `A custom component decorated with @Reusable cannot contain child components decorated with @ReusableV2.`, + message: `A custom component decorated with '@Reusable' cannot contain child components decorated with '@ReusableV2'.`, pos: node.getStart(), code: '10905245' }); @@ -105,7 +105,7 @@ function checkNestedComponents(parentComponentType: ParentType, isRecycleChild: if (parentComponentType === ParentType.ReuseComponentV2 && isRecycleChild) { log.push({ type: LogType.ERROR, - message: `A custom component decorated with @ReusableV2 cannot contain child components decorated with @Reusable.`, + message: `A custom component decorated with '@ReusableV2' cannot contain child components decorated with '@Reusable'.`, pos: node.getStart(), code: '10905246' }); @@ -113,7 +113,7 @@ function checkNestedComponents(parentComponentType: ParentType, isRecycleChild: if (parentComponentType === ParentType.NormalComponentV2 && isRecycleChild) { log.push({ type: LogType.WARN, - message: `When a custom component is decorated with @ComponentV2 and contains a child decorated with @Reusable, ` + + message: `When a custom component is decorated with '@ComponentV2' and contains a child decorated with '@Reusable', ` + `the child component will not create.`, pos: node.getStart() }); @@ -125,7 +125,7 @@ function checkIfReuseV2InRepeatTemplate(isInRepeatTemplate: boolean, isReuseV2Ch if (isInRepeatTemplate && isReuseV2Child) { log.push({ type: LogType.ERROR, - message: `The template attribute of the Repeat component cannot contain any custom component decorated with @ReusableV2.`, + message: `The template attribute of the Repeat component cannot contain any custom component decorated with '@ReusableV2'.`, pos: node.getStart(), code: '10905247' }); @@ -136,7 +136,7 @@ function checkUsageOfReuseAttribute(node: ts.CallExpression, isReusableV2NodeAtt if (!isReusableV2NodeAttr) { log.push({ type: LogType.ERROR, - message: `The reuse attribute is only applicable to custom components decorated with both @ComponentV2 and @ReusableV2.`, + message: `The reuse attribute is only applicable to custom components decorated with both '@ComponentV2' and '@ReusableV2'.`, pos: node.getStart(), code: '10905248' }); @@ -147,7 +147,7 @@ function checkUsageOfReuseIdAttribute(node: ts.CallExpression, isReusableV2NodeA if (isReusableV2NodeAttr) { log.push({ type: LogType.ERROR, - message: `The reuseId attribute is not applicable to custom components decorated with both @ComponentV2 and @ReusableV2.`, + message: `The reuseId attribute is not applicable to custom components decorated with both '@ComponentV2' and '@ReusableV2'.`, pos: node.getStart(), code: '10905249' }); diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index b3d1a940d..9090b6e67 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -49,6 +49,13 @@ export const COMPONENT_LOCAL_STORAGE_PROP_DECORATOR: string = '@LocalStorageProp export const COMPONENT_CUSTOM_DECORATOR: string = 'COMPONENT_CUSTOM_DECORATOR'; export const COMPONENT_REQUIRE_DECORATOR: string = '@Require'; +export const COMPONENTV2_LOCAL_DECORATOR: string = '@Local'; +export const COMPONENTV2_PARAM_DECORATOR: string = '@Param'; +export const COMPONENTV2_ONCE_DECORATOR: string = '@Once'; +export const COMPONENTV2_EVENT_DECORATOR: string = '@Event'; +export const COMPONENTV2_CONSUMER_DECORATOR: string = '@Consumer'; +export const COMPONENTV2_PROVIDER_DECORATOR: string = '@Provider'; + export const CLASS_TRACK_DECORATOR: string = 'Track'; export const CLASS_MIN_TRACK_DECORATOR: string = 'Trace'; export const COMPONENT_DECORATOR_COMPONENT_V2: string = '@ComponentV2'; diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 2ac4a9668..0f47c26a7 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -371,7 +371,8 @@ function validateRootNode(node: ts.MethodDeclaration, log: LogInfo[]): boolean { if (!isValid) { log.push({ type: LogType.ERROR, - message: `There should have a root container component.`, + message: `In an '@Entry' decorated component, the 'build' method can have only one root node,` + + ` which must be a container component.`, pos: node.body.statements.pos, code: '10905210' }); @@ -540,8 +541,8 @@ export function processComponentChild(node: ts.Block | ts.SourceFile, newStateme processIfStatement(item, newStatements, log, isBuilder, isGlobalBuilder, builderParamsResult, isInRepeatTemplate); } else if (!ts.isBlock(item)) { log.push({ - type: LogType.ERROR, - message: `Only UI component syntax can be written in build method.`, + type: LogType.ERROR, + message: `Only UI component syntax can be written here.`, pos: item.getStart(), code: '10905209' }); @@ -735,7 +736,7 @@ function processExpressionStatementChange(node: ts.ExpressionStatement, nextNode log.push({ type: LogType.ERROR, message: `In the trailing lambda case, '${name}' must have one and only one property decorated with ` + - '@BuilderParam, and its @BuilderParam expects no parameter.', + `'@BuilderParam', and its '@BuilderParam' expects no parameter.`, pos: node.getStart(), code: '10905102' }); @@ -2773,7 +2774,7 @@ function addComponentAttr(temp, node: ts.Identifier, lastStatement, if (newsupplement.isAcceleratePreview) { log.push({ type: LogType.ERROR, - message: `Doesn't support Extend function now`, + message: `Doesn't support '@Extend' function now`, pos: temp.getStart(), code: '10906205' }); @@ -3406,7 +3407,7 @@ function judgeBuilderType(node: ts.ExpressionStatement): boolean { export function validateStateStyleSyntax(temp, log: LogInfo[]): void { log.push({ type: LogType.ERROR, - message: `.stateStyles doesn't conform standard.`, + message: `'.stateStyles' doesn't conform standard.`, pos: temp.getStart(), code: '10905203' }); diff --git a/compiler/src/process_component_class.ts b/compiler/src/process_component_class.ts index a61f581e3..068141f2b 100644 --- a/compiler/src/process_component_class.ts +++ b/compiler/src/process_component_class.ts @@ -636,7 +636,7 @@ export function processComponentMethod(node: ts.MethodDeclaration, context: ts.T } else { log.push({ type: LogType.ERROR, - message: `@Styles can't have parameters.`, + message: `'@Styles' decorated functions and methods cannot have arguments.`, pos: node.getStart(), code: '10905105' }); @@ -653,7 +653,7 @@ function checkDecoratorMethod(node: ts.MethodDeclaration, modifiers: readonly ts if (modifiers[i].kind && modifiers[i].kind === ts.SyntaxKind.StaticKeyword) { log.push({ type: LogType.ERROR, - message: `Static methods in custom components cannot be decorated by @LocalBuilder.`, + message: `Static methods in custom components cannot be decorated by '@LocalBuilder'.`, pos: node.getStart(), code: '10905104' }); @@ -797,7 +797,7 @@ export function updateHeritageClauses(node: ts.StructDeclaration, log: LogInfo[] if (node.heritageClauses && !checkHeritageClauses(node)) { log.push({ type: LogType.ERROR, - message: 'The struct component is not allowed to extends other class or implements other interface.', + message: 'Structs are not allowed to inherit from classes or implement interfaces.', pos: node.heritageClauses.pos, code: '10905212' }); @@ -1047,7 +1047,7 @@ export function validateBuildMethodCount(buildCount: BuildCount, parentComponent if (buildCount.count !== 1) { log.push({ type: LogType.ERROR, - message: `struct '${parentComponentName.getText()}' must be at least or at most one 'build' method.`, + message: `The struct '${parentComponentName.getText()}' must have at least and at most one 'build' method.`, pos: parentComponentName.getStart(), code: '10905103', solutions: [`A structurally modified page must have at least one and no more than one 'build' method.`] @@ -1060,7 +1060,7 @@ function validateHasControllerAndControllerCount(componentName: ts.Identifier, c if (!checkController.hasController) { log.push({ type: LogType.ERROR, - message: '@CustomDialog component should have a property of the CustomDialogController type.', + message: `The '@CustomDialog' decorated custom component must contain a property of the CustomDialogController type.`, pos: componentName.pos, code: '10905211' }); diff --git a/compiler/src/process_component_member.ts b/compiler/src/process_component_member.ts index 8b92f5478..37d7f6865 100644 --- a/compiler/src/process_component_member.ts +++ b/compiler/src/process_component_member.ts @@ -561,7 +561,8 @@ function processWatch(node: ts.PropertyDeclaration, decorator: ts.Decorator, } else { log.push({ type: LogType.ERROR, - message: `Cannot find name ${argument.getText()} in struct '${node.parent.name.getText()}'.`, + message: `'@Watch' cannot be used with ${argument.getText()}.` + + ` Apply it only to parameters that correspond to existing methods.`, pos: argument.getStart(), code: '10905301' }); @@ -571,12 +572,12 @@ function processWatch(node: ts.PropertyDeclaration, decorator: ts.Decorator, const propertyNode: ts.PropertyAccessExpression = createPropertyAccessExpressionWithThis(content); watchMap.set(propertyName, propertyNode); decoratorParamSet.add(content); - validateWatchParam(LogType.WARN, argument.getStart(), log); - } else if (ts.isPropertyAccessExpression(decorator.expression.arguments[0])) { + validateWatchParam(LogType.WARN, argument.getStart(), log, argument.getText()); + } else if (ts.isPropertyAccessExpression(decorator.expression.arguments[0])) { watchMap.set(propertyName, decorator.expression.arguments[0]); - validateWatchParam(LogType.WARN, argument.getStart(), log); + validateWatchParam(LogType.WARN, argument.getStart(), log, argument.getText()); } else { - validateWatchParam(LogType.ERROR, argument.getStart(), log); + validateWatchParam(LogType.ERROR, argument.getStart(), log, argument.getText()); } } } @@ -650,7 +651,7 @@ function wrongDecoratorInPreview(node: ts.PropertyDeclaration, decorator: string if (hasPreview && projectConfig.isPreview) { log.push({ type: LogType.WARN, - message: `The variable with ${decorator} in component with @Preview may ` + + message: `The variable with '${decorator}' in component with '@Preview' may ` + `cause error in component preview mode`, pos: node.getStart() }); @@ -880,7 +881,7 @@ function updateBuilderParamProperty(node: ts.PropertyDeclaration, if (judgeBuilderParamAssignedByBuilder(node)) { log.push({ type: LogType.ERROR, - message: 'BuilderParam property can only initialized by Builder function or LocalBuilder method in struct.', + message: `'@BuilderParam' property can only initialized by '@Builder' function or '@LocalBuilder' method in struct.`, pos: node.getStart(), code: '10905101' }); @@ -1182,7 +1183,7 @@ export function isSingleKey(node: ts.PropertyDeclaration, isOptionalKey: boolean function validateMultiDecorators(name: ts.Identifier, log: LogInfo[]): void { log.push({ type: LogType.ERROR, - message: `The property '${name.escapedText.toString()}' cannot have mutilate state management decorators.`, + message: `The property '${name.escapedText.toString()}' cannot have multiple state management decorators.`, pos: name.getStart(), code: '10905302' }); @@ -1192,7 +1193,7 @@ function validatePropertyNonDefaultValue(propertyName: ts.Identifier, decorator: log: LogInfo[]): void { log.push({ type: LogType.ERROR, - message: `The ${decorator} property '${propertyName.getText()}' must be specified a default value.`, + message: `The '${decorator}' property '${propertyName.getText()}' must be specified a default value.`, pos: propertyName.getStart(), code: '10905303' }); @@ -1202,7 +1203,7 @@ function validatePropertyDefaultValue(propertyName: ts.Identifier, decorator: st log: LogInfo[]): void { log.push({ type: LogType.ERROR, - message: `The ${decorator} property '${propertyName.getText()}' cannot be specified a default value.`, + message: `The '${decorator}' property cannot be specified a default value.`, pos: propertyName.getStart(), code: '10905304', solutions: ['Please initialize the rules according to the decorator.'] @@ -1234,16 +1235,16 @@ function validateNonObservedClassType(propertyName: ts.Identifier, decorator: st if (isEsmoduleAndUpdateMode) { log.push({ type: projectConfig.optLazyForEach ? LogType.WARN : LogType.ERROR, - message: `The type of the ${decorator} property '${propertyName.getText()}' cannot be an ` + - `objects of classes decorated with ${COMPONENT_OBSERVEDV2_DECORATOR} class decorator in ets (not ts).`, + message: `'@ObjectLink' cannot be used with this type.` + + ` Apply it only to classes decorated by '@Observed' or initialized using the return value of 'makeV1Observed'.`, pos: propertyName.getStart(), code: '10905307' }); } else { log.push({ type: projectConfig.optLazyForEach ? LogType.WARN : LogType.ERROR, - message: `The type of the ${decorator} property '${propertyName.getText()}' can only be ` + - `objects of classes decorated with ${COMPONENT_OBSERVED_DECORATOR} class decorator in ets (not ts).`, + message: `'@ObjectLink' cannot be used with this type.` + + ` Apply it only to classes decorated by '@Observed' or initialized using the return value of 'makeV1Observed'.`, pos: propertyName.getStart(), code: '10905307' }); @@ -1263,8 +1264,8 @@ function validateHasIllegalDecoratorInEntry(parentName: ts.Identifier, propertyN decorator: string, log: LogInfo[]): void { log.push({ type: LogType.WARN, - message: `The @Entry component '${parentName.getText()}' cannot have the ` + - `${decorator} property '${propertyName.getText()}'.`, + message: `The '@Entry' component '${parentName.getText()}' cannot have the ` + + `'${decorator}' property '${propertyName.getText()}'.`, pos: propertyName.getStart() }); } @@ -1273,7 +1274,7 @@ function validateForbiddenUseStateType(propertyName: ts.Identifier, decorator: s log: LogInfo[]): void { log.push({ type: LogType.ERROR, - message: `The ${decorator} property '${propertyName.getText()}' cannot be a '${type}' object.`, + message: `The '${decorator}' property '${propertyName.getText()}' cannot be a '${type}' object.`, pos: propertyName.getStart(), code: '10905308' }); @@ -1300,7 +1301,7 @@ function validateWatchDecorator(propertyName: ts.Identifier, decorators: readonl if (decorators.length === 1 || isRegular) { log.push({ type: LogType.ERROR, - message: `Regular variable '${propertyName.escapedText.toString()}' can not be decorated with @Watch.`, + message: `Regular variable '${propertyName.escapedText.toString()}' can not be decorated with '@Watch'.`, pos: propertyName.getStart(), code: '10905310' }); @@ -1309,10 +1310,10 @@ function validateWatchDecorator(propertyName: ts.Identifier, decorators: readonl return true; } -function validateWatchParam(type: LogType, pos: number, log: LogInfo[]): void { +function validateWatchParam(type: LogType, pos: number, log: LogInfo[], paramName: string): void { log.push({ type: type, - message: 'The parameter should be a string.', + message: `'@Watch' cannot be used with '${paramName}'. Apply it only to 'string' parameters.`, pos, code: '10905311' }); @@ -1410,7 +1411,7 @@ function validateCustomDecorator(decorators: readonly ts.Decorator[], log: LogIn if (hasCustomDecorator && hasInnerDecorator) { log.push({ type: LogType.ERROR, - message: `The inner decorator ${innerDecorator.getText()} cannot be used together with custom decorator.`, + message: `The inner decorator '${innerDecorator.getText()}' cannot be used together with custom decorator.`, pos: innerDecorator.getStart(), code: '10905312' }); diff --git a/compiler/src/process_custom_component.ts b/compiler/src/process_custom_component.ts index 2aeb32718..2103a2ca3 100644 --- a/compiler/src/process_custom_component.ts +++ b/compiler/src/process_custom_component.ts @@ -55,7 +55,14 @@ import { COMPONENT_PARAMS_FUNCTION, COMPONENT_ABOUTTOREUSEINTERNAL_FUNCTION, NAME, - COMPONENT_CALL + COMPONENT_CALL, + COMPONENT_CONSUME_DECORATOR, + COMPONENT_STORAGE_PROP_DECORATOR, + COMPONENT_LOCAL_STORAGE_PROP_DECORATOR, + COMPONENT_LOCAL_STORAGE_LINK_DECORATOR, + COMPONENTV2_LOCAL_DECORATOR, + COMPONENTV2_CONSUMER_DECORATOR, + COMPONENTV2_PROVIDER_DECORATOR } from './pre_define'; import { stateCollection, @@ -77,7 +84,9 @@ import { provideInitialization, privateCollection, regularStaticCollection, - componentCollection + componentCollection, + localStorageLinkCollection, + localStoragePropCollection } from './validate_ui_syntax'; import { PropMapManager, @@ -413,13 +422,26 @@ function parseChildProperties(childName: string, node: ts.CallExpression, } } +function getForbbidenInitPropsV2Type(itemName: string, info: ChildAndParentComponentInfo): string { + let typeName: string = COMPONENT_NON_DECORATOR; + if (info.childStructInfo.localDecoratorSet.has(itemName)) { + typeName = COMPONENTV2_LOCAL_DECORATOR; + } else if (info.childStructInfo.consumerDecoratorSet.has(itemName)) { + typeName = COMPONENTV2_CONSUMER_DECORATOR; + } else if (info.childStructInfo.providerDecoratorSet.has(itemName)) { + typeName = COMPONENTV2_PROVIDER_DECORATOR; + } + return typeName; +} + function validateChildProperty(item: ts.PropertyAssignment, itemName: string, childParam: ts.PropertyAssignment[], log: LogInfo[], info: ChildAndParentComponentInfo): void { if (info.childStructInfo.isComponentV2) { if (info.forbiddenInitPropsV2.includes(itemName)) { + const propType: string = getForbbidenInitPropsV2Type(itemName, info); log.push({ type: LogType.ERROR, - message: `Property '${itemName}' in the custom component '${info.childName}'` + + message: `The '${propType}' property '${itemName}' in the custom component '${info.childName}'` + ` cannot be initialized here (forbidden to specify).`, pos: item.getStart(), code: '10905324' @@ -432,7 +454,7 @@ function validateChildProperty(item: ts.PropertyAssignment, itemName: string, if (isForbiddenAssignToComponentV2(item, itemName, info)) { log.push({ type: LogType.ERROR, - message: `Property '${itemName}' in the @ComponentV2 component '${info.childName}' are not allowed to be assigned values here.`, + message: `Property '${itemName}' in the '@ComponentV2' component '${info.childName}' is not allowed to be assigned value here.`, pos: item.getStart(), code: '10905323' }); @@ -536,7 +558,7 @@ function validateInitParam(childName: string, curChildProps: Set, if (!curChildProps.has(paramName)) { log.push({ type: LogType.ERROR, - message: `Property '${paramName}' must be initialized through the component constructor.`, + message: `'@Require' decorated '${paramName}' must be initialized through the component constructor.`, pos: node.getStart(), code: '10905321' }); @@ -545,7 +567,7 @@ function validateInitParam(childName: string, curChildProps: Set, } else if (parentStructInfo.isComponentV2 && childStructInfo.linkDecoratorsV1.length) { log.push({ type: LogType.ERROR, - message: 'The @ComponentV2 struct must not contain any @Component with an @Link decorated variable', + message: `A V2 component cannot be used with any member property decorated by '@Link' in a V1 component.`, pos: node.getStart(), code: '10905213' }); @@ -862,8 +884,8 @@ function updatePropertyAssignment(newProperties: ts.PropertyAssignment[], log.push({ type: LogType.ERROR, message: 'When the two-way binding syntax is used, ' + - `the variable '${itemName}' must be decorated with @Param, ` + - `and the @Event variable '$` + `${itemName}' ` + `must be defined in the ${childStructInfo.structName}.`, + `the variable '${itemName}' must be decorated with '@Param', ` + + `and the '@Event' variable '$` + `${itemName}' ` + `must be defined in the ${childStructInfo.structName}.`, pos: item.getStart(), code: '10905319' }); @@ -1396,6 +1418,46 @@ function matchStartWithDollar(name: string): boolean { return /^\$/.test(name); } +function getForbbiddenToInitViaParamType(customComponentName: string, + node: ts.Identifier): string { + let propType: string = COMPONENT_CONSUME_DECORATOR; + const propName: string = node.escapedText.toString(); + if (getCollectionSet(customComponentName, storageLinkCollection).has(propName)) { + propType = COMPONENT_STORAGE_LINK_DECORATOR; + } else if (getCollectionSet(customComponentName, storagePropCollection)) { + propType = COMPONENT_STORAGE_PROP_DECORATOR; + } else if (ifLocalStorageLink(customComponentName, propName)) { + propType = COMPONENT_LOCAL_STORAGE_LINK_DECORATOR; + } else if (ifLocalStorageProp(customComponentName, propName)) { + propType = COMPONENT_LOCAL_STORAGE_PROP_DECORATOR; + } + return propType; +} + +function ifLocalStorageProp(componentName: string, propName: string): boolean { + if (!localStoragePropCollection.get(componentName).keys) { + return false; + } else { + const collection: Set = new Set(); + for (const key of localStoragePropCollection.get(componentName).keys()) { + collection.add(key); + } + return collection.has(propName); + } +} + +function ifLocalStorageLink(componentName: string, propName: string): boolean { + if (!localStorageLinkCollection.get(componentName).keys) { + return false; + } else { + const collection: Set = new Set(); + for (const key of localStorageLinkCollection.get(componentName).keys()) { + collection.add(key); + } + return collection.has(propName); + } +} + function validateForbiddenToInitViaParam(node: ts.ObjectLiteralElementLike, customComponentName: string, log: LogInfo[]): void { const forbiddenToInitViaParamSet: Set = new Set([ @@ -1406,16 +1468,18 @@ function validateForbiddenToInitViaParam(node: ts.ObjectLiteralElementLike, const localStorageSet: Set = new Set(); getLocalStorageCollection(customComponentName, localStorageSet); if (isThisProperty(node, forbiddenToInitViaParamSet) || isThisProperty(node, localStorageSet)) { + const nodeIdentifier: ts.Identifier = node.name as ts.Identifier; + const propType: string = getForbbiddenToInitViaParamType(customComponentName, nodeIdentifier); log.push({ type: LogType.ERROR, - message: `Property '${node.name.getText()}' in the custom component '${customComponentName}'` + + message: `The '${propType}' property '${node.name.getText()}' in the custom component '${customComponentName}'` + ` cannot be initialized here (forbidden to specify).`, pos: node.name.getStart(), code: '10905317' }); } } - + function validateMandatoryToInitViaParam(node: ts.CallExpression, customComponentName: string, curChildProps: Set, log: LogInfo[], parentStructInfo: StructInfo): void { let mandatoryToInitViaParamSet: Set; @@ -1438,7 +1502,7 @@ function validateMandatoryToInitViaParam(node: ts.CallExpression, customComponen if (item && !curChildProps.has(item)) { log.push({ type: LogType.ERROR, - message: `Property '${item}' in the custom component '${customComponentName}'` + + message: `The property '${item}' in the custom component '${customComponentName}'` + ` is missing (mandatory to specify).`, pos: node.getStart(), code: '10905316' @@ -1497,8 +1561,8 @@ function validateIllegalInitFromParent(node: ts.ObjectLiteralElementLike, proper } PropMapManager.reserveLog(parentPropertyName, parentPropertyKind, { type: type, - message: `The ${parentPropertyKind} property '${parentPropertyName}' cannot be assigned to ` + - `the ${curPropertyKind} property '${propertyName}'.`, + message: `The '${parentPropertyKind}' property '${parentPropertyName}' cannot be assigned to ` + + `the '${curPropertyKind}' property '${propertyName}'.`, // @ts-ignore pos: node.initializer ? node.initializer.getStart() : node.getStart(), code: type === LogType.ERROR ? '10905315' : undefined diff --git a/compiler/src/process_struct_componentV2.ts b/compiler/src/process_struct_componentV2.ts index 88b64b613..34e0e906e 100644 --- a/compiler/src/process_struct_componentV2.ts +++ b/compiler/src/process_struct_componentV2.ts @@ -366,7 +366,7 @@ function processBuilderParamProperty(member: ts.PropertyDeclaration, log: LogInf if (judgeBuilderParamAssignedByBuilder(member)) { log.push({ type: LogType.ERROR, - message: 'BuilderParam property can only initialized by Builder function.', + message: `'@BuilderParam' property can only initialized by '@Builder' function.`, pos: member.getStart(), code: '10905107' }); @@ -571,17 +571,17 @@ function checkHasBuilderParamDecorator(propertyDecorator: PropertyDecorator, mem function checkParamDecorator(propertyDecorator: PropertyDecorator, member: ts.PropertyDeclaration, log: LogInfo[], sourceFileNode: ts.SourceFile, structInfo: StructInfo): void { if (propertyDecorator.hasParam && !member.initializer && !propertyDecorator.hasRequire) { - const message: string = 'When a variable decorated with @Param is not assigned a default value, ' + - 'it must also be decorated with @Require.'; + const message: string = 'When a variable decorated with \'@Param\' is not assigned a default value, ' + + 'it must also be decorated with \'@Require\'.'; addLog(LogType.ERROR, message, member.getStart(), log, sourceFileNode, { code: '10905327' }); } if (propertyDecorator.hasOnce && !propertyDecorator.hasParam) { - const message: string = 'When a variable decorated with @Once, it must also be decorated with @Param.'; + const message: string = 'When a variable decorated with \'@Once\', it must also be decorated with \'@Param\'.'; addLog(LogType.ERROR, message, member.getStart(), log, sourceFileNode, { code: '10905326' }); } if (propertyDecorator.hasRequire && !propertyDecorator.hasParam && !checkHasBuilderParamDecorator(propertyDecorator, member, sourceFileNode, structInfo)) { - const message: string = 'In a struct decorated with @ComponentV2, @Require can only be used with @Param.'; + const message: string = 'In a struct decorated with \'@ComponentV2\', \'@Require\' can only be used with \'@Param\'.'; addLog(LogType.ERROR, message, member.getStart(), log, sourceFileNode, { code: '10905325' }); } } diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 26ed07a95..ec3dc2f67 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -351,7 +351,7 @@ export function processUISyntax(program: ts.Program, ut = false, } else { transformLog.errors.push({ type: LogType.ERROR, - message: `@Styles can't have parameters.`, + message: `'@Styles' decorated functions and methods cannot have arguments.`, pos: node.getStart(), code: '10905110' }); @@ -397,7 +397,7 @@ export function processUISyntax(program: ts.Program, ut = false, !CUSTOM_BUILDER_METHOD.has(node.arguments[0].escapedText.toString()))) { transformLog.errors.push({ type: LogType.ERROR, - message: `wrapBuilder's parameter should be @Builder function.`, + message: `The wrapBuilder's parameter should be '@Builder' function.`, pos: node.getStart(), code: '10905109' }); @@ -767,7 +767,7 @@ function getResourceDataNode(node: ts.CallExpression, if (resourceType === undefined && !previewLog.isAcceleratePreview) { transformLog.errors.push({ type: LogType.ERROR, - message: `The resource type ${resourceData[1]} is not supported.`, + message: `The resource type '${resourceData[1]}' is not supported.`, pos: node.getStart(), code: '10906334' }); @@ -909,7 +909,7 @@ function validateResourceData(resourceData: string[], resources: object, pos: nu if (resourceData.length !== 3) { log.push({ type: LogType.ERROR, - message: 'The input parameter is not supported.', + message: `Invalid resource file parameter. Enter a value in the format of 'xxx.yyy.zzz'.`, pos, code: '10905332' }); @@ -1213,7 +1213,7 @@ function parseExtendNode(node: ts.CallExpression, extendResult: ExtendResult, ch node.arguments && node.arguments.length !== 1) { transformLog.errors.push({ type: LogType.ERROR, - message: `@${extendResult.decoratorName} should have one and only one parameter`, + message: `'@${extendResult.decoratorName}' should have one and only one parameter.`, pos: node.getStart(), code: '10905108' }); @@ -1281,7 +1281,7 @@ function createEntryFunction(name: string, context: ts.TransformationContext, ca if (entryOptionNode && ts.isObjectLiteralExpression(entryOptionNode)) { transformLog.errors.push({ type: LogType.ERROR, - message: `@Entry doesn't support {} parameter in card`, + message: `'@Entry' doesn't support {} parameter in card`, pos: componentCollection.entryComponentPos, code: '10906218' }); @@ -1681,10 +1681,10 @@ function addStorageParam(name: string): [string, ts.Expression] { if (componentCollection.localStorageName) { localStorageName = componentCollection.localStorageName; } - if (!hasStorage() && localStorageNum) { + if (!hasStorage() && localStorageNum) { transformLog.errors.push({ type: LogType.WARN, - message: `@Entry should have a parameter, like '@Entry (storage)'.`, + message: `'@Entry' should have a parameter, like '@Entry (storage)'.`, pos: componentCollection.entryComponentPos }); } @@ -1917,7 +1917,7 @@ function createPreviewElseBlock(name: string, context: ts.TransformationContext, if (entryOptionNode && ts.isObjectLiteralExpression(entryOptionNode)) { transformLog.errors.push({ type: LogType.ERROR, - message: `@Entry doesn't support {} parameter in card`, + message: `'@Entry' doesn't support {} parameter in card`, pos: componentCollection.entryComponentPos, code: '10906217' }); diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 036f8a609..2feb3a3c4 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -392,11 +392,11 @@ function validateStruct(hasInnerComponentDecorator: boolean, componentName: stri `and '@Component', '@Reusable', '@CustomDialog' at the same time.`; addLog(LogType.ERROR, message, component.pos, log, sourceFile, { code: '10905229' }); } else if (structInfo.isReusableV2 && !structInfo.isComponentV2) { - const message: string = `@ReusableV2 is only applicable to custom components decorated by @ComponentV2.`; + const message: string = `'@ReusableV2' is only applicable to custom components decorated by '@ComponentV2'.`; addLog(LogType.ERROR, message, component.pos, log, sourceFile, { code: '10905242' }); } if (structInfo.isReusable && structInfo.isReusableV2) { - const message: string = `The @Reusable and @ReusableV2 decoraotrs cannot be applied simultaneously.`; + const message: string = `The '@Reusable' and '@ReusableV2' decoraotrs cannot be applied simultaneously.`; addLog(LogType.ERROR, message, component.pos, log, sourceFile, { code: '10905241' }); } if (BUILDIN_STYLE_NAMES.has(componentName) && !COMPONENT_SYSTEMAPI_NAMES.has(componentName)) { @@ -415,11 +415,11 @@ function checkConcurrentDecorator(node: ts.FunctionDeclaration | ts.MethodDeclar sourceFile: ts.SourceFile): void { const decorators: readonly ts.Decorator[] = ts.getAllDecorators(node); if (projectConfig.compileMode === JSBUNDLE) { - const message: string = `@Concurrent can only be used in ESMODULE compile mode.`; + const message: string = `'@Concurrent' can only be used in ESMODULE compile mode.`; addLog(LogType.ERROR, message, decorators![0].pos, log, sourceFile); } if (ts.isMethodDeclaration(node)) { - const message: string = `@Concurrent can not be used on method. please use it on function declaration.`; + const message: string = `'@Concurrent' can not be used on method, please use it on function declaration.`; addLog(LogType.ERROR, message, decorators![0].pos, log, sourceFile, { code: '10905123' }); } if (node.asteriskToken) { @@ -428,7 +428,7 @@ function checkConcurrentDecorator(node: ts.FunctionDeclaration | ts.MethodDeclar const checkAsyncModifier = (modifier: ts.Modifier) : boolean => modifier.kind === ts.SyntaxKind.AsyncKeyword; modifiers && (hasAsync = modifiers.some(checkAsyncModifier)); const funcKind: string = hasAsync ? 'Async generator' : 'Generator'; - const message: string = `@Concurrent can not be used on ${funcKind} function declaration.`; + const message: string = `'@Concurrent' can not be used on '${funcKind}' function declaration.`; addLog(LogType.ERROR, message, decorators![0].pos, log, sourceFile, { code: '10905122' }); } } @@ -522,7 +522,7 @@ function validatePropertyInStruct(structContext: boolean, decoratorNode: ts.Iden } let message: string; if (isV1Decorator && classResult.hasObservedV2) { - message = `The type of the @${decoratorName} property can not be a class decorated with @ObservedV2.`; + message = `The type of the '@${decoratorName}' property can not be a class decorated with '@ObservedV2'.`; addLog(LogType.ERROR, message, decoratorNode.getStart(), log, sourceFileNode, { code: '10905348' }); return; } @@ -685,7 +685,7 @@ function validateFunction(node: ts.MethodDeclaration | ts.FunctionDeclaration, const decoratorKeys: string[] = Array.from(decoratorMap.keys()); if (decoratorKeys.length > 1 || decoratorKeys.includes('LocalBuilder')) { const message: string = 'A function can only be decorated by one of the ' + - `'AnimatableExtend, Builder, Extend, Styles, Concurrent and Sendable'.`; + `'@AnimatableExtend', '@Builder', '@Extend', '@Styles', '@Concurrent' and '@Sendable'.`; addLog(LogType.ERROR, message, node.getStart(), log, sourceFileNode, { code: '10905117' }); } } @@ -720,7 +720,7 @@ function validateSingleDecorator(node: ts.Decorator, sourceFileNode: ts.SourceFi log: LogInfo[], isComponentV2: boolean): void { const decoratorName: string = node.getText().replace(/\([^\(\)]*\)/, ''); if (decoratorName === constantDefine.COMPUTED_DECORATOR && node.parent && !ts.isGetAccessor(node.parent)) { - const message: string = `@Computed can only decorate 'GetAccessor'.`; + const message: string = `'@Computed' can only decorate 'GetAccessor'.`; addLog(LogType.ERROR, message, node.getStart(), log, sourceFileNode, { code: '10905116' }); return; } @@ -770,7 +770,7 @@ function validateClassDecorator(sourceFileNode: ts.SourceFile, node: ts.Identifi isSendableClass: boolean): void { const isTypeFromSdk: boolean = validTypeCallback(node); if (!classContext && (classDecorators.includes(decoratorName) || isTypeFromSdkCallback(classContext, decoratorName, isTypeFromSdk))) { - const message: string = `The '@${decoratorName}' decorator can only be used in 'class'.`; + const message: string = `The '@${decoratorName}' decorator can decorate only member variables of a class.`; addLog(LogType.ERROR, message, node.pos, log, sourceFileNode, { code: '10905345' }); } else if (classContext && classMemberDecorators.includes(decoratorName)) { validateMemberInClass(isObservedClass, decoratorName, node, log, sourceFileNode, isObservedV1Class, isSendableClass, isTypeFromSdk); @@ -781,7 +781,8 @@ function validateMemberInClass(isObservedClass: boolean, decoratorName: string, log: LogInfo[], sourceFileNode: ts.SourceFile, isObservedV1Class: boolean, isSendableClass: boolean, isTypeFromSdk: boolean): void { if (decoratorName === CLASS_TRACK_DECORATOR) { if (isObservedClass) { - const message: string = `The '@${decoratorName}' decorator can not be used in a 'class' decorated with ObservedV2.`; + const message: string = `'@${decoratorName}' cannot be used with classes decorated by '@ObservedV2.'` + + ` Use the '@Trace' decorator instead.`; addLog(LogType.ERROR, message, node.pos, log, sourceFileNode, { code: '10905344' }); } return; @@ -794,7 +795,7 @@ function validateMemberInClass(isObservedClass: boolean, decoratorName: string, } if (!isObservedClass || !isPropertyForTrace(node, decoratorName)) { const info: string = decoratorName === CLASS_MIN_TRACK_DECORATOR ? 'variables' : 'method'; - const message: string = `The '@${decoratorName}' can decorate only member ${info} within a 'class' decorated with ObservedV2.`; + const message: string = `The '@${decoratorName}' can decorate only member '${info}' within a 'class' decorated with '@ObservedV2'.`; addLog(LogType.ERROR, message, node.pos, log, sourceFileNode, { code: '10905343' }); return; } @@ -803,11 +804,11 @@ function validateMemberInClass(isObservedClass: boolean, decoratorName: string, function validType(sourceFileNode: ts.SourceFile, node: ts.Identifier, log: LogInfo[], decoratorName: string, isObservedV1Class: boolean, isSendableClass: boolean): void { if (isSendableClass) { - const message: string = `The '@${decoratorName}' decorator can not be used in a 'class' decorated with Sendable.`; + const message: string = `The '@${decoratorName}' decorator can not be used in a 'class' decorated with '@Sendable'.`; addLog(LogType.ERROR, message, node.pos, log, sourceFileNode, { code: '10905342' }); } if (isObservedV1Class) { - const message: string = `The '@${decoratorName}' decorator can not be used in a 'class' decorated with Observed.`; + const message: string = `The '@${decoratorName}' decorator can not be used in a 'class' decorated with '@Observed'.`; addLog(LogType.ERROR, message, node.pos, log, sourceFileNode, { code: '10905341' }); } if (ts.isDecorator(node.parent?.parent) && !ts.isPropertyDeclaration(node.parent?.parent?.parent)) { @@ -920,14 +921,12 @@ function validateInheritClassDecorator(parentNode: ts.ClassDeclaration, childCla childClass: ts.ClassDeclaration, sourceFileNode: ts.SourceFile, log: LogInfo[]): void { const parentClassResult: ClassDecoratorResult = getClassDecoratorResult(parentNode); if (childClassResult.hasObservedV2 && parentClassResult.hasObserved) { - const message: string = `Because the current class is decorated by '@ObservedV2', ` + - `it can not inherit a class decorated by '@Observed'.`; + const message: string = `A class decorated by '@ObservedV2' cannot inherit from a class decorated by '@Observed'.`; addLog(LogType.ERROR, message, childClass.getStart(), log, sourceFileNode, { code: '10905225' }); return; } if (childClassResult.hasObserved && parentClassResult.hasObservedV2) { - const message: string = `Because the current class is decorated by '@Observed', ` + - `it can not inherit a class decorated by '@ObservedV2'.`; + const message: string = `A class decorated by '@Observed' cannot inherit from a class decorated by '@ObservedV2'.`; addLog(LogType.ERROR, message, childClass.getStart(), log, sourceFileNode, { code: '10905224' }); return; } @@ -957,11 +956,11 @@ function validateMethodDecorator(sourceFileNode: ts.SourceFile, node: ts.Identif if (ts.isMethodDeclaration(node.parent.parent) || (ts.isDecorator(node.parent.parent) && ts.isMethodDeclaration(node.parent.parent.parent))) { if (!structContext && STRUCT_CONTEXT_METHOD_DECORATORS.has(`@${decoratorName}`)) { - const message: string = `The '@${decoratorName}' decorator can only be used in 'struct'.`; + const message: string = `Use the '@${decoratorName}' decorator only in the global scope or in a struct.`; addLog(LogType.ERROR, message, node.pos, log, sourceFileNode, { code: '10905114' }); } if (CHECK_EXTEND_DECORATORS.includes(decoratorName)) { - const message: string = `The '@${decoratorName}' decorator can not be a member property method of a 'class' or 'struct'.`; + const message: string = `Use the '@${decoratorName}' decorator only in the global scope.`; addLog(LogType.ERROR, message, node.pos, log, sourceFileNode, { code: '10905113' }); } } @@ -1018,8 +1017,8 @@ function checkNoChildComponent(node: ts.EtsComponentExpression, sourceFileNode: message = `The component '${componentName}' can't have any child.`; code = '10905222'; } else { - message = `When the component '${componentName}' set '${isCheckType.name}' is '${isCheckType.value}'` + - `, can't have any child.`; + message = `When the component '${componentName}' set '${isCheckType.name}' as '${isCheckType.value}'` + + `, it can't have any child.`; code = '10905223'; } addLog(LogType.ERROR, message, pos, log, sourceFileNode, { code }); @@ -1076,11 +1075,11 @@ function checkOneChildComponent(node: ts.EtsComponentExpression, allComponentNam let message: string; let code: string | undefined; if (isCheckType.name === null) { - message = `The component '${componentName}' can only have a single child component.`; + message = `The '${componentName}' component can have only one child component.`; code = '10905220'; } else { - message = `When the component '${componentName}' set '${isCheckType.name}' is ` + - `'${isCheckType.value}', can only have a single child component.`; + message = `When the component '${componentName}' set '${isCheckType.name}' as ` + + `'${isCheckType.value}', it can only have a single child component.`; code = '10905221'; } addLog(LogType.ERROR, message, pos, log, sourceFileNode, { code }); @@ -1192,9 +1191,9 @@ function checkSpecificChildComponent(node: ts.EtsComponentExpression, allCompone const componentName: string = (node.expression as ts.Identifier).escapedText.toString(); const pos: number = node.expression.getStart(); const specificChildArray: string = - Array.from(SPECIFIC_CHILD_COMPONENT.get(componentName)).join(' and '); + Array.from(SPECIFIC_CHILD_COMPONENT.get(componentName)).join(','); const message: string = - `The component '${componentName}' can only have the child component ${specificChildArray}.`; + `The component '${componentName}' can only have the child component '${specificChildArray}'.`; addLog(LogType.ERROR, message, pos, log, sourceFileNode, { code: '10905219' }); } } @@ -1442,7 +1441,7 @@ function validateAccessQualifier(node: ts.PropertyDeclaration, propertyName: str if (accessQualifierResult.hasPublic && FORBIDDEN_PUBLIC_ACCESS.includes(decoratorName)) { transformLog.errors.push({ type: LogType.WARN, - message: `Property '${propertyName}' can not be decorated with both ${decoratorName} and public.`, + message: `Property '${propertyName}' can not be decorated with both '${decoratorName}' and public.`, pos: node.getStart() }); } @@ -1450,14 +1449,14 @@ function validateAccessQualifier(node: ts.PropertyDeclaration, propertyName: str if (FORBIDDEN_PRIVATE_ACCESS.includes(decoratorName)) { transformLog.errors.push({ type: LogType.WARN, - message: `Property '${propertyName}' can not be decorated with both ${decoratorName} and private.`, + message: `Property '${propertyName}' can not be decorated with both '${decoratorName}' and private.`, pos: node.getStart() }); } if (recordRequire.hasRequire && !hasValidatePrivate) { transformLog.errors.push({ type: LogType.WARN, - message: `Property '${propertyName}' can not be decorated with both @Require and private.`, + message: `Property '${propertyName}' can not be decorated with both '@Require' and private.`, pos: node.getStart() }); } @@ -1791,7 +1790,7 @@ function checkEntryComponent(node: ts.StructDeclaration, log: LogInfo[], sourceF if (modifiers) { for (let i = 0; i < modifiers.length; i++) { if (modifiers[i].kind === ts.SyntaxKind.ExportKeyword) { - const message: string = `It's not a recommended way to export struct with @Entry decorator, ` + + const message: string = `It's not a recommended way to export struct with '@Entry' decorator, ` + `which may cause ACE Engine error in component preview mode.`; addLog(LogType.WARN, message, node.getStart(), log, sourceFile); break; diff --git a/compiler/test/transform_ut_error.json b/compiler/test/transform_ut_error.json index 50b3e7cb5..78ef073ba 100644 --- a/compiler/test/transform_ut_error.json +++ b/compiler/test/transform_ut_error.json @@ -1,28 +1,28 @@ { "@linkInitialize": { - "message": "The @Link property 'link' cannot be specified a default value.", + "message": "The '@Link' property cannot be specified a default value.", "type": "ERROR", "code": "10905304", "solutions": ["Please initialize the rules according to the decorator."] }, "@objectLinkInitialize": { - "message": "The @ObjectLink property 'objectLink' cannot be specified a default value.", + "message": "The '@ObjectLink' property cannot be specified a default value.", "type": "ERROR", "code": "10905304", "solutions": ["Please initialize the rules according to the decorator."] }, "rootContainerCheck": { - "message": "There should have a root container component.", + "message": "In an '@Entry' decorated component, the 'build' method can have only one root node, which must be a container component.", "type": "ERROR", "code": "10905210" }, "arkUIComponent": { - "message": "Only UI component syntax can be written in build method.", + "message": "Only UI component syntax can be written here.", "type": "ERROR", "code": "10905209" }, "@BuilderParam": { - "message": "In the trailing lambda case, 'CustomContainer' must have one and only one property decorated with @BuilderParam, and its @BuilderParam expects no parameter.", + "message": "In the trailing lambda case, 'CustomContainer' must have one and only one property decorated with '@BuilderParam', and its '@BuilderParam' expects no parameter.", "type": "ERROR", "code": "10905102" }, @@ -53,7 +53,7 @@ "code": "10905206" }, "stateStyles": { - "message": ".stateStyles doesn't conform standard.", + "message": "'.stateStyles' doesn't conform standard.", "type": "ERROR", "code": "10905203" }, @@ -78,48 +78,48 @@ "code": "10905106" }, "@StylesParamChack": { - "message": "@Styles can't have parameters.", + "message": "'@Styles' decorated functions and methods cannot have arguments.", "type": "ERROR", "code": "10905105" }, "updateHeritageClauses": { - "message": "The struct component is not allowed to extends other class or implements other interface.", + "message": "Structs are not allowed to inherit from classes or implement interfaces.", "type": "ERROR", "code": "10905212" }, "validateBuildMethodCount": { - "message": "struct 'ValidateBuildMethodCountIndex' must be at least or at most one 'build' method.", + "message": "The struct 'ValidateBuildMethodCountIndex' must have at least and at most one 'build' method.", "type": "ERROR", "code": "10905103", "solutions": ["A structurally modified page must have at least one and no more than one 'build' method."] }, "validateHasController": { - "message": "@CustomDialog component should have a property of the CustomDialogController type.", + "message": "The '@CustomDialog' decorated custom component must contain a property of the CustomDialogController type.", "type": "ERROR", "code": "10905211" }, "processWatch": { - "message": "Cannot find name 'onWatch' in struct 'ProcessWatchIndex'.", + "message": "'@Watch' cannot be used with 'onWatch'. Apply it only to parameters that correspond to existing methods.", "type": "ERROR", "code": "10905301" }, "updateBuilderParamProperty": { - "message": "BuilderParam property can only initialized by Builder function or LocalBuilder method in struct.", + "message": "'@BuilderParam' property can only initialized by '@Builder' function or '@LocalBuilder' method in struct.", "type": "ERROR", "code": "10905101" }, "validateMultiDecorators": { - "message": "The property 'lang' cannot have mutilate state management decorators.", + "message": "The property 'lang' cannot have multiple state management decorators.", "type": "ERROR", "code": "10905302" }, "validatePropertyNonDefaultValue": { - "message": "The @State property 'message' must be specified a default value.", + "message": "The '@State' property 'message' must be specified a default value.", "type": "ERROR", "code": "10905303" }, "validatePropertyDefaultValue": { - "message": "The @Link property 'message' cannot be specified a default value.", + "message": "The '@Link' property cannot be specified a default value.", "type": "ERROR", "code": "10905304", "solutions": ["Please initialize the rules according to the decorator."] @@ -130,7 +130,7 @@ "code": "10905305" }, "validateHasIllegalDecoratorInEntry": { - "message": "The @Entry component 'ValidateHasIllegalDecoratorInEntryIndex' cannot have the @Prop property 'message'.", + "message": "The '@Entry' component 'ValidateHasIllegalDecoratorInEntryIndex' cannot have the '@Prop' property 'message'.", "type": "WARN" }, "validateHasIllegalQuestionToken": { @@ -138,27 +138,27 @@ "type": "WARN" }, "validateForbiddenUseStateType": { - "message": "The @State property 'message' cannot be a 'CustomDialogController' object.", + "message": "The '@State' property 'message' cannot be a 'CustomDialogController' object.", "type": "ERROR", "code": "10905308" }, "validateDuplicateDecorator": { - "message": "The inner decorator @State cannot be used together with custom decorator.", + "message": "The inner decorator '@State' cannot be used together with custom decorator.", "type": "ERROR", "code": "10905312" }, "validateWatchDecorator": { - "message": "Regular variable 'message' can not be decorated with @Watch.", + "message": "Regular variable 'message' can not be decorated with '@Watch'.", "type": "ERROR", "code": "10905310" }, "validateWatchParam": { - "message": "The parameter should be a string.", + "message": "'@Watch' cannot be used with '111'. Apply it only to 'string' parameters.", "type": "ERROR", "code": "10905311" }, "validateCustomDecorator": { - "message": "The inner decorator @State cannot be used together with custom decorator.", + "message": "The inner decorator '@State' cannot be used together with custom decorator.", "type": "ERROR", "code": "10905312" }, @@ -167,12 +167,12 @@ "type": "WARN" }, "validateForbiddenToInitViaParam": { - "message": "Property 'message' in the custom component 'ValidateForbiddenToInitViaParamChild' cannot be initialized here (forbidden to specify).", + "message": "The '@StorageProp' property 'message' in the custom component 'ValidateForbiddenToInitViaParamChild' cannot be initialized here (forbidden to specify).", "type": "ERROR", "code": "10905317" }, "validateMandatoryToInitViaParam": { - "message": "Property 'message' in the custom component 'ValidateMandatoryToInitViaParamChild' is missing (mandatory to specify).", + "message": "The property 'message' in the custom component 'ValidateMandatoryToInitViaParamChild' is missing (mandatory to specify).", "type": "ERROR", "code": "10905316" }, @@ -204,7 +204,7 @@ } ], "validateIllegalInitFromParent": { - "message": "The regular property 'message' cannot be assigned to the @Link property 'message'.", + "message": "The 'regular' property 'message' cannot be assigned to the '@Link' property 'message'.", "type": "ERROR", "code": "10905315" }, @@ -236,7 +236,7 @@ "type": "WARN" }, "notConcurrentFun": { - "message": "@Concurrent can not be used on method. please use it on function declaration.", + "message": "'@Concurrent' can not be used on method, please use it on function declaration.", "type": "ERROR", "code": "10905123" }, @@ -263,7 +263,7 @@ "code": "10905228" }, "notConcurrentFunAster": { - "message": "@Concurrent can not be used on Generator function declaration.", + "message": "'@Concurrent' can not be used on 'Generator' function declaration.", "type": "ERROR", "code": "10905122" }, @@ -273,12 +273,12 @@ "code": "10905337" }, "MethodNoExtend": { - "message": "The '@Extend' decorator can not be a member property method of a 'class' or 'struct'.", + "message": "Use the '@Extend' decorator only in the global scope.", "type": "ERROR", "code": "10905113" }, "OnlyStructDeco": { - "message": "The '@Builder' decorator can only be used in 'struct'.", + "message": "Use the '@Builder' decorator only in the global scope or in a struct.", "type": "ERROR", "code": "10905114" }, @@ -288,17 +288,17 @@ "code": "10905222" }, "OneChild": { - "message": "The component 'Button' can only have a single child component.", + "message": "The 'Button' component can have only one child component.", "type": "ERROR", "code": "10905220" }, "NotSupportResrcParam": { - "message": "The input parameter is not supported.", + "message": "Invalid resource file parameter. Enter a value in the format of 'xxx.yyy.zzz'.", "type": "ERROR", "code": "10905332" }, "ExtendOneChild": { - "message": "@Extend should have one and only one parameter", + "message": "'@Extend' should have one and only one parameter.", "type": "ERROR", "code": "10905108" }, @@ -318,7 +318,7 @@ "code": "10903329" }, "NotSupportResrcType": { - "message": "The resource type font is not supported.", + "message": "The resource type 'font' is not supported.", "type": "ERROR", "code": "10906334" }, @@ -328,11 +328,11 @@ "code": "10904333" }, "EntryDecoParam": { - "message": "@Entry should have a parameter, like '@Entry (storage)'.", + "message": "'@Entry' should have a parameter, like '@Entry (storage)'.", "type": "WARN" }, "StylesNoParam": { - "message": "@Styles can't have parameters.", + "message": "'@Styles' decorated functions and methods cannot have arguments.", "type": "ERROR", "code": "10905105" }, @@ -372,24 +372,24 @@ }, "@Trace": [ { - "message": "The '@Trace' decorator can only be used in 'class'.", + "message": "The '@Trace' decorator can decorate only member variables of a class.", "type": "ERROR", "code": "10905345" }, { - "message": "The '@Trace' can decorate only member variables within a 'class' decorated with ObservedV2.", + "message": "The '@Trace' can decorate only member 'variables' within a 'class' decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905343" } ], "@Type": [ { - "message": "The '@Type' decorator can only be used in 'class'.", + "message": "The '@Type' decorator can decorate only member variables of a class.", "type": "ERROR", "code": "10905345" }, { - "message": "The '@Type' decorator can not be used in a 'class' decorated with Sendable.", + "message": "The '@Type' decorator can not be used in a 'class' decorated with '@Sendable'.", "type": "ERROR", "code": "10905342" }, @@ -399,7 +399,7 @@ "code": "10905340" }, { - "message": "The '@Type' decorator can not be used in a 'class' decorated with Observed.", + "message": "The '@Type' decorator can not be used in a 'class' decorated with '@Observed'.", "type": "ERROR", "code": "10905341" }, @@ -415,32 +415,32 @@ "type": "WARN" }, { - "message": "The '@Trace' decorator can only be used in 'class'.", + "message": "The '@Trace' decorator can decorate only member variables of a class.", "type": "ERROR", "code": "10905345" }, { - "message": "The '@ObservedV2' decorator can only be used in 'class'.", + "message": "The '@ObservedV2' decorator can decorate only member variables of a class.", "type": "ERROR", "code": "10905345" }, { - "message": "The '@Trace' can decorate only member variables within a 'class' decorated with ObservedV2.", + "message": "The '@Trace' can decorate only member 'variables' within a 'class' decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905343" } ], "validateAccessQualifier": [ { - "message": "Property 'storage_value' can not be decorated with both @StorageLink and public.", + "message": "Property 'storage_value' can not be decorated with both '@StorageLink' and public.", "type": "WARN" }, { - "message": "Property 'consume_value' can not be decorated with both @Consume and public.", + "message": "Property 'consume_value' can not be decorated with both '@Consume' and public.", "type": "WARN" }, { - "message": "Property 'link_value' can not be decorated with both @Link and private.", + "message": "Property 'link_value' can not be decorated with both '@Link' and private.", "type": "WARN" }, { @@ -448,11 +448,11 @@ "type": "WARN" }, { - "message": "Property 'prop_value' can not be decorated with both @Require and private.", + "message": "Property 'prop_value' can not be decorated with both '@Require' and private.", "type": "WARN" }, { - "message": "Property 'value' can not be decorated with both @Require and private.", + "message": "Property 'value' can not be decorated with both '@Require' and private.", "type": "WARN" }, { @@ -474,7 +474,7 @@ ], "@Monitor": [ { - "message": "The '@Monitor' can decorate only member method within a 'class' decorated with ObservedV2.", + "message": "The '@Monitor' can decorate only member 'method' within a 'class' decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905343" } @@ -671,7 +671,7 @@ ], "v2MemberDecorator": [ { - "message": "@Computed can only decorate 'GetAccessor'.", + "message": "'@Computed' can only decorate 'GetAccessor'.", "type": "ERROR", "code": "10905116" }, @@ -681,7 +681,7 @@ "code": "10905346" }, { - "message": "@Computed can only decorate 'GetAccessor'.", + "message": "'@Computed' can only decorate 'GetAccessor'.", "type": "ERROR", "code": "10905116" }, @@ -693,61 +693,61 @@ ], "param_require_once_check": [ { - "message": "When a variable decorated with @Param is not assigned a default value, it must also be decorated with @Require.", + "message": "When a variable decorated with '@Param' is not assigned a default value, it must also be decorated with '@Require'.", "type": "ERROR", "code": "10905327" }, { - "message": "In a struct decorated with @ComponentV2, @Require can only be used with @Param.", + "message": "In a struct decorated with '@ComponentV2', '@Require' can only be used with '@Param'.", "type": "ERROR", "code": "10905325" }, { - "message": "In a struct decorated with @ComponentV2, @Require can only be used with @Param.", + "message": "In a struct decorated with '@ComponentV2', '@Require' can only be used with '@Param'.", "type": "ERROR", "code": "10905325" }, { - "message": "When a variable decorated with @Once, it must also be decorated with @Param.", + "message": "When a variable decorated with '@Once', it must also be decorated with '@Param'.", "type": "ERROR", "code": "10905326" }, { - "message": "When a variable decorated with @Once, it must also be decorated with @Param.", + "message": "When a variable decorated with '@Once', it must also be decorated with '@Param'.", "type": "ERROR", "code": "10905326" } ], "v2DecoratorInitFromParent": [ { - "message": "Property 'param_value' must be initialized through the component constructor.", + "message": "'@Require' decorated 'param_value' must be initialized through the component constructor.", "type": "ERROR", "code": "10905321" }, { - "message": "Property 'regular_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", + "message": "The 'regular' property 'regular_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", "type": "ERROR", "code": "10905324" }, { - "message": "Property 'local_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", + "message": "The '@Local' property 'local_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", "type": "ERROR", "code": "10905324" }, { - "message": "Property 'provider_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", + "message": "The '@Provider' property 'provider_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", "type": "ERROR", "code": "10905324" }, { - "message": "Property 'consumer_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", + "message": "The '@Consumer' property 'consumer_value' in the custom component 'testChild' cannot be initialized here (forbidden to specify).", "type": "ERROR", "code": "10905324" } ], "validateParamTwoWayBind": [ { - "message": "When the two-way binding syntax is used, the variable 'value' must be decorated with @Param, and the @Event variable '$value' must be defined in the testParamChild1.", + "message": "When the two-way binding syntax is used, the variable 'value' must be decorated with '@Param', and the '@Event' variable '$value' must be defined in the testParamChild1.", "type": "ERROR", "code": "10905319" }, @@ -798,24 +798,24 @@ "type": "WARN" }, { - "message": "Property 'b1' in the custom component 'StaticChildTwo' cannot be initialized here (forbidden to specify).", + "message": "The 'regular' property 'b1' in the custom component 'StaticChildTwo' cannot be initialized here (forbidden to specify).", "type": "ERROR", "code": "10905324" }, { - "message": "Property 'd1' in the custom component 'StaticChildFour' cannot be initialized here (forbidden to specify).", + "message": "The 'regular' property 'd1' in the custom component 'StaticChildFour' cannot be initialized here (forbidden to specify).", "type": "ERROR", "code": "10905324" } ], "validateDifferentMethod": [ { - "message": "A function can only be decorated by one of the 'AnimatableExtend, Builder, Extend, Styles, Concurrent and Sendable'.", + "message": "A function can only be decorated by one of the '@AnimatableExtend', '@Builder', '@Extend', '@Styles', '@Concurrent' and '@Sendable'.", "type": "ERROR", "code": "10905117" }, { - "message": "A function can only be decorated by one of the 'AnimatableExtend, Builder, Extend, Styles, Concurrent and Sendable'.", + "message": "A function can only be decorated by one of the '@AnimatableExtend', '@Builder', '@Extend', '@Styles', '@Concurrent' and '@Sendable'.", "type": "ERROR", "code": "10905117" }, @@ -835,7 +835,7 @@ "code": "10905121" }, { - "message": "@Computed can only decorate 'GetAccessor'.", + "message": "'@Computed' can only decorate 'GetAccessor'.", "type": "ERROR", "code": "10905116" }, @@ -883,39 +883,39 @@ ], "v2ToV1Link": [ { - "message": "Property 'link_value' in the custom component 'V1' is missing (mandatory to specify).", + "message": "The property 'link_value' in the custom component 'V1' is missing (mandatory to specify).", "type": "ERROR", "code": "10905316" }, { - "message": "Property 'link_value' in the custom component 'V1' is missing (mandatory to specify).", + "message": "The property 'link_value' in the custom component 'V1' is missing (mandatory to specify).", "type": "ERROR", "code": "10905316" }, { - "message": "The @ComponentV2 struct must not contain any @Component with an @Link decorated variable", + "message": "A V2 component cannot be used with any member property decorated by '@Link' in a V1 component.", "type": "ERROR", "code": "10905213" }, { - "message": "The @ComponentV2 struct must not contain any @Component with an @Link decorated variable", + "message": "A V2 component cannot be used with any member property decorated by '@Link' in a V1 component.", "type": "ERROR", "code": "10905213" }, { - "message": "The @ComponentV2 struct must not contain any @Component with an @Link decorated variable", + "message": "A V2 component cannot be used with any member property decorated by '@Link' in a V1 component.", "type": "ERROR", "code": "10905213" }, { - "message": "The @ComponentV2 struct must not contain any @Component with an @Link decorated variable", + "message": "A V2 component cannot be used with any member property decorated by '@Link' in a V1 component.", "type": "ERROR", "code": "10905213" } ], "@localBuilder": [ { - "message": "A function can only be decorated by one of the 'AnimatableExtend, Builder, Extend, Styles, Concurrent and Sendable'.", + "message": "A function can only be decorated by one of the '@AnimatableExtend', '@Builder', '@Extend', '@Styles', '@Concurrent' and '@Sendable'.", "type": "ERROR", "code": "10905117" }, @@ -930,12 +930,12 @@ "code": "10905125" }, { - "message": "The '@LocalBuilder' decorator can only be used in 'struct'.", + "message": "Use the '@LocalBuilder' decorator only in the global scope or in a struct.", "type": "ERROR", "code": "10905114" }, { - "message": "Static methods in custom components cannot be decorated by @LocalBuilder.", + "message": "Static methods in custom components cannot be decorated by '@LocalBuilder'.", "type": "ERROR", "code": "10905104" } @@ -989,79 +989,79 @@ ], "v2ToV1ComponentValidate": [ { - "message": "The @ComponentV2 struct must not contain any @Component with an @Link decorated variable", + "message": "A V2 component cannot be used with any member property decorated by '@Link' in a V1 component.", "type": "ERROR", "code": "10905213" }, { - "message": "The @ComponentV2 struct must not contain any @Component with an @Link decorated variable", + "message": "A V2 component cannot be used with any member property decorated by '@Link' in a V1 component.", "type": "ERROR", "code": "10905213" } ], "property_observe_validate": [ { - "message": "The type of the @State property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@State' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @State property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@State' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @State property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@State' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @State property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@State' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @State property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@State' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @Prop property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@Prop' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @Link property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@Link' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @Provide property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@Provide' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @Consume property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@Consume' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @StorageLink property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@StorageLink' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @StorageProp property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@StorageProp' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @LocalStorageLink property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@LocalStorageLink' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" }, { - "message": "The type of the @LocalStorageProp property can not be a class decorated with @ObservedV2.", + "message": "The type of the '@LocalStorageProp' property can not be a class decorated with '@ObservedV2'.", "type": "ERROR", "code": "10905348" } @@ -1074,12 +1074,12 @@ ], "@ReusableV2": [ { - "message": "@ReusableV2 is only applicable to custom components decorated by @ComponentV2.", + "message": "'@ReusableV2' is only applicable to custom components decorated by '@ComponentV2'.", "type": "ERROR", "code": "10905242" }, { - "message": "The @Reusable and @ReusableV2 decoraotrs cannot be applied simultaneously.", + "message": "The '@Reusable' and '@ReusableV2' decoraotrs cannot be applied simultaneously.", "type": "ERROR", "code": "10905241" }, @@ -1089,27 +1089,27 @@ "code": "10905229" }, { - "message": "The @Reusable and @ReusableV2 decoraotrs cannot be applied simultaneously.", + "message": "The '@Reusable' and '@ReusableV2' decoraotrs cannot be applied simultaneously.", "type": "ERROR", "code": "10905241" }, { - "message": "@ReusableV2 is only applicable to custom components decorated by @ComponentV2.", + "message": "'@ReusableV2' is only applicable to custom components decorated by '@ComponentV2'.", "type": "ERROR", "code": "10905242" }, { - "message": "@ReusableV2 is only applicable to custom components decorated by @ComponentV2.", + "message": "'@ReusableV2' is only applicable to custom components decorated by '@ComponentV2'.", "type": "ERROR", "code": "10905242" }, { - "message": "@ReusableV2 is only applicable to custom components decorated by @ComponentV2.", + "message": "'@ReusableV2' is only applicable to custom components decorated by '@ComponentV2'.", "type": "ERROR", "code": "10905242" }, { - "message": "@ReusableV2 is only applicable to custom components decorated by @ComponentV2.", + "message": "'@ReusableV2' is only applicable to custom components decorated by '@ComponentV2'.", "type": "ERROR", "code": "10905242" }, @@ -1119,7 +1119,7 @@ "code": "10905337" }, { - "message": "A function can only be decorated by one of the 'AnimatableExtend, Builder, Extend, Styles, Concurrent and Sendable'.", + "message": "A function can only be decorated by one of the '@AnimatableExtend', '@Builder', '@Extend', '@Styles', '@Concurrent' and '@Sendable'.", "type": "ERROR", "code": "10905117" }, @@ -1129,7 +1129,7 @@ "code": "10905337" }, { - "message": "A function can only be decorated by one of the 'AnimatableExtend, Builder, Extend, Styles, Concurrent and Sendable'.", + "message": "A function can only be decorated by one of the '@AnimatableExtend', '@Builder', '@Extend', '@Styles', '@Concurrent' and '@Sendable'.", "type": "ERROR", "code": "10905117" }, @@ -1139,7 +1139,7 @@ "code": "10905337" }, { - "message": "A function can only be decorated by one of the 'AnimatableExtend, Builder, Extend, Styles, Concurrent and Sendable'.", + "message": "A function can only be decorated by one of the '@AnimatableExtend', '@Builder', '@Extend', '@Styles', '@Concurrent' and '@Sendable'.", "type": "ERROR", "code": "10905117" }, @@ -1151,108 +1151,108 @@ ], "validateNestedReusableComponents": [ { - "message": "When a custom component is decorated with @ComponentV2 and contains a child decorated with @Reusable, the child component will not create.", + "message": "When a custom component is decorated with '@ComponentV2' and contains a child decorated with '@Reusable', the child component will not create.", "type": "WARN" }, { - "message": "When a custom component is decorated with @ComponentV2 and contains a child decorated with @Reusable, the child component will not create.", + "message": "When a custom component is decorated with '@ComponentV2' and contains a child decorated with '@Reusable', the child component will not create.", "type": "WARN" }, { - "message": "A custom component decorated with @Component cannot contain child components decorated with @ReusableV2.", - "type": "ERROR", + "message": "A custom component decorated with '@Component' cannot contain child components decorated with '@ReusableV2'.", + "type": "ERROR", "code": "10905244" }, { - "message": "A custom component decorated with @Component cannot contain child components decorated with @ReusableV2.", + "message": "A custom component decorated with '@Component' cannot contain child components decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905244" }, { - "message": "A custom component decorated with @ReusableV2 cannot contain child components decorated with @Reusable.", + "message": "A custom component decorated with '@ReusableV2' cannot contain child components decorated with '@Reusable'.", "type": "ERROR", "code": "10905246" }, { - "message": "A custom component decorated with @ReusableV2 cannot contain child components decorated with @Reusable.", + "message": "A custom component decorated with '@ReusableV2' cannot contain child components decorated with '@Reusable'.", "type": "ERROR", "code": "10905246" }, { - "message": "A custom component decorated with @Reusable cannot contain child components decorated with @ReusableV2.", + "message": "A custom component decorated with '@Reusable' cannot contain child components decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905245" }, { - "message": "A custom component decorated with @Reusable cannot contain child components decorated with @ReusableV2.", + "message": "A custom component decorated with '@Reusable' cannot contain child components decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905245" } ], "validateReusableV2InRepeat": [ { - "message": "The template attribute of the Repeat component cannot contain any custom component decorated with @ReusableV2.", + "message": "The template attribute of the Repeat component cannot contain any custom component decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905247" }, { - "message": "The template attribute of the Repeat component cannot contain any custom component decorated with @ReusableV2.", + "message": "The template attribute of the Repeat component cannot contain any custom component decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905247" }, { - "message": "The template attribute of the Repeat component cannot contain any custom component decorated with @ReusableV2.", + "message": "The template attribute of the Repeat component cannot contain any custom component decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905247" }, { - "message": "The template attribute of the Repeat component cannot contain any custom component decorated with @ReusableV2.", + "message": "The template attribute of the Repeat component cannot contain any custom component decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905247" }, { - "message": "The template attribute of the Repeat component cannot contain any custom component decorated with @ReusableV2.", + "message": "The template attribute of the Repeat component cannot contain any custom component decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905247" }, { - "message": "The template attribute of the Repeat component cannot contain any custom component decorated with @ReusableV2.", + "message": "The template attribute of the Repeat component cannot contain any custom component decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905247" }, { - "message": "The template attribute of the Repeat component cannot contain any custom component decorated with @ReusableV2.", + "message": "The template attribute of the Repeat component cannot contain any custom component decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905247" }, { - "message": "The template attribute of the Repeat component cannot contain any custom component decorated with @ReusableV2.", + "message": "The template attribute of the Repeat component cannot contain any custom component decorated with '@ReusableV2'.", "type": "ERROR", "code": "10905247" } ], "validateReuseAndReuseId": [ { - "message": "When a custom component is decorated with @ComponentV2 and contains a child decorated with @Reusable, the child component will not create.", + "message": "When a custom component is decorated with '@ComponentV2' and contains a child decorated with '@Reusable', the child component will not create.", "type": "WARN" }, { - "message": "The reuse attribute is only applicable to custom components decorated with both @ComponentV2 and @ReusableV2.", + "message": "The reuse attribute is only applicable to custom components decorated with both '@ComponentV2' and '@ReusableV2'.", "type": "ERROR", "code": "10905248" }, { - "message": "The reuse attribute is only applicable to custom components decorated with both @ComponentV2 and @ReusableV2.", + "message": "The reuse attribute is only applicable to custom components decorated with both '@ComponentV2' and '@ReusableV2'.", "type": "ERROR", "code": "10905248" }, { - "message": "The reuse attribute is only applicable to custom components decorated with both @ComponentV2 and @ReusableV2.", + "message": "The reuse attribute is only applicable to custom components decorated with both '@ComponentV2' and '@ReusableV2'.", "type": "ERROR", "code": "10905248" }, { - "message": "The reuseId attribute is not applicable to custom components decorated with both @ComponentV2 and @ReusableV2.", + "message": "The reuseId attribute is not applicable to custom components decorated with both '@ComponentV2' and '@ReusableV2'.", "type": "ERROR", "code": "10905249" } -- Gitee From 29a3c94173f0edc6f948c7b133e443a27618f0da Mon Sep 17 00:00:00 2001 From: Yenan Date: Mon, 24 Mar 2025 19:07:54 +0800 Subject: [PATCH 003/140] yenan10@huawei.com Signed-off-by: Yenan --- compiler/src/process_component_build.ts | 4 ++-- compiler/src/validate_ui_syntax.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 0f47c26a7..ef2e9778a 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -371,8 +371,8 @@ function validateRootNode(node: ts.MethodDeclaration, log: LogInfo[]): boolean { if (!isValid) { log.push({ type: LogType.ERROR, - message: `In an '@Entry' decorated component, the 'build' method can have only one root node,` - + ` which must be a container component.`, + message: `In an '@Entry' decorated component, the 'build' method can have only one root node,` + + ` which must be a container component.`, pos: node.body.statements.pos, code: '10905210' }); diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 2feb3a3c4..acb245b60 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -781,8 +781,8 @@ function validateMemberInClass(isObservedClass: boolean, decoratorName: string, log: LogInfo[], sourceFileNode: ts.SourceFile, isObservedV1Class: boolean, isSendableClass: boolean, isTypeFromSdk: boolean): void { if (decoratorName === CLASS_TRACK_DECORATOR) { if (isObservedClass) { - const message: string = `'@${decoratorName}' cannot be used with classes decorated by '@ObservedV2.'` - + ` Use the '@Trace' decorator instead.`; + const message: string = `'@${decoratorName}' cannot be used with classes decorated by '@ObservedV2.'` + + ` Use the '@Trace' decorator instead.`; addLog(LogType.ERROR, message, node.pos, log, sourceFileNode, { code: '10905344' }); } return; -- Gitee From 67052219166cd57149115d2d25cb9be7573871c0 Mon Sep 17 00:00:00 2001 From: Yenan Date: Tue, 25 Mar 2025 15:40:26 +0800 Subject: [PATCH 004/140] yenan10@huawei.com Signed-off-by: Yenan --- compiler/src/ets_checker.ts | 2 +- compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 51942e5a0..6475c8715 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -568,7 +568,7 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null } } -function traverseProgramSourceFiles(props: string[]): void { +export function traverseProgramSourceFiles(props: string[]): void { globalProgram.program.getSourceFiles().forEach((sourceFile: ts.SourceFile) => { checkUISyntax(sourceFile, sourceFile.fileName, [], props); }) diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts index c17bb5c78..5e3dc9f20 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts @@ -30,7 +30,8 @@ import { runArkTSLinter, targetESVersionChanged, collectFileToIgnoreDiagnostics, - TSC_SYSTEM_CODE + TSC_SYSTEM_CODE, + traverseProgramSourceFiles } from '../../ets_checker'; import { TS_WATCH_END_MSG } from '../../pre_define'; import { @@ -110,6 +111,7 @@ export function etsChecker() { timePrinterInstance.appendTime(ts.TimePhase.START); globalProgram.builderProgram = languageService.getBuilderProgram(/*withLinterProgram*/ true); globalProgram.program = globalProgram.builderProgram.getProgram(); + traverseProgramSourceFiles(languageService.getProps()); timePrinterInstance.appendTime(ts.TimePhase.GET_PROGRAM); MemoryMonitor.stopRecordStage(buildProgramRecordInfo); const collectFileToIgnore = MemoryMonitor.recordStage(MemoryDefine.COLLECT_FILE_TOIGNORE_RUN_TSLINTER); -- Gitee From 48356c882afc92ffaa6e439854f5f8ccdc5e3d04 Mon Sep 17 00:00:00 2001 From: Yenan Date: Wed, 26 Mar 2025 17:37:54 +0800 Subject: [PATCH 005/140] yenan10@huawei.com Signed-off-by: Yenan --- compiler/src/validate_ui_syntax.ts | 34 +++++++++++++++++++++++---- compiler/test/transform_ut_error.json | 16 ++++++------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index acb245b60..46c8942c4 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -576,14 +576,14 @@ function checkDecoratorCount(node: ts.Node, sourceFileNode: ts.SourceFile, log: if (ts.isPropertyDeclaration(node) || ts.isGetAccessor(node) || ts.isMethodDeclaration(node)) { const decorators: readonly ts.Decorator[] = ts.getAllDecorators(node); let innerDecoratorCount: number = 0; - const exludeDecorators: string[] = ['@Require', '@Once']; + const excludeDecorators: string[] = ['@Require', '@Once']; const v1MethodDecorators: string[] = ['@Builder', '@Styles']; const v1DecoratorMap: Map = new Map(); const v2DecoratorMap: Map = new Map(); let checkDecoratorCount: number = 0; decorators.forEach((item: ts.Decorator) => { const decoratorName: string = item.getText().replace(/\([^\(\)]*\)/, ''); - if (!exludeDecorators.includes(decoratorName) && (constantDefine.DECORATOR_V2.includes(decoratorName) || + if (!excludeDecorators.includes(decoratorName) && (constantDefine.DECORATOR_V2.includes(decoratorName) || decoratorName === '@BuilderParam')) { const count: number = v2DecoratorMap.get(decoratorName) || 0; v2DecoratorMap.set(decoratorName, count + 1); @@ -613,15 +613,28 @@ function checkDecoratorCount(node: ts.Node, sourceFileNode: ts.SourceFile, log: v2DecoratorMapValues.some((count: number) => count > 1); const v1Duplicate: boolean = v1DecoratorMapValues.length && v1DecoratorMapValues.some((count: number) => count > 1); - const duplicateMessage: string = 'Duplicate decorators for method are not allowed.'; if (v1Duplicate) { + const duplicateDecorators: string = findDuplicateDecoratorMethod(v1DecoratorMapKeys, v1DecoratorMapValues); + const duplicateMessage: string = `Duplicate '${duplicateDecorators}' decorators for method are not allowed.`; addLog(LogType.WARN, duplicateMessage, node.getStart(), log, sourceFileNode); } else if (v2Duplicate) { + const duplicateDecorators: string = findDuplicateDecoratorMethod(v2DecoratorMapKeys, v2DecoratorMapValues); + const duplicateMessage: string = `Duplicate '${duplicateDecorators}' decorators for method are not allowed.`; addLog(LogType.ERROR, duplicateMessage, node.getStart(), log, sourceFileNode, { code: '10905119' }); } } } +function findDuplicateDecoratorMethod(mapKeys: string[], mapValues: number[]): string { + const duplicateDecorators: string[] = []; + mapValues.forEach((value, index) => { + value > 1 && duplicateDecorators.push(mapKeys[index]); + }); + const output = duplicateDecorators.length > 1 ? + duplicateDecorators.join(', ') : duplicateDecorators[0]; + return output; +} + export function methodDecoratorCollect(node: ts.MethodDeclaration | ts.FunctionDeclaration): void { const extendResult: ExtendResult = { decoratorName: '', componentName: '' }; const builderCondition: builderConditionType = { @@ -676,13 +689,14 @@ function validateFunction(node: ts.MethodDeclaration | ts.FunctionDeclaration, decoratorMap.set(decoratorName, count + 1); }); const decoratorValues: number[] = Array.from(decoratorMap.values()); + const decoratorKeys: string[] = Array.from(decoratorMap.keys()); const hasDuplicate: boolean = decoratorValues.length && decoratorValues.some((count: number) => count > 1); if (hasDuplicate) { - const message: string = 'Duplicate decorators for function are not allowed.'; + const duplicateDecorators: string = findDuplicateDecoratorFunction(decoratorKeys, decoratorValues); + const message: string = `Duplicate '@${duplicateDecorators}' decorators for function are not allowed.`; addLog(LogType.WARN, message, node.getStart(), log, sourceFileNode); } - const decoratorKeys: string[] = Array.from(decoratorMap.keys()); if (decoratorKeys.length > 1 || decoratorKeys.includes('LocalBuilder')) { const message: string = 'A function can only be decorated by one of the ' + `'@AnimatableExtend', '@Builder', '@Extend', '@Styles', '@Concurrent' and '@Sendable'.`; @@ -691,6 +705,16 @@ function validateFunction(node: ts.MethodDeclaration | ts.FunctionDeclaration, } } +function findDuplicateDecoratorFunction(mapKeys: string[], mapValues: number[]): string { + const duplicateDecorators: string[] = []; + mapValues.forEach((value, index) => { + value > 1 && duplicateDecorators.push(mapKeys[index]); + }); + const output = duplicateDecorators.length > 1 ? + duplicateDecorators.join(', @') : duplicateDecorators[0]; + return output; +} + function checkDecorator(sourceFileNode: ts.SourceFile, node: ts.Node, log: LogInfo[], structContext: boolean, classContext: boolean, isObservedClass: boolean, isComponentV2: boolean, isObservedV1Class: boolean, isSendableClass: boolean): void { diff --git a/compiler/test/transform_ut_error.json b/compiler/test/transform_ut_error.json index 78ef073ba..19b04467a 100644 --- a/compiler/test/transform_ut_error.json +++ b/compiler/test/transform_ut_error.json @@ -847,36 +847,36 @@ ], "validateDuplicateMethod": [ { - "message": "Duplicate decorators for function are not allowed.", + "message": "Duplicate '@Builder' decorators for function are not allowed.", "type": "WARN" }, { - "message": "Duplicate decorators for function are not allowed.", + "message": "Duplicate '@CustomMethod' decorators for function are not allowed.", "type": "WARN" }, { - "message": "Duplicate decorators for method are not allowed.", + "message": "Duplicate '@Builder' decorators for method are not allowed.", "type": "WARN" }, { - "message": "Duplicate decorators for method are not allowed.", + "message": "Duplicate '@Styles' decorators for method are not allowed.", "type": "WARN" }, { - "message": "Duplicate decorators for method are not allowed.", + "message": "Duplicate '@Builder' decorators for method are not allowed.", "type": "WARN" }, { - "message": "Duplicate decorators for method are not allowed.", + "message": "Duplicate '@Styles' decorators for method are not allowed.", "type": "WARN" }, { - "message": "Duplicate decorators for method are not allowed.", + "message": "Duplicate '@Monitor' decorators for method are not allowed.", "type": "ERROR", "code": "10905119" }, { - "message": "Duplicate decorators for method are not allowed.", + "message": "Duplicate '@Computed' decorators for method are not allowed.", "type": "ERROR", "code": "10905119" } -- Gitee From e56a954addb658340a2d554ed05e136fc01c422d Mon Sep 17 00:00:00 2001 From: zhangkai366 Date: Thu, 27 Feb 2025 16:55:35 +0800 Subject: [PATCH 006/140] Check whether the file contains wildcard Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IBPGE3 Test: arkTest Signed-off-by: zhangkai366 Change-Id: Ie17f79cf0a5ccf23754dbef98aa6b579f4106f81 --- .../obfuscateWhiteList.test.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 compiler/test/ark_compiler_ut/obfuscateWhiteList.test.ts diff --git a/compiler/test/ark_compiler_ut/obfuscateWhiteList.test.ts b/compiler/test/ark_compiler_ut/obfuscateWhiteList.test.ts new file mode 100644 index 000000000..3d5ba97a2 --- /dev/null +++ b/compiler/test/ark_compiler_ut/obfuscateWhiteList.test.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use rollupObject 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 { expect } from 'chai'; +import fs from 'fs'; +import JSON5 from 'json5'; +import mocha from 'mocha'; +import path from 'path'; + +mocha.describe('verify that the obfuscateWhiteList.json5 contains wildcards', () => { + const OBFUSCATE_WHITELIST_DIR = path.resolve(__dirname, '../../'); + const arkUIWhitelistPath = path.join(OBFUSCATE_WHITELIST_DIR, './config/obfuscateWhiteList.json5'); + const arkUIWhitelist = JSON5.parse(fs.readFileSync(arkUIWhitelistPath, 'utf-8')); + const wildcardsRegex = /[\*\?]/; + + mocha.it('should not contain wildcards(* or ?) in ReservedPropertyNames', () => { + arkUIWhitelist.ReservedPropertyNames.forEach((name: string) => { + expect(wildcardsRegex.test(name)).to.be.false; + }); + }); + + mocha.it('should not contain wildcards(* or ?) in OptimizedReservedPropertyNames', () => { + arkUIWhitelist.OptimizedReservedPropertyNames.forEach((name: string) => { + expect(wildcardsRegex.test(name)).to.be.false; + }); + }); +}); -- Gitee From a224c9e6b621681752acf4f51b52486b91b96952 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Thu, 3 Apr 2025 14:27:28 +0800 Subject: [PATCH 007/140] jiangbo91@huawei.com clean @Reusable add Signed-off-by: Bojiang Change-Id: I6e85992c40316c01319adbb73e0b0048eb6bc31b --- compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index e1c3280f9..eb361d0d9 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -625,6 +625,7 @@ function resetCollection() { propertyCollection.clear(); linkCollection.clear(); EXTEND_ATTRIBUTE.clear(); + storedFileInfo.getCurrentArkTsFile().reuseComponentsV2.clear(); resetComponentCollection(); storedFileInfo.hasLocalBuilderInFile = false; } -- Gitee From fa9a3bdcc9fe619519a3e5265c085794fee00ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czhuzhihui7=E2=80=9D?= <“hzharmony@123”> Date: Fri, 7 Mar 2025 16:40:58 +0800 Subject: [PATCH 008/140] Support obfuscation performance metrics Issue: IBM4SR Signed-off-by: zhuzhihui7 --- .../ark_compiler/common/ob_config_resolver.ts | 6 ++ .../ark_compiler/common/process_ark_config.ts | 3 + .../common/ob_config_resolver.test.ts | 58 ++++++++++++++++++- .../common/process_ark_config.test.ts | 33 ++++++++++- 4 files changed, 98 insertions(+), 2 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts b/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts index b01c71e06..f3e27ff9e 100644 --- a/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts +++ b/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts @@ -23,6 +23,7 @@ import { deleteLineInfoForNameString, endFilesEvent, endSingleFileEvent, + enableTimeAndMemoryPrint, EventList, getRelativeSourcePath, handleUniversalPathInObf, @@ -32,6 +33,7 @@ import { performancePrinter, printTimeSumData, printTimeSumInfo, + PerfMode, ProjectCollections, startFilesEvent, startSingleFileEvent, @@ -497,4 +499,8 @@ export function writeObfuscationCaches(sourceProjectConfig: Object, eventOrEvent } stopEvent(eventObfuscatedCode); + + if (sourceProjectConfig.perf === PerfMode.ADVANCED) { + enableTimeAndMemoryPrint(); + } } \ No newline at end of file diff --git a/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts b/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts index 3ed2cbe7b..05c8b393a 100644 --- a/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts +++ b/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts @@ -23,6 +23,7 @@ import { EventList, blockPrinter, endFilesEvent, + configurePerformancePrinter, startFilesEvent } from 'arkguard'; @@ -184,6 +185,8 @@ export function initArkProjectConfig(share: Object): Object { } if (!isDebug(projectConfig)) { arkProjectConfig.useTsHar = mainProjectConfig.useTsHar; + // Configure the performance printer for obfuscation performance tracking + configurePerformancePrinter(projectConfig.perf); startFilesEvent(EventList.OBFUSCATION_INITIALIZATION, performancePrinter.timeSumPrinter); const recordInfo = MemoryMonitor.recordStage(MemoryDefine.INIT_ARK_PROJECT_CONFIG); MemoryMonitor.stopRecordStage(recordInfo); diff --git a/compiler/test/ark_compiler_ut/common/ob_config_resolver.test.ts b/compiler/test/ark_compiler_ut/common/ob_config_resolver.test.ts index a8045dafa..19723ec8e 100644 --- a/compiler/test/ark_compiler_ut/common/ob_config_resolver.test.ts +++ b/compiler/test/ark_compiler_ut/common/ob_config_resolver.test.ts @@ -32,6 +32,7 @@ import { setUnobfuscationNames, sourceFileDependencies, writeObfuscatedFile, + writeObfuscationCaches, IDENTIFIER_CACHE, updateIncrementalCaches, readProjectCaches, @@ -47,7 +48,15 @@ import { import { OBFUSCATION_TOOL } from '../../../lib/fast_build/ark_compiler/common/ark_define'; import { RELEASE } from '../../../lib/fast_build/ark_compiler/common/ark_define'; import RollUpPluginMock from '../mock/rollup_mock/rollup_plugin_mock'; -import { ArkObfuscator, nameCacheMap, unobfuscationNamesObj, ProjectCollections } from 'arkguard'; +import { + ArkObfuscator, + nameCacheMap, + unobfuscationNamesObj, + ProjectCollections, + PerfMode, + TimeAndMemTimeTracker, + printerTimeAndMemDataConfig, +} from 'arkguard'; import * as arkUtils from '../../../lib/ark_utils' const OBFUSCATE_TESTDATA_DIR = path.resolve(__dirname, '../../../test/ark_compiler_ut/testdata/obfuscation'); @@ -1056,5 +1065,52 @@ mocha.describe('test obfuscate config resolver api', function () { expect(writeArkguardObfuscatedSourceCodeStub.calledTwice).to.be.true; }); }); + + mocha.describe('10-6: writeObfuscationCaches', function () { + let testCacheDir: string = ''; + let timePerformanceFilePath: string = ''; + let memoryPerformanceFilePath: string = ''; + + mocha.beforeEach(function () { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = true; + testCacheDir = '../../test/ark_compiler_ut/testdata/'; + TimeAndMemTimeTracker.obfuscationCacheDir = testCacheDir; + timePerformanceFilePath = path.join(testCacheDir, 'timePerformanceData.json'); + memoryPerformanceFilePath = path.join(testCacheDir, 'memoryPerformanceData.json'); + if (!fs.existsSync(testCacheDir)) { + fs.mkdirSync(testCacheDir, { recursive: true }); + } + }); + + mocha.afterEach(function () { + if (fs.existsSync(timePerformanceFilePath)) { + fs.unlinkSync(timePerformanceFilePath); + } + if (fs.existsSync(memoryPerformanceFilePath)) { + fs.unlinkSync(memoryPerformanceFilePath); + } + if (fs.existsSync(testCacheDir)) { + fs.rmdirSync(testCacheDir, { recursive: true }); + } + }); + + mocha.it('10-6-1: should call enableTimeAndMemoryPrint when perf is ADVANCED', async function () { + this.rollup.share.projectConfig.perf = PerfMode.ADVANCED; + const sourceProjectConfig = Object.assign(this.rollup.share.arkProjectConfig, this.rollup.share.projectConfig); + await writeObfuscationCaches(sourceProjectConfig, undefined); + await new Promise(resolve => setTimeout(resolve, 100)); + expect(fs.existsSync(timePerformanceFilePath)).to.be.true; + expect(fs.existsSync(memoryPerformanceFilePath)).to.be.true; + }); + + mocha.it('10-6-2: should not call enableTimeAndMemoryPrint when perf is not ADVANCED', async function () { + this.rollup.share.projectConfig.perf = PerfMode.NORMAL; + const sourceProjectConfig = Object.assign(this.rollup.share.arkProjectConfig, this.rollup.share.projectConfig); + await writeObfuscationCaches(sourceProjectConfig, undefined); + await new Promise(resolve => setTimeout(resolve, 100)); + expect(fs.existsSync(timePerformanceFilePath)).to.be.false; + expect(fs.existsSync(memoryPerformanceFilePath)).to.be.false; + }); + }); }); }); \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts b/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts index c1997535f..c8988be47 100644 --- a/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts +++ b/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts @@ -64,7 +64,13 @@ import { ObConfigResolver, MergedConfig } from '../../../lib/fast_build/ark_compiler/common/ob_config_resolver'; -import { ArkObfuscator } from 'arkguard'; +import { + ArkObfuscator, + PerfMode, + TimeAndMemTimeTracker, + performanceTimeAndMemPrinter, + printerTimeAndMemDataConfig, +} from 'arkguard'; import { UnobfuscationCollections, AtKeepCollections } from 'arkguard/lib/utils/CommonCollections'; const WINDOWS: string = 'Windows_NT'; @@ -226,6 +232,31 @@ mocha.describe('test process_ark_config file api', function () { expect(arkConfig.compileMode === ESMODULE).to.be.true; }); + mocha.it('2-5: test initArkProjectConfig under build debug: perf is not ADVANCED', function () { + performanceTimeAndMemPrinter.singleFilePrinter = new TimeAndMemTimeTracker(); + performanceTimeAndMemPrinter.filesPrinter = new TimeAndMemTimeTracker(); + this.rollup.build(RELEASE); + this.rollup.share.projectConfig.perf = PerfMode.NORMAL; + initArkProjectConfig(this.rollup.share); + + expect(performanceTimeAndMemPrinter.filesPrinter).to.be.undefined; + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.be.undefined; + }); + + mocha.it('2-6: test initArkProjectConfig under build debug: perf is ADVANCED', function () { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = false; + performanceTimeAndMemPrinter.singleFilePrinter = undefined; + performanceTimeAndMemPrinter.filesPrinter = undefined; + + this.rollup.build(RELEASE); + this.rollup.share.projectConfig.perf = PerfMode.ADVANCED; + initArkProjectConfig(this.rollup.share); + + expect(printerTimeAndMemDataConfig.mTimeAndMemPrinter).to.be.true; + expect(performanceTimeAndMemPrinter.filesPrinter).to.not.be.undefined; + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.not.be.undefined; + }); + mocha.it('3-1: test initTerserConfig under build debug', function () { this.rollup.build(); const logger: object = this.rollup.share.getLogger(OBFUSCATION_TOOL); -- Gitee From 615d88ebb158294ff21607761f5ae75984ed3434 Mon Sep 17 00:00:00 2001 From: yangbiao199318 Date: Wed, 5 Mar 2025 14:42:55 +0800 Subject: [PATCH 009/140] add toolbar and toolbaritem Signed-off-by: yangbiao199318 --- compiler/components/common_attrs.json | 3 ++- compiler/components/toolbaritem.json | 5 +++++ compiler/src/component_map.ts | 2 +- compiler/tsconfig.json | 6 ++++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 compiler/components/toolbaritem.json diff --git a/compiler/components/common_attrs.json b/compiler/components/common_attrs.json index 61d682b11..60a240c59 100644 --- a/compiler/components/common_attrs.json +++ b/compiler/components/common_attrs.json @@ -204,6 +204,7 @@ "monopolizeEvents", "onTouchIntercept", "onSizeChange", - "accessibilityFocusDrawLevel" + "accessibilityFocusDrawLevel", + "toolbar" ] } \ No newline at end of file diff --git a/compiler/components/toolbaritem.json b/compiler/components/toolbaritem.json new file mode 100644 index 000000000..54e82d8ac --- /dev/null +++ b/compiler/components/toolbaritem.json @@ -0,0 +1,5 @@ +{ + "name": "ToolBarItem", + "single": true, + "attrs": [] +} \ No newline at end of file diff --git a/compiler/src/component_map.ts b/compiler/src/component_map.ts index 01e732a2c..7a5ed536f 100644 --- a/compiler/src/component_map.ts +++ b/compiler/src/component_map.ts @@ -119,7 +119,7 @@ export const JS_BIND_COMPONENTS: Set = new Set([ export const NEEDPOP_COMPONENT: Set = new Set(['Blank', 'Search']); export const CUSTOM_BUILDER_PROPERTIES: Set = new Set(['background', 'bindPopup', 'bindMenu', 'bindContextMenu', 'title', - 'menus', 'toolBar', 'tabBar', 'onDragStart', 'onItemDragStart', 'swipeAction', 'bindContentCover', 'bindSheet', + 'menus', 'toolBar', 'tabBar', 'toolbar', 'onDragStart', 'onItemDragStart', 'swipeAction', 'bindContentCover', 'bindSheet', 'navDestination', 'overlay', 'toolbarConfiguration', 'customKeyboard', 'bindSelectionMenu', 'description', 'showUnit', 'customKeyboard', 'create', 'addBuilderSpan', 'dragPreview', 'accessibilityVirtualNode']); export const CUSTOM_BUILDER_PROPERTIES_WITHOUTKEY: Set = new Set(['showUnit', 'create']); diff --git a/compiler/tsconfig.json b/compiler/tsconfig.json index 787f0572b..f7fdd1c88 100644 --- a/compiler/tsconfig.json +++ b/compiler/tsconfig.json @@ -270,6 +270,7 @@ "TextTimer", "TimePicker", "Toggle", + "ToolBarItem", "Video", "Web", "WindowScene", @@ -857,6 +858,11 @@ "type": "ToggleAttribute", "instance": "ToggleInstance" }, + { + "name": "ToolBarItem", + "type": "ToolBarItemAttribute", + "instance": "ToolBarItemInterface" + }, { "name": "Video", "type": "VideoAttribute", -- Gitee From 7408dcff044d58c64cac4f0aebada1c277460879 Mon Sep 17 00:00:00 2001 From: Yenan Date: Wed, 9 Apr 2025 22:48:30 +0800 Subject: [PATCH 010/140] =?UTF-8?q?=E8=93=9D=E5=8C=BA=E5=95=86=E5=88=86?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- .../pages/testcases/showcaseCovid19.ets | 2 +- .../sample/pages/testcases/simpleText.ets | 8 ++++---- compiler/src/compile_info.ts | 2 +- compiler/src/component_map.ts | 4 ++-- compiler/src/ets_checker.ts | 4 ++-- compiler/src/process_component_build.ts | 4 ++-- compiler/src/process_component_class.ts | 2 +- compiler/src/process_component_member.ts | 20 +++++++++---------- compiler/src/process_ui_syntax.ts | 4 ++-- compiler/test/transform_ut/helpers/common.ts | 2 +- compiler/test/transform_ut/helpers/parser.ts | 2 +- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/compiler/sample/pages/testcases/showcaseCovid19.ets b/compiler/sample/pages/testcases/showcaseCovid19.ets index 529e5ba51..1f60d7ea7 100644 --- a/compiler/sample/pages/testcases/showcaseCovid19.ets +++ b/compiler/sample/pages/testcases/showcaseCovid19.ets @@ -122,7 +122,7 @@ class CountryData { compareName(c2: CountryData): number { return (this.name == c2.name) ? 0 : (this.name < c2.name) ? -1 : 1; - // FXXME V8 ICU issue workaround, do not use: return this.name.localeCompare(c2.name); + // FXXME ICU issue workaround, do not use: return this.name.localeCompare(c2.name); } } diff --git a/compiler/sample/pages/testcases/simpleText.ets b/compiler/sample/pages/testcases/simpleText.ets index 2a11e7c0a..d4c9065e9 100644 --- a/compiler/sample/pages/testcases/simpleText.ets +++ b/compiler/sample/pages/testcases/simpleText.ets @@ -46,15 +46,15 @@ struct UserView { } .width(700).backgroundColor("#b0c4de").margin(20) } else if(this.currentView === "button") { - Button("V8 Button test:" + this.button_name) + Button("Button test:" + this.button_name) .width(600).height(100).backgroundColor("#b0c4de").margin(50) .onClick(() => { - console.log("V8 Button test click start"); + console.log("Button test click start"); this.button_name = "After click"; - console.log("V8 Button test click end"); + console.log("Button test click end"); }) } else if(this.currentView === "text") { - Text("V8 Text test") + Text("Text test") .width(600).height(100).backgroundColor("#b0c4de") .margin(50).fontColor("#ff33aa").fontSize(50).fontWeight("bold") } else if(this.currentView === "image") { diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index 1a52b299f..45c9481f1 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -475,7 +475,7 @@ export class ResultStates { } } -function handleFinishModules(modules, callback) { +function handleFinishModules(modules, callback): void { if (projectConfig.compileHar) { modules.forEach(module => { if (module !== undefined && module.resourceResolveData !== undefined) { diff --git a/compiler/src/component_map.ts b/compiler/src/component_map.ts index 01e732a2c..86594cfd5 100644 --- a/compiler/src/component_map.ts +++ b/compiler/src/component_map.ts @@ -24,7 +24,7 @@ export const FORM_MAP: any = {}; export let COMMON_ATTRS: Set = new Set([]); -(function readComponents() { +(function readComponents(): void { const componentPath: Map = new Map([ [`${COMPONENTS}`, `../${COMPONENTS}`], [`${FORM_COMPONENTS}`, `../${FORM_COMPONENTS}`] @@ -32,7 +32,7 @@ export let COMMON_ATTRS: Set = new Set([]); for (const [id, relPath] of componentPath.entries()) { const componentsFile: string = path.join(__dirname, relPath); const files: string[] = fs.readdirSync(componentsFile); - files.forEach(function(item) { + files.forEach(function (item) { const fPath: string = path.join(componentsFile, item); const json: any = require(fPath); const stat: any = fs.statSync(fPath); diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 6475c8715..5f382fb94 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -571,7 +571,7 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null export function traverseProgramSourceFiles(props: string[]): void { globalProgram.program.getSourceFiles().forEach((sourceFile: ts.SourceFile) => { checkUISyntax(sourceFile, sourceFile.fileName, [], props); - }) + }); } function isJsonString(cacheFile: string): [boolean, WholeCache | undefined] { @@ -641,7 +641,7 @@ function isOtherProjectResolvedModulesFilePaths(rollupShareObject: Object, fileN return false; } -export function mergeRollUpFiles(rollupFileList: IterableIterator, rollupObject: Object) { +export function mergeRollUpFiles(rollupFileList: IterableIterator, rollupObject: Object): void { const recordInfo = MemoryMonitor.recordStage(MemoryDefine.MERGE_ROLL_UP_FILES_LOCAL_PACKAGE_SET); for (const moduleId of rollupFileList) { if (fs.existsSync(moduleId)) { diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index ef2e9778a..c6b740226 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -421,7 +421,7 @@ type NameResult = { node?: ts.Node }; -function validateEtsComponentNode(node: ts.CallExpression | ts.EtsComponentExpression, result?: NameResult) { +function validateEtsComponentNode(node: ts.CallExpression | ts.EtsComponentExpression, result?: NameResult): boolean { let childNode: ts.Node = node; result.name = null; while (ts.isCallExpression(childNode) && childNode.expression && @@ -2168,7 +2168,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: const isReuseComponentInV2: boolean = isReuseInV2(componentCollection.currentClassName); if (ts.isPropertyAccessExpression(temp) || isStylesUIComponent) { log.push({ - type: isStylesUIComponent ? LogType.WARN :LogType.ERROR, + type: isStylesUIComponent ? LogType.WARN : LogType.ERROR, message: `'${node.getText()}' does not meet UI component syntax.`, pos: node.getStart(), code: '10905206' diff --git a/compiler/src/process_component_class.ts b/compiler/src/process_component_class.ts index 068141f2b..6591124a8 100644 --- a/compiler/src/process_component_class.ts +++ b/compiler/src/process_component_class.ts @@ -213,7 +213,7 @@ function processMembers(members: ts.NodeArray, parentComponentN if (hasDecorator(item, COMPONENT_STYLES_DECORATOR)) { methodDecoratorCollect(item); } - }) + }); members.forEach((item: ts.ClassElement) => { let updateItem: ts.ClassElement; if (ts.isPropertyDeclaration(item)) { diff --git a/compiler/src/process_component_member.ts b/compiler/src/process_component_member.ts index 631e6d330..d1a1e4a78 100644 --- a/compiler/src/process_component_member.ts +++ b/compiler/src/process_component_member.ts @@ -181,17 +181,17 @@ export class UpdateResult { private decoratorName: string; private stateVarsParams: ts.Statement; - public setProperity(updateItem: ts.PropertyDeclaration) { + public setProperity(updateItem: ts.PropertyDeclaration): void { this.itemUpdate = true; this.properity = updateItem; } - public setCtor(updateCtor: ts.ConstructorDeclaration) { + public setCtor(updateCtor: ts.ConstructorDeclaration): void { this.ctorUpdate = true; this.ctor = updateCtor; } - public setControllerSet(updateControllerSet: ts.MethodDeclaration) { + public setControllerSet(updateControllerSet: ts.MethodDeclaration): void { this.controllerSet = updateControllerSet; } @@ -199,31 +199,31 @@ export class UpdateResult { return this.controllerSet; } - public setVariableGet(updateVariableGet: ts.GetAccessorDeclaration) { + public setVariableGet(updateVariableGet: ts.GetAccessorDeclaration): void { this.variableGet = updateVariableGet; } - public setVariableSet(updateVariableSet: ts.SetAccessorDeclaration) { + public setVariableSet(updateVariableSet: ts.SetAccessorDeclaration): void { this.variableSet = updateVariableSet; } - public setUpdateParams(updateParams: ts.Statement) { + public setUpdateParams(updateParams: ts.Statement): void { this.updateParams = updateParams; } - public setStateVarsParams(stateVarsParams: ts.Statement) { + public setStateVarsParams(stateVarsParams: ts.Statement): void { this.stateVarsParams = stateVarsParams; } - public setDeleteParams(deleteParams: boolean) { + public setDeleteParams(deleteParams: boolean): void { this.deleteParams = deleteParams; } - public setPurgeVariableDepStatement(purgeVariableDepStatement: ts.Statement) { + public setPurgeVariableDepStatement(purgeVariableDepStatement: ts.Statement): void { this.purgeVariableDepStatement = purgeVariableDepStatement; } - public setDecoratorName(decoratorName: string) { + public setDecoratorName(decoratorName: string): void { this.decoratorName = decoratorName; } diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 88db20682..97fc17187 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -215,7 +215,7 @@ export function processUISyntax(program: ts.Program, ut = false, } const id: number = ++componentInfo.id; node = ts.visitEachChild(node, processAllNodes, context); - if(context.getCompilerOptions().etsAnnotationsEnable){ + if (context.getCompilerOptions().etsAnnotationsEnable) { node = ts.getAnnotationTransformer()(context)(node); } node = createEntryNode(node, context, entryNodeKey, id); @@ -229,7 +229,7 @@ export function processUISyntax(program: ts.Program, ut = false, } INTERFACE_NODE_SET.forEach(item => { statements.unshift(item); - }) + }); if (StateManagementV2.hasReusableV2) { statements.unshift(processStructComponentV2.createReusableV2ReflectFunction()); } diff --git a/compiler/test/transform_ut/helpers/common.ts b/compiler/test/transform_ut/helpers/common.ts index 1e69c535a..3e35b3167 100644 --- a/compiler/test/transform_ut/helpers/common.ts +++ b/compiler/test/transform_ut/helpers/common.ts @@ -31,7 +31,7 @@ export const RELEASE: string = 'release'; export const ENTRY_MODULE_VERSION_DEFAULT: string = '1.0.0'; export const MODULE_NAME_HASH_DEFAULT: string = '1043bfc77febe75fafec0c4309faccf1'; export const RESOURCE_TABLE_HASH_DEFAULT: string = '790527e39c8c2be7fbbc762f7966104e'; -export const RUNTIME_OS_OPENHARMONY: string = 'HarmonyOS'; +export const RUNTIME_OS_OPENHARMONY: string = 'HIDDEN'; export const DEVICE_TYPE: string = 'phone,tablet,2in1,wearable'; export const NODE_JS_PATH: string = '/usr/local/nodejs'; export const PORT_DEFAULT: string = '29900'; diff --git a/compiler/test/transform_ut/helpers/parser.ts b/compiler/test/transform_ut/helpers/parser.ts index de00680dd..871b01a74 100644 --- a/compiler/test/transform_ut/helpers/parser.ts +++ b/compiler/test/transform_ut/helpers/parser.ts @@ -66,7 +66,7 @@ function processSystemApi(content: string): string { } export function cleanCopyRight(str: string): string { - const copyrightBlockRegex = /(?:\/\*.*Copyright \(c\) [\d\- ]+ Huawei Device Co\., Ltd\..*\*\/)/gs; + const copyrightBlockRegex = /(?:\/\*.*Copyright \([c|C]\) [- \d]+ [\w ]+\., Ltd\..*\*\/)/gs; return str.replace(copyrightBlockRegex, ''); } -- Gitee From 0e97e2cbb0c5ebae8fc8c2228131d9f292b72ad8 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 25 Mar 2025 22:14:23 +0800 Subject: [PATCH 011/140] paramcheckr Signed-off-by: zhangzezhong --- .../ets_ui/rollup-plugin-ets-typescript.ts | 22 +- compiler/src/parse_Intent.ts | 295 ------------- compiler/src/pre_define.ts | 4 +- compiler/src/process_ui_syntax.ts | 34 +- .../intentLogger.ts} | 59 +-- compiler/src/userIntents_parser/intentType.ts | 192 +++++++++ .../userIntents_parser/parseUserIntents.ts | 389 ++++++++++++++++++ .../schema/ControlPlayback_1.0.1.json | 39 ++ 8 files changed, 671 insertions(+), 363 deletions(-) delete mode 100644 compiler/src/parse_Intent.ts rename compiler/src/{Intent_Logger.ts => userIntents_parser/intentLogger.ts} (40%) create mode 100644 compiler/src/userIntents_parser/intentType.ts create mode 100644 compiler/src/userIntents_parser/parseUserIntents.ts create mode 100644 compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index a639596d0..5c12c9b85 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -91,7 +91,7 @@ import { checkHasKeepTs, resetKitImportLog } from '../../process_kit_import'; -import parseIntent from '../../parse_Intent'; +import parseUserIntents from '../../userIntents_parser/parseUserIntents'; import { resetProcessComponentMember } from '../../process_component_member'; import { collectReservedNameForObf, @@ -211,12 +211,7 @@ export function etsTransform() { } }, afterBuildEnd() { - const cacheSourceMapPath = path.join(projectConfig.aceProfilePath, 'test.json'); - fs.writeFile(cacheSourceMapPath, JSON.stringify(parseIntent.intentData, null, 2), 'utf-8', (err) => { - if (err) { - console.error('lmz fail'); - } - }); + parseUserIntents.writeUserIntentJsonFile(); // Copy the cache files in the compileArkTS directory to the loader_out directory if (projectConfig.compileHar && !projectConfig.byteCodeHar) { for (let moduleInfoId of allModuleIds.keys()) { @@ -281,6 +276,7 @@ export function etsTransform() { resetUtils(); resetValidateUiSyntax(); resetObfuscation(); + parseUserIntents.clear(); } }; } @@ -377,10 +373,12 @@ async function transform(code: string, id: string) { compilerOptions.moduleResolution = 'nodenext'; compilerOptions.module = 'es2020'; const newContent: string = jsBundlePreProcess(code, id, this.getModuleInfo(id).isEntry, logger, hvigorLogger); + const metaInfo: Object = this.getModuleInfo(id).metaInfo || {}; + metaInfo.tsProgram = globalProgram.program; const result: ts.TranspileOutput = ts.transpileModule(newContent, { compilerOptions: compilerOptions, fileName: id, - transformers: { before: [processUISyntax(globalProgram.program)] } + transformers: { before: [processUISyntax(null, false, null, id, metaInfo)] } }); resetCollection(); @@ -451,6 +449,7 @@ async function transform(code: string, id: string) { try { startTimeStatisticsLocation(compilationTime ? compilationTime.tsProgramEmitTime : undefined); const recordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_UI_KIT); + metaInfo.tsProgram = tsProgram; if (projectConfig.useArkoala) { tsProgram = getArkoalaTsProgram(tsProgram); targetSourceFile = tsProgram.getSourceFile(id); @@ -461,7 +460,7 @@ async function transform(code: string, id: string) { tsProgram.emit(targetSourceFile, writeFile, undefined, undefined, { before: [ - processUISyntax(tsProgram, false, compilationTime, id), + processUISyntax(null, false, compilationTime, id, metaInfo), processKitImport(id, metaInfo, compilationTime, true, lazyImportOptions), collectReservedNameForObf(this.share.arkProjectConfig?.obfuscationMergedObConfig, shouldETSOrTSFileTransformToJSWithoutRemove(id, projectConfig, metaInfo)) @@ -475,9 +474,10 @@ async function transform(code: string, id: string) { startTimeStatisticsLocation(compilationTime ? compilationTime.transformNodesTime : undefined); const emitResolver: ts.EmitResolver = globalProgram.checker.getEmitResolver(outFile(tsProgram.getCompilerOptions()) ? undefined : targetSourceFile, undefined); + metaInfo.tsProgram = tsProgram; transformResult = ts.transformNodes(emitResolver, tsProgram.getEmitHost?.(), ts.factory, tsProgram.getCompilerOptions(), [targetSourceFile], - [processUISyntax(tsProgram, false, compilationTime, id), + [processUISyntax(null, false, compilationTime, id, metaInfo), processKitImport(id, metaInfo, compilationTime, false, lazyImportOptions), collectReservedNameForObf(this.share.arkProjectConfig?.obfuscationMergedObConfig, shouldETSOrTSFileTransformToJSWithoutRemove(id, projectConfig, metaInfo))], false); diff --git a/compiler/src/parse_Intent.ts b/compiler/src/parse_Intent.ts deleted file mode 100644 index e9678e097..000000000 --- a/compiler/src/parse_Intent.ts +++ /dev/null @@ -1,295 +0,0 @@ -import ts from 'typescript'; - -type StaticValue = string | number | boolean | null | undefined | StaticValue[] | { [key: string]: StaticValue }; - -interface Params { - decoratorFile : string; - decoratorClass : string; - decoratorType : string; - intentName: string; - domain: string; // 根据实际需求定义具体类型 - displayName : string; - displayDescription : string; - llmDescription : string; - uri : string; - params : object[]; -} - -const requiredFields: (keyof Params)[] = ['intentName', 'domain', 'uri', 'displayName']; -const allowedFields = new Set([ - 'decoratorFile', 'decoratorClass', 'decoratorType', 'intentName', - 'domain', 'displayName', 'displayDescription', 'llmDescription', 'uri', 'params' -]); - -class ParseIntent { - constructor() { - this.intentData = []; - } - checker: ts.TypeChecker; - intentData: any[]; - - handleIntent(node: ts.ClassDeclaration, checker: ts.TypeChecker, path : string) { - this.checker = checker; - node.modifiers.forEach(decorator => { - const originalDecortor: string = decorator.getText().replace(/\(.*\)$/, '').trim(); - if (originalDecortor === '@InsightIntentLinkDecorator') { - const expr = decorator.expression; - if (ts.isCallExpression(expr)) { // 判断是否为装饰器调用(如 @Intent()) - const args = expr.arguments; // 提取参数列表(如 ['aaa', 'bbb']) - const decoratorClass = node.name.text; - const decoratorType = "InsightIntentLinkDecorator"; - this.analyzeDecoratorArgs(args, path, decoratorClass, decoratorType); - } else { - console.error('非调用形式'); - } - } - }); - } - - /** - * 判断符号是否为编译期常量 - * @param symbol 要检查的符号 - * @param checker TypeScript 类型检查器 - */ - isSymbolConstant(symbol: ts.Symbol): boolean { - const declaration = symbol.valueDeclaration; - - // 1. 必须是 const 声明的变量 - if (!this.isConstVariable(declaration)) { - return false; - } - - // 2. 获取初始值表达式 - const varDecl = declaration as ts.VariableDeclaration; - const initializer = varDecl.initializer; - - // 3. 初始值必须是编译时可确定的常量表达式 - return initializer ? this.isConstantExpression(initializer) : false; - } - - /** - * 检查变量声明是否为 const 声明 - */ - isConstVariable(node: ts.Node | undefined): node is ts.VariableDeclaration { - if (!node || !ts.isVariableDeclaration(node)) { - return false; - } - - // 获取父级 VariableDeclarationList 的 const 标志 - const varList = node.parent; - return ts.isVariableDeclarationList(varList) && - (varList.flags & ts.NodeFlags.Const) !== 0; - } - - /** - * 递归验证表达式是否为常量 - */ - isConstantExpression(node: ts.Node): boolean { - // 字面量直接通过 - if (ts.isLiteralExpression(node)) { - return true; - } - - // 标识符(变量)需指向常量 - if (ts.isIdentifier(node)) { - const symbol = this.checker.getSymbolAtLocation(node); - return symbol ? this.isSymbolConstant(symbol) : false; - } - - // 数组字面量需所有元素为常量 - if (ts.isArrayLiteralExpression(node)) { - return node.elements.every(element => this.isConstantExpression(element)); - } - - // 5. 对象字面量需所有元素为常量 - if (ts.isObjectLiteralExpression(node)) { - return node.properties.every(property => { - // 处理普通属性赋值 (key: value) - if (ts.isPropertyAssignment(property)) { - // 检查属性名(如果是计算属性名需递归) - const nameIsConst = !ts.isComputedPropertyName(property.name); // 非计算属性名直接通过(如字符串、数字字面量)/ 不允许计算属性 - - // 检查属性值 - return nameIsConst && this.isConstantExpression(property.initializer); - } - - // 拒绝其他形式(如方法、getter/setter) - return false; - }); - } - - // 其他类型(如函数调用、动态表达式)直接拒绝 需要抛出编译错误方式参考@sendable,我们自己新建一个报错类 - return false; - } - - // -------------------------- - // 2. 校验必选参数是否缺失 - // -------------------------- - validateRequiredParameters( - node: ts.ObjectLiteralExpression, - requiredFields: (keyof Params)[] - ) { - // 从 AST 节点提取所有有效参数名 - const existingParams = new Set(); - - for (const prop of node.properties) { - if ( - ts.isPropertyAssignment(prop) && // 仅处理普通属性赋值 - ts.isIdentifier(prop.name) && // 仅处理标识符作为属性名 - allowedFields.has(prop.name.text) // 验证是否为合法参数名 - ) { - existingParams.add(prop.name.text as keyof Params); - } - } - - // 检查必选参数 - const missingFields = requiredFields.filter(f => !existingParams.has(f)); - if (missingFields.length > 0) { - throw Error(`[Error] 缺少必选参数: ${missingFields.join(', ')}\n + - 节点位置: ${node.getStart()}~${node.getEnd()}`).message; - } - } - -// -------------------------- -// 3. 校验参数类型 -// -------------------------- - validateParameterTypes( - node: ts.ObjectLiteralExpression, - typeValidators: Record boolean> - ) { - node.properties.forEach(prop => { - if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) return; - - const paramName = prop.name.text as keyof Params; - const validator = typeValidators[paramName]; - - if (validator && !validator(prop.initializer)) { - throw Error(`[Error] 参数类型错误: "${paramName}"`).message; - } - }); - } - - analyzeDecoratorArgs(args: ts.NodeArray, path : string, decoratorClass:string, decoratorType:string) { - args.forEach(arg => { - // 做参数检查 - const symbol = this.checker.getSymbolAtLocation(arg); - const declaration = symbol?.valueDeclaration; - this.validateRequiredParameters(declaration.initializer, requiredFields); - const res = this.parseStaticObject(arg); - let intentObj = {}; - Object.assign(intentObj, { - 'decoratorFile': path - }); - Object.assign(intentObj, { - 'decoratorClass': decoratorClass, - }); - Object.assign(intentObj, { - 'decoratorType': decoratorType - }) - Object.assign(intentObj, res) - this.intentData.push(res); - console.log(JSON.stringify(this.intentData, null, 2)); - }); - } - - parseStaticObject(node: ts.Node): StaticValue | undefined { - if (ts.isStringLiteral(node)) { - return node.text; - } - if (ts.isNumericLiteral(node)) { - return parseFloat(node.text); - } - if (node.kind === ts.SyntaxKind.TrueKeyword) { - return true; - } - if (node.kind === ts.SyntaxKind.FalseKeyword) { - return false; - } - if (node.kind === ts.SyntaxKind.NullKeyword) { - return null; - } - if (node.kind === ts.SyntaxKind.UndefinedKeyword) { - return undefined; - } - - // 参数是变量引用 - if (ts.isIdentifier(node)) { - const isStaic = this.isConstantExpression(node); - if (isStaic) { - const symbol = this.checker.getSymbolAtLocation(node); - const declaration = symbol?.valueDeclaration; - return this.parseStaticObject(declaration.initializer); - } - } - - // 处理数组 - if (ts.isArrayLiteralExpression(node)) { - return this.processArrayElements(node.elements); - } - - // 处理对象字面量 - if (ts.isObjectLiteralExpression(node)) { - return this.processObjectElements(node); - } - - return undefined; - } - - processObjectElements(elements: ts.ObjectLiteralExpression): { [key: string]: StaticValue } { - const obj: { [key: string]: StaticValue } = {}; - for (const prop of elements.properties) { - // 处理普通属性 - if (ts.isPropertyAssignment(prop)) { - const key = this.parsePropertyKey(prop.name); - const value = this.parseStaticObject(prop.initializer); - if (key !== undefined && value !== undefined) { - obj[key] = value; - } - } - - // 处理展开运算符 - if (ts.isSpreadAssignment(prop)) { - const spreadObj = this.parseStaticObject(prop.expression); - if (typeof spreadObj === 'object' && spreadObj !== null) { - Object.assign(obj, spreadObj); - } - } - } - return obj; - } - processArrayElements(elements: readonly ts.Node[]): StaticValue[] { - const parsedElements: StaticValue[] = []; - - elements.forEach((element) => { - if (ts.isSpreadElement(element)) { - const spreadValue = this.parseStaticObject(element.expression); - if (Array.isArray(spreadValue)) { - parsedElements.push(...spreadValue); - } - } else { - const value = this.parseStaticObject(element); - if (value !== undefined) { - parsedElements.push(value); - } - } - }); - - return parsedElements; - } - // 辅助函数:解析属性名 - parsePropertyKey(node: ts.PropertyName): string | undefined { - // 字面量属性名 (如 "key" 或 123) - if (ts.isLiteralExpression(node)) { - return node.text; - } - - // 标识符属性名 (如 key) - if (ts.isIdentifier(node)) { - return node.text; - } - - return undefined; - } -} - -export default new ParseIntent(); diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 9b2f1cf0d..e31857833 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -85,7 +85,7 @@ export const COMPONENT_STYLES_DECORATOR: string = '@Styles'; export const COMPONENT_ANIMATABLE_EXTEND_DECORATOR: string = '@AnimatableExtend'; export const COMPONENT_CONCURRENT_DECORATOR: string = '@Concurrent'; export const COMPONENT_SENDABLE_DECORATOR: string = '@Sendable'; -export const COMPONENT_INTENT_DECORATOR:string = '@InsightIntentLinkDecorator'; +export const COMPONENT_USER_INTENTS_DECORATOR: string = '@InsightIntentLinkDecorator'; export const CHECK_COMPONENT_EXTEND_DECORATOR: string = 'Extend'; export const STRUCT_CONTEXT_METHOD_DECORATORS: Set = new Set([COMPONENT_BUILDER_DECORATOR, COMPONENT_STYLES_DECORATOR, COMPONENT_LOCAL_BUILDER_DECORATOR]); diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 777101de5..955e7a84a 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 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 @@ -13,7 +13,7 @@ * limitations under the License. */ -import ts from 'typescript'; +import ts, { TypeChecker } from 'typescript'; import path from 'path'; import fs from 'fs'; @@ -81,7 +81,7 @@ import { LENGTH, PUV2_VIEW_BASE, CONTEXT_STACK, - COMPONENT_INTENT_DECORATOR + COMPONENT_USER_INTENTS_DECORATOR } from './pre_define'; import { componentInfo, @@ -170,11 +170,7 @@ import { routerModuleType, routerBundleOrModule } from './process_module_package'; -import parseIntent from './parse_Intent'; -import { getNormalizedOhmUrlByFilepath } from './ark_utils'; -import { - IntentLogger -} from './Intent_Logger'; +import parseUserIntents from './userIntents_parser/parseUserIntents'; export let transformLog: IFileLog = new createAstNodeUtils.FileLog(); export let contextGlobal: ts.TransformationContext; export let resourceFileName: string = ''; @@ -408,25 +404,11 @@ export function processUISyntax(program: ts.Program, ut = false, }); } } else if (ts.isClassDeclaration(node)) { - if (hasDecorator(node, COMPONENT_INTENT_DECORATOR)) { - const checker = program.getTypeChecker(); - const currentFile = filePath; // C:\Users\l00813716\DevEcoStudioProjects\MyApplication6\entry\src\main\ets\pages\Index.ets - const realpath = program.getCurrentDirectory(); - const relativePath = '.\\' + path.relative(realpath, currentFile); - const convertedPath = relativePath.replace(/\\+/g, '/'); - const pkgParams = { - pkgName: metaInfo.pkgName, - pkgPath: metaInfo.pkgPath - }; - const Logger = IntentLogger.getInstance(); - const recordName = getNormalizedOhmUrlByFilepath(convertedPath, projectConfig, Logger, pkgParams, filePath); - console.log(`recordName------${recordName}`); - parseIntent.handleIntent(node, checker, `@normalized:${recordName}`); - - // remove @Intent - node = processSendableClass(node); + if (hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR)) { + const checker: TypeChecker = metaInfo.tsProgram.getTypeChecker(); + parseUserIntents.handleIntent(node, checker, filePath, metaInfo); + node = parseUserIntents.removeDecorator(node); } - if (hasDecorator(node, COMPONENT_SENDABLE_DECORATOR)) { if (projectConfig.compileHar && !projectConfig.useTsHar) { let warnMessage: string = 'If you use @Sendable in js har, an exception will occur during runtime.\n' + diff --git a/compiler/src/Intent_Logger.ts b/compiler/src/userIntents_parser/intentLogger.ts similarity index 40% rename from compiler/src/Intent_Logger.ts rename to compiler/src/userIntents_parser/intentLogger.ts index 277b990aa..27a8f06c2 100644 --- a/compiler/src/Intent_Logger.ts +++ b/compiler/src/userIntents_parser/intentLogger.ts @@ -1,53 +1,53 @@ +/* + * Copyright (c) 2025 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 {getLogger} from 'log4js'; type ErrorCode = string; type ErrorDescription = string; -/** - * 日志工厂类(用于创建标准化的 LogData) - */ export class LogDataFactory { static newInstance( code: ErrorCode, - description: ErrorDescription, - details: string + description: ErrorDescription ): LogData { - return new LogData(code, description, details); + return new LogData(code, description); } } -/** - * 日志数据实体类 - */ class LogData { code: string; description: string; - cause: string; + constructor( code: ErrorCode, - description: string, - cause: string = '' + description: string ) { this.code = code; this.description = description; - this.cause = cause; } toString(): string { - let errorString = `ERROR Code: ${this.code} ${this.description}\n`; - - if (this.cause) { - errorString += `Error Message: ${this.cause}`; - errorString += '\n\n'; - } - - return errorString; + return `ERROR Code: ${this.code} ${this.description}\n`; } } export class IntentLogger { private static instance: IntentLogger; private logger: Object = getLogger('ETS'); + static getInstance(): IntentLogger { if (!IntentLogger.instance) { IntentLogger.instance = new IntentLogger(); @@ -71,10 +71,6 @@ export class IntentLogger { this.logger.error(...args); } - /** - * 处理结构化错误数据(适配原始 printError 方法) - * @param error LogData 实例或原始错误字符串 - */ printError(error: LogData | string): void { if (typeof error === 'string') { this.logger.error(error); @@ -83,12 +79,17 @@ export class IntentLogger { } } - /** - * 处理致命错误(简化版直接抛出异常) - * @param error LogData 实例或错误字符串 - */ printErrorAndExit(error: LogData | string): never { const message = typeof error === 'string' ? error : error.toString(); throw new Error(message); } } + +export const ENTRYPATH_ERROR: LogData = LogDataFactory.newInstance('1001', '[InsightIntent] IntentDecorator needs to be in the .ets file'); +export const DECORATOR_STATEMENT_ERROR: LogData = LogDataFactory.newInstance('1002', '[InsightIntent] decorator is not CallExpression'); +export const DYNAMIC_PARAM_ERROR: LogData = LogDataFactory.newInstance('1003', '[InsightIntent] Dynamic variable cannot be resolved'); +export const DISALLOWED_PARAM_ERROR: LogData = LogDataFactory.newInstance('1004', '[InsightIntent] param is disallowed'); +export const UNSUPPORTED_PARSE_ERROR: LogData = LogDataFactory.newInstance('1005', '[InsightIntent] unsupported parameter type cannot be parsing'); +export const INCORRECT_PARAM_TYPE_ERROR: LogData = LogDataFactory.newInstance('1006', '[InsightIntent] param parsing occurs error param type'); +export const REQUIRED_PARAM_DISMISS_ERROR: LogData = LogDataFactory.newInstance('1007', '[InsightIntent] decorator args missing required param'); +export const INTERNAL_ERROR: LogData = LogDataFactory.newInstance('1008', '[InsightIntent] internal error'); diff --git a/compiler/src/userIntents_parser/intentType.ts b/compiler/src/userIntents_parser/intentType.ts new file mode 100644 index 000000000..1f8e3a4a3 --- /dev/null +++ b/compiler/src/userIntents_parser/intentType.ts @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2025 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 ts from 'typescript'; +import parseUserIntents from './parseUserIntents'; +import Ajv from 'ajv'; + +const ajv = new Ajv({allErrors: true}); + +export interface IntentInfo { + intentName: string; + domain: string; + intentVersion: string; + displayName: string; + displayDescription: string; + schema: string; + icon: Function; + llmDescription: string; + keywords: string[]; + parameters: object; +} + +interface LinkIntentParamMapping { + paramName: string; + paramMappingName: string; + paramCategory: string; +} + +export interface IntentLinkInfo extends IntentInfo { + uri: string; + paramMapping: LinkIntentParamMapping[] +} + +export class ParamChecker { + private _requiredFields: (keyof T)[]; + private _allowFields: Set; + private _paramValidators: Record boolean>; + private _nestedCheckers: Map>; + + get requiredFields(): (keyof T)[] { + return this._requiredFields; + } + + get allowFields(): Set { + return this._allowFields; + } + + get paramValidators(): Record boolean> { + return this._paramValidators; + } + + get nestedCheckers(): Map> { + return this._nestedCheckers; + } + + set nestedCheckers(value: Map>) { + this._nestedCheckers = value; + } + + set requiredFields(value: (keyof T)[]) { + this._requiredFields = value; + } + + set allowFields(value: Set) { + this._allowFields = value; + } + + set paramValidators(value: Record boolean>) { + this._paramValidators = value; + } + + clean(): void { + this._requiredFields = []; + + this._allowFields = new Set(); + + this._paramValidators = {} as Record boolean>; + + this._nestedCheckers = new Map>(); + } +} + +const IntentLinkParamsChecker: ParamChecker = new ParamChecker(); +IntentLinkParamsChecker.requiredFields = ['paramName']; +IntentLinkParamsChecker.allowFields = new Set([ + 'paramName', 'paramMappingName', 'paramCategory' +]); +IntentLinkParamsChecker.paramValidators = { + paramCategory(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v); + }, + paramMappingName(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v); + }, + paramName(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; + } +}; +export const IntentLinkInfoChecker: ParamChecker = new ParamChecker(); +IntentLinkInfoChecker.requiredFields = ['intentName', 'domain', 'intentVersion', 'displayName', 'llmDescription', 'uri']; +IntentLinkInfoChecker.allowFields = new Set([ + 'intentName', 'domain', 'intentVersion', 'displayName', 'displayDescription', 'schema', 'icon', 'keywords', 'llmDescription', 'uri', + 'parameters', 'paramMapping' +]); + +IntentLinkInfoChecker.paramValidators = { + parameters(v: ts.Expression): boolean { + try { + let initializer: object = {}; + if (ts.isIdentifier(v)) { + const symbol = parseUserIntents.checker.getSymbolAtLocation(v); + const declaration = symbol?.valueDeclaration; + initializer = declaration.initializer; + } else { + initializer = v; + } + if (ts.isObjectLiteralExpression(initializer)) { + ajv.compile(JSON.parse(initializer.getText())); + return true; + } else { + return false; + } + } catch (e) { + return false; + } + }, + paramMapping(v: ts.Expression): boolean { + return v !== null && + v !== undefined && ts.isArrayLiteralExpression(v); + }, + keywords(v: ts.Expression): boolean { + if (ts.isArrayLiteralExpression(v)) { + return v.elements.every(ele => { + if (ts.isIdentifier(ele)) { + const symbol = parseUserIntents.checker.getSymbolAtLocation(ele); + const declaration = symbol?.valueDeclaration; + return ts.isStringLiteral(declaration.initializer) || ts.isNoSubstitutionTemplateLiteral(declaration.initializer); + } else { + return ts.isStringLiteral(ele) || ts.isNoSubstitutionTemplateLiteral(ele); + } + }); + } else { + return false; + } + }, + intentName: (v: ts.Expression): boolean => + v !== null && + v !== undefined && + ts.isStringLiteral(v) && + v.text.trim() !== '', + domain: (v: ts.Expression): boolean => v !== null && + v !== undefined && + ts.isStringLiteral(v) && + v.text.trim() !== '', + intentVersion: (v: ts.Expression): boolean => v !== null && + v !== undefined && + ts.isStringLiteral(v) && + v.text.trim() !== '', + displayName: (v: ts.Expression): boolean => v !== null && + v !== undefined && + ts.isStringLiteral(v) && + v.text.trim() !== '', + displayDescription: (v: ts.Expression): boolean => v !== null && + v !== undefined && + ts.isStringLiteral(v), + schema: (v: ts.Expression): boolean => v !== null && + v !== undefined && + ts.isStringLiteral(v) && + v.text.trim() !== '', + icon: (v: ts.Expression): boolean => ts.isCallExpression(v) && v !== null && + v !== undefined && v.expression.getText() === '$r', + llmDescription: (v: ts.Expression): boolean => v !== null && + v !== undefined && + ts.isStringLiteral(v) && + v.text.trim() !== '', + uri: (v: ts.Expression): boolean => v !== null && + v !== undefined && ts.isStringLiteral(v) + +}; +IntentLinkInfoChecker.nestedCheckers = new Map([['paramsMapping', IntentLinkParamsChecker]]); diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts new file mode 100644 index 000000000..93a2cb0c4 --- /dev/null +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -0,0 +1,389 @@ +/* + * Copyright (c) 2025 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 ts, { CatchClause, Declaration, Expression, VariableDeclarationList } from 'typescript'; +import { ParamChecker, IntentLinkInfoChecker } from './intentType'; +import { COMPONENT_USER_INTENTS_DECORATOR } from '../pre_define'; +import { + ENTRYPATH_ERROR, + IntentLogger, + DECORATOR_STATEMENT_ERROR, + DISALLOWED_PARAM_ERROR, + DYNAMIC_PARAM_ERROR, + REQUIRED_PARAM_DISMISS_ERROR, + INCORRECT_PARAM_TYPE_ERROR, UNSUPPORTED_PARSE_ERROR +} from './intentLogger'; +import path from 'path'; +import { getNormalizedOhmUrlByFilepath } from '../ark_utils'; +import { projectConfig } from '../../main'; +import { ProjectCollections } from 'arkguard'; +import fs from 'fs'; + +type StaticValue = string | number | boolean | null | undefined | StaticValue[] | { [key: string]: StaticValue }; + +class ParseIntent { + constructor() { + this.intentData = []; + this.currentFilePath = ''; + } + + checker: ts.TypeChecker; + intentData: any[]; + currentFilePath: string; + + handleIntent(node: ts.ClassDeclaration, checker: ts.TypeChecker, filepath: string, metaInfo: Object = {}): void { + this.checker = checker; + this.currentFilePath = filepath; + if (!filepath.endsWith('.ets')) { + throw Error(`${ENTRYPATH_ERROR.toString()}, invalidDecoratorPath:${this.currentFilePath}`); + } + const pkgParams: object = { + pkgName: metaInfo.pkgName, + pkgPath: metaInfo.pkgPath + }; + const Logger: IntentLogger = IntentLogger.getInstance(); + const recordName: string = getNormalizedOhmUrlByFilepath(filepath, projectConfig, Logger, pkgParams, null); + node.modifiers.forEach(decorator => { + const originalDecortor: string = decorator.getText().replace(/\(.*\)$/, '').trim(); + if (originalDecortor === '@InsightIntentLinkDecorator') { + const expr: ts.Expression = decorator.expression; + if (ts.isCallExpression(expr)) { + const args: ts.NodeArray = expr.arguments; + const intentObj: object = { + 'decoratorFile': `@normalized:${recordName}`, + 'decoratorType': 'InsightIntentLinkDecorator', + 'decoratorClass': node.name.text + }; + this.analyzeDecoratorArgs(args, intentObj, IntentLinkInfoChecker); + this.createObfuscation(node); + } else { + throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath:${this.currentFilePath}`); + } + } + }); + } + + removeDecorator(node: ts.ClassDeclaration): ts.ClassDeclaration { + const filteredModifiers: boolean = node.modifiers.filter(decorator => { + const originalDecortor: string = decorator.getText().replace(/\(.*\)$/, '').trim(); + return originalDecortor !== COMPONENT_USER_INTENTS_DECORATOR; + }); + return ts.factory.updateClassDeclaration( + node, + filteredModifiers, + node.name, + node.typeParameters, + node.heritageClauses, + node.members + ); + } + + isSymbolConstant(symbol: ts.Symbol): boolean { + const declaration: Declaration = symbol.valueDeclaration; + + if (!this.isConstVariable(declaration)) { + return false; + } + const varDecl: ts.VariableDeclaration = declaration as ts.VariableDeclaration; + const initializer: Expression = varDecl.initializer; + return initializer ? this.isConstantExpression(initializer) : false; + } + + isConstVariable(node: ts.Node | undefined): node is ts.VariableDeclaration { + if (!node || !ts.isVariableDeclaration(node)) { + return false; + } + + const varList: VariableDeclarationList | CatchClause = node.parent; + return ts.isVariableDeclarationList(varList) && + (varList.flags & ts.NodeFlags.Const) !== 0; + } + + isConstantExpression(node: ts.Node): boolean { + let flag: boolean = true; + if (ts.isLiteralExpression(node) || node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword) { + flag = true; + } + + if (ts.isIdentifier(node)) { + const symbol: Symbol | undefined = this.checker.getSymbolAtLocation(node); + flag = symbol ? this.isSymbolConstant(symbol) : false; + } + + if (ts.isArrayLiteralExpression(node)) { + flag = node.elements.every(element => this.isConstantExpression(element)); + } + + if (ts.isObjectLiteralExpression(node)) { + flag = node.properties.every(property => { + if (ts.isPropertyAssignment(property)) { + const nameIsConst: boolean = !ts.isComputedPropertyName(property.name); + return nameIsConst && this.isConstantExpression(property.initializer); + } + + return false; + }); + } + + if (ts.isCallExpression(node) && node.expression.getText() === '$r') { + flag = node.arguments.every(node => { + return ts.isStringLiteral(node); + }); + } + if (!flag) { + throw Error(`${DYNAMIC_PARAM_ERROR}, invalidDecoratorPath:${this.currentFilePath}`); + } + return flag; + } + + validateRequiredIntentLinkInfo( + node: ts.ObjectLiteralExpression, + paramCheckFields: ParamChecker + ): void { + const existingParams: Set = new Set(); + const requiredFields: (keyof T)[] = paramCheckFields.requiredFields; + const nestedCheckers: Map> = paramCheckFields.nestedCheckers; + const allowedFields: Set = paramCheckFields.allowFields; + const paramValidators: Record boolean> = paramCheckFields.paramValidators; + for (const prop of node.properties) { + this.validateFields(prop, allowedFields, paramValidators); + existingParams.add(prop.name.text); + if (nestedCheckers && nestedCheckers.has(prop.name.text)) { + this.validateSelfParamFields(node, nestedCheckers); + } + } + const missingFields: (keyof T)[] = requiredFields.filter(f => !existingParams.has(f)); + if (missingFields.length > 0) { + throw Error(`${REQUIRED_PARAM_DISMISS_ERROR.toString()}, cause: params: ${missingFields.join(', ')}, invalidDecoratorPath:${this.currentFilePath}`); + } + } + + validateSelfParamFields(prop: ts.Node, nestedCheckers: Map>): void { + const checker: ParamChecker = nestedCheckers.get(prop.name.text); + if (ts.isArrayLiteralExpression(prop.initializer)) { + prop.initializer.elements.every(elem => { + if (ts.isIdentifier(elem)) { + const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(elem); + const declaration: ts.Declaration = symbol?.valueDeclaration; + this.validateRequiredIntentLinkInfo(declaration.initializer, checker); + } else { + this.validateRequiredIntentLinkInfo(elem.initializer, checker); + } + }); + } else if (ts.isIdentifier(prop)) { + const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(prop); + const declaration: ts.Declaration = symbol?.valueDeclaration; + this.validateRequiredIntentLinkInfo(declaration.initializer, checker); + } else { + this.validateRequiredIntentLinkInfo(prop.initializer, checker); + } + } + + validateFields( + prop: ts.Node, allowedFields: Set, paramValidators: Record boolean> + ): void { + const paramName: keyof T = prop.name.text; + if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) { + if (!allowedFields.has(paramName)) { + throw Error(`${DISALLOWED_PARAM_ERROR}, cause: undeclared param: '${paramName.toString()}', invalidDecoratorPath:${this.currentFilePath}`); + } + const validator: Function = paramValidators[paramName]; + if (ts.isIdentifier(prop.initializer)) { + const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(prop.initializer); + const declaration: ts.Declaration = symbol?.valueDeclaration; + if (validator && !validator(declaration.initializer)) { + throw Error(`${INCORRECT_PARAM_TYPE_ERROR.toString()}, cause: param: '${paramName.toString()}', invalidDecoratorPath:${this.currentFilePath}`); + } + } else { + if (validator && !validator(prop.initializer)) { + throw Error(`${INCORRECT_PARAM_TYPE_ERROR.toString()}, cause: param: '${paramName.toString()}', invalidDecoratorPath:${this.currentFilePath}`); + } + } + } + } + + analyzeDecoratorArgs(args: ts.NodeArray, intentObj: object, paramChecker: ParamChecker): void { + args.forEach(arg => { + if (ts.isIdentifier(arg)) { + const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(arg); + const declaration: ts.Declaration = symbol?.valueDeclaration; + this.validateRequiredIntentLinkInfo(declaration.initializer, paramChecker); + } else { + this.validateRequiredIntentLinkInfo(arg, paramChecker); + } + const res: StaticValue = this.parseStaticObject(arg); + Object.assign(intentObj, res); + this.collectSchemaInfo(intentObj); + this.intentData.push(intentObj); + }); + } + + collectSchemaInfo(intentObj: object): void { + if (intentObj.schema) { + const schemaPath = path.join( + __dirname + '\\schema', + `${intentObj.schema}_${intentObj.intentVersion}.json` + ); + if (fs.existsSync(schemaPath)) { + if (intentObj.parameters) { + throw Error(`${DISALLOWED_PARAM_ERROR.toString()}, the standard user intents does not allow passing the parameter 'parameter', invalidDecoratorPath:${this.currentFilePath}`); + } + const schemaContent = fs.readFileSync(schemaPath, 'utf-8'); + intentObj.parameters = JSON.parse(schemaContent); + } + } + } + + parseStaticObject(node: ts.Node): StaticValue | undefined { + if (ts.isStringLiteral(node)) { + return node.text; + } + if (ts.isNumericLiteral(node)) { + return parseFloat(node.text); + } + if (node.kind === ts.SyntaxKind.TrueKeyword) { + return true; + } + if (node.kind === ts.SyntaxKind.FalseKeyword) { + return false; + } + if (node.kind === ts.SyntaxKind.NullKeyword) { + return null; + } + if (node.kind === ts.SyntaxKind.UndefinedKeyword) { + return undefined; + } + + if (ts.isIdentifier(node)) { + const isStatic: boolean = this.isConstantExpression(node); + if (isStatic) { + const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(node); + const declaration: ts.Declaration = symbol?.valueDeclaration; + return this.parseStaticObject(declaration.initializer); + } + } + + if (ts.isArrayLiteralExpression(node)) { + return this.processArrayElements(node.elements); + } + + if (ts.isObjectLiteralExpression(node)) { + return this.processObjectElements(node); + } + + if (ts.isCallExpression(node) && node.expression.getText() === '$r') { + const isStatic: boolean = this.isConstantExpression(node); + if (!isStatic) { + return undefined; + } + return node.getText(); + } + throw Error(`${UNSUPPORTED_PARSE_ERROR.toString()}, param: '${node.text}', invalidDecoratorPath:${this.currentFilePath}`); + } + + createObfuscation(classNode: ts.Node): void { + ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.globalNames.add(classNode.symbol.name); + classNode.members.forEach(member => { + if (ts.isPropertyDeclaration(member) && member.name) { + const propName = member.name.getText(); + ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.globalNames.add(propName); + } + if (ts.isFunctionDeclaration(member) || ts.isMethodDeclaration(member) || + ts.isGetAccessor(member) || ts.isSetAccessor(member)) { + const methodName = member.name.getText(); + ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.propertyNames.add(methodName); + } + }); + } + + + processObjectElements(elements: ts.ObjectLiteralExpression): { [key: string]: StaticValue } { + const obj: { [key: string]: StaticValue } = {}; + for (const prop of elements.properties) { + if (ts.isPropertyAssignment(prop)) { + const key: string = this.parsePropertyKey(prop.name); + const value: StaticValue = this.parseStaticObject(prop.initializer); + if (key !== undefined && value !== undefined) { + obj[key] = value; + } + } + + if (ts.isSpreadAssignment(prop)) { + const spreadObj: StaticValue = this.parseStaticObject(prop.expression); + if (typeof spreadObj === 'object' && spreadObj !== null) { + Object.assign(obj, spreadObj); + } + } + } + return obj; + } + + processArrayElements(elements: readonly ts.Node[]): StaticValue[] { + const parsedElements: StaticValue[] = []; + + elements.forEach((element) => { + if (ts.isSpreadElement(element)) { + const spreadValue: StaticValue = this.parseStaticObject(element.expression); + if (Array.isArray(spreadValue)) { + parsedElements.push(...spreadValue); + } + } else { + const value: StaticValue = this.parseStaticObject(element); + parsedElements.push(value); + } + }); + + return parsedElements; + } + + parsePropertyKey(node: ts.PropertyName): string | undefined { + if (ts.isLiteralExpression(node)) { + return node.text; + } + + if (ts.isIdentifier(node)) { + return node.text; + } + + return undefined; + } + + writeUserIntentJsonFile(): void { + if (this.intentData.length > 0) { + const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'user_intents_library.json'); + if (!fs.existsSync(projectConfig.aceProfilePath)) { + fs.mkdirSync(projectConfig.aceProfilePath, {recursive: true}); + } + fs.writeFileSync(cacheSourceMapPath, JSON.stringify({'insightIntents': this.intentData}, null, 2), 'utf-8'); + } + const normalizedPath: string = path.normalize(projectConfig.aceModuleJsonPath); + const fullPath: string = path.join(path.dirname(normalizedPath), 'module.json'); + if (fs.existsSync(fullPath)) { + const rawData: string = fs.readFileSync(fullPath, 'utf8'); + const jsonData: any = JSON.parse(rawData); + jsonData.hasIntent = true; + const updatedJson: string = JSON.stringify(jsonData, null, 2); + fs.writeFileSync(fullPath, updatedJson, 'utf8'); + } + } + + clear(): void { + this.intentData = []; + this.currentFilePath = ''; + IntentLinkInfoChecker.clean(); + } +} + +export default new ParseIntent(); diff --git a/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json b/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json new file mode 100644 index 000000000..578f98861 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json @@ -0,0 +1,39 @@ +{ + "type": "object", + "propertyNames": { + "enum": [ + "playbackSpeed", + "playbackProgress" + ] + }, + "oneOf": [ + { + "required": [ + "playbackSpeed" + ] + }, + { + "required": [ + "playbackProgress" + ] + } + ], + "properties": { + "playbackSpeed": { + "description": "播放倍速", + "type": "number", + "enum": [ + 0.5, + 0.75, + 1.0, + 1.25, + 1.5, + 2.0 + ] + }, + "playbackProgress": { + "description": "播放进度,单位秒", + "type": "number" + } + } +} -- Gitee From 01f97f1412bcd2507517180d2d638b5c6c2824c8 Mon Sep 17 00:00:00 2001 From: Yenan Date: Tue, 8 Apr 2025 15:07:17 +0800 Subject: [PATCH 012/140] nn Signed-off-by: Yenan --- compiler/src/process_component_build.ts | 2 +- compiler/src/process_custom_component.ts | 2 +- compiler/src/validate_ui_syntax.ts | 2 +- compiler/test/transform_ut_error.json | 10 +++++----- ...346\214\207\345\257\274\350\247\204\350\214\203.md" | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index ef2e9778a..4a1e59a1e 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -2774,7 +2774,7 @@ function addComponentAttr(temp, node: ts.Identifier, lastStatement, if (newsupplement.isAcceleratePreview) { log.push({ type: LogType.ERROR, - message: `Doesn't support '@Extend' function now`, + message: `Doesn't support '@Extend' function now.`, pos: temp.getStart(), code: '10906205' }); diff --git a/compiler/src/process_custom_component.ts b/compiler/src/process_custom_component.ts index 2103a2ca3..a13a36ae3 100644 --- a/compiler/src/process_custom_component.ts +++ b/compiler/src/process_custom_component.ts @@ -1531,7 +1531,7 @@ function validateInitDecorator(node: ts.CallExpression, customComponentName: str if (item && !curChildProps.has(item) && decoratorVariable && decoratorVariable.has(item)) { log.push({ type: LogType.ERROR, - message: `Property '${item}' must be initialized through the component constructor.`, + message: `'@Require' decorated '${item}' must be initialized through the component constructor.`, pos: node.getStart(), code: '10905359' }); diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 46c8942c4..10bc7a70b 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -280,7 +280,7 @@ function validateEntryAndPreviewCount(result: DecoratorResult, fileQuery: string if (result.entryCount > 1 && fileQuery === '?entry') { log.push({ type: LogType.ERROR, - message: `A page can't contain more than one '@Entry' decorator`, + message: `A page can't contain more than one '@Entry' decorator.`, fileName: fileName, code: '10905231' }); diff --git a/compiler/test/transform_ut_error.json b/compiler/test/transform_ut_error.json index 19b04467a..02b11ca2c 100644 --- a/compiler/test/transform_ut_error.json +++ b/compiler/test/transform_ut_error.json @@ -178,27 +178,27 @@ }, "validateInitDecorator": [ { - "message": "Property 'build_value' must be initialized through the component constructor.", + "message": "'@Require' decorated 'build_value' must be initialized through the component constructor.", "type": "ERROR", "code": "10905359" }, { - "message": "Property 'prop_value' must be initialized through the component constructor.", + "message": "'@Require' decorated 'prop_value' must be initialized through the component constructor.", "type": "ERROR", "code": "10905359" }, { - "message": "Property 'regular_value' must be initialized through the component constructor.", + "message": "'@Require' decorated 'regular_value' must be initialized through the component constructor.", "type": "ERROR", "code": "10905359" }, { - "message": "Property 'state_value' must be initialized through the component constructor.", + "message": "'@Require' decorated 'state_value' must be initialized through the component constructor.", "type": "ERROR", "code": "10905359" }, { - "message": "Property 'provide_value' must be initialized through the component constructor.", + "message": "'@Require' decorated 'provide_value' must be initialized through the component constructor.", "type": "ERROR", "code": "10905359" } diff --git "a/compiler/\345\246\202\344\275\225\346\226\260\345\242\236\346\210\226\344\277\256\346\224\271\347\273\204\344\273\266\346\214\207\345\257\274\350\247\204\350\214\203.md" "b/compiler/\345\246\202\344\275\225\346\226\260\345\242\236\346\210\226\344\277\256\346\224\271\347\273\204\344\273\266\346\214\207\345\257\274\350\247\204\350\214\203.md" index 8923bc1fc..82d1d8bd1 100644 --- "a/compiler/\345\246\202\344\275\225\346\226\260\345\242\236\346\210\226\344\277\256\346\224\271\347\273\204\344\273\266\346\214\207\345\257\274\350\247\204\350\214\203.md" +++ "b/compiler/\345\246\202\344\275\225\346\226\260\345\242\236\346\210\226\344\277\256\346\224\271\347\273\204\344\273\266\346\214\207\345\257\274\350\247\204\350\214\203.md" @@ -2,7 +2,7 @@ #### 概述: -当新增或更新组件和属性时,需要在compiler/src/components目录下新增或修改对应的json文件。 +当新增或更新组件和属性时,需要在compiler/components目录下新增或修改对应的json文件。 同时我们将公共属性放入compiler/components/common_attrs.json文件中,若要更新公共属性在该文件下修改即可。 -- Gitee From e3e036699f44402852944aba094cee3faf5c2e76 Mon Sep 17 00:00:00 2001 From: Yenan Date: Thu, 17 Apr 2025 15:15:59 +0800 Subject: [PATCH 013/140] =?UTF-8?q?=E4=BF=AE=E5=A4=8D@Extend=E8=A3=85?= =?UTF-8?q?=E9=A5=B0=E7=9A=84=E6=96=B9=E6=B3=95=E6=B2=A1=E6=9C=89=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E5=B1=9E=E6=80=A7=E9=97=AA=E9=80=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/src/process_ui_syntax.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index d9a199dd9..50cdac53a 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -996,6 +996,21 @@ export function processAnimateToOrImmediately(node: ts.CallExpression): ts.CallE function processExtend(node: ts.FunctionDeclaration, log: LogInfo[], decoratorName: string): ts.FunctionDeclaration { const componentName: string = isExtendFunction(node, { decoratorName: '', componentName: '' }, true); + if (componentName && node.body && !node.body.statements.length && decoratorName === COMPONENT_EXTEND_DECORATOR) { + const statementArray: ts.Statement[] = []; + const bodynode: ts.Block = ts.visitEachChild(node.body, traverseExtendExpression, contextGlobal); + let extendFunctionName: string; + if (node.name.getText().startsWith('__' + componentName + '__')) { + extendFunctionName = node.name.getText(); + } else { + extendFunctionName = '__' + componentName + '__' + node.name.getText(); + collectExtend(EXTEND_ATTRIBUTE, componentName, node.name.escapedText.toString()); + } + return ts.factory.updateFunctionDeclaration(node, ts.getModifiers(node), node.asteriskToken, + ts.factory.createIdentifier(extendFunctionName), node.typeParameters, + node.parameters, ts.factory.createToken(ts.SyntaxKind.VoidKeyword), isOriginalExtend(node.body) ? + ts.factory.updateBlock(node.body, statementArray) : bodynode); + } if (componentName && node.body && node.body.statements.length) { const statementArray: ts.Statement[] = []; let bodynode: ts.Block; -- Gitee From 3de2e223bcb8284a3dc47826fe201244eecfebde Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Thu, 17 Apr 2025 19:59:48 +0800 Subject: [PATCH 014/140] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=84=8F=E5=9B=BE?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E5=AF=BC=E8=87=B4=E9=97=A8=E7=A6=81=E6=A6=82?= =?UTF-8?q?=E7=8E=87=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../userIntents_parser/parseUserIntents.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index 93a2cb0c4..d840b8749 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -23,7 +23,8 @@ import { DISALLOWED_PARAM_ERROR, DYNAMIC_PARAM_ERROR, REQUIRED_PARAM_DISMISS_ERROR, - INCORRECT_PARAM_TYPE_ERROR, UNSUPPORTED_PARSE_ERROR + INCORRECT_PARAM_TYPE_ERROR, + UNSUPPORTED_PARSE_ERROR } from './intentLogger'; import path from 'path'; import { getNormalizedOhmUrlByFilepath } from '../ark_utils'; @@ -362,20 +363,23 @@ class ParseIntent { writeUserIntentJsonFile(): void { if (this.intentData.length > 0) { + if (!projectConfig.aceModuleJsonPath) { + return; + } const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'user_intents_library.json'); if (!fs.existsSync(projectConfig.aceProfilePath)) { fs.mkdirSync(projectConfig.aceProfilePath, {recursive: true}); } fs.writeFileSync(cacheSourceMapPath, JSON.stringify({'insightIntents': this.intentData}, null, 2), 'utf-8'); - } - const normalizedPath: string = path.normalize(projectConfig.aceModuleJsonPath); - const fullPath: string = path.join(path.dirname(normalizedPath), 'module.json'); - if (fs.existsSync(fullPath)) { - const rawData: string = fs.readFileSync(fullPath, 'utf8'); - const jsonData: any = JSON.parse(rawData); - jsonData.hasIntent = true; - const updatedJson: string = JSON.stringify(jsonData, null, 2); - fs.writeFileSync(fullPath, updatedJson, 'utf8'); + const normalizedPath: string = path.normalize(projectConfig.aceModuleJsonPath); + const fullPath: string = path.join(path.dirname(normalizedPath), 'module.json'); + if (fs.existsSync(fullPath)) { + const rawData: string = fs.readFileSync(fullPath, 'utf8'); + const jsonData: any = JSON.parse(rawData); + jsonData.hasIntent = true; + const updatedJson: string = JSON.stringify(jsonData, null, 2); + fs.writeFileSync(fullPath, updatedJson, 'utf8'); + } } } -- Gitee From 052d991212b472b68b6a0d3c31d47fcb3cd39e5f Mon Sep 17 00:00:00 2001 From: Bojiang Date: Thu, 17 Apr 2025 10:16:46 +0800 Subject: [PATCH 015/140] jiangbo91@huawei.com Signed-off-by: Bojiang Change-Id: I8959fdebef8f5d47f53b4ab6e96c62d7d53202bd --- ...14\207\345\257\274\350\247\204\350\214\203.md" | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git "a/compiler/\345\246\202\344\275\225\346\226\260\345\242\236\346\210\226\344\277\256\346\224\271\347\273\204\344\273\266\346\214\207\345\257\274\350\247\204\350\214\203.md" "b/compiler/\345\246\202\344\275\225\346\226\260\345\242\236\346\210\226\344\277\256\346\224\271\347\273\204\344\273\266\346\214\207\345\257\274\350\247\204\350\214\203.md" index 8923bc1fc..9084c9175 100644 --- "a/compiler/\345\246\202\344\275\225\346\226\260\345\242\236\346\210\226\344\277\256\346\224\271\347\273\204\344\273\266\346\214\207\345\257\274\350\247\204\350\214\203.md" +++ "b/compiler/\345\246\202\344\275\225\346\226\260\345\242\236\346\210\226\344\277\256\346\224\271\347\273\204\344\273\266\346\214\207\345\257\274\350\247\204\350\214\203.md" @@ -4,7 +4,20 @@ 当新增或更新组件和属性时,需要在compiler/src/components目录下新增或修改对应的json文件。 -同时我们将公共属性放入compiler/components/common_attrs.json文件中,若要更新公共属性在该文件下修改即可。 +同时我们将公共属性放入compiler/components/common_attrs.json文件中,若要更新公共属性在该文件下修改即可。 + +#### **说明:** + +​ 通用属性是指在 **`common.d.ts`** 文件中 **`CommonMethod`** 类定义的属性,这些属性可以修饰**自定义组件**或**系统组件**。 + +##### **变更与同步要求** + +无论是**新增**还是**删除**通用属性,均需在 **`compiler/components/common_attrs.json`** 文件中进行同步更新。 + +##### 编辑器 & 编译器校验** + +- 确保自定义组件或系统组件所使用的属性均为已注册的**通用属性**。 +- 校验依据为 **`common_attrs.json`** 中定义的属性白名单。 组件形式如下: -- Gitee From dda3b5499957d508be9a4927247419e52137f406 Mon Sep 17 00:00:00 2001 From: Yenan Date: Sun, 20 Apr 2025 17:32:39 +0800 Subject: [PATCH 016/140] =?UTF-8?q?UT=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/test/transform_ut_error.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/test/transform_ut_error.json b/compiler/test/transform_ut_error.json index 02b11ca2c..e7f94f2d7 100644 --- a/compiler/test/transform_ut_error.json +++ b/compiler/test/transform_ut_error.json @@ -343,7 +343,7 @@ }, "ExceededEntry": [ { - "message": "A page can't contain more than one '@Entry' decorator", + "message": "A page can't contain more than one '@Entry' decorator.", "type": "ERROR", "code": "10905231" }, -- Gitee From 966b910c893a2556d133536fa240d8382a7b4292 Mon Sep 17 00:00:00 2001 From: Yenan Date: Mon, 21 Apr 2025 20:09:32 +0800 Subject: [PATCH 017/140] =?UTF-8?q?=E4=BF=AE=E5=A4=8DV2=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E4=B8=8B@Require@BuilderParam=E8=BF=90=E8=A1=8C=E5=8F=91?= =?UTF-8?q?=E7=94=9Fjscrash=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/src/process_struct_componentV2.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compiler/src/process_struct_componentV2.ts b/compiler/src/process_struct_componentV2.ts index 34e0e906e..17baf35db 100644 --- a/compiler/src/process_struct_componentV2.ts +++ b/compiler/src/process_struct_componentV2.ts @@ -333,6 +333,9 @@ function processComponentProperty(member: ts.PropertyDeclaration, structInfo: St if (structInfo.staticPropertySet.has(propName)) { initializer = member.initializer; } + if (structInfo.paramDecoratorMap.has(propName) && structInfo.builderParamDecoratorSet.has(propName)) { + return processRequireBuilderParamProperty(member, decorators, initializer); + } if (structInfo.paramDecoratorMap.has(propName)) { return processParamProperty(member, decorators, initializer); } @@ -361,6 +364,15 @@ function processParamProperty(member: ts.PropertyDeclaration, member.name, member.questionToken, member.type, initializer); } +function processRequireBuilderParamProperty(member: ts.PropertyDeclaration, + decorators: readonly ts.Decorator[], initializer: ts.Expression): ts.PropertyDeclaration { + const tempDecorators: readonly ts.Decorator[] = removeDecorator(decorators, constantDefine.REQUIRE); + const newDecorators: readonly ts.Decorator[] = removeDecorator(tempDecorators, constantDefine.BUILDER_PARAM); + return ts.factory.updatePropertyDeclaration(member, + ts.concatenateDecoratorsAndModifiers(newDecorators, ts.getModifiers(member)), + member.name, member.questionToken, member.type, initializer); +} + function processBuilderParamProperty(member: ts.PropertyDeclaration, log: LogInfo[], decorators: readonly ts.Decorator[], initializer: ts.Expression): ts.PropertyDeclaration { if (judgeBuilderParamAssignedByBuilder(member)) { -- Gitee From d811c80ffae48708bea79ca21c45c9d0e6582908 Mon Sep 17 00:00:00 2001 From: wangcaoyu Date: Thu, 24 Apr 2025 16:27:09 +0800 Subject: [PATCH 018/140] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20tags=20undefined?= =?UTF-8?q?=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangcaoyu --- compiler/src/fast_build/system_api/api_check_utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index 7a1fd71e8..da30bfff2 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -543,7 +543,7 @@ function checkSinceValue(jsDocTags: readonly ts.JSDocTag[], config: ts.JsDocNode } let minSince: string = ''; const hasSince: boolean = currentNode.jsDoc.some((doc: ts.JSDoc) => { - return doc.tags.some((tag: ts.JSDocTag) => { + return doc.tags?.some((tag: ts.JSDocTag) => { if (tag.tagName.escapedText.toString() === SINCE_TAG_NAME) { minSince = tag.comment.toString(); return true; -- Gitee From 70bee543f3fb09a82b3b5dcb2ce98f434a2419d0 Mon Sep 17 00:00:00 2001 From: liduo Date: Fri, 25 Apr 2025 09:40:25 +0800 Subject: [PATCH 019/140] fix system resource path Signed-off-by: liduo --- compiler/main.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/compiler/main.js b/compiler/main.js index 2f6fb867f..64589ea32 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -691,15 +691,20 @@ function filterWorker(workerPath) { if (fs.existsSync(sysResourcePath)) { resources.sys = require(sysResourcePath).sys; } - if (process.env.externalApiPaths) { - const sysResourceExtPath = path.resolve(__dirname, process.env.externalApiPaths, 'sysResource.js'); - if (fs.existsSync(sysResourceExtPath)) { - Object.entries(require(sysResourceExtPath).sys).forEach(([key, value]) => { - if (key in resources.sys) { - Object.assign(resources.sys[key], value); - } - }); + if (!process.env.externalApiPaths) { + return; + } + const sdkPaths = process.env.externalApiPaths.split(path.delimiter); + for (let i = 0; i < sdkPaths.length; i++) { + const sysResourceExtPath = path.resolve(__dirname, sdkPaths[i], 'sysResource.js'); + if (!fs.existsSync(sysResourceExtPath)) { + continue; } + Object.entries(require(sysResourceExtPath).sys).forEach(([key, value]) => { + if (key in resources.sys) { + Object.assign(resources.sys[key], value); + } + }); } })(); -- Gitee From 4adcd51b2cfe4d81e911c35c9cf89797725969b6 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Sat, 19 Apr 2025 15:49:53 +0800 Subject: [PATCH 020/140] jiangbo91@huawei.com Signed-off-by: Bojiang Change-Id: I30334536350419bd944fbd04df92e9395d541ff1 --- compiler/src/process_component_build.ts | 41 +++++++++++++++---------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index f8de9db62..c96ce51bf 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -2648,24 +2648,31 @@ function validateIdentifierWithCustomBuilder(node: ts.Node): boolean { } function createArrowFunctionForDollar($$varExp: ts.Expression): ts.ArrowFunction { - return ts.factory.createArrowFunction( - undefined, undefined, - [ts.factory.createParameterDeclaration( + let varExp: ts.ConditionalExpression | ts.BinaryExpression; + if (ts.isConditionalExpression($$varExp)) { + varExp = ts.factory.updateConditionalExpression( + $$varExp, $$varExp.condition, ts.factory.createToken(ts.SyntaxKind.QuestionToken), $$varExp.whenTrue, + ts.factory.createToken(ts.SyntaxKind.ColonToken), ts.factory.createBinaryExpression( + $$varExp.whenFalse, ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createIdentifier($$_NEW_VALUE))); + } else { + varExp = ts.factory.createBinaryExpression( + $$varExp, ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createIdentifier($$_NEW_VALUE) + ); + } + return ts.factory.createArrowFunction( undefined, undefined, - ts.factory.createIdentifier($$_NEW_VALUE), - undefined, undefined, undefined - )], - undefined, - ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - ts.factory.createBlock( - [ts.factory.createExpressionStatement(ts.factory.createBinaryExpression( - $$varExp, - ts.factory.createToken(ts.SyntaxKind.EqualsToken), - ts.factory.createIdentifier($$_NEW_VALUE) - ))], - false - ) - ); + [ts.factory.createParameterDeclaration( + undefined, undefined, + ts.factory.createIdentifier($$_NEW_VALUE), + undefined, undefined, undefined + )], + undefined, + ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), + ts.factory.createBlock( + [ts.factory.createExpressionStatement(varExp)], + false + ) + ); } function updateArgumentForExclamation(argument): ts.Expression { -- Gitee From cc3ced335c4daf13fe4769765988c3bd42e6da9f Mon Sep 17 00:00:00 2001 From: zhanghang Date: Mon, 24 Mar 2025 10:57:46 +0800 Subject: [PATCH 021/140] add curve for tabs(tools). Signed-off-by: zhanghang --- compiler/components/tabs.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/components/tabs.json b/compiler/components/tabs.json index 0180f58f8..cbb876012 100644 --- a/compiler/components/tabs.json +++ b/compiler/components/tabs.json @@ -6,6 +6,7 @@ "onChange", "onAnimationStart", "onAnimationEnd", "onGestureSwipe", "barPosition", "barOverlap", "barBackgroundColor", "customContentTransition", "barBackgroundBlurStyle", "onContentWillChange", "animationMode", "edgeEffect", "onTabBarClick", "fadingEdge", "divider", - "barGridAlign", "barBackgroundEffect", "pageFlipMode", "onSelected", "onUnselected", "cachedMaxCount" + "barGridAlign", "barBackgroundEffect", "pageFlipMode", "onSelected", "onUnselected", "cachedMaxCount", + "animationCurve" ] } -- Gitee From 20c320534d30514bc43639bc956b84adb7d916a5 Mon Sep 17 00:00:00 2001 From: shanweiqian Date: Mon, 10 Mar 2025 16:42:06 +0800 Subject: [PATCH 022/140] Add a performance optimization switch Issue:https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IBYHOK Signed-off-by: shanweiqian --- compiler/src/ets_checker.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 5f382fb94..548c3d04d 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -557,14 +557,17 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null MemoryMonitor.stopRecordStage(processBuildHaprrecordInfo); } - if (globalProgram.program && - (process.env.watchMode !== 'true' && !projectConfig.isPreview && - !projectConfig.hotReload && !projectConfig.coldReload)) { - globalProgram.program.releaseTypeChecker(); - const allowGC: boolean = global && global.gc && typeof global.gc === 'function'; - if (allowGC) { - global.gc(); - } + // Release the typeChecker early and perform GC in the following scenarios: + // In memory-priority mode or default mode, when the preview mode is disabled in a full compilation scenario, + // and it is not a preview, hot reload, or cold reload scenario. The typeChecker is not released early in performance-priority mode. + let shouldReleaseTypeChecker: boolean = rollupShareObject?.projectConfig?.executionMode !== 'performance' && globalProgram.program && + process.env.watchMode !== 'true' && !projectConfig.isPreview && !projectConfig.hotReload && !projectConfig.coldReload; + if (shouldReleaseTypeChecker) { + globalProgram.program.releaseTypeChecker(); + const allowGC: boolean = global && global.gc && typeof global.gc === 'function'; + if (allowGC) { + global.gc(); + } } } -- Gitee From c7bf09c7eb0e825a4d1c410de3b3734b68caa8e8 Mon Sep 17 00:00:00 2001 From: wuhailong Date: Tue, 7 Jan 2025 16:41:20 +0800 Subject: [PATCH 023/140] Unify performance management Issue: #IC5152 Signed-off-by: wuhailong Change-Id: Ib3d4f32875c6d05c3b5e7b1b24dc88ad56a7b35c --- compiler/src/ark_utils.ts | 36 ----- .../ark_compiler/common/ark_define.ts | 1 + .../ark_compiler/common/ob_config_resolver.ts | 11 +- .../ark_compiler/generate_module_abc.ts | 11 +- .../ark_compiler/generate_sourcemap.ts | 11 +- .../ark_compiler/module/module_build_mode.ts | 7 +- .../module/module_coldreload_mode.ts | 21 +-- .../ark_compiler/module/module_hotfix_mode.ts | 5 +- .../module/module_hotreload_mode.ts | 21 +-- .../ark_compiler/module/module_mode.ts | 31 ++-- .../module/module_preview_mode.ts | 7 +- .../ark_compiler/module/module_source_file.ts | 25 ++- .../ark_compiler/rollup-plugin-gen-abc.ts | 9 +- .../src/fast_build/ark_compiler/transform.ts | 17 ++- compiler/src/fast_build/ark_compiler/utils.ts | 10 +- compiler/src/performance.ts | 143 ++++++++++++++++++ compiler/src/process_module_files.ts | 10 +- .../mock/class_mock/module_mode_mock.ts | 3 +- 18 files changed, 260 insertions(+), 119 deletions(-) create mode 100644 compiler/src/performance.ts diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index 70674432f..59e9cbf18 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -955,42 +955,6 @@ export function cleanUpUtilsObjects(): void { packageCollection.clear(); } -export function getHookEventFactory(share: Object, pluginName: string, hookName: string): Object { - if (typeof share.getHookEventFactory === 'function') { - return share.getHookEventFactory(pluginName, hookName); - } else { - return undefined; - } -} - -export function createAndStartEvent(eventOrEventFactory: Object, eventName: string, syncFlag = false): Object { - if (eventOrEventFactory === undefined) { - return undefined; - } - let event: Object; - if (typeof eventOrEventFactory.createSubEvent === 'function') { - event = eventOrEventFactory.createSubEvent(eventName); - } else { - event = eventOrEventFactory.createEvent(eventName); - } - if (typeof event.startAsyncEvent === 'function' && syncFlag) { - event.startAsyncEvent(); - } else { - event.start(); - } - return event; -} - -export function stopEvent(event: Object, syncFlag = false): void { - if (event !== undefined) { - if (typeof event.stopAsyncEvent === 'function' && syncFlag) { - event.stopAsyncEvent(); - } else { - event.stop(); - } - } -} - export function compileToolIsRollUp(): boolean { return process.env.compileTool === 'rollup'; } diff --git a/compiler/src/fast_build/ark_compiler/common/ark_define.ts b/compiler/src/fast_build/ark_compiler/common/ark_define.ts index ed74f0b17..e87ba8573 100644 --- a/compiler/src/fast_build/ark_compiler/common/ark_define.ts +++ b/compiler/src/fast_build/ark_compiler/common/ark_define.ts @@ -34,6 +34,7 @@ export const NPM_ENTRIES_PROTO_BIN: string = 'npm_entries.protoBin'; export const PACKAGE_JSON: string = 'package.json'; export const FAKE_JS: string = 'fake.js'; export const COMPILE_CONTEXT_INFO_JSON: string = 'compileContextInfo.json'; +export const PERFREPORT_JSON: string = 'perfReport.json'; export const ESMODULE: string = 'esmodule'; export const JSBUNDLE: string = 'jsbundle'; diff --git a/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts b/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts index f3e27ff9e..b352cfc20 100644 --- a/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts +++ b/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts @@ -52,10 +52,8 @@ import { isCurrentProjectFiles } from '../utils'; import { sourceFileBelongProject } from '../module/module_source_file'; import { compileToolIsRollUp, - createAndStartEvent, mangleDeclarationFileName, ModuleInfo, - stopEvent, writeArkguardObfuscatedSourceCode } from '../../../ark_utils'; import { OBFUSCATION_TOOL, red, yellow } from './ark_define'; @@ -67,6 +65,11 @@ import { CommonLogger } from '../logger'; import { MemoryMonitor } from '../../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../../meomry_monitor/memory_define'; import { ESMODULE } from '../../../pre_define'; +import { + CompileEvent, + createAndStartEvent, + stopEvent +} from '../../../performance'; export { collectResevedFileNameInIDEConfig, // For running unit test. @@ -479,8 +482,8 @@ export async function handlePostObfuscationTasks( /** * Write obfuscation caches if needed */ -export function writeObfuscationCaches(sourceProjectConfig: Object, eventOrEventFactory: Object): void { - const eventObfuscatedCode = createAndStartEvent(eventOrEventFactory, 'write obfuscation name cache'); +export function writeObfuscationCaches(sourceProjectConfig: Object, parentEvent: CompileEvent): void { + const eventObfuscatedCode = createAndStartEvent(parentEvent, 'write obfuscation name cache'); const needToWriteCache = compileToolIsRollUp() && sourceProjectConfig.arkObfuscator && sourceProjectConfig.obfuscationOptions; const isWidgetCompile = sourceProjectConfig.widgetCompile; diff --git a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts index 4d3caf0a9..2df6115ed 100644 --- a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts +++ b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts @@ -20,18 +20,19 @@ import { ModuleHotfixMode } from './module/module_hotfix_mode'; import { ModuleHotreloadMode } from './module/module_hotreload_mode'; import { ModulePreviewMode } from './module/module_preview_mode'; import { ModuleSourceFile } from './module/module_source_file'; +import type { ModuleMode } from './module/module_mode'; +import { SourceMapGenerator } from './generate_sourcemap'; import { + CompileEvent, getHookEventFactory, createAndStartEvent, stopEvent -} from '../../ark_utils'; -import type { ModuleMode } from './module/module_mode'; -import { SourceMapGenerator } from './generate_sourcemap'; +} from '../../performance'; let moduleMode: ModuleMode = null; export async function generateModuleAbc(error) { - const hookEventFactory = getHookEventFactory(this.share, 'genAbc', 'buildEnd'); + const hookEventFactory: CompileEvent | undefined = getHookEventFactory(this.share, 'genAbc', 'buildEnd'); if (error) { // When error thrown in previous plugins, rollup will catch and call buildEnd plugin. // Stop generate abc if error exists @@ -56,7 +57,7 @@ export async function generateModuleAbc(error) { } } -function generateAbc(rollupObject: Object, parentEvent: Object): void { +function generateAbc(rollupObject: Object, parentEvent: CompileEvent | undefined): void { const eventGenerateAbc = createAndStartEvent(parentEvent, 'generate abc'); if (rollupObject.share.projectConfig.watchMode !== 'true') { if (rollupObject.share.arkProjectConfig.coldReload) { diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index 26c05860f..d2c825e17 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -15,10 +15,6 @@ import path from 'path'; import fs from 'fs'; -import { - createAndStartEvent, - stopEvent -} from '../../ark_utils'; import { EXTNAME_ETS, EXTNAME_JS, @@ -59,6 +55,11 @@ import { LogData, LogDataFactory } from './logger'; +import { + createAndStartEvent, + CompileEvent, + stopEvent +} from '../../performance'; export class SourceMapGenerator { private static instance: SourceMapGenerator | undefined = undefined; @@ -193,7 +194,7 @@ export class SourceMapGenerator { path.join(this.projectConfig.cachePath, SOURCEMAPS); } - public buildModuleSourceMapInfo(parentEvent: Object): void { + public buildModuleSourceMapInfo(parentEvent: CompileEvent | undefined): void { if (this.projectConfig.widgetCompile) { return; } diff --git a/compiler/src/fast_build/ark_compiler/module/module_build_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_build_mode.ts index 4dd4f7ba9..7e9c0bb57 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_build_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_build_mode.ts @@ -31,23 +31,24 @@ import { LogData, LogDataFactory } from '../logger'; +import { CompileEvent } from '../../../performance'; export class ModuleBuildMode extends ModuleMode { constructor(rollupObject: Object) { super(rollupObject); } - generateAbc(rollupObject: Object, parentEvent: Object): void { + generateAbc(rollupObject: Object, parentEvent: CompileEvent): void { this.prepareForCompilation(rollupObject, parentEvent); SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); this.executeArkCompiler(parentEvent); } - executeArkCompiler(parentEvent: Object): void { + executeArkCompiler(parentEvent: CompileEvent): void { if (isEs2Abc(this.projectConfig)) { this.generateEs2AbcCmd(); this.addCacheFileArgs(); - this.genDescriptionsForMergedEs2abc(!!this.projectConfig.byteCodeHarInfo); + this.genDescriptionsForMergedEs2abc(!!this.projectConfig.byteCodeHarInfo, parentEvent); this.generateMergedAbcOfEs2Abc(parentEvent); } else if (isTs2Abc(this.projectConfig)) { this.filterModulesByHashJson(); diff --git a/compiler/src/fast_build/ark_compiler/module/module_coldreload_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_coldreload_mode.ts index 72593464e..d72d7e007 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_coldreload_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_coldreload_mode.ts @@ -30,10 +30,6 @@ import { toUnixPath, validateFilePathLength } from '../../../utils'; -import { - createAndStartEvent, - stopEvent -} from '../../../ark_utils'; import { SourceMapGenerator } from '../generate_sourcemap'; import { ArkTSInternalErrorDescription, @@ -43,6 +39,11 @@ import { LogData, LogDataFactory } from '../logger'; +import { + CompileEvent, + createAndStartEvent, + stopEvent +} from '../../../performance'; let isFirstBuild: boolean = true; @@ -62,7 +63,7 @@ export class ModuleColdreloadMode extends ModuleMode { } } - generateAbc(rollupObject: Object, parentEvent: Object): void { + generateAbc(rollupObject: Object, parentEvent: CompileEvent): void { isFirstBuild = this.projectConfig.isFirstBuild; if (isFirstBuild) { this.compileAllFiles(rollupObject, parentEvent); @@ -83,13 +84,13 @@ export class ModuleColdreloadMode extends ModuleMode { this.cmdArgs.push('--cold-reload'); } - private compileAllFiles(rollupObject: Object, parentEvent: Object): void { + private compileAllFiles(rollupObject: Object, parentEvent: CompileEvent): void { this.prepareForCompilation(rollupObject, parentEvent); SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); this.generateAbcByEs2abc(parentEvent, !!this.projectConfig.byteCodeHarInfo); } - private compileChangeListFiles(rollupObject: Object, parentEvent: Object): void { + private compileChangeListFiles(rollupObject: Object, parentEvent: CompileEvent): void { if (!fs.existsSync(this.projectConfig.changedFileList)) { this.logger.debug(blue, `ArkTS: Cannot find file: ${ this.projectConfig.changedFileList}, skip cold reload build`, reset); @@ -134,7 +135,7 @@ export class ModuleColdreloadMode extends ModuleMode { this.generateAbcByEs2abc(parentEvent, false); } - private updateSourceMapFromFileList(fileList: Array, parentEvent: Object): void { + private updateSourceMapFromFileList(fileList: Array, parentEvent: CompileEvent): void { const eventUpdateSourceMapFromFileList = createAndStartEvent(parentEvent, 'update source map from file list'); const sourceMapGenerator = SourceMapGenerator.getInstance(); const relativeProjectPath: string = this.projectConfig.projectPath.slice( @@ -160,10 +161,10 @@ export class ModuleColdreloadMode extends ModuleMode { stopEvent(eventUpdateSourceMapFromFileList); } - private generateAbcByEs2abc(parentEvent: Object, includeByteCodeHarInfo: boolean): void { + private generateAbcByEs2abc(parentEvent: CompileEvent, includeByteCodeHarInfo: boolean): void { this.generateEs2AbcCmd(); this.addColdReloadArgs(); - this.genDescriptionsForMergedEs2abc(includeByteCodeHarInfo); + this.genDescriptionsForMergedEs2abc(includeByteCodeHarInfo, parentEvent); this.generateMergedAbcOfEs2Abc(parentEvent); } } diff --git a/compiler/src/fast_build/ark_compiler/module/module_hotfix_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_hotfix_mode.ts index 42d1b0e5d..385d5e709 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_hotfix_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_hotfix_mode.ts @@ -19,6 +19,7 @@ import { ModuleMode } from './module_mode'; import { PATCH_SYMBOL_TABLE } from '../common/ark_define'; import { getEs2abcFileThreadNumber } from '../utils'; import { SourceMapGenerator } from '../generate_sourcemap'; +import { CompileEvent } from '../../../performance'; export class ModuleHotfixMode extends ModuleMode { patch: boolean; @@ -32,7 +33,7 @@ export class ModuleHotfixMode extends ModuleMode { this.enableMap = false; } - generateAbc(rollupObject: Object, parentEvent: Object): void { + generateAbc(rollupObject: Object, parentEvent: CompileEvent): void { this.patch = this.projectConfig.patch || false; this.inOldSymbolTablePath = this.projectConfig.inOldSymbolTablePath || this.projectConfig.projectRootPath; this.enableMap = this.projectConfig.enableMap || false; @@ -40,7 +41,7 @@ export class ModuleHotfixMode extends ModuleMode { SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); this.generateEs2AbcCmdForHotfix(); - this.genDescriptionsForMergedEs2abc(!!this.projectConfig.byteCodeHarInfo); + this.genDescriptionsForMergedEs2abc(!!this.projectConfig.byteCodeHarInfo, parentEvent); this.generateMergedAbcOfEs2Abc(parentEvent); } diff --git a/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts index 44d397d3d..a56654b20 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts @@ -30,10 +30,6 @@ import { toUnixPath, validateFilePathLength } from '../../../utils'; -import { - createAndStartEvent, - stopEvent -} from '../../../ark_utils'; import { SourceMapGenerator } from '../generate_sourcemap'; import { ArkTSInternalErrorDescription, @@ -43,6 +39,11 @@ import { LogData, LogDataFactory } from '../logger'; +import { + CompileEvent, + createAndStartEvent, + stopEvent +} from '../../../performance'; let isFirstBuild: boolean = true; @@ -62,7 +63,7 @@ export class ModuleHotreloadMode extends ModuleMode { } } - generateAbc(rollupObject: Object, parentEvent: Object): void { + generateAbc(rollupObject: Object, parentEvent: CompileEvent): void { // To support hotreload of multiple HSP modules, rollup no longer runs in watch mode. // In this case isFirstBuild needs to be passed in by hvigor, because if multiple HSP // module build tasks are running in the same worker in the IDE, the isFirstBuild of @@ -92,13 +93,13 @@ export class ModuleHotreloadMode extends ModuleMode { this.cmdArgs.push('--hot-reload'); } - private compileAllFiles(rollupObject: Object, parentEvent: Object): void { + private compileAllFiles(rollupObject: Object, parentEvent: CompileEvent): void { this.prepareForCompilation(rollupObject, parentEvent); SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); this.generateAbcByEs2abc(parentEvent, !!this.projectConfig.byteCodeHarInfo); } - private compileChangeListFiles(rollupObject: Object, parentEvent: Object): void { + private compileChangeListFiles(rollupObject: Object, parentEvent: CompileEvent): void { if (!fs.existsSync(this.projectConfig.changedFileList)) { this.logger.debug(blue, `ArkTS: Cannot find file: ${ this.projectConfig.changedFileList}, skip hot reload build`, reset); @@ -168,7 +169,7 @@ export class ModuleHotreloadMode extends ModuleMode { } } - private updateSourceMapFromFileList(fileList: Array, parentEvent: Object): void { + private updateSourceMapFromFileList(fileList: Array, parentEvent: CompileEvent): void { const eventUpdateSourceMapFromFileList = createAndStartEvent(parentEvent, 'update source map from file list'); const sourceMapGenerator = SourceMapGenerator.getInstance(); const relativeProjectPath: string = this.projectConfig.projectPath.slice( @@ -194,10 +195,10 @@ export class ModuleHotreloadMode extends ModuleMode { stopEvent(eventUpdateSourceMapFromFileList); } - private generateAbcByEs2abc(parentEvent: Object, includeByteCodeHarInfo: boolean): void { + private generateAbcByEs2abc(parentEvent: CompileEvent, includeByteCodeHarInfo: boolean): void { this.generateEs2AbcCmd(); this.addHotReloadArgs(); - this.genDescriptionsForMergedEs2abc(includeByteCodeHarInfo); + this.genDescriptionsForMergedEs2abc(includeByteCodeHarInfo, parentEvent); this.generateMergedAbcOfEs2Abc(parentEvent); } } diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index c14c3c04e..0d8636ba3 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -53,7 +53,8 @@ import { ES2ABC, ETS, TS, - JS + JS, + PERFREPORT_JSON } from '../common/ark_define'; import { needAotCompiler, @@ -88,8 +89,6 @@ import { getOhmUrlByExternalPackage, isTs2Abc, isEs2Abc, - createAndStartEvent, - stopEvent, transformOhmurlToPkgName, transformOhmurlToRecordName } from '../../../ark_utils'; @@ -115,6 +114,14 @@ import { LogData, LogDataFactory } from '../logger'; +import { + CompileEvent, + createAndStartEvent, + ExternalEventType, + isNeedPerformanceDotting, + processExternalEvents, + stopEvent + } from '../../../performance'; export class ModuleInfo { filePath: string; @@ -166,6 +173,7 @@ export class ModuleMode extends CommonMode { compileContextInfoPath: string; abcPaths: string[] = []; byteCodeHar: boolean; + perfReportPath: string; constructor(rollupObject: Object) { super(rollupObject); @@ -173,6 +181,7 @@ export class ModuleMode extends CommonMode { this.pkgEntryInfos = new Map(); this.hashJsonObject = {}; this.filesInfoPath = path.join(this.projectConfig.cachePath, FILESINFO_TXT); + this.perfReportPath = path.join(this.projectConfig.cachePath, PERFREPORT_JSON); this.npmEntriesInfoPath = path.join(this.projectConfig.cachePath, NPMENTRIES_TXT); const outPutABC: string = this.projectConfig.widgetCompile ? WIDGETS_ABC : MODULES_ABC; this.moduleAbcPath = path.join(this.projectConfig.aceModuleBuild, outPutABC); @@ -295,7 +304,7 @@ export class ModuleMode extends CommonMode { }); } - prepareForCompilation(rollupObject: Object, parentEvent: Object): void { + prepareForCompilation(rollupObject: Object, parentEvent: CompileEvent): void { const eventPrepareForCompilation = createAndStartEvent(parentEvent, 'preparation for compilation'); this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); this.removeCacheInfo(rollupObject); @@ -566,6 +575,9 @@ export class ModuleMode extends CommonMode { if (this.projectConfig.allowEtsAnnotations) { this.cmdArgs.push('--enable-annotations'); } + if (isNeedPerformanceDotting(this.projectConfig)) { + this.cmdArgs.push(`--perf-file=${this.perfReportPath}`); + } } addCacheFileArgs() { @@ -647,23 +659,23 @@ export class ModuleMode extends CommonMode { return changeFileExtension(tempPath, EXTNAME_PROTO_BIN); } - genDescriptionsForMergedEs2abc(includeByteCodeHarInfo: boolean): void { + genDescriptionsForMergedEs2abc(includeByteCodeHarInfo: boolean, parentEvent: CompileEvent): void { + const eventEenDescriptionsForMergedEs2abc = createAndStartEvent(parentEvent, 'generate descriptions for merged es2abc'); this.generateCompileFilesInfo(includeByteCodeHarInfo); if (!this.byteCodeHar) { this.generateNpmEntriesInfo(); } this.generateAbcCacheFilesInfo(); + stopEvent(eventEenDescriptionsForMergedEs2abc) } - generateMergedAbcOfEs2Abc(parentEvent: Object): void { + generateMergedAbcOfEs2Abc(parentEvent: CompileEvent): void { // collect data error from subprocess let logDataList: Object[] = []; let errMsg: string = ''; - const eventGenDescriptionsForMergedEs2abc = createAndStartEvent(parentEvent, 'generate descriptions for merged es2abc'); - stopEvent(eventGenDescriptionsForMergedEs2abc); const genAbcCmd: string = this.cmdArgs.join(' '); + let eventGenAbc: CompileEvent; try { - let eventGenAbc: Object; const child = this.triggerAsync(() => { eventGenAbc = createAndStartEvent(parentEvent, 'generate merged abc by es2abc (async)', true); return childProcess.exec(genAbcCmd, { windowsHide: true }); @@ -673,6 +685,7 @@ export class ModuleMode extends CommonMode { stopEvent(eventGenAbc, true); this.triggerEndSignal(); this.processAotIfNeeded(); + processExternalEvents(this.projectConfig, ExternalEventType.ES2ABC, { parentEvent: eventGenAbc, filePath: this.perfReportPath }); return; } for (const logData of logDataList) { diff --git a/compiler/src/fast_build/ark_compiler/module/module_preview_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_preview_mode.ts index a043986c8..727e1a9f3 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_preview_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_preview_mode.ts @@ -31,23 +31,24 @@ import { LogData, LogDataFactory } from '../logger'; +import { CompileEvent } from '../../../performance'; export class ModulePreviewMode extends ModuleMode { constructor(rollupObject: Object) { super(rollupObject); } - generateAbc(rollupObject: Object, parentEvent: Object): void { + generateAbc(rollupObject: Object, parentEvent: CompileEvent): void { this.prepareForCompilation(rollupObject, parentEvent); SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); this.executeArkCompiler(parentEvent); } - executeArkCompiler(parentEvent: Object): void { + executeArkCompiler(parentEvent: CompileEvent): void { if (isEs2Abc(this.projectConfig)) { this.generateEs2AbcCmd(); this.addCacheFileArgs(); - this.genDescriptionsForMergedEs2abc(!!this.projectConfig.byteCodeHarInfo); + this.genDescriptionsForMergedEs2abc(!!this.projectConfig.byteCodeHarInfo, parentEvent); this.generateMergedAbcOfEs2Abc(parentEvent); } else if (isTs2Abc(this.projectConfig)) { this.filterModulesByHashJson(); diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index c6b75a9d6..c2790540f 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -38,11 +38,6 @@ import { writeFileContentToTempDir } from '../utils'; import { toUnixPath } from '../../../utils'; -import { - createAndStartEvent, - getHookEventFactory, - stopEvent -} from '../../../ark_utils'; import { SourceMapGenerator } from '../generate_sourcemap'; import { printObfLogger, @@ -77,6 +72,11 @@ import { ErrorCode } from '../error_code'; import { checkIfJsImportingArkts } from '../check_import_module'; +import { + CompileEvent, + createAndStartEvent, + stopEvent +} from '../../../performance'; const ROLLUP_IMPORT_NODE: string = 'ImportDeclaration'; const ROLLUP_EXPORTNAME_NODE: string = 'ExportNamedDeclaration'; const ROLLUP_EXPORTALL_NODE: string = 'ExportAllDeclaration'; @@ -319,11 +319,9 @@ export class ModuleSourceFile { return ModuleSourceFile.sourceFiles; } - static async processSingleModuleSourceFile(rollupObject: Object, moduleId: string): Promise { + static async processSingleModuleSourceFile(rollupObject: Object, moduleId: string, parentEvent: CompileEvent| undefined): Promise { if (!ModuleSourceFile.isEnvInitialized) { this.initPluginEnv(rollupObject); - - ModuleSourceFile.hookEventFactory = getHookEventFactory(rollupObject.share, 'genAbc', 'moduleParsed'); ModuleSourceFile.setProcessMock(rollupObject); if (ModuleSourceFile.needProcessMock) { ModuleSourceFile.collectMockConfigInfo(rollupObject); @@ -343,17 +341,17 @@ export class ModuleSourceFile { if (!rollupObject.share.projectConfig.compileHar || ModuleSourceFile.projectConfig.byteCodeHar) { //compileHar: compile closed source har of project, which convert .ets to .d.ts and js, doesn't transform module request. - const eventBuildModuleSourceFile = createAndStartEvent(ModuleSourceFile.hookEventFactory, 'build module source files'); + const eventBuildModuleSourceFile = createAndStartEvent(parentEvent, 'build module source files'); await moduleSourceFile.processModuleRequest(rollupObject, eventBuildModuleSourceFile); stopEvent(eventBuildModuleSourceFile); } - const eventWriteSourceFile = createAndStartEvent(ModuleSourceFile.hookEventFactory, 'write source file'); + const eventWriteSourceFile = createAndStartEvent(parentEvent, 'write source file'); await moduleSourceFile.writeSourceFile(eventWriteSourceFile); stopEvent(eventWriteSourceFile); } } - static async processModuleSourceFiles(rollupObject: Object, parentEvent: Object): Promise { + static async processModuleSourceFiles(rollupObject: Object, parentEvent: CompileEvent | undefined): Promise { this.initPluginEnv(rollupObject); // collect mockConfigInfo @@ -409,7 +407,7 @@ export class ModuleSourceFile { return this.moduleId; } - private async writeSourceFile(parentEvent: Object): Promise { + private async writeSourceFile(parentEvent: CompileEvent): Promise { if (this.isSourceNode && !isJsSourceFile(this.moduleId)) { await writeFileSyncByNode( this.source, ModuleSourceFile.projectConfig, this.metaInfo, this.moduleId, parentEvent, printObfLogger); @@ -650,7 +648,7 @@ export class ModuleSourceFile { // Replace each module request in source file to a unique representation which is called 'ohmUrl'. // This 'ohmUrl' will be the same as the record name for each file, to make sure runtime can find the corresponding // record based on each module request. - async processModuleRequest(rollupObject: Object, parentEvent: Object): Promise { + async processModuleRequest(rollupObject: Object, parentEvent: CompileEvent): Promise { if (isJsonSourceFile(this.moduleId)) { return; } @@ -696,7 +694,6 @@ export class ModuleSourceFile { ModuleSourceFile.needProcessMock = false; ModuleSourceFile.moduleIdMap = new Map(); ModuleSourceFile.isEnvInitialized = false; - ModuleSourceFile.hookEventFactory = undefined; } } diff --git a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts index 99bcf140a..2a32aaddd 100644 --- a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts +++ b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts @@ -27,6 +27,11 @@ import { cleanUpUtilsObjects, writeDeclarationFiles } from '../../ark_utils'; import { cleanUpKitImportObjects } from '../../process_kit_import'; import { cleanUpFilesList } from './utils'; import { CommonLogger } from './logger'; +import { + getHookEventFactory, + cleanUpAsyncEvents, + CompileEvent +} from '../../performance'; export function genAbc() { return { @@ -43,7 +48,8 @@ export function genAbc() { moduleParsed(moduleInfo: moduleInfoType): void { // process single ModuleSourceFile if (this.share.projectConfig.singleFileEmit) { - ModuleSourceFile.processSingleModuleSourceFile(this, moduleInfo.id); + const hookEventFactory: CompileEvent | undefined = getHookEventFactory(this.share, 'genAbc', 'moduleParsed'); + ModuleSourceFile.processSingleModuleSourceFile(this, moduleInfo.id, hookEventFactory); } }, beforeBuildEnd: { @@ -73,6 +79,7 @@ export function genAbc() { ModuleSourceFile.cleanUpObjects(); cleanSharedModuleSet(); CommonLogger.destroyInstance(); + cleanUpAsyncEvents(); } }; } diff --git a/compiler/src/fast_build/ark_compiler/transform.ts b/compiler/src/fast_build/ark_compiler/transform.ts index 7bff84a2c..a40b85c7a 100644 --- a/compiler/src/fast_build/ark_compiler/transform.ts +++ b/compiler/src/fast_build/ark_compiler/transform.ts @@ -34,11 +34,6 @@ import { emitLogInfo, getTransformLog } from '../../utils'; -import { - getHookEventFactory, - createAndStartEvent, - stopEvent -} from '../../ark_utils'; import { resetReExportCheckLog, reExportNoCheckMode, @@ -49,6 +44,12 @@ import { import { SourceMapGenerator } from './generate_sourcemap'; import { MemoryMonitor } from '../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../meomry_monitor/memory_define'; +import { + getHookEventFactory, + createAndStartEvent, + stopEvent, + CompileEvent +} from '../../performance'; /** * rollup transform hook @@ -56,7 +57,7 @@ import { MemoryDefine } from '../meomry_monitor/memory_define'; * @param {string} id: absolute path of an input file */ export function transformForModule(code: string, id: string): string { - const hookEventFactory = getHookEventFactory(this.share, 'genAbc', 'transform'); + const hookEventFactory: CompileEvent | undefined = getHookEventFactory(this.share, 'genAbc', 'transform'); const eventTransformForModule = createAndStartEvent(hookEventFactory, 'transform for module'); const { autoLazyImport, @@ -107,7 +108,7 @@ export function transformForModule(code: string, id: string): string { return code; } -function preserveSourceMap(sourceFilePath: string, sourcemap: Object, projectConfig: Object, metaInfo: Object, parentEvent: Object): void { +function preserveSourceMap(sourceFilePath: string, sourcemap: Object, projectConfig: Object, metaInfo: Object, parentEvent: CompileEvent): void { if (isCommonJsPluginVirtualFile(sourceFilePath)) { // skip automatic generated files like 'jsfile.js?commonjs-exports' return; @@ -127,7 +128,7 @@ function preserveSourceMap(sourceFilePath: string, sourcemap: Object, projectCon stopEvent(eventAddSourceMapInfo); } -function transformJsByBabelPlugin(code: string, parentEvent: Object): Object { +function transformJsByBabelPlugin(code: string, parentEvent: CompileEvent): Object { const eventTransformByBabel = createAndStartEvent(parentEvent, 'transform Js by babel plugin'); const transformed: Object = require('@babel/core').transformSync(code, { diff --git a/compiler/src/fast_build/ark_compiler/utils.ts b/compiler/src/fast_build/ark_compiler/utils.ts index c4c94a77d..ce12fc949 100644 --- a/compiler/src/fast_build/ark_compiler/utils.ts +++ b/compiler/src/fast_build/ark_compiler/utils.ts @@ -43,9 +43,6 @@ import { import { tryMangleFileName, writeObfuscatedSourceCode, - cleanUpUtilsObjects, - createAndStartEvent, - stopEvent } from '../../ark_utils'; import { AOT_FULL, AOT_PARTIAL, AOT_TYPE } from '../../pre_define'; import { SourceMapGenerator } from './generate_sourcemap'; @@ -55,6 +52,11 @@ import { enableObfuscatedFilePathConfig, getRelativeSourcePath } from './common/ob_config_resolver'; +import { + CompileEvent, + createAndStartEvent, + stopEvent +} from '../../performance'; export let hasTsNoCheckOrTsIgnoreFiles: string[] = []; export let compilingEtsOrTsFiles: string[] = []; @@ -150,7 +152,7 @@ function updateCacheFilePathIfEnableObuscatedFilePath(filePath: string, cacheFil } export async function writeFileContentToTempDir(id: string, content: string, projectConfig: Object, - logger: Object, parentEvent: Object, metaInfo: Object): Promise { + logger: Object, parentEvent: CompileEvent, metaInfo: Object): Promise { if (isCommonJsPluginVirtualFile(id)) { return; } diff --git a/compiler/src/performance.ts b/compiler/src/performance.ts new file mode 100644 index 000000000..9486290ce --- /dev/null +++ b/compiler/src/performance.ts @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2025 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 * as fs from 'fs'; +import * as ts from 'typescript'; + +export interface CompileEvent { + createSubEvent?: (eventName: string) => CompileEvent; + createEvent: (eventName: string) => CompileEvent; + startAsyncEvent?: () => void; + start: () => void; + stopAsyncEvent?: () => void; + stop: () => void; + setTotalTime: (time: number) => void; +} + +interface Event { + // id: Unique identifier of the event. + id: string; + // name: The name of the event. Duplicates exist. + name: string; + startTime: number; + endTime: number; + parentEvent: string; + parentId: string; + duration: number; +} + +export enum AnalyzeMode { + DEFAULT, + VERBOSE, + FALSE, + TRACE +} + +export enum ExternalEventType { + TSC, + ES2ABC +} + +let asyncEvents: Map = new Map(); + +export function isNeedPerformanceDotting(projectConfig: Object): boolean { + return projectConfig.perf === AnalyzeMode.TRACE || projectConfig.perf === AnalyzeMode.VERBOSE; +} + +export function getHookEventFactory(share: Object, pluginName: string, hookName: string): CompileEvent | undefined { + if (typeof share.getHookEventFactory === 'function' && isNeedPerformanceDotting(share.projectConfig)) { + return share.getHookEventFactory(pluginName, hookName); + } else { + return undefined; + } +} + +export function createAndStartEvent(eventOrEventFactory: CompileEvent | undefined, eventName: string, + isAsyncEvent = false): CompileEvent | undefined { + if (eventOrEventFactory === undefined) { + return undefined; + } + let event: CompileEvent; + if (isSubEvent(eventOrEventFactory)) { + event = eventOrEventFactory.createSubEvent(eventName); + } else { + event = eventOrEventFactory.createEvent(eventName); + } + if (isAsyncEvent) { + event.startAsyncEvent(); + } else { + event.start(); + } + return event; +} + +function isSubEvent(event: CompileEvent): boolean { + return typeof event.createSubEvent === 'function'; +} + +export function stopEvent(event: CompileEvent | undefined, isAsyncEvent: boolean = false): void { + if (event === undefined) { + return; + } + if (isAsyncEvent) { + event.stopAsyncEvent(); + } else { + event.stop(); + } +} + +export function processExternalEvents(projectConfig: Object, eventType: number, externalEventsInfo: Object): void { + if (!isNeedPerformanceDotting(projectConfig)) { + return; + } + const isTsc: boolean = isTscEvents(eventType); + const { parentEvent, filePath } = externalEventsInfo; + let events: Event[] = isTsc ? ts.PerformanceDotting.getEventData() : + (fs.existsSync(filePath) ? JSON.parse(fs.readFileSync(filePath, 'utf-8')): []); + if (events && events.length) { + events = events.sort((a, b) => a.startTime - b.startTime); + asyncEvents.set(isTsc ? events[0].parentId : events[0].parentEvent, parentEvent); + for (const event of events) { + setTotalTime(event, isTsc); + } + } + asyncEvents.clear(); +} + +function isTscEvents(eventType: number): boolean { + return eventType === ExternalEventType.TSC; +} + +function setTotalTime(event: Event, isTsc: boolean): void { + const parentEvent: CompileEvent | undefined = getCurrentAsyncEvent(isTsc ? event.parentId : event.parentEvent); + if (parentEvent) { + const subEvent: CompileEvent = parentEvent.createSubEvent(event.name); + subEvent.start(); + subEvent.stop(); + subEvent.setTotalTime(event.duration); + asyncEvents.set(isTsc ? event.id : event.name, subEvent) + } +} + +function getCurrentAsyncEvent(eventName): CompileEvent | undefined { + if (asyncEvents && asyncEvents.has(eventName)) { + return asyncEvents.get(eventName); + } + return undefined; +} + +export function cleanUpAsyncEvents(): void { + asyncEvents.clear(); +} \ No newline at end of file diff --git a/compiler/src/process_module_files.ts b/compiler/src/process_module_files.ts index b016860f5..63b38aa1a 100644 --- a/compiler/src/process_module_files.ts +++ b/compiler/src/process_module_files.ts @@ -28,21 +28,23 @@ import { toUnixPath, } from './utils'; import { - genSourceMapFileName, newSourceMaps as webpackNewSourceMaps, transformModuleSpecifier, writeObfuscatedSourceCode, - createAndStartEvent, - stopEvent } from './ark_utils'; import { processSystemApi } from './validate_ui_syntax'; import { isDebug } from './fast_build/ark_compiler/utils'; import { getRelativeSourcePath } from './fast_build/ark_compiler/common/ob_config_resolver'; +import { + CompileEvent, + createAndStartEvent, + stopEvent, + } from './performance'; export const SRC_MAIN: string = 'src/main'; export async function writeFileSyncByNode(node: ts.SourceFile, projectConfig: Object, metaInfo: Object, moduleId?: string, - parentEvent?: Object, logger?: Object): Promise { + parentEvent?: CompileEvent, logger?: Object): Promise { const eventWriteFileSyncByNode = createAndStartEvent(parentEvent, 'write file sync by node'); const eventGenContentAndSourceMapInfo = createAndStartEvent(eventWriteFileSyncByNode, 'generate content and source map information'); const mixedInfo: { content: string, sourceMapJson: ts.RawSourceMap } = genContentAndSourceMapInfo(node, moduleId, projectConfig, metaInfo); diff --git a/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts b/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts index 6fabca242..dbc7a1b15 100644 --- a/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts +++ b/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts @@ -39,6 +39,7 @@ import { toUnixPath } from '../../../../lib/utils'; import { META } from '../rollup_mock/common'; import { sharedModuleSet } from '../../../../lib/fast_build/ark_compiler/check_shared_module'; import { SourceMapGenerator } from '../../../../lib/fast_build/ark_compiler/generate_sourcemap'; +import { CompileEvent } from '../../../../lib/performance'; class ModuleModeMock extends ModuleMode { collectModuleFileListMock(rollupObject: object) { const fileList = Array.from(rollupObject.getModuleIds()); @@ -270,7 +271,7 @@ class ModuleModeMock extends ModuleMode { } } - generateMergedAbcOfEs2AbcMock(parentEvent: Object) { + generateMergedAbcOfEs2AbcMock(parentEvent: CompileEvent) { this.generateMergedAbcOfEs2Abc(parentEvent) } -- Gitee From 2bd0c1b1c0445ef8e7a78f15780c809f01a6a791 Mon Sep 17 00:00:00 2001 From: liyancheng2 Date: Tue, 18 Mar 2025 21:47:06 +0800 Subject: [PATCH 024/140] performance dotting in tsc Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IBUFMF Signed-off-by: liyancheng2 Change-Id: Iaa25b98d45d8f06ffae2a265aa541a9d79f44d4b --- compiler/src/ets_checker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 5f382fb94..7aa8df462 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -373,6 +373,7 @@ export function createLanguageService(rootFileNames: string[], resolveModulePath return reuseLanguageServiceForDepChange && needReCheckForChangedDepUsers; } }; + ts.PerformanceDotting?.setPerformanceSwitch(projectConfig?.perf); if (process.env.watchMode === 'true') { const recordInfo = MemoryMonitor.recordStage(MemoryDefine.ETS_CHECKER_CREATE_LANGUAGE_SERVICE); -- Gitee From 9329c6307389b2670e042fae3d391d0e6b9579f2 Mon Sep 17 00:00:00 2001 From: lixinnan Date: Mon, 5 May 2025 09:53:02 +0800 Subject: [PATCH 025/140] add objectLink wrapBuilder UT Signed-off-by: lixinnan Change-Id: I440e45fc6eca07e9a1ece794c319c234a7536166 --- .../wrapBuilder/wrapBuilder.js.sample | 246 ++++++++++++++++++ .../@observed_@objectLink1.js.sample | 138 ++++++++++ .../wrapBuilder/wrapBuilder.ets | 106 ++++++++ .../@observed_@objectLink1.ets | 41 +++ .../test/transform_ut/helpers/pathConfig.ts | 2 + 5 files changed, 533 insertions(+) create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.js.sample create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1.js.sample create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.ets create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1.ets diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.js.sample new file mode 100644 index 000000000..e7f38f92b --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.js.sample @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2025 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. + */ +"use strict"; +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +function MyBuilder(value, size, parent = null) { + (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(value); + Text.fontSize(size); + }, Text); + Text.pop(); + Column.pop(); +} +let globalBuilder = wrapBuilder(MyBuilder); +class TestWrapperBuilder extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__message = new ObservedPropertySimplePU('Hello World', this, "message"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + if (params.message !== undefined) { + this.message = params.message; + } + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__message.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__message.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get message() { + return this.__message.get(); + } + set message(newValue) { + this.__message.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + Row.height('100%'); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.width('100%'); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create("wrapperBuilder 场景一:"); + Text.fontSize(20); + }, Text); + Text.pop(); + globalBuilder.builder.bind(this)(this.message, 50); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); + }, Divider); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create("wrapperBuilder 场景二:"); + Text.fontSize(20); + }, Text); + Text.pop(); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new TestWrapperBuilderChild(this, {}, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.ets", line: 39, col: 9 }); + ViewV2.create(componentCall); + let paramsLambda = () => { + return {}; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "TestWrapperBuilderChild" }); + } + this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); + }, Divider); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create("wrapperBuilder 场景三:"); + Text.fontSize(20); + }, Text); + Text.pop(); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new TestWrapperBuilderChildTwo(this, {}, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.ets", line: 43, col: 9 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return {}; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "TestWrapperBuilderChildTwo" }); + } + Column.pop(); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName() { + return "TestWrapperBuilder"; + } +} +function YourBuilder(value, size, parent = null) { + (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(value); + Text.fontSize(size); + Text.fontColor(Color.Pink); + }, Text); + Text.pop(); + Column.pop(); +} +const builderArr = [wrapBuilder(MyBuilder), wrapBuilder(YourBuilder)]; +class TestWrapperBuilderChild extends ViewV2 { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda, extraInfo) { + super(parent, elmtId, extraInfo); + this.finalizeConstruction(); + } + resetStateVarsOnReuse(params) { + } + testBuilder(parent = null) { + this.observeComponentCreation2((elmtId, isInitialRender) => { + ForEach.create(); + const forEachItemGenFunction = _item => { + const item = _item; + item.builder.bind(this)('Hello World', 30); + }; + this.forEachUpdateFunction(elmtId, builderArr, forEachItemGenFunction); + }, ForEach); + ForEach.pop(); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + this.testBuilder.bind(this)(); + Column.pop(); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +class Tmp { + constructor() { + this.paramA2 = 'hello'; + } +} +function overBuilder(param, parent = null) { + const __param__ = param; + (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, param = __param__) => { + Column.create(); + }, Column); + (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, param = __param__) => { + Text.create(`wrapBuilderValue:${param.paramA2}`); + }, Text); + Text.pop(); + Column.pop(); +} +const wBuilder = wrapBuilder(overBuilder); +class TestWrapperBuilderChildTwo extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__label = new ObservedPropertyObjectPU(new Tmp(), this, "label"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + if (params.label !== undefined) { + this.label = params.label; + } + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__label.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__label.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get label() { + return this.__label.get(); + } + set label(newValue) { + this.__label.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + wBuilder.builder.bind(this)(makeBuilderParameterProxy("builder", { paramA2: () => this.label.paramA2 })); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Click me change UI update'); + Button.onClick(() => { + this.label.paramA2 = 'ArkUI'; + }); + }, Button); + Button.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +registerNamedRoute(() => new TestWrapperBuilder(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder", integratedHsp: "false", moduleType: "followWithHap" }); +//# sourceMappingURL=wrapBuilder.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1.js.sample new file mode 100644 index 000000000..28245f4e2 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1.js.sample @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2025 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. + */ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { +var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; +if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); +else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; +return c > 3 && r && Object.defineProperty(target, key, r), r; +}; + +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +let TestObserved_ObjectLink = class TestObserved_ObjectLink { +constructor() { +this.name = "TestObserved_ObjectLink"; +} +}; +TestObserved_ObjectLink = __decorate([ +Observed +], TestObserved_ObjectLink); + +class TestObjectLink extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__state_value = new ObservedPropertyObjectPU(new TestObserved_ObjectLink(), this, "state_value"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + if (params.state_value !== undefined) { + this.state_value = params.state_value; + } + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__state_value.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__state_value.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get state_value() { + return this.__state_value.get(); + } + set state_value(newValue) { + this.__state_value.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + RelativeContainer.create(); + RelativeContainer.height('100%'); + RelativeContainer.width('100%'); + }, RelativeContainer); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new TestObjectLink_Child(this, { objectLinkValue: this.state_value }, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1.ets", line: 27, col: 7 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + objectLinkValue: this.state_value + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, { + objectLinkValue: this.state_value + }); + } + }, { name: "TestObjectLink_Child" }); + } + RelativeContainer.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName() { + return "TestObjectLink"; + } +} +class TestObjectLink_Child extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__objectLinkValue = new SynchedPropertyNesedObjectPU(params.objectLinkValue, this, "objectLinkValue"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + this.__objectLinkValue.set(params.objectLinkValue); + } + updateStateVars(params) { + this.__objectLinkValue.set(params.objectLinkValue); + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__objectLinkValue.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__objectLinkValue.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get objectLinkValue() { + return this.__objectLinkValue.get(); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.objectLinkValue.name); + }, Text); + Text.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +registerNamedRoute(() => new TestObjectLink(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1", integratedHsp: "false", moduleType: "followWithHap" }); +//# sourceMappingURL=@observed_@objectLink1.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.ets new file mode 100644 index 000000000..096c7e0b4 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/application_state_management/wrapBuilder/wrapBuilder.ets @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 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. + */ +@Builder +function MyBuilder(value: string, size: number) { + Column() { + Text(value) + .fontSize(size) + } +} + +let globalBuilder: WrappedBuilder<[string, number]> = wrapBuilder(MyBuilder); + +@Entry +@Component +struct TestWrapperBuilder { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text("wrapperBuilder 场景一:") + .fontSize(20) + globalBuilder.builder(this.message, 50) + Divider() + Text("wrapperBuilder 场景二:") + .fontSize(20) + TestWrapperBuilderChild() + Divider() + Text("wrapperBuilder 场景三:") + .fontSize(20) + TestWrapperBuilderChildTwo() + } + .width('100%') + } + .height('100%') + } +} + +@Builder +function YourBuilder(value: string, size: number) { + Column() { + Text(value) + .fontSize(size) + .fontColor(Color.Pink) + } +} + +const builderArr: WrappedBuilder<[string, number]>[] = [wrapBuilder(MyBuilder), wrapBuilder(YourBuilder)]; + +@ComponentV2 +struct TestWrapperBuilderChild { + @Builder + testBuilder() { + ForEach(builderArr, (item: WrappedBuilder<[string, number]>) => { + item.builder('Hello World', 30) + }) + } + + build() { + Row() { + Column() { + this.testBuilder() + } + } + } +} + +class Tmp { + paramA2: string = 'hello'; +} + +@Builder +function overBuilder(param: Tmp) { + Column() { + Text(`wrapBuilderValue:${param.paramA2}`) + } +} + +const wBuilder: WrappedBuilder<[Tmp]> = wrapBuilder(overBuilder); + +@Component +struct TestWrapperBuilderChildTwo { + @State label: Tmp = new Tmp(); + + build() { + Column() { + wBuilder.builder({ paramA2: this.label.paramA2 }) + Button('Click me change UI update') + .onClick(() => { + this.label.paramA2 = 'ArkUI'; + }) + } + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1.ets new file mode 100644 index 000000000..4429519f7 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink1.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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. + */ +@Observed +class TestObserved_ObjectLink { + name: string = "TestObserved_ObjectLink"; +} + +@Entry +@Component +struct TestObjectLink { + @State state_value: TestObserved_ObjectLink = new TestObserved_ObjectLink(); + + build() { + RelativeContainer() { + TestObjectLink_Child({ objectLinkValue: this.state_value }) + } + .height('100%') + .width('100%') + } +} + +@Component +struct TestObjectLink_Child { + @ObjectLink objectLinkValue: TestObserved_ObjectLink; + + build() { + Text(this.objectLinkValue.name) + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/pathConfig.ts b/compiler/test/transform_ut/helpers/pathConfig.ts index b9a4511ff..ca5aa605f 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -169,6 +169,7 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'ui_state_management/application_state_management/localStorage/localStorageForThree', 'ui_state_management/application_state_management/localStorage/localStorageForThreeParam', 'ui_state_management/application_state_management/localStorage/localStorageParam', + 'ui_state_management/application_state_management/wrapBuilder/wrapBuilder', 'ui_state_management/inner_struct_state_management/@link/@link', 'ui_state_management/inner_struct_state_management/@objectLink/@objectLink', 'ui_state_management/inner_struct_state_management/@prop/@prop', @@ -177,6 +178,7 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'ui_state_management/inner_struct_state_management/@state/@state1', 'ui_state_management/others/@consume_@provide/@consume_@provide', 'ui_state_management/others/@observed_@objectLink/@observed_@objectLink', + 'ui_state_management/others/@observed_@objectLink/@observed_@objectLink1', 'ui_state_management/others/@watch/@watch', 'ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck', 'ui_state_management/ObservedObject_GetRawObject/enableV2Compatibility', -- Gitee From 2c7cbd53846580a53325296a332586cab80d5d32 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Mon, 5 May 2025 14:21:43 +0800 Subject: [PATCH 026/140] =?UTF-8?q?=E2=80=99jiangbo91@huawei.com=E2=80=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix import * as A ERROR Signed-off-by: Bojiang Change-Id: I157b5a6cc40da4e2c6c21d884a615ed22e54d751 --- compiler/src/process_component_build.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index c96ce51bf..225c7f1d2 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -3363,7 +3363,8 @@ function getComponentType(node: ts.ExpressionStatement, log: LogInfo[], name: st function isCustomComponentAttributes(node: ts.ExpressionStatement, log: LogInfo[]): void { if (node.expression && ts.isCallExpression(node.expression) && ts.isPropertyAccessExpression(node.expression.expression) && - ts.isIdentifier(node.expression.expression.name) && !COMMON_ATTRS.has(node.expression.expression.name.escapedText.toString())) { + !ts.isIdentifier(node.expression.expression.expression) && ts.isIdentifier(node.expression.expression.name) && + !COMMON_ATTRS.has(node.expression.expression.name.escapedText.toString())) { log.push({ type: LogType.ERROR, message: `'${node.getText()}' does not meet UI component syntax.`, -- Gitee From 6bb8c7462927a1f2cfc13e223e93444705748399 Mon Sep 17 00:00:00 2001 From: c30058867 Date: Thu, 10 Apr 2025 17:57:17 +0800 Subject: [PATCH 027/140] add skipOhModulesLint Issue:https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IC5IS6 Signed-off-by: caiy --- compiler/src/ets_checker.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 5f382fb94..522d4fc35 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -110,6 +110,7 @@ export interface LanguageServiceCache { targetESVersion?: ts.ScriptTarget; maxFlowDepth?: number; preTsImportSendable?: boolean; + preSkipOhModulesLint?: boolean; } export const SOURCE_FILES: Map = new Map(); @@ -191,7 +192,8 @@ function setCompilerOptions(resolveModulePaths: string[]): void { 'tsImportSendableEnable': tsImportSendable, 'skipPathsInKeyForCompilationSettings': reuseLanguageServiceForDepChange, 'compatibleSdkVersionStage': projectConfig.compatibleSdkVersionStage, - 'compatibleSdkVersion': projectConfig.compatibleSdkVersion + 'compatibleSdkVersion': projectConfig.compatibleSdkVersion, + 'skipOhModulesLint': skipOhModulesLint }); if (projectConfig.compileMode === ESMODULE) { Object.assign(compilerOptions, { @@ -408,13 +410,16 @@ function getOrCreateLanguageService(servicesHost: ts.LanguageServiceHost, rootFi const tsImportSendableDiff: boolean = (cache?.preTsImportSendable === undefined && !tsImportSendable) ? false : cache?.preTsImportSendable !== tsImportSendable; - const shouldRebuild: boolean | undefined = shouldRebuildForDepDiffers || targetESVersionDiffers || tsImportSendableDiff || maxFlowDepthDiffers; + const skipOhModulesLintDiff: boolean = (cache?.preSkipOhModulesLint === undefined && !skipOhModulesLint) ? + false : cache?.preSkipOhModulesLint !== skipOhModulesLint; + const shouldRebuild: boolean | undefined = shouldRebuildForDepDiffers || targetESVersionDiffers || + tsImportSendableDiff || maxFlowDepthDiffers || skipOhModulesLintDiff; if (reuseLanguageServiceForDepChange && hashDiffers && rollupShareObject?.depInfo?.enableIncre) { needReCheckForChangedDepUsers = true; } if (!service || shouldRebuild) { - rebuildProgram(targetESVersionDiffers, tsImportSendableDiff, maxFlowDepthDiffers); + rebuildProgram(targetESVersionDiffers, tsImportSendableDiff, maxFlowDepthDiffers, skipOhModulesLintDiff); service = ts.createLanguageService(servicesHost, ts.createDocumentRegistry()); } else { // Found language service from cache, update root files @@ -427,18 +432,20 @@ function getOrCreateLanguageService(servicesHost: ts.LanguageServiceHost, rootFi pkgJsonFileHash: currentHash, targetESVersion: currentTargetESVersion, maxFlowDepth: currentMaxFlowDepth, - preTsImportSendable: tsImportSendable + preTsImportSendable: tsImportSendable, + preSkipOhModulesLint: skipOhModulesLint }; setRollupCache(rollupShareObject, projectConfig, cacheKey, newCache); return service; } -function rebuildProgram(targetESVersionDiffers: boolean | undefined, tsImportSendableDiff: boolean, maxFlowDepthDiffers: boolean | undefined): void { +function rebuildProgram(targetESVersionDiffers: boolean | undefined, tsImportSendableDiff: boolean, + maxFlowDepthDiffers: boolean | undefined, skipOhModulesLintDiff: boolean): void { if (targetESVersionDiffers) { // If the targetESVersion is changed, we need to delete the build info cahce files deleteBuildInfoCache(compilerOptions.tsBuildInfoFile); targetESVersionChanged = true; - } else if (tsImportSendableDiff || maxFlowDepthDiffers) { + } else if (tsImportSendableDiff || maxFlowDepthDiffers || skipOhModulesLintDiff) { // When tsImportSendable or maxFlowDepth is changed, we need to delete the build info cahce files deleteBuildInfoCache(compilerOptions.tsBuildInfoFile); } @@ -498,11 +505,13 @@ export const checkerResult: CheckerResult = { count: 0 }; export const warnCheckerResult: WarnCheckerResult = { count: 0 }; export let languageService: ts.LanguageService = null; let tsImportSendable: boolean = false; +let skipOhModulesLint: boolean = false; export function serviceChecker(rootFileNames: string[], newLogger: Object = null, resolveModulePaths: string[] = null, compilationTime: CompilationTimeStatistics = null, rollupShareObject?: Object): void { fastBuildLogger = newLogger; let cacheFile: string = null; tsImportSendable = rollupShareObject?.projectConfig.tsImportSendable; + skipOhModulesLint = rollupShareObject?.projectConfig.skipOhModulesLint; if (projectConfig.xtsMode || process.env.watchMode === 'true') { if (projectConfig.hotReload) { rootFileNames.forEach(fileName => { -- Gitee From e41de85028072449994c8f6f6b71631ce91e1e60 Mon Sep 17 00:00:00 2001 From: luxinyu Date: Tue, 6 May 2025 11:44:25 +0800 Subject: [PATCH 028/140] =?UTF-8?q?HdsListItemCard=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=9B=B8=E5=85=B3Config=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luxinyu --- compiler/tsconfig.esm.json | 8 +++++++- compiler/tsconfig.json | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/compiler/tsconfig.esm.json b/compiler/tsconfig.esm.json index 1f706ffa5..0725c43f7 100755 --- a/compiler/tsconfig.esm.json +++ b/compiler/tsconfig.esm.json @@ -285,7 +285,8 @@ "ArcScrollBar", "ArcAlphabetIndexer", "HdsNavigation", - "HdsNavDestination" + "HdsNavDestination", + "HdsListItemCard" ], "extend": { "decorator": ["Extend", "AnimatableExtend"], @@ -560,6 +561,11 @@ "type": "HdsNavDestinationAttribute", "instance": "HdsNavDestinationInstance" }, + { + "name": "HdsListItemCard", + "type": "HdsListItemCardAttribute", + "instance": "HdsListItemCardInstance" + }, { "name": "NavRouter", "type": "NavRouterAttribute", diff --git a/compiler/tsconfig.json b/compiler/tsconfig.json index d2f05ac1e..da8bf0305 100644 --- a/compiler/tsconfig.json +++ b/compiler/tsconfig.json @@ -293,7 +293,8 @@ "ArcScrollBar", "ArcAlphabetIndexer", "HdsNavigation", - "HdsNavDestination" + "HdsNavDestination", + "HdsListItemCard" ], "extend": { "decorator": ["Extend", "AnimatableExtend"], @@ -583,6 +584,11 @@ "type": "HdsNavDestinationAttribute", "instance": "HdsNavDestinationInstance" }, + { + "name": "HdsListItemCard", + "type": "HdsListItemCardAttribute", + "instance": "HdsListItemCardInstance" + }, { "name": "NavRouter", "type": "NavRouterAttribute", -- Gitee From 7d457f71540b560b74968ae7796c55b7d1f75e43 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 6 May 2025 17:13:42 +0800 Subject: [PATCH 029/140] =?UTF-8?q?insightintent=E8=A3=85=E9=A5=B0?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../ets_ui/rollup-plugin-ets-typescript.ts | 9 +- compiler/src/pre_define.ts | 3 +- compiler/src/process_ui_syntax.ts | 11 +- .../src/userIntents_parser/intentLogger.ts | 15 +- compiler/src/userIntents_parser/intentType.ts | 123 ++++- .../userIntents_parser/parseUserIntents.ts | 503 +++++++++++++++--- .../schema/ControlPlayback_1.0.1.json | 70 +-- 7 files changed, 589 insertions(+), 145 deletions(-) diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index 84aca962f..1d1b8bbc9 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -91,7 +91,6 @@ import { checkHasKeepTs, resetKitImportLog } from '../../process_kit_import'; -import parseUserIntents from '../../userIntents_parser/parseUserIntents'; import { resetProcessComponentMember } from '../../process_component_member'; import { collectReservedNameForObf, @@ -110,6 +109,7 @@ import { MemoryDefine } from '../meomry_monitor/memory_define'; import { ModuleSourceFile } from '../ark_compiler/module/module_source_file'; import { ARKUI_SUBSYSTEM_CODE } from '../../../lib/hvigor_error_code/hvigor_error_info'; import { ProjectCollections } from 'arkguard'; +import parseIntent from '../../userIntents_parser/parseUserIntents'; const filter: any = createFilter(/(? 0) { + parseIntent.verifyInheritanceChain(); + parseIntent.writeUserIntentJsonFile(); + } // Copy the cache files in the compileArkTS directory to the loader_out directory if (projectConfig.compileHar && !projectConfig.byteCodeHar) { for (let moduleInfoId of allModuleIds.keys()) { @@ -276,7 +279,7 @@ export function etsTransform() { resetUtils(); resetValidateUiSyntax(); resetObfuscation(); - parseUserIntents.clear(); + parseIntent.clear(); } }; } diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 2aa9f0c8d..e5044eacf 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -92,7 +92,8 @@ export const COMPONENT_STYLES_DECORATOR: string = '@Styles'; export const COMPONENT_ANIMATABLE_EXTEND_DECORATOR: string = '@AnimatableExtend'; export const COMPONENT_CONCURRENT_DECORATOR: string = '@Concurrent'; export const COMPONENT_SENDABLE_DECORATOR: string = '@Sendable'; -export const COMPONENT_USER_INTENTS_DECORATOR: string = '@InsightIntentLinkDecorator'; +export const COMPONENT_USER_INTENTS_DECORATOR: string = '@InsightIntentLink'; +export const COMPONENT_USER_INTENTS_DECORATOR_ENTRY: string = '@InsightIntentEntry'; export const CHECK_COMPONENT_EXTEND_DECORATOR: string = 'Extend'; export const STRUCT_CONTEXT_METHOD_DECORATORS: Set = new Set([COMPONENT_BUILDER_DECORATOR, COMPONENT_STYLES_DECORATOR, COMPONENT_LOCAL_BUILDER_DECORATOR]); diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 50cdac53a..ff8739c14 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -80,8 +80,7 @@ import { PAGE_FULL_PATH, LENGTH, PUV2_VIEW_BASE, - CONTEXT_STACK, - COMPONENT_USER_INTENTS_DECORATOR + CONTEXT_STACK } from './pre_define'; import { componentInfo, @@ -170,11 +169,11 @@ import { routerModuleType, routerBundleOrModule } from './process_module_package'; -import parseUserIntents from './userIntents_parser/parseUserIntents'; export let transformLog: IFileLog = new createAstNodeUtils.FileLog(); export let contextGlobal: ts.TransformationContext; export let resourceFileName: string = ''; export const builderTypeParameter: { params: string[] } = { params: [] }; +import parseIntent from './userIntents_parser/parseUserIntents'; export function processUISyntax(program: ts.Program, ut = false, compilationTime: CompilationTimeStatistics = null, filePath: string = '', metaInfo: Object = {}): Function { @@ -404,11 +403,7 @@ export function processUISyntax(program: ts.Program, ut = false, }); } } else if (ts.isClassDeclaration(node)) { - if (hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR)) { - const checker: TypeChecker = metaInfo.tsProgram.getTypeChecker(); - parseUserIntents.handleIntent(node, checker, filePath, metaInfo); - node = parseUserIntents.removeDecorator(node); - } + node = parseIntent.detectInsightIntent(node, metaInfo, filePath); if (hasDecorator(node, COMPONENT_SENDABLE_DECORATOR)) { if (projectConfig.compileHar && !projectConfig.useTsHar) { let warnMessage: string = 'If you use @Sendable in js har, an exception will occur during runtime.\n' + diff --git a/compiler/src/userIntents_parser/intentLogger.ts b/compiler/src/userIntents_parser/intentLogger.ts index 27a8f06c2..ceed5a34a 100644 --- a/compiler/src/userIntents_parser/intentLogger.ts +++ b/compiler/src/userIntents_parser/intentLogger.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import {getLogger} from 'log4js'; +import { getLogger } from 'log4js'; type ErrorCode = string; type ErrorDescription = string; @@ -80,7 +80,7 @@ export class IntentLogger { } printErrorAndExit(error: LogData | string): never { - const message = typeof error === 'string' ? error : error.toString(); + const message: string = typeof error === 'string' ? error : error.toString(); throw new Error(message); } } @@ -89,7 +89,16 @@ export const ENTRYPATH_ERROR: LogData = LogDataFactory.newInstance('1001', '[Ins export const DECORATOR_STATEMENT_ERROR: LogData = LogDataFactory.newInstance('1002', '[InsightIntent] decorator is not CallExpression'); export const DYNAMIC_PARAM_ERROR: LogData = LogDataFactory.newInstance('1003', '[InsightIntent] Dynamic variable cannot be resolved'); export const DISALLOWED_PARAM_ERROR: LogData = LogDataFactory.newInstance('1004', '[InsightIntent] param is disallowed'); -export const UNSUPPORTED_PARSE_ERROR: LogData = LogDataFactory.newInstance('1005', '[InsightIntent] unsupported parameter type cannot be parsing'); +export const UNSUPPORTED_PARSE_ERROR: LogData = LogDataFactory.newInstance('1005', '[InsightIntent] unsupported parameter type cannot be parsed'); export const INCORRECT_PARAM_TYPE_ERROR: LogData = LogDataFactory.newInstance('1006', '[InsightIntent] param parsing occurs error param type'); export const REQUIRED_PARAM_DISMISS_ERROR: LogData = LogDataFactory.newInstance('1007', '[InsightIntent] decorator args missing required param'); export const INTERNAL_ERROR: LogData = LogDataFactory.newInstance('1008', '[InsightIntent] internal error'); +export const SCHEMA_VALIDATE_ONE_OF_ERROR: LogData = LogDataFactory.newInstance('1009', '[InsightIntent] Not meeting the one of schema verification rules'); +export const SCHEMA_VALIDATE_ANY_OF_ERROR: LogData = LogDataFactory.newInstance('1010', '[InsightIntent] Not meeting the any of schema verification rules'); +export const SCHEMA_VALIDATE_TYPE_ERROR: LogData = LogDataFactory.newInstance('1011', '[InsightIntent] schema verification parameter type error'); +export const SCHEMA_VALIDATE_REQUIRED_ERROR: LogData = LogDataFactory.newInstance('1012', '[InsightIntent] schema verification parameter does not exist'); +export const SCHEMA_ROOT_TYPE_MISMATCH_ERROR: LogData = LogDataFactory.newInstance('1013', '[InsightIntent] Schema root type must be \'object\''); +export const INVALID_BASE_CLASS_ERROR: LogData = LogDataFactory.newInstance('1014', + '[InsightIntent] decorated with @InsightIntentEntry has an invalid inheritance hierarchy.'); +export const PARAM_CIRCULAR_REFERENCE_ERROR: LogData = LogDataFactory.newInstance('1015', + '[InsightIntent] Circular reference detected in param'); diff --git a/compiler/src/userIntents_parser/intentType.ts b/compiler/src/userIntents_parser/intentType.ts index 1f8e3a4a3..6833fd614 100644 --- a/compiler/src/userIntents_parser/intentType.ts +++ b/compiler/src/userIntents_parser/intentType.ts @@ -14,7 +14,7 @@ */ import ts from 'typescript'; -import parseUserIntents from './parseUserIntents'; +import parseIntent from './parseUserIntents'; import Ajv from 'ajv'; const ajv = new Ajv({allErrors: true}); @@ -40,7 +40,16 @@ interface LinkIntentParamMapping { export interface IntentLinkInfo extends IntentInfo { uri: string; - paramMapping: LinkIntentParamMapping[] + paramMappings: LinkIntentParamMapping[] +} + +export interface IntentEntryInfo extends IntentInfo { + abilityName: string; + executeMode: number[]; +} + +export interface IntentEntryParam { + description: string; } export class ParamChecker { @@ -109,10 +118,10 @@ IntentLinkParamsChecker.paramValidators = { } }; export const IntentLinkInfoChecker: ParamChecker = new ParamChecker(); -IntentLinkInfoChecker.requiredFields = ['intentName', 'domain', 'intentVersion', 'displayName', 'llmDescription', 'uri']; +IntentLinkInfoChecker.requiredFields = ['intentName', 'domain', 'intentVersion', 'displayName', 'uri']; IntentLinkInfoChecker.allowFields = new Set([ 'intentName', 'domain', 'intentVersion', 'displayName', 'displayDescription', 'schema', 'icon', 'keywords', 'llmDescription', 'uri', - 'parameters', 'paramMapping' + 'parameters', 'paramMappings' ]); IntentLinkInfoChecker.paramValidators = { @@ -120,8 +129,8 @@ IntentLinkInfoChecker.paramValidators = { try { let initializer: object = {}; if (ts.isIdentifier(v)) { - const symbol = parseUserIntents.checker.getSymbolAtLocation(v); - const declaration = symbol?.valueDeclaration; + const symbol: ts.Symbol | undefined = parseIntent.checker.getSymbolAtLocation(v); + const declaration: ts.Declaration = symbol?.valueDeclaration; initializer = declaration.initializer; } else { initializer = v; @@ -136,7 +145,7 @@ IntentLinkInfoChecker.paramValidators = { return false; } }, - paramMapping(v: ts.Expression): boolean { + paramMappings(v: ts.Expression): boolean { return v !== null && v !== undefined && ts.isArrayLiteralExpression(v); }, @@ -144,8 +153,8 @@ IntentLinkInfoChecker.paramValidators = { if (ts.isArrayLiteralExpression(v)) { return v.elements.every(ele => { if (ts.isIdentifier(ele)) { - const symbol = parseUserIntents.checker.getSymbolAtLocation(ele); - const declaration = symbol?.valueDeclaration; + const symbol: ts.Symbol | undefined = parseIntent.checker.getSymbolAtLocation(ele); + const declaration: ts.Declaration = symbol?.valueDeclaration; return ts.isStringLiteral(declaration.initializer) || ts.isNoSubstitutionTemplateLiteral(declaration.initializer); } else { return ts.isStringLiteral(ele) || ts.isNoSubstitutionTemplateLiteral(ele); @@ -183,10 +192,100 @@ IntentLinkInfoChecker.paramValidators = { v !== undefined && v.expression.getText() === '$r', llmDescription: (v: ts.Expression): boolean => v !== null && v !== undefined && - ts.isStringLiteral(v) && - v.text.trim() !== '', + ts.isStringLiteral(v), uri: (v: ts.Expression): boolean => v !== null && v !== undefined && ts.isStringLiteral(v) }; -IntentLinkInfoChecker.nestedCheckers = new Map([['paramsMapping', IntentLinkParamsChecker]]); +IntentLinkInfoChecker.nestedCheckers = new Map([['paramMappings', IntentLinkParamsChecker]]); + +export const intentEntryInfoChecker: ParamChecker = new ParamChecker(); +intentEntryInfoChecker.requiredFields = ['abilityName', 'intentName', 'domain', 'intentVersion', 'displayName']; +intentEntryInfoChecker.allowFields = new Set([ + 'intentName', 'domain', 'intentVersion', 'displayName', 'displayDescription', 'schema', 'llmDescription', 'icon', 'abilityName', + 'executeMode', 'keywords' +]); + +intentEntryInfoChecker.paramValidators = { + parameters(v: ts.Expression): boolean { + try { + let initializer: object = {}; + if (ts.isIdentifier(v)) { + const symbol: ts.Symbol | undefined = parseIntent.checker.getSymbolAtLocation(v); + const declaration: ts.Declaration = symbol?.valueDeclaration; + initializer = declaration.initializer; + } else { + initializer = v; + } + if (ts.isObjectLiteralExpression(initializer)) { + ajv.compile(JSON.parse(initializer.getText())); + return true; + } else { + return false; + } + } catch (e) { + return false; + } + }, + icon: (v: ts.Expression): boolean => ts.isCallExpression(v) && v !== null && + v !== undefined && v.expression.getText() === '$r', + keywords(v: ts.Expression): boolean { + if (ts.isArrayLiteralExpression(v)) { + return v.elements.every(ele => { + if (ts.isIdentifier(ele)) { + const symbol: ts.Symbol | undefined = parseIntent.checker.getSymbolAtLocation(ele); + const declaration: ts.Declaration = symbol?.valueDeclaration; + return ts.isStringLiteral(declaration.initializer) || ts.isNoSubstitutionTemplateLiteral(declaration.initializer); + } else { + return ts.isStringLiteral(ele) || ts.isNoSubstitutionTemplateLiteral(ele); + } + }); + } else { + return false; + } + }, + schema: (v: ts.Expression): boolean => v !== null && + v !== undefined && + ts.isStringLiteral(v) && + v.text.trim() !== '', + abilityName(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; + }, + displayDescription(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; + }, + displayName(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; + }, + domain(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; + }, + executeMode(v: ts.Expression): boolean { + return ts.isArrayLiteralExpression(v) && + v.elements.every(e => + ts.isNumericLiteral(e) && + [0, 1, 2, 3].includes(Number(e.text)) + ); + }, + intentName(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; + }, + intentVersion(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; + }, + llmDescription(v: ts.Expression): boolean { + return v !== null && v !== undefined && ts.isStringLiteral(v); + } +}; + +export const intentEntryParamChecker: ParamChecker = new ParamChecker(); +intentEntryParamChecker.requiredFields = ['description']; +intentEntryParamChecker.allowFields = new Set([ + 'description' +]); +intentEntryParamChecker.paramValidators = { + description: (v: ts.Expression): boolean => v !== null && + v !== undefined && + ts.isStringLiteral(v) && + v.text.trim() !== '' +}; diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index d840b8749..fc74c25df 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -13,24 +13,33 @@ * limitations under the License. */ -import ts, { CatchClause, Declaration, Expression, VariableDeclarationList } from 'typescript'; -import { ParamChecker, IntentLinkInfoChecker } from './intentType'; -import { COMPONENT_USER_INTENTS_DECORATOR } from '../pre_define'; +import ts, { CatchClause, Declaration, Expression, TypeChecker, VariableDeclarationList } from 'typescript'; +import { intentEntryInfoChecker, IntentLinkInfoChecker, ParamChecker } from './intentType'; import { - ENTRYPATH_ERROR, - IntentLogger, DECORATOR_STATEMENT_ERROR, DISALLOWED_PARAM_ERROR, DYNAMIC_PARAM_ERROR, - REQUIRED_PARAM_DISMISS_ERROR, + ENTRYPATH_ERROR, INCORRECT_PARAM_TYPE_ERROR, - UNSUPPORTED_PARSE_ERROR + IntentLogger, + INTERNAL_ERROR, + REQUIRED_PARAM_DISMISS_ERROR, + SCHEMA_VALIDATE_REQUIRED_ERROR, + UNSUPPORTED_PARSE_ERROR, + SCHEMA_VALIDATE_TYPE_ERROR, + SCHEMA_VALIDATE_ANY_OF_ERROR, + SCHEMA_VALIDATE_ONE_OF_ERROR, + SCHEMA_ROOT_TYPE_MISMATCH_ERROR, + INVALID_BASE_CLASS_ERROR, + PARAM_CIRCULAR_REFERENCE_ERROR } from './intentLogger'; import path from 'path'; import { getNormalizedOhmUrlByFilepath } from '../ark_utils'; -import { projectConfig } from '../../main'; -import { ProjectCollections } from 'arkguard'; +import { projectConfig, globalModulePaths } from '../../main'; import fs from 'fs'; +import { ProjectCollections } from 'arkguard'; +import { COMPONENT_USER_INTENTS_DECORATOR, COMPONENT_USER_INTENTS_DECORATOR_ENTRY } from '../pre_define'; +import { hasDecorator } from '../utils'; type StaticValue = string | number | boolean | null | undefined | StaticValue[] | { [key: string]: StaticValue }; @@ -38,48 +47,260 @@ class ParseIntent { constructor() { this.intentData = []; this.currentFilePath = ''; + this.heritageClassSet = new Set(); + this.heritageClassSet.add('IntentEntity_sdk'); } checker: ts.TypeChecker; intentData: any[]; currentFilePath: string; + heritageClassSet: Set; + + detectInsightIntent(node: ts.ClassDeclaration, metaInfo: object, filePath: string): ts.Node { + if (hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR) || hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR_ENTRY + )) { + const checker: TypeChecker = metaInfo.tsProgram.getTypeChecker(); + this.handleIntent(node, checker, filePath, metaInfo); + node = this.removeDecorator(node, [COMPONENT_USER_INTENTS_DECORATOR, COMPONENT_USER_INTENTS_DECORATOR_ENTRY]); + return node; + } + return node; + } handleIntent(node: ts.ClassDeclaration, checker: ts.TypeChecker, filepath: string, metaInfo: Object = {}): void { this.checker = checker; this.currentFilePath = filepath; if (!filepath.endsWith('.ets')) { - throw Error(`${ENTRYPATH_ERROR.toString()}, invalidDecoratorPath:${this.currentFilePath}`); + throw Error(`${ENTRYPATH_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); } const pkgParams: object = { pkgName: metaInfo.pkgName, pkgPath: metaInfo.pkgPath }; - const Logger: IntentLogger = IntentLogger.getInstance(); - const recordName: string = getNormalizedOhmUrlByFilepath(filepath, projectConfig, Logger, pkgParams, null); node.modifiers.forEach(decorator => { - const originalDecortor: string = decorator.getText().replace(/\(.*\)$/, '').trim(); - if (originalDecortor === '@InsightIntentLinkDecorator') { - const expr: ts.Expression = decorator.expression; - if (ts.isCallExpression(expr)) { - const args: ts.NodeArray = expr.arguments; - const intentObj: object = { - 'decoratorFile': `@normalized:${recordName}`, - 'decoratorType': 'InsightIntentLinkDecorator', - 'decoratorClass': node.name.text - }; - this.analyzeDecoratorArgs(args, intentObj, IntentLinkInfoChecker); - this.createObfuscation(node); - } else { - throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath:${this.currentFilePath}`); - } + const expr: ts.Expression = decorator.expression; + if (!expr || !ts.isCallExpression(expr)) { + return; + } + const symbol: ts.Symbol = checker.getTypeAtLocation(decorator.expression.expression)?.getSymbol(); + const declarations: ts.Declaration[] | undefined = symbol?.getDeclarations(); + if (!declarations || declarations.length === 0) { + return; + } + const decoratorSourceFile: string = declarations[0].getSourceFile().fileName; + const isGlobalPath: boolean = globalModulePaths?.some(path => decoratorSourceFile.startsWith(path)); + if (!isGlobalPath) { + return; + } + const Logger: IntentLogger = IntentLogger.getInstance(); + const recordName: string = getNormalizedOhmUrlByFilepath(filepath, projectConfig, Logger, pkgParams, null); + const intentObj: object = { + 'decoratorFile': `@normalized:${recordName}`, + 'decoratorClass': node.name.text + }; + const originalDecorator: string = decorator.getText().replace(/\(.*\)$/, '').trim(); + if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR) { + this.handleLinkDecorator(intentObj, node, decorator); + } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_ENTRY) { + this.handleEntryDecorator(intentObj, node, decorator, pkgParams); + } + }); + } + + handleLinkDecorator(intentObj: object, node: ts.Node, decorator: ts.Decorator): void { + const expr: ts.Expression = decorator.expression; + if (ts.isCallExpression(expr)) { + const args: ts.NodeArray = expr.arguments; + this.analyzeDecoratorArgs(args, intentObj, IntentLinkInfoChecker); + Object.assign(intentObj, { + 'bundleName': projectConfig.bundleName, + 'moduleName': projectConfig.moduleName, + 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR + }); + this.createObfuscation(node); + this.intentData.push(intentObj); + } else { + throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + } + + handleEntryDecorator(intentObj: object, node: ts.Node, decorator: ts.Decorator, pkgParams: object): void { + const expr: ts.Expression = decorator.expression; + if (ts.isCallExpression(expr)) { + const args: ts.NodeArray = expr.arguments; + Object.assign(intentObj, { + 'bundleName': projectConfig.bundleName, + 'moduleName': projectConfig.moduleName, + 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_ENTRY + }); + this.analyzeDecoratorArgs(args, intentObj, intentEntryInfoChecker); + const properties: Record = this.parseClassNode(node); + this.schemaValidateSync(properties, intentObj); + this.analyzeBaseClass(node, pkgParams, intentObj); + this.createObfuscation(node); + this.intentData.push(intentObj); + } else { + throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + } + + analyzeBaseClass(node: ts.ClassDeclaration, pkgParams: object, intentObj: object): void { + const interfaces: ts.ExpressionWithTypeArguments[] = []; + node.heritageClauses?.forEach(clause => { + if (clause.token === ts.SyntaxKind.ImplementsKeyword || clause.token === ts.SyntaxKind.ExtendsKeyword) { + interfaces.push(...clause.types); + } + }); + if (interfaces.length > 0) { + const parentNode: ts.ExpressionWithTypeArguments = interfaces[0]; + if (parentNode) { + this.analyzeClassHeritage(parentNode, node, pkgParams, intentObj); } + } + } + + analyzeClassHeritage( + parentNode: ts.ExpressionWithTypeArguments, node: ts.ClassDeclaration, pkgParams: object, intentObj: object + ): void { + const parentSymbol: ts.Symbol = this.checker.getTypeAtLocation(parentNode).getSymbol(); + const parentClassName: string = parentSymbol.getName(); + const parentFilePath: string = parentSymbol.getDeclarations()?.[0].getSourceFile().fileName; + const logger: IntentLogger = IntentLogger.getInstance(); + const parentRecordName: string = getNormalizedOhmUrlByFilepath(parentFilePath, projectConfig, logger, pkgParams, null); + const baseClassName: string = this.checker.getTypeAtLocation(node).getSymbol().getName(); + const baseFilePath: string = node.getSourceFile().fileName; + const baseRecordName: string = getNormalizedOhmUrlByFilepath(baseFilePath, projectConfig, logger, pkgParams, null); + const isGlobalPath: boolean = globalModulePaths?.some(path => parentFilePath.startsWith(path)); + const recordPath: string = isGlobalPath ? `sdk` : `@normalized:${parentRecordName}`; + if (isGlobalPath) { + if (parentClassName !== 'IntentEntity') { + throw Error(`${INVALID_BASE_CLASS_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + } + this.heritageClassSet.add(baseClassName + '_' + `@normalized:${baseRecordName}`); + this.collectClassInheritanceInfo(parentNode, intentObj, parentClassName, recordPath); + } + + collectClassInheritanceInfo( + parentNode: ts.ExpressionWithTypeArguments, intentObj: object, parentClassName: string, recordPath: string + ): void { + const ClassInheritanceInfo: object = { + 'parentClassName': parentClassName, + 'definitionFilePath': recordPath, + 'generics': [] + }; + if (parentNode.typeArguments?.length > 0) { + parentNode.typeArguments.forEach((arg): void => { + this.getInheritanceInfoByTypeNode(arg, ClassInheritanceInfo); + }); + } + Object.assign(intentObj, { + 'ClassInheritanceInfo': ClassInheritanceInfo }); } - removeDecorator(node: ts.ClassDeclaration): ts.ClassDeclaration { - const filteredModifiers: boolean = node.modifiers.filter(decorator => { + getInheritanceInfoByTypeNode(arg: ts.TypeNode, ClassInheritanceInfo: object): void { + const generic = {}; + const genericType: ts.Type = this.checker.getTypeAtLocation(arg); + let genericName: string; + let genericSource: string | undefined; + const genericSymbol: ts.Symbol | undefined = genericType.getSymbol(); + if (genericSymbol) { + genericName = genericSymbol.getName(); + genericSource = genericSymbol.declarations?.[0]?.getSourceFile().fileName; + } else { + genericName = this.checker.typeToString(genericType); + const parentTypeNode: ts.Node = arg.parent; + if (ts.isTypeReferenceNode(parentTypeNode)) { + const contextualType: ts.Type = this.checker.getContextualType(parentTypeNode); + const symbol: ts.Type = contextualType?.getSymbol(); + genericSource = symbol?.declarations?.[0]?.getSourceFile().fileName; + } + if (!genericSource && this.isPrimitiveType(genericType)) { + genericSource = 'lib.es5.d.ts'; + } + } + Object.assign(generic, + { + 'typeName': genericName, + 'definitionFilePath': genericSource + }); + ClassInheritanceInfo.generics.push(generic); + } + + isPrimitiveType(type: ts.Type): boolean { + return ( + (type.flags & ts.TypeFlags.StringLike) || + (type.flags & ts.TypeFlags.NumberLike) || + (type.flags & ts.TypeFlags.BooleanLike) + ) !== 0; + } + + parseClassNode(node: ts.ClassDeclaration): Record { + const type: ts.Type = this.checker.getTypeAtLocation(node); + const mergedObject: Record = {}; + this.checker.getPropertiesOfType(type) + .filter(prop => { + const declarations: Declaration[] | undefined = prop.getDeclarations(); + return declarations?.some(decl => + ts.isPropertyDeclaration(decl) + ); + }).forEach(prop => { + const objItem: Record = this.processProperty(prop); + Object.assign(mergedObject, objItem); + }); + return mergedObject; + } + + processProperty(prop: ts.Symbol): Record { + const propType: ts.Type = this.checker.getTypeOfSymbol(prop); + const {category} = this.getTypeCategory(propType); + const obj: Record = {}; + const propName: string = prop.getName(); + if (category === 'object') { + obj[propName] = 'object'; + } else if (category === 'array') { + obj[propName] = 'array'; + } else { + obj[propName] = this.checker.typeToString(propType); + } + return obj; + } + + getTypeCategory(type: ts.Type): { category: 'array' | 'object'; } { + const flags: ts.TypeFlags = type.getFlags(); + + const isPrimitive: boolean = !!(flags & ts.TypeFlags.StringLike) || + !!(flags & ts.TypeFlags.NumberLike) || + !!(flags & ts.TypeFlags.BooleanLike) || + !!(flags & ts.TypeFlags.Null) || + !!(flags & ts.TypeFlags.Undefined); + + let isArray: boolean; + const symbol: ts.Symbol | undefined = type.getSymbol(); + if (symbol) { + isArray = symbol.getName() === 'Array'; + } else { + isArray = !!(flags & ts.TypeFlags.Object) && + !!(type as ts.ObjectType).objectFlags && ts.ObjectFlags.Reference && + ((type as ts.TypeReference).target.getSymbol()?.getName() === 'Array'); + } + const isObject: boolean = !isPrimitive && + !isArray && + !!(flags & ts.TypeFlags.Object); + let category: 'array' | 'object'; + if (isArray) { + category = 'array'; + } else if (isObject) { + category = 'object'; + } + return {category}; + } + + removeDecorator(node: ts.ClassDeclaration, decoratorNames: string[]): ts.ClassDeclaration { + const filteredModifiers: ts.ClassDeclaration = node.modifiers.filter(decorator => { const originalDecortor: string = decorator.getText().replace(/\(.*\)$/, '').trim(); - return originalDecortor !== COMPONENT_USER_INTENTS_DECORATOR; + return !decoratorNames.includes(originalDecortor); }); return ts.factory.updateClassDeclaration( node, @@ -108,7 +329,7 @@ class ParseIntent { } const varList: VariableDeclarationList | CatchClause = node.parent; - return ts.isVariableDeclarationList(varList) && + return !!varList && ts.isVariableDeclarationList(varList) && (varList.flags & ts.NodeFlags.Const) !== 0; } @@ -144,7 +365,7 @@ class ParseIntent { }); } if (!flag) { - throw Error(`${DYNAMIC_PARAM_ERROR}, invalidDecoratorPath:${this.currentFilePath}`); + throw Error(`${DYNAMIC_PARAM_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); } return flag; } @@ -162,12 +383,12 @@ class ParseIntent { this.validateFields(prop, allowedFields, paramValidators); existingParams.add(prop.name.text); if (nestedCheckers && nestedCheckers.has(prop.name.text)) { - this.validateSelfParamFields(node, nestedCheckers); + this.validateSelfParamFields(prop, nestedCheckers); } } const missingFields: (keyof T)[] = requiredFields.filter(f => !existingParams.has(f)); if (missingFields.length > 0) { - throw Error(`${REQUIRED_PARAM_DISMISS_ERROR.toString()}, cause: params: ${missingFields.join(', ')}, invalidDecoratorPath:${this.currentFilePath}`); + throw Error(`${REQUIRED_PARAM_DISMISS_ERROR.toString()}, cause params: ${missingFields.join(', ')}, invalidDecoratorPath: ${this.currentFilePath}`); } } @@ -198,18 +419,18 @@ class ParseIntent { const paramName: keyof T = prop.name.text; if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) { if (!allowedFields.has(paramName)) { - throw Error(`${DISALLOWED_PARAM_ERROR}, cause: undeclared param: '${paramName.toString()}', invalidDecoratorPath:${this.currentFilePath}`); + throw Error(`${DISALLOWED_PARAM_ERROR}, cause undeclared param: '${paramName.toString()}', invalidDecoratorPath: ${this.currentFilePath}`); } const validator: Function = paramValidators[paramName]; if (ts.isIdentifier(prop.initializer)) { const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(prop.initializer); const declaration: ts.Declaration = symbol?.valueDeclaration; if (validator && !validator(declaration.initializer)) { - throw Error(`${INCORRECT_PARAM_TYPE_ERROR.toString()}, cause: param: '${paramName.toString()}', invalidDecoratorPath:${this.currentFilePath}`); + throw Error(`${INCORRECT_PARAM_TYPE_ERROR.toString()}, cause param: '${paramName.toString()}', invalidDecoratorPath: ${this.currentFilePath}`); } } else { if (validator && !validator(prop.initializer)) { - throw Error(`${INCORRECT_PARAM_TYPE_ERROR.toString()}, cause: param: '${paramName.toString()}', invalidDecoratorPath:${this.currentFilePath}`); + throw Error(`${INCORRECT_PARAM_TYPE_ERROR.toString()}, cause param: '${paramName.toString()}', invalidDecoratorPath: ${this.currentFilePath}`); } } } @@ -227,27 +448,29 @@ class ParseIntent { const res: StaticValue = this.parseStaticObject(arg); Object.assign(intentObj, res); this.collectSchemaInfo(intentObj); - this.intentData.push(intentObj); }); } - collectSchemaInfo(intentObj: object): void { - if (intentObj.schema) { - const schemaPath = path.join( - __dirname + '\\schema', - `${intentObj.schema}_${intentObj.intentVersion}.json` - ); - if (fs.existsSync(schemaPath)) { - if (intentObj.parameters) { - throw Error(`${DISALLOWED_PARAM_ERROR.toString()}, the standard user intents does not allow passing the parameter 'parameter', invalidDecoratorPath:${this.currentFilePath}`); - } - const schemaContent = fs.readFileSync(schemaPath, 'utf-8'); - intentObj.parameters = JSON.parse(schemaContent); - } + createObfuscation(classNode: ts.Node): void { + ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.globalNames.add(classNode.symbol.name); + const isExported: boolean = classNode.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword); + if (isExported) { + ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.propertyNames.add(classNode.symbol.name); } + classNode.members.forEach(member => { + if (ts.isPropertyDeclaration(member) && member.name || ts.isFunctionDeclaration(member) || ts.isMethodDeclaration(member) || + ts.isGetAccessor(member) || ts.isSetAccessor(member)) { + const propName: string = member.name.getText(); + ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.propertyNames.add(propName); + } + }); } - parseStaticObject(node: ts.Node): StaticValue | undefined { + parseStaticObject(node: ts.Node, visited: Set = new Set()): StaticValue | undefined { + if (visited.has(node)) { + throw Error(`${PARAM_CIRCULAR_REFERENCE_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + visited.add(node); if (ts.isStringLiteral(node)) { return node.text; } @@ -272,7 +495,7 @@ class ParseIntent { if (isStatic) { const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(node); const declaration: ts.Declaration = symbol?.valueDeclaration; - return this.parseStaticObject(declaration.initializer); + return this.parseStaticObject(declaration.initializer, visited); } } @@ -291,25 +514,10 @@ class ParseIntent { } return node.getText(); } - throw Error(`${UNSUPPORTED_PARSE_ERROR.toString()}, param: '${node.text}', invalidDecoratorPath:${this.currentFilePath}`); - } - createObfuscation(classNode: ts.Node): void { - ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.globalNames.add(classNode.symbol.name); - classNode.members.forEach(member => { - if (ts.isPropertyDeclaration(member) && member.name) { - const propName = member.name.getText(); - ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.globalNames.add(propName); - } - if (ts.isFunctionDeclaration(member) || ts.isMethodDeclaration(member) || - ts.isGetAccessor(member) || ts.isSetAccessor(member)) { - const methodName = member.name.getText(); - ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.propertyNames.add(methodName); - } - }); + throw Error(`${UNSUPPORTED_PARSE_ERROR.toString()}, cause param: '${node.text}', invalidDecoratorPath: ${this.currentFilePath}`); } - processObjectElements(elements: ts.ObjectLiteralExpression): { [key: string]: StaticValue } { const obj: { [key: string]: StaticValue } = {}; for (const prop of elements.properties) { @@ -357,36 +565,159 @@ class ParseIntent { if (ts.isIdentifier(node)) { return node.text; } - return undefined; } - writeUserIntentJsonFile(): void { - if (this.intentData.length > 0) { - if (!projectConfig.aceModuleJsonPath) { - return; + collectSchemaInfo(intentObj: object): void { + if (intentObj.schema) { + const schemaPath: string = path.join( + __dirname, 'schema', + `${intentObj.schema}_${intentObj.intentVersion}.json` + ); + if (fs.existsSync(schemaPath)) { + if (intentObj.parameters) { + throw Error(`${DISALLOWED_PARAM_ERROR.toString()}` + + `, the standard user intents does not allow passing the parameter 'parameter', invalidDecoratorPath: ${this.currentFilePath}`); + } + if (intentObj.keywords) { + throw Error(`${DISALLOWED_PARAM_ERROR.toString()}` + + `, the standard user intents does not allow passing the parameter 'keywords', invalidDecoratorPath: ${this.currentFilePath}`); + } + if (intentObj.llmDescription) { + throw Error(`${DISALLOWED_PARAM_ERROR.toString()}` + + `, the standard user intents does not allow passing the parameter 'llmDescription', invalidDecoratorPath: ${this.currentFilePath}`); + } + const schemaContent: string = fs.readFileSync(schemaPath, 'utf-8'); + const schemaObj: object = JSON.parse(schemaContent); + intentObj.parameters = schemaObj.params; + if (schemaObj.llmDescription) { + intentObj.llmDescription = schemaObj.llmDescription; + } + if (schemaObj.keywords) { + intentObj.keywords = schemaObj.keywords; + } } - const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'user_intents_library.json'); - if (!fs.existsSync(projectConfig.aceProfilePath)) { - fs.mkdirSync(projectConfig.aceProfilePath, {recursive: true}); + } + } + + verifyInheritanceChain(): void { + this.intentData.forEach((element): void => { + if (element.ClassInheritanceInfo) { + const parentClassName: string = element.ClassInheritanceInfo.parentClassName; + const definitionFilePath: string = element.ClassInheritanceInfo.definitionFilePath; + const verifiedString: string = parentClassName + '_' + definitionFilePath; + if (!this.heritageClassSet.has(verifiedString)) { + throw Error(`${INVALID_BASE_CLASS_ERROR.toString()} + , Subclass must inherit from a class decorated with @InsightIntentEntry, invalidDecoratorPath: ${this.currentFilePath}\``); + } } - fs.writeFileSync(cacheSourceMapPath, JSON.stringify({'insightIntents': this.intentData}, null, 2), 'utf-8'); - const normalizedPath: string = path.normalize(projectConfig.aceModuleJsonPath); - const fullPath: string = path.join(path.dirname(normalizedPath), 'module.json'); - if (fs.existsSync(fullPath)) { - const rawData: string = fs.readFileSync(fullPath, 'utf8'); - const jsonData: any = JSON.parse(rawData); - jsonData.hasIntent = true; - const updatedJson: string = JSON.stringify(jsonData, null, 2); - fs.writeFileSync(fullPath, updatedJson, 'utf8'); + }); + } + + schemaValidationRequiredRule(schemaData: Record, schemaObj: object): void { + const reqData: Map = new Map(); + schemaObj.required.forEach(key => reqData.set(key, true)); + if (schemaObj.properties) { + const paramsSchema: object = schemaObj.properties; + const keyArr: string[] = Object.keys(paramsSchema); + keyArr.forEach(key => { + if (!schemaData[key] && reqData.get(key)) { + throw Error(`${SCHEMA_VALIDATE_REQUIRED_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + }); + } + } + + schemaPropertiesValidation(schemaData: Record, schemaObj: object): void { + if (schemaObj.properties) { + Object.entries(schemaObj.properties).forEach(([key, value]) => { + if (schemaData[key] && value.type !== schemaData[key]) { + throw Error(`${SCHEMA_VALIDATE_TYPE_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + }); + } + } + + private schemaValidateRules(schemaData: Record, schemaObj: object): void { + const requiredOne: string[][] = schemaObj.oneOf.map(item => item.required); + const schemaKeys: string[] = Object.keys(schemaData); + if (schemaObj.oneOf) { + let count: number = 0; + requiredOne.forEach(val => { + const isContain: boolean = val.every((item): boolean => { + return schemaKeys.includes(item); + }); + if (isContain) { + count++; + } + }); + if (count !== 1) { + throw Error(`${SCHEMA_VALIDATE_ONE_OF_ERROR.toString()} , invalidDecoratorPath: ${this.currentFilePath}`); + } + } + if (schemaObj.anyOf) { + let count: number = 0; + const requiredAny: string[][] = schemaObj.anyOf.map(item => item.required); + requiredAny.forEach(val => { + const isContain: boolean = val.every((item): boolean => { + return schemaKeys.includes(item); + }); + if (isContain) { + count++; + } + }); + if (count === 0) { + throw Error(`${SCHEMA_VALIDATE_ANY_OF_ERROR.toString()} , invalidDecoratorPath: ${this.currentFilePath}`); + } + } + } + + schemaValidateSync(schemaData: Record, intentObj: object): void { + const schemaObj: object = intentObj.parameters; + if (!schemaObj) { + return; + } + if (schemaObj.type !== 'object') { + throw Error(`${SCHEMA_ROOT_TYPE_MISMATCH_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + if (schemaObj.properties) { + this.schemaPropertiesValidation(schemaData, schemaObj); + } + if (schemaObj.required) { + this.schemaValidationRequiredRule(schemaData, schemaObj); + } + this.schemaValidateRules(schemaData, schemaObj); + } + + writeUserIntentJsonFile(): void { + if (!projectConfig.aceProfilePath) { + throw Error(`${INTERNAL_ERROR.toString()}, aceProfilePath not found, invalidDecoratorPath: ${this.currentFilePath}`); + } + const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'extract_insight_intent.json'); + if (!fs.existsSync(projectConfig.aceProfilePath)) { + fs.mkdirSync(projectConfig.aceProfilePath, {recursive: true}); + } + fs.writeFileSync(cacheSourceMapPath, JSON.stringify({'insightIntents': this.intentData}, null, 2), 'utf-8'); + const normalizedPath: string = path.normalize(projectConfig.aceProfilePath); + const fullPath: string = path.join(normalizedPath, '../../../module.json'); + if (fs.existsSync(fullPath)) { + const rawData: string = fs.readFileSync(fullPath, 'utf8'); + const jsonData: any = JSON.parse(rawData); + if (jsonData?.module) { + jsonData.module.hasInsightIntent = true; } + const updatedJson: string = JSON.stringify(jsonData, null, 2); + fs.writeFileSync(fullPath, updatedJson, 'utf8'); } } clear(): void { this.intentData = []; + this.checker = null; this.currentFilePath = ''; IntentLinkInfoChecker.clean(); + intentEntryInfoChecker.clean(); + this.heritageClassSet = new Set(); } } diff --git a/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json b/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json index 578f98861..4619ef885 100644 --- a/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json +++ b/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json @@ -1,39 +1,45 @@ { - "type": "object", - "propertyNames": { - "enum": [ - "playbackSpeed", - "playbackProgress" - ] - }, - "oneOf": [ - { - "required": [ - "playbackSpeed" - ] - }, - { - "required": [ - "playbackProgress" - ] - } - ], - "properties": { - "playbackSpeed": { - "description": "播放倍速", - "type": "number", + "intentName": "ControlPlayback", + "intentVersion": "1.0.1", + "llmDescription": "播放音乐控制", + "keywords": ["ControlPlayback"], + "params": { + "type": "object", + "propertyNames": { "enum": [ - 0.5, - 0.75, - 1.0, - 1.25, - 1.5, - 2.0 + "playbackSpeed", + "playbackProgress" ] }, - "playbackProgress": { - "description": "播放进度,单位秒", - "type": "number" + "oneOf": [ + { + "required": [ + "playbackSpeed" + ] + }, + { + "required": [ + "playbackProgress" + ] + } + ], + "properties": { + "playbackSpeed": { + "description": "播放倍速", + "type": "number", + "enum": [ + 0.5, + 0.75, + 1.0, + 1.25, + 1.5, + 2.0 + ] + }, + "playbackProgress": { + "description": "播放进度,单位秒", + "type": "number" + } } } } -- Gitee From eae2e648c859f51dcbc9d71d9eabf6639e6052d2 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Wed, 7 May 2025 14:59:35 +0800 Subject: [PATCH 030/140] =?UTF-8?q?=E6=84=8F=E5=9B=BE=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E6=8F=92=E4=BB=B6ut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../@InsightIntentEntry.js.sample | 37 ++++ .../@InsightIntentFunction.js.sample | 47 +++++ .../@InsightIntentLink.js.sample | 38 ++++ .../@InsightIntentPage.js.sample | 52 ++++++ .../@InsightIntentEntry.ets | 34 ++++ .../@InsightIntentFunction.ets | 37 ++++ .../@InsightIntentLink/@InsightIntentLink.ets | 38 ++++ .../@InsightIntentPage/@InsightIntentPage.ets | 41 +++++ .../transform_ut/helpers/insightUTPath.ts | 23 +++ compiler/test/transform_ut/ut_insight.test.ts | 162 ++++++++++++++++++ 10 files changed, 509 insertions(+) create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.js.sample create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentFunction/@InsightIntentFunction.js.sample create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentLink/@InsightIntentLink.js.sample create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentPage/@InsightIntentPage.js.sample create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.ets create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentFunction/@InsightIntentFunction.ets create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentLink/@InsightIntentLink.ets create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentPage/@InsightIntentPage.ets create mode 100644 compiler/test/transform_ut/helpers/insightUTPath.ts create mode 100644 compiler/test/transform_ut/ut_insight.test.ts diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.js.sample new file mode 100644 index 000000000..2767d6d83 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.js.sample @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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. + */ + +let __generate__Id = 0; +function generateId() { + return "@InsightIntentEntry_" + ++__generate__Id; +} +import { InsightIntentEntry } from "@ohos.app.ability.InsightIntentDecorator"; +const validDataEntry2 = { + abilityName: "EntryAbility", + intentName: "Heeloeqasd155", + keywords: ['123234345', '12345654321'], + domain: "music", + intentVersion: "100000", + displayName: "Home", + icon: $r('app.media.startIcon'), + llmDescription: '123111321', + schema: "work", +}; +class aaaa { + constructor() { + this.entityId = ""; + } +} +//# sourceMappingURL=@InsightIntentEntry.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentFunction/@InsightIntentFunction.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentFunction/@InsightIntentFunction.js.sample new file mode 100644 index 000000000..864a72689 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentFunction/@InsightIntentFunction.js.sample @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 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. + */ + +let __generate__Id = 0; +function generateId() { + return "@InsightIntentFunction_" + ++__generate__Id; +} +import { InsightIntentFunction, InsightIntentFunctionMethod } from "@ohos.app.ability.InsightIntentDecorator"; +const validDataFunc = { + intentName: 'ViewYourHisAccount', + domain: "game", + intentVersion: '1.0.1', + displayName: '查看我的账户我是个天才', + displayDescription: '查看账户信息,包括余额、消费明细等信息', + schema: "ControlPlayback", +}; +class Index extends View { + constructor(compilerAssignedUniqueChildId, parent, params, localStorage) { + super(compilerAssignedUniqueChildId, parent, localStorage); + this.updateWithValueParams(params); + } + updateWithValueParams(params) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id()); + } + static function(playbackProgress, entityId) { + } + render() { + Row.create(); + Row.pop(); + } +} +loadDocument(new Index("1", undefined, {})); +//# sourceMappingURL=@InsightIntentFunction.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentLink/@InsightIntentLink.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentLink/@InsightIntentLink.js.sample new file mode 100644 index 000000000..1bb5e94df --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentLink/@InsightIntentLink.js.sample @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 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. + */ + +let __generate__Id = 0; +function generateId() { + return "@InsightIntentLink_" + ++__generate__Id; +} +import { InsightIntentLink } from "@ohos.app.ability.InsightIntentDecorator"; +const linkParamMapping = { + paramName: "aaa", + paramMappingName: "ccc", +}; +const validDataLink2 = { + intentName: "Hello202a5", + domain: "qqq", + intentVersion: "1.0.1", + displayName: "Home", + icon: $r('app.media.startIcon'), + displayDescription: 'music', + uri: "/data/app/base", + schema: "ControlPlayback", + paramMappings: [linkParamMapping], +}; +class aaa { +} +//# sourceMappingURL=@InsightIntentLink.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentPage/@InsightIntentPage.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentPage/@InsightIntentPage.js.sample new file mode 100644 index 000000000..42493fd57 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentPage/@InsightIntentPage.js.sample @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 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. + */ + +let __generate__Id = 0; +function generateId() { + return "@InsightIntentPage_" + ++__generate__Id; +} +import { InsightIntentPage } from "@ohos.app.ability.InsightIntentDecorator"; +const validDataPage = { + intentName: 'ViewMyAccount', + domain: "Game", + intentVersion: '1.0.1', + displayName: '查看我的账户', + displayDescription: '查看账户信息,包括余额、消费明细等信息', + schema: "PlayMusicList", + icon: $r('app.media.startIcon'), + llmDescription: '查看账户信息,包括余额、消费明细等信息', + keywords: ['123234345', '12345654321'], + uiAbility: 'Entry', + pagePath: 'ets/pages/Index', + navigationId: 'navId', + navDestinationName: 'PageOne', +}; +class Index extends View { + constructor(compilerAssignedUniqueChildId, parent, params, localStorage) { + super(compilerAssignedUniqueChildId, parent, localStorage); + this.updateWithValueParams(params); + } + updateWithValueParams(params) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id()); + } + render() { + Row.create(); + Row.pop(); + } +} +loadDocument(new Index("1", undefined, {})); +//# sourceMappingURL=@InsightIntentPage.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.ets new file mode 100644 index 000000000..db529c4dc --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 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 { EntryIntentDecoratorInfo,InsightIntentEntry } from "@ohos.app.ability.InsightIntentDecorator"; +import { insightIntent } from "@kit.AbilityKit"; + +const validDataEntry2: EntryIntentDecoratorInfo = { + abilityName : "EntryAbility", + intentName: "Heeloeqasd155", + keywords: ['123234345', '12345654321'], + domain: "music", + intentVersion: "100000", + displayName: "Home", + icon: $r('app.media.startIcon'), + llmDescription: '123111321', + schema: "work", +}; + +@InsightIntentEntry(validDataEntry2) +class aaaa implements insightIntent.IntentEntity{ + entityId: string = ""; +} \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentFunction/@InsightIntentFunction.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentFunction/@InsightIntentFunction.ets new file mode 100644 index 000000000..c9a6029df --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentFunction/@InsightIntentFunction.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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 {FunctionIntentDecoratorInfo,InsightIntentFunction, InsightIntentFunctionMethod} from "@ohos.app.ability.InsightIntentDecorator"; + +const validDataFunc: FunctionIntentDecoratorInfo = { + intentName: 'ViewYourHisAccount', + domain: "game", + intentVersion:'1.0.1', + displayName: '查看我的账户我是个天才', + displayDescription: '查看账户信息,包括余额、消费明细等信息', + schema: "ControlPlayback", +}; +@Entry +@Component +@InsightIntentFunction() +struct Index { + @InsightIntentFunctionMethod(validDataFunc) + static function(playbackProgress:number, entityId?: number){ + } + build() { + Row() { + } + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentLink/@InsightIntentLink.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentLink/@InsightIntentLink.ets new file mode 100644 index 000000000..f6e293a3c --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentLink/@InsightIntentLink.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 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 { InsightIntentLink, + LinkIntentDecoratorInfo, + LinkIntentParamMapping } from "@ohos.app.ability.InsightIntentDecorator"; + +const linkParamMapping : LinkIntentParamMapping = { + paramName : "aaa", + paramMappingName : "ccc", +} +const validDataLink2: LinkIntentDecoratorInfo = { + intentName: "Hello202a5", + domain: "qqq", + intentVersion: "1.0.1", + displayName: "Home", + icon: $r('app.media.startIcon'), + displayDescription: 'music', + uri: "/data/app/base", + schema: "ControlPlayback", + paramMappings : [linkParamMapping], +}; + +@InsightIntentLink(validDataLink2) +class aaa { +} \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentPage/@InsightIntentPage.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentPage/@InsightIntentPage.ets new file mode 100644 index 000000000..4949ba1a6 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentPage/@InsightIntentPage.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { InsightIntentPage, PageIntentDecoratorInfo} from "@ohos.app.ability.InsightIntentDecorator"; + +const validDataPage: PageIntentDecoratorInfo = { + intentName:'ViewMyAccount', + domain: "Game", + intentVersion: '1.0.1', + displayName: '查看我的账户', + displayDescription:'查看账户信息,包括余额、消费明细等信息', + schema: "PlayMusicList", + icon: $r('app.media.startIcon'), + llmDescription:'查看账户信息,包括余额、消费明细等信息', + keywords: ['123234345', '12345654321'], + uiAbility: 'Entry', + pagePath: 'ets/pages/Index', + navigationId:'navId', + navDestinationName: 'PageOne', +}; +@Entry +@Component +@InsightIntentPage(validDataPage) +struct Index { + build() { + Row() { + } + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/insightUTPath.ts b/compiler/test/transform_ut/helpers/insightUTPath.ts new file mode 100644 index 000000000..2b5cba81d --- /dev/null +++ b/compiler/test/transform_ut/helpers/insightUTPath.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 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 const UT_PAGES: string[] = [ + '@InsightIntentLink/@InsightIntentLink', + '@InsightIntentEntry/@InsightIntentEntry', + '@InsightIntentFunction/@InsightIntentFunction', + '@InsightIntentPage/@InsightIntentPage' +] + +export const CACHE_PATH: string = 'default/cache/default/default@CompileArkTS/esmodule/debug'; \ No newline at end of file diff --git a/compiler/test/transform_ut/ut_insight.test.ts b/compiler/test/transform_ut/ut_insight.test.ts new file mode 100644 index 000000000..6e8d2f4bd --- /dev/null +++ b/compiler/test/transform_ut/ut_insight.test.ts @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2025 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 path from 'path'; +import fs from 'fs'; +import mocha from 'mocha'; +import sinon from 'sinon'; +import { expect } from 'chai'; + +import { + BUILD_ON, +} from '../../lib/pre_define'; +import { + resetComponentCollection, + componentCollection +} from '../../lib/validate_ui_syntax'; +import { + transformLog +} from '../../lib/process_ui_syntax'; +import { + componentInfo, + resetUtils, + storedFileInfo +} from '../../lib/utils'; +import { + partialUpdateConfig, + projectConfig, + resetGlobalProgram, + resetMain, + resources +} from '../../../../../yzhmaster/developtools_ace_ets2bundle/compiler/main'; +import { + etsChecker +} from '../../lib/fast_build/ets_ui/rollup-plugin-ets-checker'; +import { + etsTransform +} from '../../lib/fast_build/ets_ui/rollup-plugin-ets-typescript'; +import processStructComponentV2 from '../../lib/process_struct_componentV2'; +import { + RollUpPluginMock +} from '../../../../../yzhmaster/developtools_ace_ets2bundle/compiler/test/transform_ut/helpers/mockRollupContext'; +import { + PartialUpdateConfig, + ProjectConfig +} from '../../../../../yzhmaster/developtools_ace_ets2bundle/compiler/test/transform_ut/helpers/projectConfig'; +import { + CACHE_PATH, + UT_PAGES +} from './helpers/insightUTPath'; +import { + parseCode, + sourceReplace +} from '../../../../../yzhmaster/developtools_ace_ets2bundle/compiler/test/transform_ut/helpers/parser'; + +const PROJECT_ROOT: string = path.resolve(__dirname, '../../test/transform_ut'); +const DEFAULT_PROJECT: string = 'application'; +const TEST_CASES_PATH: string = path.resolve(PROJECT_ROOT, DEFAULT_PROJECT, 'entry/src/main/ets/pages'); +const OUTPUTS_PATH: string = path.resolve(PROJECT_ROOT, DEFAULT_PROJECT, 'entry/build', CACHE_PATH, 'entry/src/main/ets/pages'); +const MAIN_PAGES: string[] = UT_PAGES.map((p) => `pages/utForInsightDecorator/${p}`); + +mocha.describe('test InsightDecorator UT testcases', function () { + this.timeout(10000); + + mocha.before(function () { + resetUtils(); + resetGlobalProgram(); + resetMain(); + this.rollup = new RollUpPluginMock(); + this.rollup.build(PROJECT_ROOT, DEFAULT_PROJECT, MAIN_PAGES); + + this.globalProjectConfig = new ProjectConfig(); + this.globalProjectConfig.setPreview(false); + this.globalProjectConfig.setIgnoreWarning(true); + this.globalProjectConfig.scan(PROJECT_ROOT, DEFAULT_PROJECT, MAIN_PAGES); + this.globalProjectConfig.mockCompileContextInfo(`${PROJECT_ROOT}/${DEFAULT_PROJECT}`, MAIN_PAGES); + this.globalProjectConfig.concat(RollUpPluginMock.mockArkProjectConfig(PROJECT_ROOT, DEFAULT_PROJECT, false)); + + this.rollup.share.projectConfig.concat(this.globalProjectConfig); + Object.assign(projectConfig, this.globalProjectConfig); + + this.globalPartialUpdateConfig = new PartialUpdateConfig(); + this.globalPartialUpdateConfig.mockDisableArkTSLinter(); + + Object.assign(partialUpdateConfig, this.globalPartialUpdateConfig); + + this.etsCheckerPlugin = etsChecker(); + this.etsTransformPlugin = etsTransform(); + + // disable writing to local files + sinon.stub(fs, 'writeSync'); + + // run etsChecker once + const buildStart = this.etsCheckerPlugin.buildStart.bind(this.rollup); + buildStart(); + }); + + mocha.after(() => { + this.rollup?.share?.flushLogger(); + delete this.rollup; + delete this.globalProjectConfig; + delete this.globalPartialUpdateConfig; + delete this.etsCheckerPlugin; + delete this.etsTransformPlugin; + + resetUtils(); + resetGlobalProgram(); + resetMain(); + sinon.restore(); + }); + + mocha.beforeEach(function () { + resources.app["media"] = {icon:16777222}; + resources.app["font"] = {song:16777223}; + + process.env.rawFileResource = './'; + process.env.compileMode = 'moduleJson'; + process.env.compiler = BUILD_ON; + process.env.compileTool = 'rollup'; + + transformLog.errors = []; + componentInfo.id = 0; + componentCollection.customComponents.clear(); + resetComponentCollection(); + storedFileInfo.setCurrentArkTsFile(); + }); + + mocha.afterEach(function () { + processStructComponentV2.resetStructMapInEts(); + }); + + UT_PAGES.forEach((utPage, index) => { + mocha.it(`1-${index + 1}: test ${utPage}`, function (done) { + const sourceFilePath: string = path.resolve(TEST_CASES_PATH, `utForInsightDecorator/${utPage}.ets`); + const sourceCode: string = fs.readFileSync(sourceFilePath, 'utf-8'); + + const targetFilePath: string = path.resolve(OUTPUTS_PATH, `utForInsightDecorator/${utPage}.js.sample`); + const targetCode: string = fs.readFileSync(targetFilePath, 'utf-8'); + + storedFileInfo.addFileCacheInfo(sourceFilePath); + + const transform = this.etsTransformPlugin.transform.bind(this.rollup); + + transform(sourceReplace(sourceCode), sourceFilePath) + .then(res => { + expect(parseCode(res.code)).eql(parseCode(targetCode)); + done(); + }) + .catch(err => done(err)); + }); + }); +}); -- Gitee From 15ac43e7e5dbaa61c55ed345892b7f5b2663dd41 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Thu, 8 May 2025 15:00:25 +0800 Subject: [PATCH 031/140] =?UTF-8?q?=E6=84=8F=E5=9B=BE=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E6=96=B0=E5=A2=9EFunction=E5=92=8Cpage=E8=A3=85=E9=A5=B0?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../ets_ui/rollup-plugin-ets-typescript.ts | 8 +- compiler/src/pre_define.ts | 3 + compiler/src/process_ui_syntax.ts | 1 + .../src/userIntents_parser/intentLogger.ts | 9 +- compiler/src/userIntents_parser/intentType.ts | 308 +++++++-------- .../userIntents_parser/parseUserIntents.ts | 366 +++++++++++++++--- 6 files changed, 473 insertions(+), 222 deletions(-) diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index 1d1b8bbc9..47ce23d72 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -211,7 +211,7 @@ export function etsTransform() { } }, afterBuildEnd() { - if (parseIntent.intentData.length > 0) { + if (parseIntent.intentData.length > 0 || parseIntent.isUpdateCompile) { parseIntent.verifyInheritanceChain(); parseIntent.writeUserIntentJsonFile(); } @@ -377,7 +377,7 @@ async function transform(code: string, id: string) { compilerOptions.module = 'es2020'; const newContent: string = jsBundlePreProcess(code, id, this.getModuleInfo(id).isEntry, logger, hvigorLogger); const metaInfo: Object = this.getModuleInfo(id).metaInfo || {}; - metaInfo.tsProgram = globalProgram.program; + metaInfo.checker = globalProgram.program.getTypeChecker(); const result: ts.TranspileOutput = ts.transpileModule(newContent, { compilerOptions: compilerOptions, fileName: id, @@ -452,7 +452,7 @@ async function transform(code: string, id: string) { try { startTimeStatisticsLocation(compilationTime ? compilationTime.tsProgramEmitTime : undefined); const recordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_UI_KIT); - metaInfo.tsProgram = tsProgram; + metaInfo.checker = tsProgram.getTypeChecker(); if (projectConfig.useArkoala) { tsProgram = getArkoalaTsProgram(tsProgram); targetSourceFile = tsProgram.getSourceFile(id); @@ -477,7 +477,7 @@ async function transform(code: string, id: string) { startTimeStatisticsLocation(compilationTime ? compilationTime.transformNodesTime : undefined); const emitResolver: ts.EmitResolver = globalProgram.checker.getEmitResolver(outFile(tsProgram.getCompilerOptions()) ? undefined : targetSourceFile, undefined); - metaInfo.tsProgram = tsProgram; + metaInfo.checker = tsProgram.getTypeChecker(); transformResult = ts.transformNodes(emitResolver, tsProgram.getEmitHost?.(), ts.factory, tsProgram.getCompilerOptions(), [targetSourceFile], [processUISyntax(null, false, compilationTime, id, metaInfo), diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index e5044eacf..8c50d7646 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -94,6 +94,9 @@ export const COMPONENT_CONCURRENT_DECORATOR: string = '@Concurrent'; export const COMPONENT_SENDABLE_DECORATOR: string = '@Sendable'; export const COMPONENT_USER_INTENTS_DECORATOR: string = '@InsightIntentLink'; export const COMPONENT_USER_INTENTS_DECORATOR_ENTRY: string = '@InsightIntentEntry'; +export const COMPONENT_USER_INTENTS_DECORATOR_FUNCTION: string = '@InsightIntentFunction'; +export const COMPONENT_USER_INTENTS_DECORATOR_METHOD: string = '@InsightIntentFunctionMethod'; +export const COMPONENT_USER_INTENTS_DECORATOR_PAGE: string = '@InsightIntentPage'; export const CHECK_COMPONENT_EXTEND_DECORATOR: string = 'Extend'; export const STRUCT_CONTEXT_METHOD_DECORATORS: Set = new Set([COMPONENT_BUILDER_DECORATOR, COMPONENT_STYLES_DECORATOR, COMPONENT_LOCAL_BUILDER_DECORATOR]); diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index ff8739c14..dfee37f2f 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -294,6 +294,7 @@ export function processUISyntax(program: ts.Program, ut = false, processImport(node, pagesDir, transformLog.errors); } if (ts.isStructDeclaration(node)) { + node = parseIntent.detectInsightIntent(node, metaInfo, filePath); hasStruct = true; componentCollection.currentClassName = node.name.getText(); componentCollection.entryComponent === componentCollection.currentClassName && entryKeyNode(node); diff --git a/compiler/src/userIntents_parser/intentLogger.ts b/compiler/src/userIntents_parser/intentLogger.ts index ceed5a34a..40848c1c8 100644 --- a/compiler/src/userIntents_parser/intentLogger.ts +++ b/compiler/src/userIntents_parser/intentLogger.ts @@ -96,9 +96,16 @@ export const INTERNAL_ERROR: LogData = LogDataFactory.newInstance('1008', '[Insi export const SCHEMA_VALIDATE_ONE_OF_ERROR: LogData = LogDataFactory.newInstance('1009', '[InsightIntent] Not meeting the one of schema verification rules'); export const SCHEMA_VALIDATE_ANY_OF_ERROR: LogData = LogDataFactory.newInstance('1010', '[InsightIntent] Not meeting the any of schema verification rules'); export const SCHEMA_VALIDATE_TYPE_ERROR: LogData = LogDataFactory.newInstance('1011', '[InsightIntent] schema verification parameter type error'); -export const SCHEMA_VALIDATE_REQUIRED_ERROR: LogData = LogDataFactory.newInstance('1012', '[InsightIntent] schema verification parameter does not exist'); +export const SCHEMA_VALIDATE_REQUIRED_ERROR: LogData = LogDataFactory.newInstance('1012', + '[InsightIntent] schema verification required parameter does not exist'); export const SCHEMA_ROOT_TYPE_MISMATCH_ERROR: LogData = LogDataFactory.newInstance('1013', '[InsightIntent] Schema root type must be \'object\''); export const INVALID_BASE_CLASS_ERROR: LogData = LogDataFactory.newInstance('1014', '[InsightIntent] decorated with @InsightIntentEntry has an invalid inheritance hierarchy.'); export const PARAM_CIRCULAR_REFERENCE_ERROR: LogData = LogDataFactory.newInstance('1015', '[InsightIntent] Circular reference detected in param'); +export const INVALID_PAGEPATH_ERROR: LogData = LogDataFactory.newInstance('1016', + '[InsightIntent] @InsightIntentPage Resolved \'pagePath\' path not found in project directory'); +export const DECORATOR_ILLEGAL_USE: LogData = LogDataFactory.newInstance('1017', + '[InsightIntent] @InsightIntentFunctionMethod must be declared under the @InsightIntentFunction decorator'); +export const DECORATOR_DUPLICATE_INTENTNAME: LogData = LogDataFactory.newInstance('1018', + '[InsightIntent] user intents has duplicate intentName param'); diff --git a/compiler/src/userIntents_parser/intentType.ts b/compiler/src/userIntents_parser/intentType.ts index 6833fd614..417462989 100644 --- a/compiler/src/userIntents_parser/intentType.ts +++ b/compiler/src/userIntents_parser/intentType.ts @@ -32,7 +32,7 @@ export interface IntentInfo { parameters: object; } -interface LinkIntentParamMapping { +export interface LinkIntentParamMapping { paramName: string; paramMappingName: string; paramCategory: string; @@ -48,15 +48,21 @@ export interface IntentEntryInfo extends IntentInfo { executeMode: number[]; } -export interface IntentEntryParam { - description: string; +export interface IntentFunctionInfo extends IntentInfo { +} + +export interface IntentPageInfo extends IntentInfo { + uiAbility: string; + pagePath: string; + navigationId: string; + navDestinationName: string; } export class ParamChecker { private _requiredFields: (keyof T)[]; private _allowFields: Set; private _paramValidators: Record boolean>; - private _nestedCheckers: Map>; + private _nestedCheckers: Map>; get requiredFields(): (keyof T)[] { return this._requiredFields; @@ -70,11 +76,11 @@ export class ParamChecker { return this._paramValidators; } - get nestedCheckers(): Map> { + get nestedCheckers(): Map> { return this._nestedCheckers; } - set nestedCheckers(value: Map>) { + set nestedCheckers(value: Map>) { this._nestedCheckers = value; } @@ -97,195 +103,153 @@ export class ParamChecker { this._paramValidators = {} as Record boolean>; - this._nestedCheckers = new Map>(); + this._nestedCheckers = new Map>(); + } +} + +function validateRequiredString(v: ts.Expression): boolean { + return v !== null && ts.isStringLiteral(v) && v.text.trim() !== ''; +} + +function validateOptionalString(v: ts.Expression): boolean { + return v !== null && ts.isStringLiteral(v); +} + +function validateIcon(v: ts.Expression): boolean { + return ts.isCallExpression(v) && v.expression.getText() === '$r'; +} + +function validateParameters(v: ts.Expression): boolean { + try { + const initializer = ts.isIdentifier(v) ? + parseIntent.checker.getSymbolAtLocation(v)?.valueDeclaration?.initializer : + v; + return ts.isObjectLiteralExpression(initializer) && ajv.compile(JSON.parse(initializer.getText())); + } catch { + return false; } } +function validateKeywords(v: ts.Expression): boolean { + if (!ts.isArrayLiteralExpression(v)) { + return false; + } + return v.elements.every(ele => { + const element = ts.isIdentifier(ele) ? + parseIntent.checker.getSymbolAtLocation(ele)?.valueDeclaration?.initializer : + ele; + return ts.isStringLiteral(element) || ts.isNoSubstitutionTemplateLiteral(element); + }); +} + +const BASE_REQUIRED = ['intentName', 'domain', 'intentVersion', 'displayName']; +const BASE_ALLOW = ['displayDescription', 'schema', 'icon', 'llmDescription', 'keywords', 'parameters', ...BASE_REQUIRED]; + const IntentLinkParamsChecker: ParamChecker = new ParamChecker(); IntentLinkParamsChecker.requiredFields = ['paramName']; IntentLinkParamsChecker.allowFields = new Set([ 'paramName', 'paramMappingName', 'paramCategory' ]); IntentLinkParamsChecker.paramValidators = { - paramCategory(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v); - }, - paramMappingName(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v); - }, - paramName(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; - } + paramCategory: validateOptionalString, + paramMappingName: validateOptionalString, + paramName: validateRequiredString }; + export const IntentLinkInfoChecker: ParamChecker = new ParamChecker(); -IntentLinkInfoChecker.requiredFields = ['intentName', 'domain', 'intentVersion', 'displayName', 'uri']; +IntentLinkInfoChecker.requiredFields = [...BASE_REQUIRED as Array, 'uri']; IntentLinkInfoChecker.allowFields = new Set([ - 'intentName', 'domain', 'intentVersion', 'displayName', 'displayDescription', 'schema', 'icon', 'keywords', 'llmDescription', 'uri', - 'parameters', 'paramMappings' + ...BASE_ALLOW as Array, + 'uri', + 'paramMappings' ]); - IntentLinkInfoChecker.paramValidators = { - parameters(v: ts.Expression): boolean { - try { - let initializer: object = {}; - if (ts.isIdentifier(v)) { - const symbol: ts.Symbol | undefined = parseIntent.checker.getSymbolAtLocation(v); - const declaration: ts.Declaration = symbol?.valueDeclaration; - initializer = declaration.initializer; - } else { - initializer = v; - } - if (ts.isObjectLiteralExpression(initializer)) { - ajv.compile(JSON.parse(initializer.getText())); - return true; - } else { - return false; - } - } catch (e) { - return false; - } - }, - paramMappings(v: ts.Expression): boolean { - return v !== null && - v !== undefined && ts.isArrayLiteralExpression(v); - }, - keywords(v: ts.Expression): boolean { - if (ts.isArrayLiteralExpression(v)) { - return v.elements.every(ele => { - if (ts.isIdentifier(ele)) { - const symbol: ts.Symbol | undefined = parseIntent.checker.getSymbolAtLocation(ele); - const declaration: ts.Declaration = symbol?.valueDeclaration; - return ts.isStringLiteral(declaration.initializer) || ts.isNoSubstitutionTemplateLiteral(declaration.initializer); - } else { - return ts.isStringLiteral(ele) || ts.isNoSubstitutionTemplateLiteral(ele); - } - }); - } else { - return false; - } - }, - intentName: (v: ts.Expression): boolean => - v !== null && - v !== undefined && - ts.isStringLiteral(v) && - v.text.trim() !== '', - domain: (v: ts.Expression): boolean => v !== null && - v !== undefined && - ts.isStringLiteral(v) && - v.text.trim() !== '', - intentVersion: (v: ts.Expression): boolean => v !== null && - v !== undefined && - ts.isStringLiteral(v) && - v.text.trim() !== '', - displayName: (v: ts.Expression): boolean => v !== null && - v !== undefined && - ts.isStringLiteral(v) && - v.text.trim() !== '', - displayDescription: (v: ts.Expression): boolean => v !== null && - v !== undefined && - ts.isStringLiteral(v), - schema: (v: ts.Expression): boolean => v !== null && - v !== undefined && - ts.isStringLiteral(v) && - v.text.trim() !== '', - icon: (v: ts.Expression): boolean => ts.isCallExpression(v) && v !== null && - v !== undefined && v.expression.getText() === '$r', - llmDescription: (v: ts.Expression): boolean => v !== null && - v !== undefined && - ts.isStringLiteral(v), - uri: (v: ts.Expression): boolean => v !== null && - v !== undefined && ts.isStringLiteral(v) - + parameters: validateParameters, + paramMappings: validateOptionalString, + keywords: validateKeywords, + intentName: validateRequiredString, + domain: validateRequiredString, + intentVersion: validateRequiredString, + displayName: validateRequiredString, + displayDescription: validateOptionalString, + schema: validateRequiredString, + icon: validateIcon, + llmDescription: validateOptionalString, + uri: validateRequiredString }; IntentLinkInfoChecker.nestedCheckers = new Map([['paramMappings', IntentLinkParamsChecker]]); export const intentEntryInfoChecker: ParamChecker = new ParamChecker(); -intentEntryInfoChecker.requiredFields = ['abilityName', 'intentName', 'domain', 'intentVersion', 'displayName']; -intentEntryInfoChecker.allowFields = new Set([ - 'intentName', 'domain', 'intentVersion', 'displayName', 'displayDescription', 'schema', 'llmDescription', 'icon', 'abilityName', - 'executeMode', 'keywords' -]); - +intentEntryInfoChecker.requiredFields = [...BASE_REQUIRED as Array, 'abilityName']; +intentEntryInfoChecker.allowFields = new Set([...BASE_ALLOW as Array, 'abilityName', 'executeMode']); intentEntryInfoChecker.paramValidators = { - parameters(v: ts.Expression): boolean { - try { - let initializer: object = {}; - if (ts.isIdentifier(v)) { - const symbol: ts.Symbol | undefined = parseIntent.checker.getSymbolAtLocation(v); - const declaration: ts.Declaration = symbol?.valueDeclaration; - initializer = declaration.initializer; - } else { - initializer = v; - } - if (ts.isObjectLiteralExpression(initializer)) { - ajv.compile(JSON.parse(initializer.getText())); - return true; - } else { - return false; - } - } catch (e) { - return false; - } - }, - icon: (v: ts.Expression): boolean => ts.isCallExpression(v) && v !== null && - v !== undefined && v.expression.getText() === '$r', - keywords(v: ts.Expression): boolean { - if (ts.isArrayLiteralExpression(v)) { - return v.elements.every(ele => { - if (ts.isIdentifier(ele)) { - const symbol: ts.Symbol | undefined = parseIntent.checker.getSymbolAtLocation(ele); - const declaration: ts.Declaration = symbol?.valueDeclaration; - return ts.isStringLiteral(declaration.initializer) || ts.isNoSubstitutionTemplateLiteral(declaration.initializer); - } else { - return ts.isStringLiteral(ele) || ts.isNoSubstitutionTemplateLiteral(ele); - } - }); - } else { - return false; - } - }, - schema: (v: ts.Expression): boolean => v !== null && - v !== undefined && - ts.isStringLiteral(v) && - v.text.trim() !== '', - abilityName(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; - }, - displayDescription(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; - }, - displayName(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; - }, - domain(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; - }, + parameters: validateParameters, + icon: validateIcon, + keywords: validateKeywords, + schema: validateRequiredString, + abilityName: validateRequiredString, + displayDescription: validateRequiredString, + displayName: validateRequiredString, + domain: validateRequiredString, executeMode(v: ts.Expression): boolean { return ts.isArrayLiteralExpression(v) && - v.elements.every(e => - ts.isNumericLiteral(e) && - [0, 1, 2, 3].includes(Number(e.text)) - ); - }, - intentName(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; - }, - intentVersion(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v) && v.text.trim() !== ''; + v.elements.every(e => { + const validModes = [ + 'insightIntent.ExecuteMode.UI_ABILITY_FOREGROUND', + 'insightIntent.ExecuteMode.UI_ABILITY_BACKGROUND', + 'insightIntent.ExecuteMode.UI_EXTENSION_ABILITY', + 'insightIntent.ExecuteMode.SERVICE_EXTENSION_ABILITY' + ]; + return (ts.isNumericLiteral(e) && [0, 1, 2, 3].includes(Number(e.text))) || validModes.includes(e.getText()); + }); }, - llmDescription(v: ts.Expression): boolean { - return v !== null && v !== undefined && ts.isStringLiteral(v); - } + intentName: validateRequiredString, + intentVersion: validateRequiredString, + llmDescription: validateOptionalString }; +// todo 把下面的几个checker换成上面的格式! +export const intentMethodInfoChecker: ParamChecker = new ParamChecker(); +intentMethodInfoChecker.requiredFields = [...BASE_REQUIRED as Array]; +intentMethodInfoChecker.allowFields = new Set([ + ...BASE_ALLOW as Array +]); -export const intentEntryParamChecker: ParamChecker = new ParamChecker(); -intentEntryParamChecker.requiredFields = ['description']; -intentEntryParamChecker.allowFields = new Set([ - 'description' +intentMethodInfoChecker.paramValidators = { + parameters: validateParameters, + icon: validateIcon, + keywords: validateKeywords, + schema: validateRequiredString, + intentName: validateRequiredString, + domain: validateRequiredString, + intentVersion: validateRequiredString, + displayName: validateRequiredString, + displayDescription: validateOptionalString, + llmDescription: validateOptionalString +}; + +export const IntentPageInfoChecker: ParamChecker = new ParamChecker(); +IntentPageInfoChecker.requiredFields = [...BASE_REQUIRED as Array, 'pagePath']; +IntentPageInfoChecker.allowFields = new Set([ + ...BASE_ALLOW as Array, + 'uiAbility', + 'pagePath', + 'navigationId', + 'navDestinationName' ]); -intentEntryParamChecker.paramValidators = { - description: (v: ts.Expression): boolean => v !== null && - v !== undefined && - ts.isStringLiteral(v) && - v.text.trim() !== '' + +IntentPageInfoChecker.paramValidators = { + parameters: validateParameters, + icon: validateIcon, + keywords: validateKeywords, + schema: validateRequiredString, + intentName: validateRequiredString, + domain: validateRequiredString, + intentVersion: validateRequiredString, + displayName: validateRequiredString, + displayDescription: validateOptionalString, + llmDescription: validateOptionalString, + uiAbility: validateOptionalString, + pagePath: validateRequiredString, + navigationId: validateOptionalString, + navDestinationName: validateOptionalString }; diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index fc74c25df..f35c08424 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -14,8 +14,18 @@ */ import ts, { CatchClause, Declaration, Expression, TypeChecker, VariableDeclarationList } from 'typescript'; -import { intentEntryInfoChecker, IntentLinkInfoChecker, ParamChecker } from './intentType'; import { + IntentEntryInfo, + intentEntryInfoChecker, + IntentLinkInfo, + IntentLinkInfoChecker, intentMethodInfoChecker, + LinkIntentParamMapping, + IntentPageInfoChecker, + ParamChecker +} from './intentType'; +import { + DECORATOR_DUPLICATE_INTENTNAME, + DECORATOR_ILLEGAL_USE, DECORATOR_STATEMENT_ERROR, DISALLOWED_PARAM_ERROR, DYNAMIC_PARAM_ERROR, @@ -23,46 +33,85 @@ import { INCORRECT_PARAM_TYPE_ERROR, IntentLogger, INTERNAL_ERROR, + INVALID_BASE_CLASS_ERROR, INVALID_PAGEPATH_ERROR, + PARAM_CIRCULAR_REFERENCE_ERROR, REQUIRED_PARAM_DISMISS_ERROR, - SCHEMA_VALIDATE_REQUIRED_ERROR, - UNSUPPORTED_PARSE_ERROR, - SCHEMA_VALIDATE_TYPE_ERROR, + SCHEMA_ROOT_TYPE_MISMATCH_ERROR, SCHEMA_VALIDATE_ANY_OF_ERROR, SCHEMA_VALIDATE_ONE_OF_ERROR, - SCHEMA_ROOT_TYPE_MISMATCH_ERROR, - INVALID_BASE_CLASS_ERROR, - PARAM_CIRCULAR_REFERENCE_ERROR + SCHEMA_VALIDATE_REQUIRED_ERROR, + SCHEMA_VALIDATE_TYPE_ERROR, + UNSUPPORTED_PARSE_ERROR } from './intentLogger'; import path from 'path'; import { getNormalizedOhmUrlByFilepath } from '../ark_utils'; -import { projectConfig, globalModulePaths } from '../../main'; +import { globalModulePaths, projectConfig } from '../../main'; import fs from 'fs'; import { ProjectCollections } from 'arkguard'; -import { COMPONENT_USER_INTENTS_DECORATOR, COMPONENT_USER_INTENTS_DECORATOR_ENTRY } from '../pre_define'; +import { + COMPONENT_USER_INTENTS_DECORATOR, + COMPONENT_USER_INTENTS_DECORATOR_ENTRY, + COMPONENT_USER_INTENTS_DECORATOR_FUNCTION, + COMPONENT_USER_INTENTS_DECORATOR_METHOD, + COMPONENT_USER_INTENTS_DECORATOR_PAGE +} from '../pre_define'; import { hasDecorator } from '../utils'; type StaticValue = string | number | boolean | null | undefined | StaticValue[] | { [key: string]: StaticValue }; +interface methodParametersInfo { + functionName: string; + parameters: Record, + args: ts.NodeArray; +} + class ParseIntent { constructor() { this.intentData = []; this.currentFilePath = ''; this.heritageClassSet = new Set(); this.heritageClassSet.add('IntentEntity_sdk'); + this.updatePageIntentObj = new Map(); } checker: ts.TypeChecker; - intentData: any[]; + intentData: object[]; currentFilePath: string; heritageClassSet: Set; + updatePageIntentObj: Map; + isUpdateCompile: boolean = false; + isInitCache : boolean = false; detectInsightIntent(node: ts.ClassDeclaration, metaInfo: object, filePath: string): ts.Node { - if (hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR) || hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR_ENTRY - )) { - const checker: TypeChecker = metaInfo.tsProgram.getTypeChecker(); + if (!this.isInitCache && projectConfig.cachePath) { + const cacheSourceMapPath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); + this.isUpdateCompile = fs.existsSync(cacheSourceMapPath); + this.isInitCache = true; + } + if (this.isUpdateCompile) { + const pkgParams: object = { + pkgName: metaInfo.pkgName, + pkgPath: metaInfo.pkgPath + }; + const Logger: IntentLogger = IntentLogger.getInstance(); + const recordName: string = getNormalizedOhmUrlByFilepath(filePath, projectConfig, Logger, pkgParams, null); + if (!this.updatePageIntentObj.has(`@normalized:${recordName}`)) { + this.updatePageIntentObj.set(`@normalized:${recordName}`, []); + } + } + if (hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR) || hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR_ENTRY) || + hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR_FUNCTION) || hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR_PAGE)) { + const checker: TypeChecker = metaInfo.checker; this.handleIntent(node, checker, filePath, metaInfo); - node = this.removeDecorator(node, [COMPONENT_USER_INTENTS_DECORATOR, COMPONENT_USER_INTENTS_DECORATOR_ENTRY]); - return node; + node = this.removeDecorator(node, [COMPONENT_USER_INTENTS_DECORATOR, COMPONENT_USER_INTENTS_DECORATOR_ENTRY, + COMPONENT_USER_INTENTS_DECORATOR_FUNCTION, COMPONENT_USER_INTENTS_DECORATOR_PAGE, COMPONENT_USER_INTENTS_DECORATOR_METHOD]); + } else { + node.members.forEach((member) => { + if (ts.isMethodDeclaration(member) && this.hasModifier(member, ts.SyntaxKind.StaticKeyword) && + hasDecorator(member, COMPONENT_USER_INTENTS_DECORATOR_METHOD)) { + throw Error(`${DECORATOR_ILLEGAL_USE.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + }); } return node; } @@ -88,7 +137,11 @@ class ParseIntent { return; } const decoratorSourceFile: string = declarations[0].getSourceFile().fileName; - const isGlobalPath: boolean = globalModulePaths?.some(path => decoratorSourceFile.startsWith(path)); + const isGlobalPath: boolean = globalModulePaths?.some(globalPath => { + const normalizedParent: string = path.normalize(decoratorSourceFile).replace(/\\/g, '/'); + const normalizedGlobalPath: string = path.normalize(globalPath).replace(/\\/g, '/'); + return normalizedParent.startsWith(normalizedGlobalPath); + }); if (!isGlobalPath) { return; } @@ -103,21 +156,86 @@ class ParseIntent { this.handleLinkDecorator(intentObj, node, decorator); } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_ENTRY) { this.handleEntryDecorator(intentObj, node, decorator, pkgParams); + } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_FUNCTION) { + this.handleMethodDecorator(intentObj, node, decorator); + } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_PAGE) { + this.handlePageDecorator(intentObj, node, decorator, pkgParams); } }); } + handlePageDecorator(intentObj: object, node: ts.Node, decorator: ts.Decorator, pkgParams: object): void { + const expr: ts.Expression = decorator.expression; + if (ts.isCallExpression(expr)) { + const args: ts.NodeArray = expr.arguments; + Object.assign(intentObj, { + 'bundleName': projectConfig.bundleName, + 'moduleName': projectConfig.moduleName, + 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_PAGE + }); + this.analyzeDecoratorArgs(args, intentObj, IntentPageInfoChecker); + const properties: Record = this.parsePageProperties(node); + this.schemaValidateSync(properties, intentObj.parameters); + this.createObfuscation(node); + this.transformPagePath(intentObj, pkgParams); + if (this.isUpdateCompile) { + this.updatePageIntentObj.get(intentObj.decoratorFile).push(intentObj); + } + this.intentData.push(intentObj); + } else { + throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + } + + handleMethodDecorator(intentObj: object, node: ts.Node, decorator: ts.Decorator): void { + const expr: ts.Expression = decorator.expression; + if (ts.isCallExpression(expr)) { + Object.assign(intentObj, { + 'bundleName': projectConfig.bundleName, + 'moduleName': projectConfig.moduleName, + 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_METHOD, + 'intentType': 'function' + }); + + interface methodParametersInfo { + functionName: string, + parameters: Record, + args: ts.NodeArray, + } + + const methodParameters: methodParametersInfo[] = this.parseClassMethods(node, COMPONENT_USER_INTENTS_DECORATOR_METHOD); + methodParameters.forEach(methodDecorator => { + const functionName: string = methodDecorator.functionName; + const methodArgs: ts.NodeArray = methodDecorator.args; + const properties: Record = methodDecorator.parameters; + const methodObj: object = Object.assign({}, intentObj, {functionName}); + this.analyzeDecoratorArgs(methodArgs, methodObj, intentMethodInfoChecker); + this.schemaValidateSync(properties, methodObj.parameters); + if (this.isUpdateCompile) { + this.updatePageIntentObj.get(methodObj.decoratorFile).push(methodObj); + } + this.intentData.push(methodObj); + }); + this.createObfuscation(node); + } else { + throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + } + handleLinkDecorator(intentObj: object, node: ts.Node, decorator: ts.Decorator): void { const expr: ts.Expression = decorator.expression; if (ts.isCallExpression(expr)) { const args: ts.NodeArray = expr.arguments; - this.analyzeDecoratorArgs(args, intentObj, IntentLinkInfoChecker); + this.analyzeDecoratorArgs(args, intentObj, IntentLinkInfoChecker); Object.assign(intentObj, { 'bundleName': projectConfig.bundleName, 'moduleName': projectConfig.moduleName, 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR }); this.createObfuscation(node); + if (this.isUpdateCompile) { + this.updatePageIntentObj.get(intentObj.decoratorFile).push(intentObj); + } this.intentData.push(intentObj); } else { throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); @@ -133,17 +251,47 @@ class ParseIntent { 'moduleName': projectConfig.moduleName, 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_ENTRY }); - this.analyzeDecoratorArgs(args, intentObj, intentEntryInfoChecker); + this.analyzeDecoratorArgs(args, intentObj, intentEntryInfoChecker); const properties: Record = this.parseClassNode(node); - this.schemaValidateSync(properties, intentObj); + this.schemaValidateSync(properties, intentObj.parameters); this.analyzeBaseClass(node, pkgParams, intentObj); this.createObfuscation(node); + this.processExecuteModeParam(intentObj); + if (this.isUpdateCompile) { + this.updatePageIntentObj.get(intentObj.decoratorFile).push(intentObj); + } this.intentData.push(intentObj); } else { throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); } } + transformPagePath(intentObj: object, pkgParams: object): void { + if (pkgParams.pkgPath) { + const normalPagePath: string = path.join(pkgParams.pkgPath, 'src/main', intentObj.pagePath + '.ets'); + if (!fs.existsSync(normalPagePath)) { + throw Error(`${INVALID_PAGEPATH_ERROR.toString()}, ${normalPagePath} does not exist, invalidDecoratorPath: ${this.currentFilePath}`); + } else { + const Logger: IntentLogger = IntentLogger.getInstance(); + intentObj.pagePath = '@normalized:' + getNormalizedOhmUrlByFilepath(normalPagePath, projectConfig, Logger, pkgParams, null); + } + } + } + + parsePageProperties(node: ts.Node): Record { + const mergeObject: Record = {}; + node.members.forEach(member => { + if (ts.isPropertyDeclaration(member)) { + const symbol = this.checker.getSymbolAtLocation(member.name); + if (symbol) { + const objItem: Record = this.processProperty(symbol); + Object.assign(mergeObject, objItem); + } + } + }); + return mergeObject; + } + analyzeBaseClass(node: ts.ClassDeclaration, pkgParams: object, intentObj: object): void { const interfaces: ts.ExpressionWithTypeArguments[] = []; node.heritageClauses?.forEach(clause => { @@ -159,6 +307,41 @@ class ParseIntent { } } + hasModifier(node: ts.Node, modifier: ts.SyntaxKind): boolean { + return (node.modifiers || []).some(m => m.kind === modifier); + } + + parseClassMethods(classNode: ts.ClassDeclaration, decoratorType: string): methodParametersInfo[] { + const methodsArr: methodParametersInfo[] = []; + for (const member of classNode.members) { + if (!ts.isMethodDeclaration(member) || !this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { + continue; + } + const decorator: boolean = member.modifiers?.find(m => { + const text = m.getText(); + return text.replace(/\(.*\)$/, '').trim() === decoratorType; + }); + if (decorator && ts.isCallExpression(decorator.expression)) { + const parameters: Record = {}; + member.parameters.forEach(param => { + const paramName: string = param.name.getText(); + parameters[paramName] = this.checker.typeToString( + this.checker.getTypeAtLocation(param), + param, + ts.TypeFormatFlags.NoTruncation + ); + }); + const obj: methodParametersInfo = { + functionName: member.name.getText(), + parameters: parameters, + args: decorator.expression.arguments + }; + methodsArr.push(obj); + } + } + return methodsArr; + } + analyzeClassHeritage( parentNode: ts.ExpressionWithTypeArguments, node: ts.ClassDeclaration, pkgParams: object, intentObj: object ): void { @@ -170,7 +353,11 @@ class ParseIntent { const baseClassName: string = this.checker.getTypeAtLocation(node).getSymbol().getName(); const baseFilePath: string = node.getSourceFile().fileName; const baseRecordName: string = getNormalizedOhmUrlByFilepath(baseFilePath, projectConfig, logger, pkgParams, null); - const isGlobalPath: boolean = globalModulePaths?.some(path => parentFilePath.startsWith(path)); + const isGlobalPath: boolean = globalModulePaths?.some(globalPath => { + const normalizedParent: string = path.normalize(parentFilePath).replace(/\\/g, '/'); + const normalizedGlobalPath: string = path.normalize(globalPath).replace(/\\/g, '/'); + return normalizedParent.startsWith(normalizedGlobalPath); + }); const recordPath: string = isGlobalPath ? `sdk` : `@normalized:${parentRecordName}`; if (isGlobalPath) { if (parentClassName !== 'IntentEntity') { @@ -298,17 +485,39 @@ class ParseIntent { } removeDecorator(node: ts.ClassDeclaration, decoratorNames: string[]): ts.ClassDeclaration { - const filteredModifiers: ts.ClassDeclaration = node.modifiers.filter(decorator => { + const filteredModifiers: ts.ModifierLike[] = node.modifiers.filter(decorator => { const originalDecortor: string = decorator.getText().replace(/\(.*\)$/, '').trim(); return !decoratorNames.includes(originalDecortor); }); + const updatedMembers: ts.ClassElement[] = node.members.map(member => { + if (ts.isMethodDeclaration(member) && this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { + const memberModifiers: ts.ModifierLike[] = (member.modifiers ?? []).filter(decorator => { + const originalDecorator = decorator.getText().replace(/\(.*\)$/, '').trim(); + return originalDecorator !== COMPONENT_USER_INTENTS_DECORATOR_METHOD; + }); + if (memberModifiers.length !== (member.modifiers?.length ?? 0)) { + return ts.factory.updateMethodDeclaration( + member, + memberModifiers, + member.asteriskToken, + member.name, + member.questionToken, + member.typeParameters, + member.parameters, + member.type, + member.body! + ); + } + } + return member; + }); return ts.factory.updateClassDeclaration( node, filteredModifiers, node.name, node.typeParameters, node.heritageClauses, - node.members + ts.factory.createNodeArray(updatedMembers) ); } @@ -376,7 +585,7 @@ class ParseIntent { ): void { const existingParams: Set = new Set(); const requiredFields: (keyof T)[] = paramCheckFields.requiredFields; - const nestedCheckers: Map> = paramCheckFields.nestedCheckers; + const nestedCheckers: Map> = paramCheckFields.nestedCheckers; const allowedFields: Set = paramCheckFields.allowFields; const paramValidators: Record boolean> = paramCheckFields.paramValidators; for (const prop of node.properties) { @@ -392,24 +601,24 @@ class ParseIntent { } } - validateSelfParamFields(prop: ts.Node, nestedCheckers: Map>): void { - const checker: ParamChecker = nestedCheckers.get(prop.name.text); + validateSelfParamFields(prop: ts.Node, nestedCheckers: Map>): void { + const checker: ParamChecker = nestedCheckers.get(prop.name.text); if (ts.isArrayLiteralExpression(prop.initializer)) { prop.initializer.elements.every(elem => { if (ts.isIdentifier(elem)) { const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(elem); const declaration: ts.Declaration = symbol?.valueDeclaration; - this.validateRequiredIntentLinkInfo(declaration.initializer, checker); + this.validateRequiredIntentLinkInfo(declaration.initializer, checker); } else { - this.validateRequiredIntentLinkInfo(elem.initializer, checker); + this.validateRequiredIntentLinkInfo(elem.initializer, checker); } }); } else if (ts.isIdentifier(prop)) { const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(prop); const declaration: ts.Declaration = symbol?.valueDeclaration; - this.validateRequiredIntentLinkInfo(declaration.initializer, checker); + this.validateRequiredIntentLinkInfo(declaration.initializer, checker); } else { - this.validateRequiredIntentLinkInfo(prop.initializer, checker); + this.validateRequiredIntentLinkInfo(prop.initializer, checker); } } @@ -436,14 +645,14 @@ class ParseIntent { } } - analyzeDecoratorArgs(args: ts.NodeArray, intentObj: object, paramChecker: ParamChecker): void { + analyzeDecoratorArgs(args: ts.NodeArray, intentObj: object, paramChecker: ParamChecker): void { args.forEach(arg => { if (ts.isIdentifier(arg)) { const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(arg); const declaration: ts.Declaration = symbol?.valueDeclaration; - this.validateRequiredIntentLinkInfo(declaration.initializer, paramChecker); + this.validateRequiredIntentLinkInfo(declaration.initializer, paramChecker); } else { - this.validateRequiredIntentLinkInfo(arg, paramChecker); + this.validateRequiredIntentLinkInfo(arg, paramChecker); } const res: StaticValue = this.parseStaticObject(arg); Object.assign(intentObj, res); @@ -489,7 +698,6 @@ class ParseIntent { if (node.kind === ts.SyntaxKind.UndefinedKeyword) { return undefined; } - if (ts.isIdentifier(node)) { const isStatic: boolean = this.isConstantExpression(node); if (isStatic) { @@ -498,15 +706,12 @@ class ParseIntent { return this.parseStaticObject(declaration.initializer, visited); } } - if (ts.isArrayLiteralExpression(node)) { return this.processArrayElements(node.elements); } - if (ts.isObjectLiteralExpression(node)) { return this.processObjectElements(node); } - if (ts.isCallExpression(node) && node.expression.getText() === '$r') { const isStatic: boolean = this.isConstantExpression(node); if (!isStatic) { @@ -514,10 +719,26 @@ class ParseIntent { } return node.getText(); } - + if (ts.isPropertyAccessExpression(node)) { + return this.processEnumElement(node); + } throw Error(`${UNSUPPORTED_PARSE_ERROR.toString()}, cause param: '${node.text}', invalidDecoratorPath: ${this.currentFilePath}`); } + processEnumElement(node: ts.PropertyAccessExpression): number { + const enumValue: string = node.getText(); + const executeModeEnum: Map = new Map(); + executeModeEnum.set('insightIntent.ExecuteMode.UI_ABILITY_FOREGROUND', 0); + executeModeEnum.set('insightIntent.ExecuteMode.UI_ABILITY_BACKGROUND', 1); + executeModeEnum.set('insightIntent.ExecuteMode.UI_EXTENSION_ABILITY', 2); + executeModeEnum.set('insightIntent.ExecuteMode.SERVICE_EXTENSION_ABILITY', 3); + if (executeModeEnum.has(enumValue)) { + return executeModeEnum.get(enumValue); + } else { + throw Error(`${UNSUPPORTED_PARSE_ERROR.toString()}, cause param: '${node.text}', invalidDecoratorPath: ${this.currentFilePath}`); + } + } + processObjectElements(elements: ts.ObjectLiteralExpression): { [key: string]: StaticValue } { const obj: { [key: string]: StaticValue } = {}; for (const prop of elements.properties) { @@ -568,6 +789,25 @@ class ParseIntent { return undefined; } + processExecuteModeParam(intentObj: object): void { + if (intentObj.executeMode) { + intentObj.executeMode.forEach((item: number, index: number) => { + if (item === 0) { + intentObj.executeMode[index] = 'foreground'; + } + if (item === 1) { + intentObj.executeMode[index] = 'background'; + } + if (item === 2) { + intentObj.executeMode[index] = 'insightIntent.ExecuteMode.UI_EXTENSION_ABILITY'; + } + if (item === 3) { + intentObj.executeMode[index] = 'insightIntent.ExecuteMode.SERVICE_EXTENSION_ABILITY'; + } + }); + } + } + collectSchemaInfo(intentObj: object): void { if (intentObj.schema) { const schemaPath: string = path.join( @@ -581,11 +821,11 @@ class ParseIntent { } if (intentObj.keywords) { throw Error(`${DISALLOWED_PARAM_ERROR.toString()}` + - `, the standard user intents does not allow passing the parameter 'keywords', invalidDecoratorPath: ${this.currentFilePath}`); + `, the standard user intents does not allow passing the parameter 'keywords', invalidDecoratorPath: ${this.currentFilePath}`); } if (intentObj.llmDescription) { throw Error(`${DISALLOWED_PARAM_ERROR.toString()}` + - `, the standard user intents does not allow passing the parameter 'llmDescription', invalidDecoratorPath: ${this.currentFilePath}`); + `, the standard user intents does not allow passing the parameter 'llmDescription', invalidDecoratorPath: ${this.currentFilePath}`); } const schemaContent: string = fs.readFileSync(schemaPath, 'utf-8'); const schemaObj: object = JSON.parse(schemaContent); @@ -639,10 +879,10 @@ class ParseIntent { } private schemaValidateRules(schemaData: Record, schemaObj: object): void { - const requiredOne: string[][] = schemaObj.oneOf.map(item => item.required); const schemaKeys: string[] = Object.keys(schemaData); if (schemaObj.oneOf) { let count: number = 0; + const requiredOne: string[][] = schemaObj.oneOf.map(item => item.required); requiredOne.forEach(val => { const isContain: boolean = val.every((item): boolean => { return schemaKeys.includes(item); @@ -672,11 +912,13 @@ class ParseIntent { } } - schemaValidateSync(schemaData: Record, intentObj: object): void { - const schemaObj: object = intentObj.parameters; + schemaValidateSync(schemaData: Record, schemaObj: object): void { if (!schemaObj) { return; } + if (schemaObj.items && schemaObj.items.type === 'array') { + this.schemaValidateSync(schemaData, schemaObj.items.items); + } if (schemaObj.type !== 'object') { throw Error(`${SCHEMA_ROOT_TYPE_MISMATCH_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); } @@ -694,30 +936,64 @@ class ParseIntent { throw Error(`${INTERNAL_ERROR.toString()}, aceProfilePath not found, invalidDecoratorPath: ${this.currentFilePath}`); } const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'extract_insight_intent.json'); + const cachePath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); if (!fs.existsSync(projectConfig.aceProfilePath)) { fs.mkdirSync(projectConfig.aceProfilePath, {recursive: true}); } - fs.writeFileSync(cacheSourceMapPath, JSON.stringify({'insightIntents': this.intentData}, null, 2), 'utf-8'); + if (this.isUpdateCompile) { + const cacheData: string = fs.readFileSync(cachePath, 'utf8'); + const cacheDataObj: object = JSON.parse(cacheData); + const insightIntents: object[] = cacheDataObj.insightIntents.filter(insightIntent => { + return !this.updatePageIntentObj.has(insightIntent.decoratorFile); + }); + this.updatePageIntentObj.forEach(insightIntent => { + insightIntents.push(...insightIntent); + }); + this.intentData = insightIntents; + } + this.validateIntentIntentName(); + if (this.intentData.length > 0) { + fs.writeFileSync(cacheSourceMapPath, JSON.stringify({'insightIntents': this.intentData}, null, 2), 'utf-8'); + fs.writeFileSync(cachePath, JSON.stringify({'insightIntents': this.intentData}, null, 2), 'utf-8'); + } else if (fs.existsSync(cacheSourceMapPath)) { + fs.unlinkSync(cacheSourceMapPath); + } const normalizedPath: string = path.normalize(projectConfig.aceProfilePath); const fullPath: string = path.join(normalizedPath, '../../../module.json'); if (fs.existsSync(fullPath)) { const rawData: string = fs.readFileSync(fullPath, 'utf8'); - const jsonData: any = JSON.parse(rawData); + const jsonData: object = JSON.parse(rawData); if (jsonData?.module) { - jsonData.module.hasInsightIntent = true; + jsonData.module.hasInsightIntent = this.intentData.length > 0 ? true : undefined; } const updatedJson: string = JSON.stringify(jsonData, null, 2); fs.writeFileSync(fullPath, updatedJson, 'utf8'); } } + validateIntentIntentName(): void { + const duplicates = new Set(); + this.intentData.forEach(item => { + if (duplicates.has(item.intentName)) { + throw Error(`${DECORATOR_DUPLICATE_INTENTNAME.toString()}, value : ${item.intentName}, invalidDecoratorPath: ${this.currentFilePath}`); + } else { + duplicates.add(item.intentName); + } + }); + } + clear(): void { this.intentData = []; this.checker = null; this.currentFilePath = ''; IntentLinkInfoChecker.clean(); intentEntryInfoChecker.clean(); + intentMethodInfoChecker.clean(); + intentMethodInfoChecker.clean(); this.heritageClassSet = new Set(); + this.isInitCache = false; + this.isUpdateCompile = false; + this.updatePageIntentObj = new Map(); } } -- Gitee From c62a061f63ff75e6ec29362db1286e4a147a885f Mon Sep 17 00:00:00 2001 From: wuhailong Date: Thu, 8 May 2025 19:40:37 +0800 Subject: [PATCH 032/140] pass allowEtsAnnotations to arkProjectConfig Issue: #IC6EOQ Signed-off-by: wuhailong Change-Id: Ia27b5e899dab0e225e78216ce62e9fc4c6979325 --- .../src/fast_build/ark_compiler/common/process_ark_config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts b/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts index 05c8b393a..1c5f8c513 100644 --- a/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts +++ b/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts @@ -165,6 +165,9 @@ export function initArkProjectConfig(share: Object): Object { } } + // pass allowEtsAnnotations to arkProjectConfig + arkProjectConfig.allowEtsAnnotations = mainProjectConfig.allowEtsAnnotations; + // Hotreload attributes are initialized by arkui in main.js, just copy them. arkProjectConfig.hotReload = mainProjectConfig.hotReload; arkProjectConfig.coldReload = mainProjectConfig.coldReload; -- Gitee From ec966608d9eb354fa2cfa5820a31ad45ef737c3e Mon Sep 17 00:00:00 2001 From: Yenan Date: Fri, 9 May 2025 11:06:47 +0800 Subject: [PATCH 033/140] =?UTF-8?q?worker=20file=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=E9=94=99=E8=AF=AF=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/main.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/main.js b/compiler/main.js index 64589ea32..4906a43af 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -638,8 +638,9 @@ function readWorkerFile() { aceBuildJson.workers.forEach(worker => { if (!/\.(ts|js|ets)$/.test(worker)) { throw Error( - '\u001b[31mArkTS:ERROR: File: ' + worker + '.' + '\n' + - " The worker file can only be an '.ets', '.ts', or '.js' file.\u001b[39m" + '\u001b[31m10906402 ArkTS Compiler Error' + '\n' + + 'Error Message: ' + 'File: ' + worker + '.' + '\n' + + "The worker file can only be an '.ets', '.ts', or '.js' file.\u001b[39m" ).message; } const relativePath = path.relative(projectConfig.projectPath, worker); @@ -647,7 +648,8 @@ function readWorkerFile() { const workerKey = relativePath.replace(/\.(ts|js)$/, '').replace(/\\/g, '/'); if (workerFileEntry[workerKey]) { throw Error( - '\u001b[31m ERROR: The worker file cannot use the same file name: \n' + + '\u001b[31m10905407 ArkTS Compiler Error' + '\n' + + 'Error Message: ' + 'The worker file cannot use the same file name: \n' + workerFileEntry[workerKey] + '\n' + worker + '\u001b[39m' ).message; } else { -- Gitee From 6dd868ad910c5972502be7638fb647f3e3f825d2 Mon Sep 17 00:00:00 2001 From: maoruihao Date: Thu, 17 Apr 2025 14:49:59 +0800 Subject: [PATCH 034/140] Optimize validateError and getRealModulePath Signed-off-by: maoruihao --- compiler/src/ets_checker.ts | 24 +++++++++++++++--------- compiler/src/process_component_build.ts | 5 ++--- compiler/src/process_component_member.ts | 9 ++++----- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 5f382fb94..5583b7d26 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -362,11 +362,11 @@ export function createLanguageService(rootFileNames: string[], resolveModulePath getJsDocNodeConditionCheckedResult: (jsDocFileCheckedInfo: ts.FileCheckModuleInfo, jsDocs: ts.JsDocTagInfo[]) => { return getJsDocNodeConditionCheckResult(jsDocFileCheckedInfo, jsDocs); }, - uiProps: [], + uiProps: new Set(), clearProps: function() { dollarCollection.clear(); extendCollection.clear(); - this.uiProps.length = 0; + this.uiProps = new Set(); }, // TSC will re-do resolution if this callback return true. hasInvalidatedResolutions: (filePath: string): boolean => { @@ -490,7 +490,7 @@ const allResolvedModules: Set = new Set(); export const allSourceFilePaths: Set = new Set(); // Used to collect file paths that have not been converted toUnixPath. export const allModuleIds: Set = new Set(); -export let props: string[] = []; +export let props: Set = new Set(); export let fastBuildLogger = null; @@ -568,7 +568,7 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null } } -export function traverseProgramSourceFiles(props: string[]): void { +export function traverseProgramSourceFiles(props: Set): void { globalProgram.program.getSourceFiles().forEach((sourceFile: ts.SourceFile) => { checkUISyntax(sourceFile, sourceFile.fileName, [], props); }); @@ -931,7 +931,7 @@ function validateError(message: string): boolean { function matchMessage(message: string, nameArr: any, reg: RegExp): boolean { if (reg.test(message)) { const match: string[] = message.match(reg); - if (match[1] && nameArr.includes(match[1])) { + if (match[1] && nameArr.has(match[1])) { return true; } } @@ -1269,7 +1269,7 @@ export function watchChecker(rootFileNames: string[], newLogger: any = null, res } export function instanceInsteadThis(content: string, fileName: string, extendFunctionInfo: extendInfo[], - props: string[]): string { + props: Set): string { extendFunctionInfo.reverse().forEach((item) => { const subStr: string = content.substring(item.start, item.end); const insert: string = subStr.replace(/(\s)\$(\.)/g, (origin, item1, item2) => { @@ -1292,14 +1292,20 @@ export const dollarCollection: Set = new Set(); export const extendCollection: Set = new Set(); export const importModuleCollection: Set = new Set(); -function checkUISyntax(sourceFile: ts.SourceFile, fileName: string, extendFunctionInfo: extendInfo[], props: string[]): void { +function checkUISyntax(sourceFile: ts.SourceFile, fileName: string, extendFunctionInfo: extendInfo[], + props: Set): void { if (/\.ets$/.test(fileName) && !/\.d.ets$/.test(fileName)) { if (process.env.compileMode === 'moduleJson' || path.resolve(fileName) !== path.resolve(projectConfig.projectPath, 'app.ets')) { collectComponents(sourceFile); collectionCustomizeStyles(sourceFile); parseAllNode(sourceFile, sourceFile, extendFunctionInfo); - props.push(...dollarCollection, ...extendCollection); + dollarCollection.forEach((item) => { + props.add(item); + }); + extendCollection.forEach((item) => { + props.add(item); + }); } } } @@ -1795,7 +1801,7 @@ export function resetEtsCheckTypeScript(): void { export function resetEtsCheck(): void { cache = {}; - props = []; + props = new Set(); needReCheckForChangedDepUsers = false; resetEtsCheckTypeScript(); allResolvedModules.clear(); diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 225c7f1d2..f30c90cd1 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -2308,11 +2308,10 @@ function isBuilderChangeNode(argument: ts.Node, identifierNode: ts.Identifier, p } export function isWrappedBuilder(node: ts.PropertyAccessExpression): boolean { + const typeAtLocation = globalProgram.checker.getTypeAtLocation(node.expression); if (projectConfig.minAPIVersion >= 11 && ts.isPropertyAccessExpression(node) && node.name && ts.isIdentifier(node.name) && node.name.escapedText.toString() === WRAPBUILDER_BUILDERPROP && - globalProgram.checker.getTypeAtLocation(node.expression) && - globalProgram.checker.getTypeAtLocation(node.expression).symbol && - globalProgram.checker.getTypeAtLocation(node.expression).symbol.escapedName === WRAPPEDBUILDER_CLASS) { + typeAtLocation && typeAtLocation.symbol && typeAtLocation.symbol.escapedName === WRAPPEDBUILDER_CLASS) { return true; } return false; diff --git a/compiler/src/process_component_member.ts b/compiler/src/process_component_member.ts index d1a1e4a78..9bd793f75 100644 --- a/compiler/src/process_component_member.ts +++ b/compiler/src/process_component_member.ts @@ -979,11 +979,10 @@ function manageLocalStorageComponents(node: ts.CallExpression, argumentsArray: t } export function isLocalStorageParameter(node: ts.CallExpression): boolean { - return globalProgram.checker && globalProgram.checker.getResolvedSignature && - globalProgram.checker.getResolvedSignature(node) && - globalProgram.checker.getResolvedSignature(node).parameters && - globalProgram.checker.getResolvedSignature(node).parameters.length === 1 && - globalProgram.checker.getResolvedSignature(node).parameters[0].escapedName === '##storage'; + const resolvedSignature = globalProgram.checker?.getResolvedSignature ? + globalProgram.checker.getResolvedSignature(node) : undefined; + return resolvedSignature && resolvedSignature.parameters && resolvedSignature.parameters.length === 1 && + resolvedSignature.parameters[0].escapedName === '##storage'; } function componentParamRowAndColumn(line: number, col: number): ts.ObjectLiteralExpression { -- Gitee From 82b38d1cc8dc5d97a750ac223208b6505f6af0b5 Mon Sep 17 00:00:00 2001 From: zenghang Date: Fri, 6 Dec 2024 11:33:48 +0800 Subject: [PATCH 035/140] Bytecode obfuscation Integrate Issue: IB1TRO Signed-off-by: zenghang Change-Id: I6c0d8c2ba2bedc47f09e9f5f34819e241081cd11 --- compiler/src/ark_utils.ts | 30 +- .../ark_compiler/bytecode_obfuscator.ts | 707 ++++++++++++++++++ .../ark_compiler/common/ark_define.ts | 22 + .../ark_compiler/common/common_mode.ts | 4 + .../ark_compiler/common/ob_config_resolver.ts | 7 + .../ark_compiler/common/process_ark_config.ts | 21 +- .../src/fast_build/ark_compiler/error_code.ts | 7 +- .../ark_compiler/generate_sourcemap.ts | 14 +- .../src/fast_build/ark_compiler/logger.ts | 59 ++ .../ark_compiler/module/module_mode.ts | 7 +- .../ark_compiler/rollup-plugin-gen-abc.ts | 2 + compiler/src/fast_build/ark_compiler/utils.ts | 3 +- .../test/ark_compiler_ut/ark_utils.test.ts | 22 + .../common/bytecode_obfuscatior.test.ts | 164 ++++ .../common/process_ark_config.test.ts | 11 +- .../mock/rollup_mock/path_config.ts | 7 +- .../byte_obfuscation_enable.txt | 10 + 17 files changed, 1081 insertions(+), 16 deletions(-) create mode 100644 compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts create mode 100644 compiler/test/ark_compiler_ut/common/bytecode_obfuscatior.test.ts create mode 100644 compiler/test/ark_compiler_ut/testdata/bytecode_obfuscation/byte_obfuscation_enable.txt diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index 59e9cbf18..7cb7d4c7c 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -582,7 +582,20 @@ export interface ModuleInfo { export async function writeObfuscatedSourceCode(moduleInfo: ModuleInfo, logger: Function | Object, projectConfig: Object, rollupNewSourceMaps: Object = {}): Promise { - if (compileToolIsRollUp() && projectConfig.arkObfuscator) { + /** + * Obfuscation mode rules: + * - When isArkguardEnabled=true (source code obfuscation): Obfuscate ALL files + * - When isBytecodeObfEnabled=true (bytecode obfuscation): Only decl files will be obfuscated + * - These two flags are mutually exclusive (only one can be true at a time) + */ + let shouldSkipObfuscation = false; + if (projectConfig.isBytecodeObfEnabled) { + shouldSkipObfuscation = !/\.d\.e?ts$/.test(moduleInfo.buildFilePath); + } + + const isObfuscatorEnabled = projectConfig.arkObfuscator && + (projectConfig.isArkguardEnabled || !shouldSkipObfuscation); + if (compileToolIsRollUp() && isObfuscatorEnabled) { startFilesEvent(moduleInfo.buildFilePath); const recordInfo = MemoryMonitor.recordStage(MemoryDefine.WRITE_OBFUSCATED_SOURCE_CODE); const previousStageSourceMap: sourceMap.RawSourceMap | undefined = getPreviousStageSourceMap(moduleInfo, rollupNewSourceMaps); @@ -711,8 +724,15 @@ export async function writeArkguardObfuscatedSourceCode(moduleInfo: ModuleInfo, writeObfuscatedFile(newFilePath, mixedInfo.content ?? ''); } - -export function tryMangleFileName(filePath: string, projectConfig: Object, originalFilePath: string): string { +/** + * This function will be called when obfuscating sourceFile and declaration file. + * Declaration file is not affected by bytecode obfuscation. + * When bytecode obfuscation is enabel, the name of sourceFile will not be obfuscated. + * Because harFilesRecord is collected in this function + * This parameter is added to process sourceFile and return early only when bytecode obfuscation is turned on. + * It does not affect the original call effect. + */ +export function tryMangleFileName(filePath: string, projectConfig: Object, originalFilePath: string, skipObf: boolean = false): string { originalFilePath = toUnixPath(originalFilePath); let isOhModule = isPackageModulesFile(originalFilePath, projectConfig); let genFileInHar: GeneratedFileInHar = harFilesRecord.get(originalFilePath); @@ -720,7 +740,9 @@ export function tryMangleFileName(filePath: string, projectConfig: Object, origi genFileInHar = { sourcePath: originalFilePath }; harFilesRecord.set(originalFilePath, genFileInHar); } - + if (skipObf) { + return filePath; + } if (projectConfig.obfuscationMergedObConfig?.options?.enableFileNameObfuscation && !isOhModule) { const mangledFilePath: string = mangleFilePath(filePath); if ((/\.d\.e?ts$/).test(filePath)) { diff --git a/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts new file mode 100644 index 000000000..cae8b798d --- /dev/null +++ b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts @@ -0,0 +1,707 @@ +/* + * 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 childProcess from 'child_process'; +import path from 'path'; +import fs from 'fs'; +import { + FILESINFO_TXT, + MODULES_ABC, + SOURCEMAPS +} from '../../pre_define'; +import { + mkDir, + writeFileSync +} from '../../utils'; +import { + ES_ANNOTATIONS, + SOURCEMAPS_JSON, + WIDGETS_ABC, + yellow, + DECORATOR_WHITE_LIST, + BYTECODE_OBFUSCATION_PROPERTY_WHITE_LIST, + IDENTIFIER_CACHE, + MEMBER_METHOD_CACHE +} from './common/ark_define'; +import { + ReservedNameInfo, + separateUniversalReservedItem, + UnobfuscationCollections, +} from 'arkguard'; +import { + SourceMapSegmentObj, + decodeSourcemap, + SourceMapLink, + Source +} from 'arkguard/lib/utils/SourceMapMergingUtil'; +import { MergedConfig } from './common/ob_config_resolver'; +import { ModuleInfo } from './module/module_mode'; +import { initArkConfig } from './common/process_ark_config'; +import esInfo from 'arkguard/lib/configs/preset/es_reserved_properties.json'; +import { + CommonLogger, + LogData, + LogDataFactory +} from './logger'; +import { + ArkTSErrorDescription, + ErrorCode +} from './error_code'; +import { FILE_WHITE_LISTS } from 'arkguard/lib/utils/ProjectCollections'; +import { + FileKeepInfo, + FileReservedInfo +} from 'arkguard/lib/utils/ProjectCollections'; + +const FILE_NAME_CACHE: string = 'FileNameCache'; +const OBF_NAME_MAP: string = 'ObfNameMap'; +const PROPERTY_CACHE: string = 'ProPertyCache'; +const ENTRY_PACKAGE_INFO: string = 'entryPackageInfo'; +const COMPILE_SDK_VERSION: string = 'compileSdkVersion'; + +export class BytecodeObfuscator { + public static enable = false; + private static instance: BytecodeObfuscator | undefined = undefined; + public cmdArgs: string[]; + private projectConfig: Object; + private logger: Object; + private originDir: string; + private obfDir: string; + private obfuscationCacheDir: string; + private bytecodeObfuscateConfig: BytecodeObfuscationConfig; + private debugging: boolean; + private enhanced: boolean; + private arkConfig: ArkConfig; + private configPath: string; + private nameCachePath: string; + private backupSourceMapPath: string; + + constructor(share: Object, arkProjectConfig: Object) { + this.projectConfig = Object.assign(arkProjectConfig, share.projectConfig); + const rollup = { + share: share, + }; + this.logger = CommonLogger.getInstance(rollup); + this.obfuscationCacheDir = this.projectConfig.obfuscationOptions.obfuscationCacheDir; + this.originDir = path.join(this.obfuscationCacheDir, 'origin'); + this.obfDir = path.join(this.obfuscationCacheDir, 'obf'); + this.configPath = path.join(this.obfuscationCacheDir, 'config.json'); + this.backupSourceMapPath = path.join(this.originDir, SOURCEMAPS_JSON); + /** + * When enhanced == true, + * a bytecode har will be obfuscated when it is referenced by HAP, + * but it is not obfuscated by default + */ + this.enhanced = false; + this.debugging = arkProjectConfig.obfuscationMergedObConfig?.options.bytecodeObf?.debugging; + this.arkConfig = initArkConfig(this.projectConfig); + this.cmdArgs = []; + } + + public static cleanBcObfuscatorObject(): void { + if (this.instance) { + this.instance = undefined; + } + if (this.enable) { + this.enable = null; + } + } + + static initForTest(share: Object): void { + if (!share.arkProjectConfig.isBytecodeObfEnabled) { + this.enable = false; + return; + } + this.enable = true; + BytecodeObfuscator.instance = new BytecodeObfuscator(share, share.arkProjectConfig); + BytecodeObfuscator.instance.bytecodeObfuscateConfig = + new BytecodeObfuscationConfig(share, share.arkProjectConfig); + } + + static init(share: Object, arkProjectConfig: Object): void { + if (!arkProjectConfig.isBytecodeObfEnabled) { + this.enable = false; + return; + } + this.enable = true; + BytecodeObfuscator.instance = new BytecodeObfuscator(share, arkProjectConfig); + if (!isVersionCompatible( + BytecodeObfuscator.instance.projectConfig.compatibleSdkVersion, + BytecodeObfuscator.instance.projectConfig.compatibleSdkVersionStage)) { + const errInfo: LogData = LogDataFactory.newInstance( + ErrorCode.BYTECODE_OBFUSCATION_UNSUPPORT_COMPATIBLESDKVERSION, + ArkTSErrorDescription, + `bytecodeObfuscation only can be used in the beta3 version of API 12 or higher version`, + '', + [ + 'Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json', + 'if compatibleSdkVersion is set to API 12,then compatibleSdkVersionStage needs to be configured as beta3', + ] + ); + BytecodeObfuscator.instance.logger.printErrorAndExit(errInfo); + } + if (!fs.existsSync(BytecodeObfuscator.instance.originDir)) { + mkDir(BytecodeObfuscator.instance.originDir); + } + if (!fs.existsSync(BytecodeObfuscator.instance.obfDir)) { + mkDir(BytecodeObfuscator.instance.obfDir); + } + + BytecodeObfuscator.instance.bytecodeObfuscateConfig = + new BytecodeObfuscationConfig(share, arkProjectConfig); + this.getInstance().getSystemApiConfigsByCache(); + this.getInstance().bytecodeObfuscateConfig.addReservedNames(collectReservedLangForProperty()); + } + + static getInstance(): BytecodeObfuscator { + return BytecodeObfuscator.instance; + } + + public removeStructProp(): void { + if (!BytecodeObfuscator.enable || + !this.bytecodeObfuscateConfig.obfuscationRules.enableDecoratorObfuscation) { + return; + } + + const reservedNames = this.bytecodeObfuscateConfig.getReservedNames(); + + for (const item of [...UnobfuscationCollections.reservedStruct]) { + if (!reservedNames?.has(item)) { + UnobfuscationCollections.reservedStruct.delete(item); + } + } + } + + public execute(moduleInfos: Map): void { + if (!BytecodeObfuscator.enable) { + return; + } + this.collectSkipModuleName(); + this.convertAbstractPathToRecordName(moduleInfos); + this.collectWhiteList(); + const fileWhiteListsCachePath = path.join(this.obfuscationCacheDir, FILE_WHITE_LISTS); + this.collectPropertyBySourceScan(fileWhiteListsCachePath); + fs.writeFileSync(this.configPath, JSON.stringify(this.bytecodeObfuscateConfig, (key, value) => { + if (value instanceof Set) { + return Array.from(value); + } + return value; + }, 2)); + this.generateObfCmd(); + this.createWarnings(); + const outPutABC: string = this.projectConfig.widgetCompile ? WIDGETS_ABC : MODULES_ABC; + const abcPath = path.join(this.projectConfig.aceModuleBuild, outPutABC); + //backup abc file + fs.copyFileSync(abcPath, this.bytecodeObfuscateConfig.abcFilePath); + const result = childProcess.spawnSync(this.arkConfig.bcObfuscatorPath, this.cmdArgs, { + env: { ...process.env } + }); + if (result.status !== 0) { + const stderrString = result.stderr ? result.stderr.toString() : ''; + const errInfo: LogData = LogDataFactory.newInstanceFromBytecodeObfuscation(stderrString, result.status); + BytecodeObfuscator.instance.logger.printErrorAndExit(errInfo); + } + fs.copyFileSync(this.bytecodeObfuscateConfig.obfAbcFilePath, abcPath); + if (this.projectConfig.widgetCompile) { + return; + } + this.updateAfterObfuscation(); + } + + private collectSkipModuleName(): void { + const matchedPaths = new Set(); + + // collect keep bytecode har module pkgName + const regex = /\/oh_modules\/([^/]+)$/; + this.projectConfig.obfuscationMergedObConfig.keepSourceOfPaths.forEach(item => { + const match = item.match(regex); + if (match) { + matchedPaths.add(match[1]); + } + }); + // collect remote har pkgName,which shouldn't to be obfuscated + this.projectConfig.byteCodeHarInfo && + Object.entries(this.projectConfig.byteCodeHarInfo).forEach(([key, value]) => { + if (!isVersionCompatible(value?.compatibleSdkVersion, null) || !this.enhanced || matchedPaths.has(key)) { + this.bytecodeObfuscateConfig.addSkippedRemoteHarList(key); + this.projectConfig.byteCodeHarToDependencyKeys?.get(key)?.forEach(dependentModule => { + this.bytecodeObfuscateConfig.addSkippedRemoteHarList(dependentModule); + }); + } + }); + } + + public convertAbstractPathToRecordName(moduleInfos: Map): void { + if (this.bytecodeObfuscateConfig.obfuscationRules.keepOptions && + this.bytecodeObfuscateConfig.obfuscationRules.keepOptions.keepPaths.length > 0) { + const convertedPath: Set = new Set(); + this.bytecodeObfuscateConfig.obfuscationRules.keepOptions.keepPaths.forEach(path => { + if (moduleInfos.get(path)) { + convertedPath.add(moduleInfos.get(path).recordName); + } + }); + this.bytecodeObfuscateConfig.addKeepPaths(convertedPath); + } + } + + public generateObfCmd(): void { + if (this.debugging) { + this.cmdArgs.push('--debug'); + this.cmdArgs.push('--debug-file'); + const defaultDebugLogPath: string = path.join(this.obfuscationCacheDir, 'debug.log'); + if (!fs.existsSync(defaultDebugLogPath)) { + writeFileSync(defaultDebugLogPath, ''); + } + this.cmdArgs.push(defaultDebugLogPath); + } + this.cmdArgs.push(this.configPath); + } + + private createWarnings(): void { + this.logger.warn( + yellow, + 'ArkTS:WARN When enabling bytecode obfuscation, the following exceptions may occur:\n' + + '1. When enabling fileName, export, and property obfuscation, and a HAR is depended on by both HAP and HSP,\n' + + 'this scenario may result in the error:' + + ' \"The requested module \'xxxx\' does not provide an export name \'x\' which is imported by \'xxxxx\'.\"' + ); + + if (this.enhanced) { + this.logger.warn( + yellow, + 'ArkTS:WARN When enabling the enhanced option, the following exceptions may occur:\n' + + '1. When enabling export and property obfuscation, and a HAR is depended on by both HAP and HSP,\n' + + ' this scenario may result in the error:' + + ' \"The requested module \'xxxx\' does not provide an export name \'x\' which is imported by \'xxxxx\'.\"' + ); + } + } + + private updateAfterObfuscation(): void { + let nameCache: Object; + let sourceMap: Object; + + this.nameCachePath = this.bytecodeObfuscateConfig.obfuscationRules.printNameCache || + this.bytecodeObfuscateConfig.defaultNameCachePath; + + const sourceMapPath = path.join(this.projectConfig.cachePath, SOURCEMAPS); + const souceMapJsonPath = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON); + nameCache = JSON.parse(fs.readFileSync(this.nameCachePath, 'utf-8')); + sourceMap = JSON.parse(fs.readFileSync(sourceMapPath, 'utf-8')); + //copy origin sourceMaps for Incremental compilation + if (fs.existsSync(souceMapJsonPath)) { + fs.copyFileSync(souceMapJsonPath, this.backupSourceMapPath); + } + const nameMapping: Map = generateMapping(nameCache); + const sourceMapUpdated: Object = updateSourceMap(sourceMap, nameMapping); + fs.writeFileSync(sourceMapPath, JSON.stringify(sourceMapUpdated, null, 2)); + fs.writeFileSync(souceMapJsonPath, JSON.stringify(sourceMapUpdated, null, 2)); + const nameCacheUpdated: Object = this.bytecodeObfuscateConfig.obfuscationRules.compact ? + nameCache : processNameCache(nameCache, sourceMap); + fs.writeFileSync(this.nameCachePath, JSON.stringify(nameCacheUpdated, null, 2)); + } + + private collectWhiteList(): void { + this.bytecodeObfuscateConfig.addReservedNames(ES_ANNOTATIONS); + this.bytecodeObfuscateConfig.addReservedProperties(BYTECODE_OBFUSCATION_PROPERTY_WHITE_LIST); + } + + public getBackupSourceMapPath(): string { + return this ? this.backupSourceMapPath : ''; + } + + public setKeepSourceOfPaths(keepPath: Set): void { + this.bytecodeObfuscateConfig.addKeepPaths(keepPath); + } + + public isDecoratorObfuscationEnabled(): boolean { + return this.bytecodeObfuscateConfig?.obfuscationRules?.enableDecoratorObfuscation; + } + + private getSystemApiConfigsByCache(): void { + const uniqueNames = new Set([ + ...(UnobfuscationCollections.reservedSdkApiForLocal || []), + ...(UnobfuscationCollections.reservedSdkApiForGlobal || []), + ...(UnobfuscationCollections.reservedSdkApiForProp || []) + ]); + this.bytecodeObfuscateConfig.addReservedNames(uniqueNames); + } + + collectPropertyBySourceScan(fileWhiteListsCachePath: string): void { + const fileContent = fs.readFileSync(fileWhiteListsCachePath, 'utf8'); + const parsed: Object = JSON.parse(fileContent); + const allValues: string[] = []; + + Object.values(parsed).forEach(fileData => { + this.processFileKeepInfo(fileData.fileKeepInfo, allValues); + this.processFileReservedInfo(fileData.fileReservedInfo, allValues); + // only collect decorator when decorator Obfuscation is disabled + if (!this.isDecoratorObfuscationEnabled()) { + this.processDecoratorMap(fileData.bytecodeObfuscateKeepInfo?.decoratorMap); + } + }); + + this.bytecodeObfuscateConfig.addReservedNames(allValues); + } + + private processFileKeepInfo(fileKeepInfo: FileKeepInfo, allValues: string[]): void { + if (!fileKeepInfo) { + return; + } + + let { + keepSymbol, + keepAsConsumer, + structProperties, + enumProperties, + stringProperties, + exported, + } = fileKeepInfo; + + const rules = this.bytecodeObfuscateConfig.obfuscationRules; + if (rules.enableDecoratorObfuscation) { + const reservedNames = this.bytecodeObfuscateConfig.getReservedNames(); + structProperties = new Set( + Array.from(structProperties || []).filter(item => reservedNames?.has(item)) + ); + } + + const arrayProperties = [ + keepSymbol?.propertyNames, + keepSymbol?.globalNames, + keepAsConsumer?.propertyNames, + keepAsConsumer?.globalNames, + exported?.propertyNames, + exported?.globalNames, + structProperties, + enumProperties, + stringProperties + ]; + + arrayProperties.forEach(arr => { + if (arr) { + allValues.push(...arr); + } + }); + } + + private processFileReservedInfo(fileReservedInfo: FileReservedInfo, allValues: string[]): void { + if (!fileReservedInfo) { + return; + } + + const { enumProperties, propertyParams } = fileReservedInfo; + + [enumProperties, propertyParams].forEach(props => { + if (props) { + allValues.push(...props); + } + }); + } + + private processDecoratorMap(decoratorMap: Object): void { + if (!decoratorMap) { + return; + } + for (const [decoratorName, propertyList] of Object.entries(decoratorMap)) { + const processedList = new Set( + [...propertyList].flatMap(name => + name.includes('.') ? name.split('.') : [name] + ) + ); + + this.bytecodeObfuscateConfig.addReservedNames(processedList); + processedList.forEach(name => { + UnobfuscationCollections.reservedSdkApiForGlobal.add(name); + }); + } + } +} + +export class BytecodeObfuscationConfig { + abcFilePath: string; + obfAbcFilePath: string; + obfPaFilePath: string; + compileSdkVersion: string; + targetApiVersion: number; + targetApiSubVersion: string; + filesInfoPath: string; + entryPackageInfo: string; + sourceMapsPath: string; + defaultNameCachePath: string; + skippedRemoteHarList: Set; + useNormalizedOHMUrl: boolean; + obfuscationRules: { + disableObfuscation: boolean; + compact: boolean; + enableExportObfuscation: boolean; + enableRemoveLog: boolean; + enableDecoratorObfuscation: boolean; + printNameCache: string; + applyNameCache: string; + reservedNames: Set; + propertyObfuscation: { + enable: boolean; + reservedProperties: Set; + universalReservedProperties: Set; + }; + toplevelObfuscation: { + enable: boolean; + reservedToplevelNames: Set; + universalReservedToplevelNames: Set; + }; + fileNameObfuscation: { + enable: boolean; + reservedFileNames: Set; + universalReservedFileNames: Set; + reservedRemoteHarPkgNames: Set; + }; + keepOptions: { + enable: boolean; + keepPaths: Set; + }; + }; + + constructor(share: Object, arkProjectConfig: Object) { + const mergedObConfig: MergedConfig = arkProjectConfig.obfuscationMergedObConfig; + const obfuscationCacheDir: string = share.projectConfig.obfuscationOptions.obfuscationCacheDir; + const originDir: string = path.join(obfuscationCacheDir, 'origin'); + const obfDir: string = path.join(obfuscationCacheDir, 'obf'); + const outPutABC: string = share.projectConfig.widgetCompile ? WIDGETS_ABC : MODULES_ABC; + this.abcFilePath = path.join(originDir, outPutABC); + this.obfAbcFilePath = path.join(obfDir, outPutABC); + this.targetApiVersion = share.projectConfig.compatibleSdkVersion; + this.targetApiSubVersion = share.projectConfig.compatibleSdkVersionStage; + this.filesInfoPath = path.join(share.projectConfig.cachePath, FILESINFO_TXT); + this.sourceMapsPath = path.join(share.projectConfig.cachePath, SOURCEMAPS); + this.useNormalizedOHMUrl = share.projectConfig.useNormalizedOHMUrl; + this.compileSdkVersion = share.projectConfig.etsLoaderVersion; + this.entryPackageInfo = arkProjectConfig.entryPackageInfo; + this.defaultNameCachePath = path.join(obfuscationCacheDir, 'nameCache.json'); + this.skippedRemoteHarList = new Set(); + if (mergedObConfig.options.bytecodeObf.debugging) { + const parsedPath = path.parse(this.obfAbcFilePath); + this.obfPaFilePath = path.join(parsedPath.dir, `${parsedPath.name}.pa`); + } else { + this.obfPaFilePath = ''; + } + const { options, reservedNames, reservedPropertyNames, universalReservedPropertyNames, + reservedGlobalNames, universalReservedGlobalNames, reservedFileNames, + keepSourceOfPaths } = mergedObConfig; + const fileNameReservedInfo: ReservedNameInfo = processReservedFileNames(reservedFileNames); + + this.obfuscationRules = { + disableObfuscation: false, + compact: options.compact, + enableExportObfuscation: options.enableExportObfuscation, + enableRemoveLog: options.removeLog, + enableDecoratorObfuscation: false, + printNameCache: options.printNameCache, + applyNameCache: options.applyNameCache, + reservedNames: new Set(reservedNames), + propertyObfuscation: { + enable: options.enablePropertyObfuscation, + reservedProperties: new Set(reservedPropertyNames), + universalReservedProperties: new Set( + universalReservedPropertyNames?.map(regexp => regexp.toString()) + ) + }, + toplevelObfuscation: { + enable: options.enableToplevelObfuscation, + reservedToplevelNames: new Set(reservedGlobalNames), + universalReservedToplevelNames: new Set( + universalReservedGlobalNames?.map(regexp => regexp.toString()) || [] + ) + + }, + fileNameObfuscation: { + enable: options.enableFileNameObfuscation, + reservedFileNames: new Set(fileNameReservedInfo.specificReservedArray), + universalReservedFileNames: new Set( + fileNameReservedInfo.universalReservedArray?.map(regexp => regexp.toString()) || [] + ) + , + reservedRemoteHarPkgNames: new Set() + }, + keepOptions: { + enable: keepSourceOfPaths.length > 0, + keepPaths: new Set(keepSourceOfPaths), + } + }; + } + + getReservedNames(): Set { + return this.obfuscationRules.reservedNames; + } + + addToSet(set: Set, values: string | string[] | Set): void { + if (typeof values === 'string') { + set.add(values); + } else { + values.forEach(value => set.add(value)); + } + } + + addReservedProperties(values: string | string[] | Set): void { + this.addToSet(this.obfuscationRules.propertyObfuscation.reservedProperties, values); + } + + addReservedNames(values: string | string[] | Set): void { + this.addToSet(this.obfuscationRules.reservedNames, values); + } + + addSkippedRemoteHarList(values: string | string[] | Set): void { + this.addToSet(this.skippedRemoteHarList, values); + } + + addKeepPaths(values: string | string[] | Set): void { + this.addToSet(this.obfuscationRules.keepOptions.keepPaths, values); + } +} + +function processReservedFileNames(reservedFileNames: string[]): ReservedNameInfo { + const fileNameReservedInfo: ReservedNameInfo = separateUniversalReservedItem(reservedFileNames, false); + fileNameReservedInfo.specificReservedArray = fileNameReservedInfo.specificReservedArray.map(fileName => { + return fileName.replace(/^(?!\.)[^.]+\.[^.]+$/, match => { + return match.replace(/\.[^.]+$/, ''); + }); + }); + return fileNameReservedInfo; +} + +function collectReservedLangForProperty(): Set { + let languageSet: Set = new Set; + for (const key of Object.keys(esInfo)) { + const valueArray = esInfo[key]; + valueArray.forEach((element: string) => { + languageSet.add(element); + }); + } + return languageSet; +} + +function isVersionCompatible( + compatibleSdkVersion: number | null | undefined, + compatibleSdkVersionStage: string | null | undefined +): boolean { + if (compatibleSdkVersion == null) { + return false; + } + + if (compatibleSdkVersion >= 13) { + return true; + } + + if (compatibleSdkVersion === 12) { + return compatibleSdkVersionStage === 'beta3'; + } + + return false; +} + +function generateMapping(nameCache: Object): Map { + const whiteList = new Set([ + FILE_NAME_CACHE, + OBF_NAME_MAP, + PROPERTY_CACHE, + ENTRY_PACKAGE_INFO, + COMPILE_SDK_VERSION + ]); + const obfSourceFileMapping = new Map(); + + Object.entries(nameCache).forEach(([key, value]) => { + if (!whiteList.has(key)) { + const { ObfSourceFile: obfSourceFile, OriSourceFile: originSouceFile } = value; + if (obfSourceFile && originSouceFile) { + obfSourceFileMapping.set(originSouceFile, obfSourceFile); + } + } + }); + return obfSourceFileMapping; +} + +function updateSourceMap(sourceMap: Object, obfSourceFileMapping: Map): Object { + const newSourceMap: Object = {}; + Object.entries(sourceMap).forEach(([key, value]) => { + const obfSourceKey = obfSourceFileMapping.get(key) || key; + newSourceMap[obfSourceKey] = value; + }); + return newSourceMap; +} + +function processNameCache(nameCache: Object, sourceMap: Object): Object { + const nameCacheUpdated = {}; + const entries = Object.entries(nameCache); + for (let i = 0; i < entries.length; i++) { + const [nameCacheKey, nameCacheValue] = entries[i]; + processNameCacheEntry(nameCacheKey, nameCacheValue, sourceMap, nameCacheUpdated); + } + return nameCacheUpdated; +} + +function processNameCacheEntry(nameCacheKey: string, nameCacheValue: Object, sourceMap: Object, nameCacheUpdated: Object): void { + if (!nameCacheValue.OriSourceFile) { + nameCacheUpdated[nameCacheKey] = nameCacheValue; + return; + } + const sourceMapKey = nameCacheValue.OriSourceFile; + const sourcemap = sourceMap[sourceMapKey]; + if (!sourcemap) { + return; + } + const sourceFileName = sourcemap.sources?.length === 1 ? sourcemap.sources[0] : ''; + const source = new Source(sourceFileName, null); + const decodedSourceMap = decodeSourcemap(sourcemap); + const sourceMapLink = new SourceMapLink(decodedSourceMap, [source]); + + if (!nameCacheUpdated[nameCacheKey]) { + nameCacheUpdated[nameCacheKey] = {}; + } + for (const [itemKey, itemValue] of Object.entries(nameCacheValue)) { + if (itemKey !== IDENTIFIER_CACHE && itemKey !== MEMBER_METHOD_CACHE) { + nameCacheUpdated[nameCacheKey][itemKey] = itemValue; + continue; + } + processItemKey(nameCacheKey, itemKey, itemValue, nameCacheUpdated, sourceMapLink); + } +} +/** + + * @param itemKey IdentifierCache || MemberMethodCache + * @param itemValue + */ +function processItemKey(nameCacheKey, itemKey, itemValue, nameCacheUpdated, sourceMapLink): void { + if (!nameCacheUpdated[nameCacheKey][itemKey]) { + nameCacheUpdated[nameCacheKey][itemKey] = {}; + } + /** + * key=>originName eg.#fun1:3:24 + * value => obfuscated Name + */ + for (const [key, value] of Object.entries(itemValue)) { + const [scopeName, oldStartLine, oldEndLine] = key.split(':'); + const startPosition: SourceMapSegmentObj = sourceMapLink.traceSegment(Number(oldStartLine) - 1, 0, ''); + const endPosition: SourceMapSegmentObj = sourceMapLink.traceSegment( + Number(oldEndLine) - 1, 0, ''); + if (!startPosition || !endPosition) { + nameCacheUpdated[nameCacheKey][itemKey][key] = value; + continue; + } + const startLine = startPosition.line + 1; + const endLine = endPosition.line + 1; + const newKey = `${scopeName}:${startLine}:${endLine}`; + nameCacheUpdated[nameCacheKey][itemKey][newKey] = value; + } +} \ No newline at end of file diff --git a/compiler/src/fast_build/ark_compiler/common/ark_define.ts b/compiler/src/fast_build/ark_compiler/common/ark_define.ts index e87ba8573..385d49f18 100644 --- a/compiler/src/fast_build/ark_compiler/common/ark_define.ts +++ b/compiler/src/fast_build/ark_compiler/common/ark_define.ts @@ -91,6 +91,7 @@ export const SCRIPT: string = 'script'; export const SRC_MAIN: string = 'src/main'; export const GEN_ABC_PLUGIN_NAME: string = 'Gen_Abc_Plugin'; export const OBFUSCATION_TOOL: string = 'Obfuscation_Tool'; +export const BYTECODE_OBFUSCATOR_INIT = 'Bytecode_obfuscator_init'; export const SUCCESS: number = 0; export const FAIL: number = 1; @@ -121,3 +122,24 @@ export const USE_SHARED_COMMENT: string = '// "use shared"'; export const SEPARATOR_BITWISE_AND: string = '&'; export const SEPARATOR_AT: string = '@'; export const SEPARATOR_SLASH: string = '/'; + +export const ES_ANNOTATIONS = [ + '_ESConcurrentModuleRequestsAnnotation', + '_ESSlotNumberAnnotation', + '_ESAnnotation' +]; + +export const DECORATOR_WHITE_LIST = [ + 'Monitor', + 'Track', + 'Trace', +]; + +export const BYTECODE_OBFUSCATION_PROPERTY_WHITE_LIST = [ + 'componentClass', + 'getReuseId', + 'resetStateVarsOnReuse' +]; + +export const IDENTIFIER_CACHE = 'IdentifierCache'; +export const MEMBER_METHOD_CACHE = 'MemberMethodCache'; \ No newline at end of file diff --git a/compiler/src/fast_build/ark_compiler/common/common_mode.ts b/compiler/src/fast_build/ark_compiler/common/common_mode.ts index 81eb41319..7edb9b764 100644 --- a/compiler/src/fast_build/ark_compiler/common/common_mode.ts +++ b/compiler/src/fast_build/ark_compiler/common/common_mode.ts @@ -59,6 +59,8 @@ export abstract class CommonMode { genAbcScriptPath: string; triggerAsync: Object; triggerEndSignal: Object; + isArkguardEnabled: boolean; + isBytecodeObfEnabled: boolean; constructor(rollupObject: Object) { this.projectConfig = Object.assign(rollupObject.share.arkProjectConfig, rollupObject.share.projectConfig); @@ -74,6 +76,8 @@ export abstract class CommonMode { // If the child process throws an error by calling throwArkTsCompilerError(), IDE will reset the counting state. this.triggerAsync = rollupObject.async; this.triggerEndSignal = rollupObject.signal; + this.isArkguardEnabled = rollupObject.share.arkProjectConfig.isArkguardEnabled; + this.isBytecodeObfEnabled = rollupObject.share.arkProjectConfig.isBytecodeObfEnabled; } initCmdEnv() { diff --git a/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts b/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts index b352cfc20..8da204eff 100644 --- a/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts +++ b/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts @@ -70,6 +70,7 @@ import { createAndStartEvent, stopEvent } from '../../../performance'; +import { BytecodeObfuscator } from '../bytecode_obfuscator'; export { collectResevedFileNameInIDEConfig, // For running unit test. @@ -193,6 +194,9 @@ export function handleKeepFilesAndGetDependencies(mergedObConfig: MergedConfig, const excludePaths = mergedObConfig.excludePathSet; let allKeepFiles: Set = collectAllKeepFiles(keepPaths, excludePaths); arkObfuscator.setKeepSourceOfPaths(allKeepFiles); + if (BytecodeObfuscator.enable) { + BytecodeObfuscator.getInstance().setKeepSourceOfPaths(allKeepFiles); + } const keepFilesAndDependencies: Set = getFileNamesForScanningWhitelist(mergedObConfig, allKeepFiles, projectConfig); sourceFileDependencies.clear(); return keepFilesAndDependencies; @@ -380,6 +384,9 @@ export function obfuscationPreprocess( ); updateIncrementalCaches(sourceProjectConfig.arkObfuscator); + if (BytecodeObfuscator.enable) { + BytecodeObfuscator.getInstance().removeStructProp(); + } ProjectCollections.clearProjectWhiteListManager(); } } diff --git a/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts b/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts index 1c5f8c513..a77916061 100644 --- a/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts +++ b/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts @@ -54,6 +54,7 @@ import type { ReseverdSetForArkguard } from 'arkguard'; import { MemoryMonitor } from '../../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../../meomry_monitor/memory_define'; import { initObfLogger, printObfLogger } from './ob_config_resolver'; +import { BytecodeObfuscator } from '../bytecode_obfuscator'; type ArkConfig = { arkRootPath: string; @@ -62,6 +63,7 @@ type ArkConfig = { mergeAbcPath: string; es2abcPath: string; aotCompilerPath: string; + bcObfuscatorPath: string; nodePath: string; isDebug: boolean; isBranchElimination: boolean; @@ -80,6 +82,7 @@ export function initArkConfig(projectConfig: Object): ArkConfig { mergeAbcPath: '', es2abcPath: '', aotCompilerPath: '', + bcObfuscatorPath: '', nodePath: '', isDebug: false, isBranchElimination: false, @@ -196,6 +199,7 @@ export function initArkProjectConfig(share: Object): Object { initObfLogger(share); initObfuscationConfig(projectConfig, arkProjectConfig, printObfLogger); endFilesEvent(EventList.OBFUSCATION_INITIALIZATION, performancePrinter.timeSumPrinter); + BytecodeObfuscator.init(share, arkProjectConfig); } else { // Set performance printer to undefined in case we cannot disable it without obfuscation initialization blockPrinter(); @@ -249,12 +253,20 @@ function initTerserConfig(projectConfig: any, logger: any, mergedObConfig: Merge } // Scan the source code of project and libraries to collect whitelists. -export function readProjectAndLibsSource(allFiles: Set, mergedObConfig: MergedConfig, arkObfuscator: ArkObfuscator, isHarCompiled: boolean, - keepFilesAndDependencies: Set): void { +export function readProjectAndLibsSource( + allFiles: Set, + mergedObConfig: MergedConfig, + arkObfuscator: ArkObfuscator, + isHarCompiled: boolean, + keepFilesAndDependencies: Set +): void { if (mergedObConfig?.options === undefined || mergedObConfig.options.disableObfuscation || allFiles.size === 0) { return; } + const obfOptions = mergedObConfig.options; + const enableDecoratorScan = + BytecodeObfuscator.enable && !BytecodeObfuscator.getInstance().isDecoratorObfuscationEnabled(); let projectAndLibs: ReseverdSetForArkguard = readProjectPropertiesByCollectedPaths(allFiles, { mNameObfuscation: { @@ -269,7 +281,8 @@ export function readProjectAndLibsSource(allFiles: Set, mergedObConfig: mKeepSourceOfPaths: new Set(), mkeepFilesAndDependencies: keepFilesAndDependencies, } - }, isHarCompiled); + }, isHarCompiled, + enableDecoratorScan); if (obfOptions.enablePropertyObfuscation) { arkObfuscator.addReservedSetForPropertyObf(projectAndLibs); } @@ -290,6 +303,7 @@ function processPlatformInfo(arkConfig: ArkConfig): void { arkConfig.mergeAbcPath = path.join(arkPlatformPath, 'bin', 'merge_abc.exe'); arkConfig.js2abcPath = path.join(arkPlatformPath, 'bin', 'js2abc.exe'); arkConfig.aotCompilerPath = path.join(arkPlatformPath, 'bin', 'ark_aot_compiler.exe'); + arkConfig.bcObfuscatorPath = path.join(arkPlatformPath, 'bin', 'panda_guard.exe'); return; } if (isLinux() || isMac()) { @@ -298,6 +312,7 @@ function processPlatformInfo(arkConfig: ArkConfig): void { arkConfig.mergeAbcPath = path.join(arkPlatformPath, 'bin', 'merge_abc'); arkConfig.js2abcPath = path.join(arkPlatformPath, 'bin', 'js2abc'); arkConfig.aotCompilerPath = path.join(arkPlatformPath, 'bin', 'ark_aot_compiler'); + arkConfig.bcObfuscatorPath = path.join(arkPlatformPath, 'bin', 'panda_guard'); return; } if (isHarmonyOs()) { diff --git a/compiler/src/fast_build/ark_compiler/error_code.ts b/compiler/src/fast_build/ark_compiler/error_code.ts index b74ab275e..9b1a594a5 100644 --- a/compiler/src/fast_build/ark_compiler/error_code.ts +++ b/compiler/src/fast_build/ark_compiler/error_code.ts @@ -61,7 +61,12 @@ export enum ErrorCode { // CONSTANTS FOR ES2ABC ERROR CODE ES2ABC_SYNTAX_ERROR_ERROR_CODE = '10705000', - ES2ABC_PATCH_FIX_ERROR_ERROR_CODE = '10706001' + ES2ABC_PATCH_FIX_ERROR_ERROR_CODE = '10706001', + + //BYTECODE OBFUSCATION ERROR CODE + BYTECODE_OBFUSCATION_UNSUPPORT_COMPATIBLESDKVERSION = '11306001', + BYTECODE_OBFUSCATION_COMMON_ERROR = '11310001', + ETS2BUNDLE_INTERNAL_ESBYTECODE_OBFUSCATIONABC_SUBPROCESS_START_FAILED = '11310002' } // DESCRIPTION diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index d2c825e17..00ab52a52 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -60,6 +60,7 @@ import { CompileEvent, stopEvent } from '../../performance'; +import { BytecodeObfuscator } from './bytecode_obfuscator'; export class SourceMapGenerator { private static instance: SourceMapGenerator | undefined = undefined; @@ -245,12 +246,19 @@ export class SourceMapGenerator { } let cacheSourceMapObject: Object; - if (!fs.existsSync(this.cacheSourceMapPath)) { cacheSourceMapObject = this.sourceMaps; } else { - cacheSourceMapObject = JSON.parse(fs.readFileSync(this.cacheSourceMapPath).toString()); - + /** + * bytecode obfuscation requires that the input sourceMap must be unobfuscated, + * the sourceMap will be saved in the cache directory before the first bytecode obfuscation, + * and it will as the input for merging sourceMap during incremental compilation. + */ + if (BytecodeObfuscator.enable && fs.existsSync(BytecodeObfuscator.getInstance().getBackupSourceMapPath())) { + cacheSourceMapObject = JSON.parse(fs.readFileSync(BytecodeObfuscator.getInstance().getBackupSourceMapPath()).toString()); + } else { + cacheSourceMapObject = JSON.parse(fs.readFileSync(this.cacheSourceMapPath).toString()); + } // remove unused source files's sourceMap let unusedFiles = []; let compileFileList: Set = new Set(); diff --git a/compiler/src/fast_build/ark_compiler/logger.ts b/compiler/src/fast_build/ark_compiler/logger.ts index 508727613..0add910ee 100644 --- a/compiler/src/fast_build/ark_compiler/logger.ts +++ b/compiler/src/fast_build/ark_compiler/logger.ts @@ -136,6 +136,65 @@ export class LogDataFactory { } return undefined; } + + static newInstanceFromBytecodeObfuscation(errorOutput: string, statusCode: number): LogData | undefined { + const trimmedOutput = errorOutput?.trim(); + if (!trimmedOutput) { + return LogDataFactory.newInstance( + ErrorCode.BYTECODE_OBFUSCATION_COMMON_ERROR, + 'Bytecode program terminated abnormally', + `Status code: ${statusCode}` + ); + } + + const parseErrorLines = (output: string): Record => + output + .split('\n') + .reduce((acc: Record, line) => { + const [key, ...values] = line.split(':').map(part => part.trim()); + return key && values.length ? { ...acc, [key]: values.join(':').trim() } : acc; + }, {}); + + const parsedErrors = parseErrorLines(trimmedOutput); + + const getErrorInfo = (): { + code: ErrorCode; + description: string; + cause: string; + position: string; + solutions: string[]; + details: string; + } => { + if (Object.keys(parsedErrors).length === 0) { + return { + code: ErrorCode.BYTECODE_OBFUSCATION_COMMON_ERROR, + description: trimmedOutput, + cause: '', + position: '', + solutions: [], + details: `Status code: ${statusCode}`, + }; + } + + return { + code: parsedErrors['[ErrorCode]'] ?? ErrorCode.BYTECODE_OBFUSCATION_COMMON_ERROR, + description: parsedErrors['[Description]'] ?? parsedErrors['[Cause]'] ?? 'Unknown error', + cause: parsedErrors['[Cause]'] ?? '', + position: parsedErrors['[Position]'] ?? '', + solutions: parsedErrors['[Solutions]']?.split(',').filter(Boolean) ?? [], + details: `Status code: ${statusCode}`, + }; + }; + + const { code, description, cause, position, solutions, details } = getErrorInfo(); + return LogDataFactory.newInstance( + code, + description, + details ?? cause, + position, + solutions + ); + } } export class LogData { diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index 0d8636ba3..94b827a6c 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -122,6 +122,7 @@ import { processExternalEvents, stopEvent } from '../../../performance'; +import { BytecodeObfuscator } from '../bytecode_obfuscator'; export class ModuleInfo { filePath: string; @@ -554,7 +555,8 @@ export class ModuleMode extends CommonMode { if (this.projectConfig.compatibleSdkVersionStage) { this.cmdArgs.push(`"--target-api-sub-version=${this.projectConfig.compatibleSdkVersionStage}"`); } - if (this.arkConfig.isBranchElimination) { + // when enable branch elimination and bytecode obfuscation will crash + if (this.arkConfig.isBranchElimination && !BytecodeObfuscator.enable) { this.cmdArgs.push('--branch-elimination'); } if (this.projectConfig.transformLib) { @@ -683,9 +685,10 @@ export class ModuleMode extends CommonMode { child.on('close', (code: any) => { if (code === SUCCESS) { stopEvent(eventGenAbc, true); - this.triggerEndSignal(); this.processAotIfNeeded(); processExternalEvents(this.projectConfig, ExternalEventType.ES2ABC, { parentEvent: eventGenAbc, filePath: this.perfReportPath }); + BytecodeObfuscator.enable && BytecodeObfuscator.getInstance().execute(this.moduleInfos); + this.triggerEndSignal(); return; } for (const logData of logDataList) { diff --git a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts index 2a32aaddd..c537de191 100644 --- a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts +++ b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts @@ -32,6 +32,7 @@ import { cleanUpAsyncEvents, CompileEvent } from '../../performance'; +import { BytecodeObfuscator } from './bytecode_obfuscator'; export function genAbc() { return { @@ -80,6 +81,7 @@ export function genAbc() { cleanSharedModuleSet(); CommonLogger.destroyInstance(); cleanUpAsyncEvents(); + BytecodeObfuscator.cleanBcObfuscatorObject(); } }; } diff --git a/compiler/src/fast_build/ark_compiler/utils.ts b/compiler/src/fast_build/ark_compiler/utils.ts index ce12fc949..58306c9b7 100644 --- a/compiler/src/fast_build/ark_compiler/utils.ts +++ b/compiler/src/fast_build/ark_compiler/utils.ts @@ -57,6 +57,7 @@ import { createAndStartEvent, stopEvent } from '../../performance'; +import { BytecodeObfuscator } from './bytecode_obfuscator'; export let hasTsNoCheckOrTsIgnoreFiles: string[] = []; export let compilingEtsOrTsFiles: string[] = []; @@ -182,7 +183,7 @@ export async function writeFileContentToTempDir(id: string, content: string, pro await writeFileContent(id, filePath, content, projectConfig, logger, metaInfo); break; case EXTNAME_JSON: - const newFilePath: string = tryMangleFileName(filePath, projectConfig, id); + const newFilePath: string = tryMangleFileName(filePath, projectConfig, id, projectConfig.isBytecodeObfEnabled); mkdirsSync(path.dirname(newFilePath)); fs.writeFileSync(newFilePath, content ?? ''); break; diff --git a/compiler/test/ark_compiler_ut/ark_utils.test.ts b/compiler/test/ark_compiler_ut/ark_utils.test.ts index baeadd704..404a79eda 100644 --- a/compiler/test/ark_compiler_ut/ark_utils.test.ts +++ b/compiler/test/ark_compiler_ut/ark_utils.test.ts @@ -503,6 +503,28 @@ mocha.describe('test ark_utils file api', function () { expect(result === newFilePath).to.be.true; }); + mocha.it('8-3: test tryMangleFileName when bytecode obfuscation is enabled', async function () { + const filePath = '/mnt/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/release/src/main/ets/entryability/EntryAbility.ts'; + const originalFilePath = '/mnt/application/entry/src/main/ets/entryability/EntryAbility.ets'; + const projectConfig = { + projectRootPath: '/mnt/application', + packageDir: 'oh_modules', + modulePathMap: { + entry: '/mnt/application/entry' + }, + obfuscationMergedObConfig: { + options: { + enableFileNameObfuscation: true + } + }, + isArkguardEnabled: false, + isBytecodeObfEnabled: true + } + const result = tryMangleFileName(filePath, projectConfig, originalFilePath, projectConfig.isBytecodeObfEnabled); + expect(result === filePath).to.be.true; + projectConfig.isBytecodeObfEnabled = false + }); + mocha.it('9-1: test writeArkguardObfuscatedSourceCode when obfuscation is enabled', async function () { this.rollup.build(RELEASE); const logger = this.rollup.share.getLogger(GEN_ABC_PLUGIN_NAME); diff --git a/compiler/test/ark_compiler_ut/common/bytecode_obfuscatior.test.ts b/compiler/test/ark_compiler_ut/common/bytecode_obfuscatior.test.ts new file mode 100644 index 000000000..5a91d1aff --- /dev/null +++ b/compiler/test/ark_compiler_ut/common/bytecode_obfuscatior.test.ts @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use rollupObject 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 mocha from 'mocha'; +import { expect } from 'chai'; +import RollUpPluginMock from '../mock/rollup_mock/rollup_plugin_mock'; +import { RELEASE } from '../../../lib/fast_build/ark_compiler/common/ark_define'; +import { BytecodeObfuscator } from '../../../lib/fast_build/ark_compiler/bytecode_obfuscator'; +import { OBFUSCATE_RULE_BYTECODE_OBFUSCATION_ENABLE_PATH } from '../mock/rollup_mock/path_config'; + + +mocha.describe('test bytecodeObfuscator file api', function () { + mocha.before(function () { + this.rollup = new RollUpPluginMock(); + this.rollup.build(RELEASE); + this.rollup.share.projectConfig.compatibleSdkVersion=14; + this.rollup.share.projectConfig.obfuscationOptions = { + 'selfConfig': { + 'ruleOptions': { + 'enable': true, + 'rules': [OBFUSCATE_RULE_BYTECODE_OBFUSCATION_ENABLE_PATH] + }, + 'consumerRules': [], + }, + 'dependencies': { + 'libraries': [], + 'hars': [] + }, + obfuscationCacheDir:"" + }; + this.rollup.share.arkProjectConfig.obfuscationMergedObConfig={ + options:{ + bytecodeObf: { enable: true, enhanced: false, debugging: false }, + disableObfuscation: false, + enablePropertyObfuscation: true, + enableStringPropertyObfuscation: false, + enableToplevelObfuscation: true, + enableFileNameObfuscation: true, + enableExportObfuscation: true, + printKeptNames: false, + removeComments: false, + compact: false, + removeLog: false, + printNameCache: '', + printKeptNamesPath: '', + applyNameCache: '' + }, + reservedPropertyNames: [], + reservedGlobalNames: [], + reservedNames: [], + reservedFileNames: [], + keepComments: [], + keepSourceOfPaths: [], + universalReservedPropertyNames: [], + universalReservedGlobalNames: [], + keepUniversalPaths: [], + excludeUniversalPaths: [], + excludePathSet: new Set() + } + }); + + mocha.after(() => { + delete this.rollup; + }); + + mocha.it('1-1: test initBytecodeObfuscator when obfuscation disabled', function () { + this.rollup.share.arkProjectConfig.isArkguardEnabled=true; + this.rollup.share.arkProjectConfig.isBytecodeObfEnabled=false; + BytecodeObfuscator.initForTest(this.rollup.share); + expect(BytecodeObfuscator.enable === false).to.be.true; + BytecodeObfuscator.cleanBcObfuscatorObject(); + }); + + mocha.it('1-2: test init when obfuscation is arkguard', function () { + this.rollup.share.arkProjectConfig.isArkguardEnabled=true; + this.rollup.share.arkProjectConfig.isBytecodeObfEnabled=false; + BytecodeObfuscator.initForTest(this.rollup.share); + expect(BytecodeObfuscator.enable === false).to.be.true; + BytecodeObfuscator.cleanBcObfuscatorObject(); + }); + + mocha.it('1-3: test init when obfuscation is bytecode obfuscation', function () { + this.rollup.share.arkProjectConfig.isArkguardEnabled=false; + this.rollup.share.arkProjectConfig.isBytecodeObfEnabled=true; + BytecodeObfuscator.initForTest(this.rollup.share); + expect(BytecodeObfuscator.enable === true).to.be.true; + BytecodeObfuscator.cleanBcObfuscatorObject(); + }); + + mocha.it('2-1: test collectSkipModuleName add skip module pkgName correctly with keep bytecode har', function () { + this.rollup.share.arkProjectConfig.isArkguardEnabled=false; + this.rollup.share.arkProjectConfig.isBytecodeObfEnabled=true; + this.rollup.share.arkProjectConfig.obfuscationMergedObConfig.keepSourceOfPaths.push( + 'xxxx/xxxx/kohtpunnbppmmzjb0tw2ry4=/oh_modules/har', + 'xxxx/xxxx/kohtpunnbppmmzjb0tw2ry4=/oh_modules/har1' + ); + this.rollup.share.projectConfig.byteCodeHarInfo={ + 'har':{ + "compatibleSdkVersion":"14", + "abcPath":"adsasd" + }, + } + BytecodeObfuscator.initForTest(this.rollup.share) + BytecodeObfuscator.getInstance().collectSkipModuleName(); + expect(BytecodeObfuscator.getInstance().bytecodeObfuscateConfig.skippedRemoteHarList.has('har')).to.be.true; + BytecodeObfuscator.cleanBcObfuscatorObject(); + }); + + mocha.it('2-2: test collectSkipModuleName add skip module pkgName correctly with bytecode har', function () { + this.rollup.share.arkProjectConfig.isArkguardEnabled=false; + this.rollup.share.arkProjectConfig.isBytecodeObfEnabled=true; + this.rollup.share.projectConfig.byteCodeHarInfo={ + 'Har_version_11':{ + "compatibleSdkVersion":"11", + }, + 'Har_version_14':{ + "compatibleSdkVersion":"14", + } + } + BytecodeObfuscator.initForTest(this.rollup.share) + BytecodeObfuscator.getInstance().collectSkipModuleName(); + expect(BytecodeObfuscator.getInstance().bytecodeObfuscateConfig.skippedRemoteHarList.has('Har_version_11')).to.be.true; + expect(BytecodeObfuscator.getInstance().bytecodeObfuscateConfig.skippedRemoteHarList.has('Har_version_14')).to.be.true; + BytecodeObfuscator.cleanBcObfuscatorObject(); + }); + + + mocha.it('3-1: test generateObfCmd add config path correctly',function(){ + this.rollup.share.arkProjectConfig.isArkguardEnabled=false; + this.rollup.share.arkProjectConfig.isBytecodeObfEnabled=true; + BytecodeObfuscator.initForTest(this.rollup.share); + expect(BytecodeObfuscator.enable === true).to.be.true; + BytecodeObfuscator.getInstance().generateObfCmd(); + expect(BytecodeObfuscator.getInstance().cmdArgs.includes('config.json')).to.be.true; + BytecodeObfuscator.cleanBcObfuscatorObject(); + }); + + mocha.it('3-2: test generateObfCmd add debug correctly',function(){ + this.rollup.share.arkProjectConfig.isArkguardEnabled=false; + this.rollup.share.arkProjectConfig.isBytecodeObfEnabled=true; + this.rollup.share.arkProjectConfig.obfuscationMergedObConfig.options.bytecodeObf.debugging=true; + BytecodeObfuscator.initForTest(this.rollup.share); + expect(BytecodeObfuscator.enable === true).to.be.true; + BytecodeObfuscator.getInstance().generateObfCmd(); + expect(BytecodeObfuscator.getInstance().cmdArgs.length==4).to.be.true; + expect(BytecodeObfuscator.getInstance().cmdArgs.includes('--debug')).to.be.true; + expect(BytecodeObfuscator.getInstance().cmdArgs.includes('--debug-file')).to.be.true; + expect(BytecodeObfuscator.getInstance().cmdArgs.includes('debug.log')).to.be.true; + expect(BytecodeObfuscator.getInstance().cmdArgs.includes('config.json')).to.be.true; + BytecodeObfuscator.cleanBcObfuscatorObject(); + }); +}); \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts b/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts index c8988be47..10b44a715 100644 --- a/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts +++ b/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts @@ -51,7 +51,10 @@ import { MAC_JS2ABC_PATH, MAC_AOTCOMPILER_PATH, ARKROOT_PATH, - ARKCONFIG_TS2ABC_PATH + ARKCONFIG_TS2ABC_PATH, + WIN_BC_OBFUSCATOR_PATH, + BC_OBFUSCATOR_PATH, + MAC_BC_OBFUSCATOR_PATH } from '../mock/rollup_mock/path_config'; import RollUpPluginMock from '../mock/rollup_mock/rollup_plugin_mock'; import { @@ -558,11 +561,13 @@ mocha.describe('test process_ark_config file api', function () { const expectMergeAbcPath = path.join(ARKROOT_PATH, WIN_MERGERABC_PATH); const expectJs2abcPath = path.join(ARKROOT_PATH, WIN_JS2ABC_PATH); const expectAotCompilerPath = path.join(ARKROOT_PATH, WIN_AOTCOMPILER_PATH); + const expectBcObfuscatorPath = path.join(ARKROOT_PATH, WIN_BC_OBFUSCATOR_PATH); expect(arkConfig.es2abcPath === expectEs2abcPath).to.be.true; expect(arkConfig.ts2abcPath === expectTs2abcPath).to.be.true; expect(arkConfig.mergeAbcPath === expectMergeAbcPath).to.be.true; expect(arkConfig.js2abcPath === expectJs2abcPath).to.be.true; expect(arkConfig.aotCompilerPath === expectAotCompilerPath).to.be.true; + expect(arkConfig.bcObfuscatorPath === expectBcObfuscatorPath).to.be.true; stub.restore(); }); @@ -575,11 +580,13 @@ mocha.describe('test process_ark_config file api', function () { const expectMergeAbcPath = path.join(ARKROOT_PATH, MERGERABC_PATH); const expectJs2abcPath = path.join(ARKROOT_PATH, JS2ABC_PATH); const expectAotCompilerPath = path.join(ARKROOT_PATH, AOTCOMPILER_PATH); + const expectBcObfuscatorPath = path.join(ARKROOT_PATH, BC_OBFUSCATOR_PATH); expect(arkConfig.es2abcPath === expectEs2abcPath).to.be.true; expect(arkConfig.ts2abcPath === expectTs2abcPath).to.be.true; expect(arkConfig.mergeAbcPath === expectMergeAbcPath).to.be.true; expect(arkConfig.js2abcPath === expectJs2abcPath).to.be.true; expect(arkConfig.aotCompilerPath === expectAotCompilerPath).to.be.true; + expect(arkConfig.bcObfuscatorPath === expectBcObfuscatorPath).to.be.true; stub.restore(); }); @@ -592,11 +599,13 @@ mocha.describe('test process_ark_config file api', function () { const expectMergeAbcPath = path.join(ARKROOT_PATH, MAC_MERGERABC_PATH); const expectJs2abcPath = path.join(ARKROOT_PATH, MAC_JS2ABC_PATH); const expectAotCompilerPath = path.join(ARKROOT_PATH, MAC_AOTCOMPILER_PATH); + const expectBcObfuscatorPath = path.join(ARKROOT_PATH, MAC_BC_OBFUSCATOR_PATH); expect(arkConfig.es2abcPath === expectEs2abcPath).to.be.true; expect(arkConfig.ts2abcPath === expectTs2abcPath).to.be.true; expect(arkConfig.mergeAbcPath === expectMergeAbcPath).to.be.true; expect(arkConfig.js2abcPath === expectJs2abcPath).to.be.true; expect(arkConfig.aotCompilerPath === expectAotCompilerPath).to.be.true; + expect(arkConfig.bcObfuscatorPath === expectBcObfuscatorPath).to.be.true; stub.restore(); }); diff --git a/compiler/test/ark_compiler_ut/mock/rollup_mock/path_config.ts b/compiler/test/ark_compiler_ut/mock/rollup_mock/path_config.ts index a11edd318..39a77f61f 100644 --- a/compiler/test/ark_compiler_ut/mock/rollup_mock/path_config.ts +++ b/compiler/test/ark_compiler_ut/mock/rollup_mock/path_config.ts @@ -36,16 +36,19 @@ export const TS2ABC_PATH: string = '/build/src/index.js'; export const MERGERABC_PATH: string = '/build/bin/merge_abc'; export const JS2ABC_PATH: string = '/build/bin/js2abc'; export const AOTCOMPILER_PATH: string = '/build/bin/ark_aot_compiler'; +export const BC_OBFUSCATOR_PATH: string = '/build/bin/panda_guard'; export const WIN_ES2ABC_PATH: string = '/build-win/bin/es2abc.exe'; export const WIN_TS2ABC_PATH: string = '/build-win/src/index.js'; export const WIN_MERGERABC_PATH: string = '/build-win/bin/merge_abc.exe'; export const WIN_JS2ABC_PATH: string = '/build-win/bin/js2abc.exe'; export const WIN_AOTCOMPILER_PATH: string = '/build-win/bin/ark_aot_compiler.exe'; +export const WIN_BC_OBFUSCATOR_PATH: string = '/build-win/bin/panda_guard.exe'; export const MAC_ES2ABC_PATH: string = '/build-mac/bin/es2abc'; export const MAC_TS2ABC_PATH: string = '/build-mac/src/index.js'; export const MAC_MERGERABC_PATH: string = '/build-mac/bin/merge_abc'; export const MAC_JS2ABC_PATH: string = '/build-mac/bin/js2abc'; export const MAC_AOTCOMPILER_PATH: string = '/build-mac/bin/ark_aot_compiler'; +export const MAC_BC_OBFUSCATOR_PATH: string = '/build-mac/bin/panda_guard'; export const ARKROOT_PATH: string = path.resolve(__dirname, '../../../../bin/ark') export const MODULE_TEST_PATH: string = `${PROJECT_ROOT}/testTsModuleRequest/src/main/ets/`; export const TEST_TS: string = 'src/main/ets/pages/test.ts'; @@ -86,4 +89,6 @@ export const PKG_MODULES_OHPM_HYPIUM_SHORT: string = 'pkg_modules/@ohos/hypium'; export const MOCK_CONFIG_PATH: string = "openharmony/mockconfig"; export const OBFUSCATION_RULE_TEMPLATE_PATH: string = `${PROJECT_ROOT}/obfuscation/keepDts/obfuscation-template.txt`; -export const OBFUSCATION_RULE_PATH: string = `${PROJECT_ROOT}/obfuscation/obfuscation.txt`; \ No newline at end of file +export const OBFUSCATION_RULE_PATH: string = `${PROJECT_ROOT}/obfuscation/obfuscation.txt`; + +export const OBFUSCATE_RULE_BYTECODE_OBFUSCATION_ENABLE_PATH: string = `${PROJECT_ROOT}/bytecode_obfuscation/byte_obfuscation_enable.txt`; \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/testdata/bytecode_obfuscation/byte_obfuscation_enable.txt b/compiler/test/ark_compiler_ut/testdata/bytecode_obfuscation/byte_obfuscation_enable.txt new file mode 100644 index 000000000..e5d9cfe61 --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/bytecode_obfuscation/byte_obfuscation_enable.txt @@ -0,0 +1,10 @@ +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation + +-enable-bytecode-obfuscation +-keep-file-name +main +pages +entry \ No newline at end of file -- Gitee From 697c01904bc100a69e2b0088af8423b53ff8bd62 Mon Sep 17 00:00:00 2001 From: maoruihao Date: Fri, 9 May 2025 14:47:24 +0800 Subject: [PATCH 036/140] [Master] Add performance dotting for ArkUI Issue: #IC6KR7 Signed-off-by: maoruihao --- compiler/src/ets_checker.ts | 47 +++++----- .../ets_ui/rollup-plugin-ets-checker.ts | 26 +++-- .../ets_ui/rollup-plugin-ets-typescript.ts | 94 ++++++++++++------- compiler/src/process_import.ts | 31 +++--- compiler/src/process_kit_import.ts | 20 ++-- compiler/src/process_ui_syntax.ts | 32 ++++--- compiler/src/utils.ts | 2 + 7 files changed, 148 insertions(+), 104 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 5f382fb94..3da346ad2 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -64,10 +64,6 @@ import { hasDecorator, isString, generateSourceFilesInHar, - startTimeStatisticsLocation, - stopTimeStatisticsLocation, - resolveModuleNamesTime, - CompilationTimeStatistics, storedFileInfo, toUnixPath, isWindows, @@ -97,6 +93,9 @@ import { import { sourceFileDependencies } from './fast_build/ark_compiler/common/ob_config_resolver'; import { MemoryMonitor } from './fast_build/meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from './fast_build/meomry_monitor/memory_define'; +import { + CompileEvent +} from './performance'; import { LINTER_SUBSYSTEM_CODE, HvigorErrorInfo @@ -319,7 +318,7 @@ const reuseLanguageServiceForDepChange: boolean = true; export let needReCheckForChangedDepUsers: boolean = false; export function createLanguageService(rootFileNames: string[], resolveModulePaths: string[], - compilationTime: CompilationTimeStatistics = null, rollupShareObject?: any): ts.LanguageService { + parentEvent?: CompileEvent, rollupShareObject?: any): ts.LanguageService { setCompilerOptions(resolveModulePaths); const servicesHost: ts.LanguageServiceHost = { getScriptFileNames: () => [...rootFileNames, ...readDeaclareFiles()], @@ -329,12 +328,12 @@ export function createLanguageService(rootFileNames: string[], resolveModulePath return undefined; } if (/(? = new Map(); export function resolveModuleNames(moduleNames: string[], containingFile: string): ts.ResolvedModuleFull[] { - startTimeStatisticsLocation(resolveModuleNamesTime); + ts.PerformanceDotting.startAdvanced('resolveModuleNames'); const resolvedModules: ts.ResolvedModuleFull[] = []; const cacheFileContent: ts.ResolvedModuleFull[] = resolvedModulesCache.get(path.resolve(containingFile)); if (![...shouldResolvedFiles].length || shouldResolvedFiles.has(path.resolve(containingFile)) || @@ -1160,10 +1159,10 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string createOrUpdateCache(resolvedModules, path.resolve(containingFile)); } resolvedModulesCache.set(path.resolve(containingFile), resolvedModules); - stopTimeStatisticsLocation(resolveModuleNamesTime); + ts.PerformanceDotting.stopAdvanced('resolveModuleNames'); return resolvedModules; } - stopTimeStatisticsLocation(resolveModuleNamesTime); + ts.PerformanceDotting.stopAdvanced('resolveModuleNames'); return resolvedModulesCache.get(path.resolve(containingFile)); } @@ -1568,7 +1567,7 @@ export function incrementWatchFile(watchModifiedFiles: string[], }); } -export function runArkTSLinter(errorCodeLogger?: Object | undefined): void { +export function runArkTSLinter(errorCodeLogger?: Object | undefined, parentEvent?: CompileEvent): void { const originProgram: ts.BuilderProgram = globalProgram.builderProgram; const timePrinterInstance = ts.ArkTSLinterTimePrinter.getInstance(); @@ -1581,12 +1580,14 @@ export function runArkTSLinter(errorCodeLogger?: Object | undefined): void { buildInfoWriteFile, errorCodeLogger); + ts.PerformanceDotting.startAdvanced('updateErrorFile'); if (process.env.watchMode !== 'true' && !projectConfig.xtsMode) { arkTSLinterDiagnostics.forEach((diagnostic: ts.Diagnostic) => { updateErrorFileCache(diagnostic); }); timePrinterInstance.appendTime(ts.TimePhase.UPDATE_ERROR_FILE); } + ts.PerformanceDotting.stopAdvanced('updateErrorFile'); timePrinterInstance.printTimes(); ts.ArkTSLinterTimePrinter.destroyInstance(); } diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts index 5e3dc9f20..b58ff1fb6 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts @@ -35,10 +35,7 @@ import { } from '../../ets_checker'; import { TS_WATCH_END_MSG } from '../../pre_define'; import { - setChecker, - startTimeStatisticsLocation, - stopTimeStatisticsLocation, - CompilationTimeStatistics + setChecker } from '../../utils'; import { configureSyscapInfo, @@ -46,6 +43,14 @@ import { } from '../system_api/api_check_utils'; import { MemoryMonitor } from '../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../meomry_monitor/memory_define'; +import { + CompileEvent, + createAndStartEvent, + stopEvent, + getHookEventFactory, + processExternalEvents, + ExternalEventType +} from '../../performance'; import { LINTER_SUBSYSTEM_CODE } from '../../hvigor_error_code/hvigor_error_info'; import { ErrorCodeModule } from '../../hvigor_error_code/const/error_code_module'; @@ -58,7 +63,8 @@ export function etsChecker() { name: 'etsChecker', buildStart() { const recordInfo = MemoryMonitor.recordStage(MemoryDefine.ROLLUP_PLUGIN_BUILD_START); - const compilationTime: CompilationTimeStatistics = new CompilationTimeStatistics(this.share, 'etsChecker', 'buildStart'); + const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsChecker', 'buildStart'); + const eventServiceChecker = createAndStartEvent(hookEventFactory, 'serviceChecker'); if (process.env.watchMode === 'true' && process.env.triggerTsWatch === 'true') { tsWatchEmitter = new EventEmitter(); tsWatchEndPromise = new Promise(resolve => { @@ -102,8 +108,8 @@ export function etsChecker() { resolveModulePaths.push(...this.share.projectConfig.resolveModulePaths); } if (process.env.watchMode === 'true') { - !executedOnce && serviceChecker(rootFileNames, logger, resolveModulePaths, compilationTime, this.share); - startTimeStatisticsLocation(compilationTime ? compilationTime.diagnosticTime : undefined); + !executedOnce && serviceChecker(rootFileNames, logger, resolveModulePaths, eventServiceChecker, this.share); + ts.PerformanceDotting.startAdvanced('diagnostic'); if (executedOnce) { const timePrinterInstance = ts.ArkTSLinterTimePrinter.getInstance(); timePrinterInstance.setArkTSTimePrintSwitch(false); @@ -123,7 +129,7 @@ export function etsChecker() { const allDiagnostics: ts.Diagnostic[] = globalProgram.builderProgram .getSyntacticDiagnostics() .concat(globalProgram.builderProgram.getSemanticDiagnostics()); - stopTimeStatisticsLocation(compilationTime ? compilationTime.diagnosticTime : undefined); + ts.PerformanceDotting.stopAdvanced('diagnostic'); emitBuildInfo(); let errorCodeLogger: Object | undefined = this.share?.getHvigorConsoleLogger ? this.share?.getHvigorConsoleLogger(TSC_SYSTEM_CODE) : undefined; @@ -134,10 +140,12 @@ export function etsChecker() { fastBuildLogger.debug(TS_WATCH_END_MSG); tsWatchEmitter.emit(TS_WATCH_END_MSG); } else { - serviceChecker(rootFileNames, logger, resolveModulePaths, compilationTime, this.share); + serviceChecker(rootFileNames, logger, resolveModulePaths, eventServiceChecker, this.share); } setChecker(); MemoryMonitor.stopRecordStage(recordInfo); + processExternalEvents(projectConfig, ExternalEventType.TSC, {parentEvent: eventServiceChecker, filePath: ''}); + stopEvent(eventServiceChecker); }, shouldInvalidCache(): boolean { // The generated js file might be different in some cases when we change the targetESVersion, diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index 47ce23d72..9ea3c0acc 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -34,9 +34,6 @@ import { resourcesRawfile, differenceResourcesRawfile, CacheFile, - startTimeStatisticsLocation, - stopTimeStatisticsLocation, - CompilationTimeStatistics, genLoaderOutPathOfHar, harFilesRecord, resetUtils, @@ -91,6 +88,12 @@ import { checkHasKeepTs, resetKitImportLog } from '../../process_kit_import'; +import { + CompileEvent, + createAndStartEvent, + stopEvent, + getHookEventFactory +} from '../../performance'; import { resetProcessComponentMember } from '../../process_component_member'; import { collectReservedNameForObf, @@ -111,6 +114,8 @@ import { ARKUI_SUBSYSTEM_CODE } from '../../../lib/hvigor_error_code/hvigor_erro import { ProjectCollections } from 'arkguard'; import parseIntent from '../../userIntents_parser/parseUserIntents'; +let switchTsAst: boolean = true; + const filter: any = createFilter(/(? = new Map(); @@ -144,8 +149,8 @@ export function etsTransform() { } }, buildStart() { - const compilationTime: CompilationTimeStatistics = new CompilationTimeStatistics(this.share, 'etsTransform', 'buildStart'); - startTimeStatisticsLocation(compilationTime ? compilationTime.etsTransformBuildStartTime : undefined); + const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsTransform', 'buildStart'); + const eventEtsTransformBuildStart = createAndStartEvent(hookEventFactory, 'etsTransformBuildStart'); judgeCacheShouldDisabled.call(this); if (process.env.compileMode === 'moduleJson') { cacheFile = this.cache.get('transformCacheFiles'); @@ -162,12 +167,12 @@ export function etsTransform() { if (!!this.cache.get('enableDebugLine') !== projectConfig.enableDebugLine) { ShouldEnableDebugLine.enableDebugLine = true; } - stopTimeStatisticsLocation(compilationTime ? compilationTime.etsTransformBuildStartTime : undefined); + stopEvent(eventEtsTransformBuildStart); }, load(id: string) { let fileCacheInfo: fileInfo; - const compilationTime: CompilationTimeStatistics = new CompilationTimeStatistics(this.share, 'etsTransform', 'load'); - startTimeStatisticsLocation(compilationTime ? compilationTime.etsTransformLoadTime : undefined); + const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsTransform', 'load'); + const eventEtsTransformLoad = createAndStartEvent(hookEventFactory, 'etsTransformLoad'); if (this.cache.get('fileCacheInfo')) { fileCacheInfo = this.cache.get('fileCacheInfo')[path.resolve(id)]; } @@ -178,7 +183,7 @@ export function etsTransform() { } storedFileInfo.addFileCacheInfo(path.resolve(id), fileCacheInfo); storedFileInfo.setCurrentArkTsFile(); - stopTimeStatisticsLocation(compilationTime ? compilationTime.etsTransformLoadTime : undefined); + stopEvent(eventEtsTransformLoad); }, shouldInvalidCache(options) { const fileName: string = path.resolve(options.id); @@ -188,7 +193,11 @@ export function etsTransform() { if (cacheFile && cacheFile[fileName] && cacheFile[fileName].children.length) { for (let child of cacheFile[fileName].children) { const newTimeMs: number = fs.existsSync(child.fileName) ? fs.statSync(child.fileName).mtimeMs : -1; - if (newTimeMs !== child.mtimeMs) { + const fileHash: string = this.share?.getHashByFilePath ? this.share?.getHashByFilePath(child.fileName) : ''; + if (this.share?.getHashByFilePath && (fileHash !== child.hash || fileHash === '')) { + shouldDisable = true; + break; + } else if (!(this.share?.getHashByFilePath) && newTimeMs !== child.mtimeMs) { shouldDisable = true; break; } @@ -211,6 +220,8 @@ export function etsTransform() { } }, afterBuildEnd() { + const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsTransform', 'afterBuildEnd'); + const eventEtsTransformAfterBuildEnd = createAndStartEvent(hookEventFactory, 'etsTransformafterBuildEnd'); if (parseIntent.intentData.length > 0 || parseIntent.isUpdateCompile) { parseIntent.verifyInheritanceChain(); parseIntent.writeUserIntentJsonFile(); @@ -240,7 +251,7 @@ export function etsTransform() { process.env.cachePath, projectConfig, metaInfo); const buildFilePath: string = genTemporaryPath(filePath, projectConfig.moduleRootPath, projectConfig.buildPath, projectConfig, metaInfo, true); - const recordInfo = MemoryMonitor.recordStage(MemoryDefine.SET_INCREMENTAL_FILE_IN_HAR); + const recordInfo = MemoryMonitor.recordStage(MemoryDefine.SET_INCREMENTAL_FILE_IN_HAR); if (filePath.match(/\.e?ts$/)) { setIncrementalFileInHar(cacheFilePath, buildFilePath, allFilesInHar); } else { @@ -268,6 +279,7 @@ export function etsTransform() { } storedFileInfo.clearCollectedInfo(this.cache); this.cache.set('transformCacheFiles', storedFileInfo.transformCacheFiles); + stopEvent(eventEtsTransformAfterBuildEnd); }, cleanUp(): void { resetMain(); @@ -360,7 +372,7 @@ function getArkoalaTsProgram(program: ts.Program): ts.Program { } async function transform(code: string, id: string) { - const compilationTime: CompilationTimeStatistics = new CompilationTimeStatistics(this.share, 'etsTransform', 'transform'); + const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsTransform', 'transform'); if (!filter(id)) { return null; } @@ -371,6 +383,7 @@ async function transform(code: string, id: string) { const hvigorLogger = this.share.getHvigorConsoleLogger?.(ARKUI_SUBSYSTEM_CODE); if (projectConfig.compileMode !== 'esmodule') { + const eventEtsTransformForJsbundle = createAndStartEvent(hookEventFactory, 'transform for jsbundle'); const compilerOptions = ts.readConfigFile( path.resolve(__dirname, '../../../tsconfig.json'), ts.sys.readFile).config.compilerOptions; compilerOptions.moduleResolution = 'nodenext'; @@ -390,12 +403,14 @@ async function transform(code: string, id: string) { resetLog(); } + stopEvent(eventEtsTransformForJsbundle); return { code: result.outputText, map: result.sourceMapText ? JSON.parse(result.sourceMapText) : new MagicString(code).generateMap() }; } + const eventEtsTransformForEsmodule = createAndStartEvent(hookEventFactory, 'transform for esmodule'); let tsProgram: ts.Program = globalProgram.program; let targetSourceFile: ts.SourceFile | undefined = tsProgram.getSourceFile(id); @@ -404,7 +419,7 @@ async function transform(code: string, id: string) { // 1. .ets/.ts imported by .js file with tsc's `allowJS` option is false. // 2. .ets/.ts imported by .js file with same name '.d.ts' file which is prior to .js by tsc default resolving if (!targetSourceFile) { - await processNoTargetSourceFile(id, code, compilationTime); + await processNoTargetSourceFile(id, code, eventEtsTransformForEsmodule); const recordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_GET_CHECKER); // init TypeChecker to run binding globalProgram.checker = tsProgram.getTypeChecker(); @@ -423,9 +438,9 @@ async function transform(code: string, id: string) { storedFileInfo.reUseProgram = true; } setPkgNameForFile(this.getModuleInfo(id)); - startTimeStatisticsLocation(compilationTime ? compilationTime.validateEtsTime : undefined); + const eventValidateEts = createAndStartEvent(eventEtsTransformForEsmodule, 'validateEts'); validateEts(code, id, this.getModuleInfo(id).isEntry, logger, targetSourceFile, hvigorLogger); - stopTimeStatisticsLocation(compilationTime ? compilationTime.validateEtsTime : undefined); + stopEvent(eventValidateEts); const emitResult: EmitResult = { outputText: '', sourceMapText: '' }; const writeFile: ts.WriteFileCallback = (fileName: string, data: string) => { if (/.map$/.test(fileName)) { @@ -443,14 +458,14 @@ async function transform(code: string, id: string) { reExportCheckMode: this.share.projectConfig?.reExportCheckMode ?? reExportNoCheckMode }; // use `try finally` to restore `noEmit` when error thrown by `processUISyntax` in preview mode - startTimeStatisticsLocation(compilationTime ? compilationTime.shouldEmitJsTime : undefined); + const eventShouldEmitJs = createAndStartEvent(eventEtsTransformForEsmodule, 'shouldEmitJs'); const shouldEmitJsFlag: boolean = getShouldEmitJs(projectConfig.shouldEmitJs, targetSourceFile, id); shouldEmitJsFlagMap.set(id, shouldEmitJsFlag); - stopTimeStatisticsLocation(compilationTime ? compilationTime.shouldEmitJsTime : undefined); + stopEvent(eventShouldEmitJs); let transformResult: ts.TransformationResult = null; ProjectCollections.projectWhiteListManager?.setCurrentCollector(id); try { - startTimeStatisticsLocation(compilationTime ? compilationTime.tsProgramEmitTime : undefined); + const eventTsProgramEmit = createAndStartEvent(eventEtsTransformForEsmodule, 'tsProgramEmit'); const recordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_UI_KIT); metaInfo.checker = tsProgram.getTypeChecker(); if (projectConfig.useArkoala) { @@ -458,36 +473,36 @@ async function transform(code: string, id: string) { targetSourceFile = tsProgram.getSourceFile(id); } if (shouldEmitJsFlag) { - startTimeStatisticsLocation(compilationTime ? compilationTime.emitTime : undefined); + const eventEmit = createAndStartEvent(eventTsProgramEmit, 'emit'); const uiKitrecordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_UI_KIT); tsProgram.emit(targetSourceFile, writeFile, undefined, undefined, { before: [ - processUISyntax(null, false, compilationTime, id, metaInfo), - processKitImport(id, metaInfo, compilationTime, true, lazyImportOptions), + processUISyntax(null, false, eventEmit, id, this.share, metaInfo), + processKitImport(id, metaInfo, eventEmit, true, lazyImportOptions), collectReservedNameForObf(this.share.arkProjectConfig?.obfuscationMergedObConfig, shouldETSOrTSFileTransformToJSWithoutRemove(id, projectConfig, metaInfo)) ] } ); MemoryMonitor.stopRecordStage(uiKitrecordInfo); - stopTimeStatisticsLocation(compilationTime ? compilationTime.emitTime : undefined); + stopEvent(eventEmit); } else { - const uiKitrecordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_UI_KIT); - startTimeStatisticsLocation(compilationTime ? compilationTime.transformNodesTime : undefined); + const uiKitrecordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_UI_KIT); + const eventTransformNodes = createAndStartEvent(eventTsProgramEmit, 'transformNodes'); const emitResolver: ts.EmitResolver = globalProgram.checker.getEmitResolver(outFile(tsProgram.getCompilerOptions()) ? undefined : targetSourceFile, undefined); metaInfo.checker = tsProgram.getTypeChecker(); transformResult = ts.transformNodes(emitResolver, tsProgram.getEmitHost?.(), ts.factory, tsProgram.getCompilerOptions(), [targetSourceFile], - [processUISyntax(null, false, compilationTime, id, metaInfo), - processKitImport(id, metaInfo, compilationTime, false, lazyImportOptions), + [processUISyntax(null, false, eventTransformNodes, id, this.share, metaInfo), + processKitImport(id, metaInfo, eventTransformNodes, false, lazyImportOptions), collectReservedNameForObf(this.share.arkProjectConfig?.obfuscationMergedObConfig, shouldETSOrTSFileTransformToJSWithoutRemove(id, projectConfig, metaInfo))], false); - stopTimeStatisticsLocation(compilationTime ? compilationTime.transformNodesTime : undefined); + stopEvent(eventTransformNodes); MemoryMonitor.stopRecordStage(uiKitrecordInfo); } - stopTimeStatisticsLocation(compilationTime ? compilationTime.tsProgramEmitTime : undefined); + stopEvent(eventTsProgramEmit); MemoryMonitor.stopRecordStage(recordInfo); } finally { // restore `noEmit` to prevent tsc's watchService emitting automatically. @@ -504,18 +519,25 @@ async function transform(code: string, id: string) { resetKitImportLog(); } - return shouldEmitJsFlag ? { + const result = shouldEmitJsFlag ? { code: emitResult.outputText, // Use magicString to generate sourceMap because of Typescript do not emit sourceMap in some cases map: emitResult.sourceMapText ? JSON.parse(emitResult.sourceMapText) : new MagicString(code).generateMap(), meta: { shouldEmitJs: true } - } : printSourceFile(transformResult.transformed[0], compilationTime); + } : switchTsAst ? { + meta: { + tsAst: transformResult.transformed[0] + } + } : printSourceFile(transformResult.transformed[0], eventEtsTransformForEsmodule); + + stopEvent(eventEtsTransformForEsmodule); + return result; } -async function processNoTargetSourceFile(id: string, code: string, compilationTime?: CompilationTimeStatistics): Promise { - startTimeStatisticsLocation(compilationTime ? compilationTime.noSourceFileRebuildProgramTime : undefined); +async function processNoTargetSourceFile(id: string, code: string, parentEvent?: CompileEvent): Promise { + const eventNoSourceFileRebuildProgram = createAndStartEvent(parentEvent, 'noSourceFileRebuildProgram'); if (storedFileInfo.isFirstBuild && storedFileInfo.changeFiles.length) { storedFileInfo.newTsProgram = ts.createProgram(storedFileInfo.changeFiles, etsCheckerCompilerOptions, compilerHost); storedFileInfo.isFirstBuild = false; @@ -545,15 +567,15 @@ async function processNoTargetSourceFile(id: string, code: string, compilationTi }); } globalProgram.program.refreshTypeChecker(); - stopTimeStatisticsLocation(compilationTime ? compilationTime.noSourceFileRebuildProgramTime : undefined); + stopEvent(eventNoSourceFileRebuildProgram); } -function printSourceFile(sourceFile: ts.SourceFile, compilationTime: CompilationTimeStatistics): string | null { +function printSourceFile(sourceFile: ts.SourceFile, parentEvent: CompileEvent): string | null { if (sourceFile) { - startTimeStatisticsLocation(compilationTime ? compilationTime.printNodeTime : undefined); + const eventPrintNode = createAndStartEvent(parentEvent, 'printNode'); const printer: ts.Printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); const sourceCode: string = printer.printNode(ts.EmitHint.Unspecified, sourceFile, sourceFile); - stopTimeStatisticsLocation(compilationTime ? compilationTime.printNodeTime : undefined); + stopEvent(eventPrintNode); return sourceCode; } return null; diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index ed8466daa..bdfbb6886 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -754,7 +754,8 @@ interface PageInfo { setChildOnce: boolean; } -export function processImportModule(node: ts.ImportDeclaration, pageFile: string, log: LogInfo[]): void { +export function processImportModule(node: ts.ImportDeclaration, pageFile: string, log: LogInfo[], + share: object = null): void { let importSymbol: ts.Symbol; let realSymbol: ts.Symbol; let originNode: ts.Node; @@ -763,7 +764,7 @@ export function processImportModule(node: ts.ImportDeclaration, pageFile: string // import xxx from 'xxx' if (node.importClause && node.importClause.name && ts.isIdentifier(node.importClause.name)) { - getDefinedNode(importSymbol, realSymbol, originNode, node.importClause.name, pageInfo); + getDefinedNode(importSymbol, realSymbol, originNode, node.importClause.name, pageInfo, share); } // import {xxx} from 'xxx' @@ -772,7 +773,7 @@ export function processImportModule(node: ts.ImportDeclaration, pageFile: string node.importClause.namedBindings.elements) { node.importClause.namedBindings.elements.forEach((importSpecifier: ts.ImportSpecifier) => { if (ts.isImportSpecifier(importSpecifier) && importSpecifier.name && ts.isIdentifier(importSpecifier.name)) { - getDefinedNode(importSymbol, realSymbol, originNode, importSpecifier.name, pageInfo); + getDefinedNode(importSymbol, realSymbol, originNode, importSpecifier.name, pageInfo, share); } }); } @@ -782,12 +783,12 @@ export function processImportModule(node: ts.ImportDeclaration, pageFile: string ts.isNamespaceImport(node.importClause.namedBindings) && node.importClause.namedBindings.name && ts.isIdentifier(node.importClause.namedBindings.name)) { storedFileInfo.isAsPageImport = true; - getDefinedNode(importSymbol, realSymbol, originNode, node.importClause.namedBindings.name, pageInfo); + getDefinedNode(importSymbol, realSymbol, originNode, node.importClause.namedBindings.name, pageInfo, share); } } function getDefinedNode(importSymbol: ts.Symbol, realSymbol: ts.Symbol, originNode: ts.Node, - usedNode: ts.Identifier, pageInfo: PageInfo): void { + usedNode: ts.Identifier, pageInfo: PageInfo, share: object = null): void { importSymbol = globalProgram.checker.getSymbolAtLocation(usedNode); if (importSymbol) { realSymbol = globalProgram.checker.getAliasedSymbol(importSymbol); @@ -804,16 +805,16 @@ function getDefinedNode(importSymbol: ts.Symbol, realSymbol: ts.Symbol, originNo const escapedName: string = realSymbol.escapedName.toString().replace(/^("|')/, '').replace(/("|')$/, ''); if (fs.existsSync(escapedName + '.ets') || fs.existsSync(escapedName + '.ts') && realSymbol.exports && realSymbol.exports instanceof Map) { - getIntegrationNodeInfo(originNode, usedNode, realSymbol.exports, pageInfo); + getIntegrationNodeInfo(originNode, usedNode, realSymbol.exports, pageInfo, share); return; } } - processImportNode(originNode, usedNode, false, null, pageInfo); + processImportNode(originNode, usedNode, false, null, pageInfo, share); } } function getIntegrationNodeInfo(originNode: ts.Node, usedNode: ts.Identifier, exportsMap: ts.SymbolTable, - pageInfo: PageInfo): void { + pageInfo: PageInfo, share: object = null): void { for (const usedSymbol of exportsMap) { try { originNode = globalProgram.checker.getAliasedSymbol(usedSymbol[1]).declarations[0]; @@ -821,16 +822,16 @@ function getIntegrationNodeInfo(originNode: ts.Node, usedNode: ts.Identifier, ex if (usedSymbol[1] && usedSymbol[1].declarations) { for (let i = 0; i < usedSymbol[1].declarations.length; i++) { originNode = usedSymbol[1].declarations[i]; - exportAllManage(originNode, usedNode, pageInfo); + exportAllManage(originNode, usedNode, pageInfo, share); } } } - processImportNode(originNode, usedNode, true, usedSymbol[0], pageInfo); + processImportNode(originNode, usedNode, true, usedSymbol[0], pageInfo, share); } } // export * from 'xxx'; -function exportAllManage(originNode: ts.Node, usedNode: ts.Identifier, pageInfo: PageInfo): void { +function exportAllManage(originNode: ts.Node, usedNode: ts.Identifier, pageInfo: PageInfo, share: object = null): void { let exportOriginNode: ts.Node; if (!originNode.exportClause && originNode.moduleSpecifier && ts.isStringLiteral(originNode.moduleSpecifier)) { const exportSymbol: ts.Symbol = globalProgram.checker.getSymbolAtLocation(originNode.moduleSpecifier); @@ -844,7 +845,7 @@ function exportAllManage(originNode: ts.Node, usedNode: ts.Identifier, pageInfo: const escapedName: string = exportSymbol.escapedName.toString().replace(/^("|')/, '').replace(/("|')$/, ''); if (fs.existsSync(escapedName + '.ets') || fs.existsSync(escapedName + '.ts') && exportSymbol.exports && exportSymbol.exports instanceof Map) { - getIntegrationNodeInfo(originNode, usedNode, exportSymbol.exports, pageInfo); + getIntegrationNodeInfo(originNode, usedNode, exportSymbol.exports, pageInfo, share); return; } } @@ -853,7 +854,7 @@ function exportAllManage(originNode: ts.Node, usedNode: ts.Identifier, pageInfo: } function processImportNode(originNode: ts.Node, usedNode: ts.Identifier, importIntegration: boolean, - usedPropName: string, pageInfo: PageInfo): void { + usedPropName: string, pageInfo: PageInfo, share: object = null): void { const structDecorator: structDecoratorResult = { hasRecycle: false }; let name: string; let asComponentName: string; @@ -881,9 +882,11 @@ function processImportNode(originNode: ts.Node, usedNode: ts.Identifier, importI } if (needCollection && pageInfo.pageFile && !pageInfo.setChildOnce && originFile) { const childFile: string = path.resolve(getRealPath(originFile) || originFile); + const fileHash = share?.getHashByFilePath ? share.getHashByFilePath(childFile) : ''; storedFileInfo.transformCacheFiles[pageInfo.pageFile].children.push({ fileName: childFile, - mtimeMs: fs.existsSync(childFile) ? fs.statSync(childFile).mtimeMs : 0 + mtimeMs: fs.existsSync(childFile) ? fs.statSync(childFile).mtimeMs : 0, + hash: fileHash }); pageInfo.setChildOnce = true; } diff --git a/compiler/src/process_kit_import.ts b/compiler/src/process_kit_import.ts index 5469cd0c8..8ffeabec5 100644 --- a/compiler/src/process_kit_import.ts +++ b/compiler/src/process_kit_import.ts @@ -19,10 +19,7 @@ import path from 'path'; import { IFileLog, - LogType, - startTimeStatisticsLocation, - stopTimeStatisticsLocation, - CompilationTimeStatistics + LogType } from './utils'; import { projectConfig } from '../main'; import { ModuleSourceFile } from './fast_build/ark_compiler/module/module_source_file'; @@ -38,6 +35,11 @@ import { import createAstNodeUtils from './create_ast_node_utils'; import { MemoryMonitor } from './fast_build/meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from './fast_build/meomry_monitor/memory_define'; +import { + CompileEvent, + createAndStartEvent, + stopEvent +} from './performance'; import { ArkTSErrorDescription, ErrorCode @@ -73,7 +75,7 @@ const KEEPTS = '// @keepTs'; * import ErrorCode from '@ohos.ability.errorCode' * ``` */ -export function processKitImport(id: string, metaInfo: Object, compilationTime: CompilationTimeStatistics, +export function processKitImport(id: string, metaInfo: Object, parentEvent: CompileEvent, shouldReturnOriginalNode: boolean = true, lazyImportOptions: LazyImportOptions = { autoLazyImport: false, reExportCheckMode: reExportNoCheckMode }): Function { const { autoLazyImport, reExportCheckMode } = lazyImportOptions; @@ -111,7 +113,7 @@ export function processKitImport(id: string, metaInfo: Object, compilationTime: }; return (node: ts.SourceFile) => { - startTimeStatisticsLocation(compilationTime ? compilationTime.processKitImportTime : undefined); + const eventProcessKitImport = createAndStartEvent(parentEvent, 'processKitImport'); const newSourceFileRecordInfo = MemoryMonitor.recordStage(MemoryDefine.NEW_SOURCE_FILE); compilingEtsOrTsFiles.push(path.normalize(node.fileName)); @@ -132,7 +134,7 @@ export function processKitImport(id: string, metaInfo: Object, compilationTime: const processedNode: ts.SourceFile = ts.visitEachChild(node, visitor, context); // this node used for [writeFile] MemoryMonitor.stopRecordStage(newSourceFileRecordInfo); - stopTimeStatisticsLocation(compilationTime ? compilationTime.processKitImportTime : undefined); + stopEvent(eventProcessKitImport); // this processNode is used to convert ets/ts to js intermediate products return processedNode; } @@ -145,13 +147,13 @@ export function processKitImport(id: string, metaInfo: Object, compilationTime: lazyImportReExportCheck(processedNode, reExportCheckMode); ModuleSourceFile.newSourceFile(id, processedNode, metaInfo, projectConfig.singleFileEmit); MemoryMonitor.stopRecordStage(newSourceFileRecordInfo); - stopTimeStatisticsLocation(compilationTime ? compilationTime.processKitImportTime : undefined); + stopEvent(eventProcessKitImport); return shouldReturnOriginalNode ? node : processedNode; // this node not used for [writeFile] } // process KitImport transforming const processedNode: ts.SourceFile = ts.visitEachChild(node, visitor, context); MemoryMonitor.stopRecordStage(newSourceFileRecordInfo); - stopTimeStatisticsLocation(compilationTime ? compilationTime.processKitImportTime : undefined); + stopEvent(eventProcessKitImport); return processedNode; }; }; diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index dfee37f2f..9bb392e45 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -91,9 +91,6 @@ import { getPossibleBuilderTypeParameter, storedFileInfo, ExtendResult, - startTimeStatisticsLocation, - stopTimeStatisticsLocation, - CompilationTimeStatistics, getStoredFileInfo, ProcessFileInfo, RouterInfo, @@ -169,6 +166,12 @@ import { routerModuleType, routerBundleOrModule } from './process_module_package'; +import { + CompileEvent, + createAndStartEvent, + stopEvent +} from './performance'; + export let transformLog: IFileLog = new createAstNodeUtils.FileLog(); export let contextGlobal: ts.TransformationContext; export let resourceFileName: string = ''; @@ -176,8 +179,9 @@ export const builderTypeParameter: { params: string[] } = { params: [] }; import parseIntent from './userIntents_parser/parseUserIntents'; export function processUISyntax(program: ts.Program, ut = false, - compilationTime: CompilationTimeStatistics = null, filePath: string = '', metaInfo: Object = {}): Function { + parentEvent?: CompileEvent, filePath: string = '', share: object = null, metaInfo: Object = {}): Function { let entryNodeKey: ts.Expression; + let eventProcessUISyntax: CompileEvent = undefined; return (context: ts.TransformationContext) => { contextGlobal = context; let pagesDir: string; @@ -186,13 +190,15 @@ export function processUISyntax(program: ts.Program, ut = false, let hasStruct: boolean = false; let StateManagementV2: { hasReusableV2: boolean } = { hasReusableV2: false }; return (node: ts.SourceFile) => { - startTimeStatisticsLocation(compilationTime ? compilationTime.processUISyntaxTime : undefined); + eventProcessUISyntax = createAndStartEvent(parentEvent, 'processUISyntax'); pagesDir = path.resolve(path.dirname(node.fileName)); resourceFileName = path.resolve(node.fileName); pageFile = path.resolve(filePath !== '' ? filePath : node.fileName); if (process.env.compiler === BUILD_ON || process.env.compileTool === 'rollup') { + const fileHash = share?.getHashByFilePath ? share?.getHashByFilePath(pageFile) : ''; storedFileInfo.transformCacheFiles[pageFile] = { mtimeMs: fs.existsSync(pageFile) ? fs.statSync(pageFile).mtimeMs : 0, + hash: fileHash, children: [] }; transformLog.sourceFile = node; @@ -210,7 +216,7 @@ export function processUISyntax(program: ts.Program, ut = false, } } const visitEachChildNode: ts.SourceFile = ts.visitEachChild(node, visitor, context); - stopTimeStatisticsLocation(compilationTime ? compilationTime.processUISyntaxTime : undefined); + stopEvent(eventProcessUISyntax); return visitEachChildNode; } const id: number = ++componentInfo.id; @@ -250,10 +256,10 @@ export function processUISyntax(program: ts.Program, ut = false, } } const visitEachChildNode: ts.SourceFile = ts.visitEachChild(node, visitor, context); - stopTimeStatisticsLocation(compilationTime ? compilationTime.processUISyntaxTime : undefined); + stopEvent(eventProcessUISyntax); return visitEachChildNode; } else { - stopTimeStatisticsLocation(compilationTime ? compilationTime.processUISyntaxTime : undefined); + stopEvent(eventProcessUISyntax); return node; } }; @@ -285,9 +291,9 @@ export function processUISyntax(program: ts.Program, ut = false, function processAllNodes(node: ts.Node): ts.Node { if (projectConfig.compileMode === 'esmodule' && process.env.compileTool === 'rollup' && ts.isImportDeclaration(node)) { - startTimeStatisticsLocation(compilationTime ? compilationTime.processImportTime : undefined); - processImportModule(node, pageFile, transformLog.errors); - stopTimeStatisticsLocation(compilationTime ? compilationTime.processImportTime : undefined); + const eventProcessImport = createAndStartEvent(eventProcessUISyntax, 'processImport'); + processImportModule(node, pageFile, transformLog.errors, share); + stopEvent(eventProcessImport); } else if ((projectConfig.compileMode !== 'esmodule' || process.env.compileTool !== 'rollup') && (ts.isImportDeclaration(node) || ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier))) { @@ -298,11 +304,11 @@ export function processUISyntax(program: ts.Program, ut = false, hasStruct = true; componentCollection.currentClassName = node.name.getText(); componentCollection.entryComponent === componentCollection.currentClassName && entryKeyNode(node); - startTimeStatisticsLocation(compilationTime ? compilationTime.processComponentClassTime : undefined); + const eventProcessComponentClass = createAndStartEvent(eventProcessUISyntax, 'processComponentClass'); node = processStructComponentV2.getOrCreateStructInfo(componentCollection.currentClassName).isComponentV2 ? processStructComponentV2.processStructComponentV2(node, transformLog.errors, context, StateManagementV2) : processComponentClass(node, context, transformLog.errors, program); - stopTimeStatisticsLocation(compilationTime ? compilationTime.processComponentClassTime : undefined); + stopEvent(eventProcessComponentClass); componentCollection.currentClassName = null; INNER_STYLE_FUNCTION.forEach((block, styleName) => { BUILDIN_STYLE_NAMES.delete(styleName); diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 6427d0055..1cf080059 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -759,10 +759,12 @@ function isDollarParameter(parameters: ts.ParameterDeclaration[]): boolean { interface ChildrenCacheFile { fileName: string, mtimeMs: number, + hash: string } export interface CacheFile { mtimeMs: number, + hash: string, children: Array, } -- Gitee From c00234925509f0b8008ac35ed87ee7584e1594ad Mon Sep 17 00:00:00 2001 From: lihao Date: Tue, 15 Apr 2025 23:16:00 +0800 Subject: [PATCH 037/140] write files with case-sensitive file path Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IC1G30 Signed-off-by: lihao --- compiler/src/ark_utils.ts | 13 +++++++++++-- compiler/src/fast_build/ark_compiler/logger.ts | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index 70674432f..f2cadf870 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -616,7 +616,7 @@ export async function writeObfuscatedSourceCode(moduleInfo: ModuleInfo, logger: harFilesRecord.set(originSourceFilePath, genFileInHar); } - fs.writeFileSync(moduleInfo.buildFilePath, moduleInfo.content); + writeFileSyncCaseAware(moduleInfo.buildFilePath, moduleInfo.content); } export function getPreviousStageSourceMap(moduleInfo: ModuleInfo, rollupNewSourceMaps: Object = {}): sourceMap.RawSourceMap | undefined { @@ -789,7 +789,7 @@ export function writeDeclarationFiles(compileMode: string): void { for (const genFilesInHar of harFilesRecord.values()) { if (genFilesInHar.originalDeclarationCachePath && genFilesInHar.originalDeclarationContent) { mkdirsSync(path.dirname(genFilesInHar.originalDeclarationCachePath)); - fs.writeFileSync(genFilesInHar.originalDeclarationCachePath, genFilesInHar.originalDeclarationContent); + writeFileSyncCaseAware(genFilesInHar.originalDeclarationCachePath, genFilesInHar.originalDeclarationContent); } } } @@ -1010,4 +1010,13 @@ export function transformOhmurlToPkgName(ohmurl: string): string { return paths.slice(0, 2).join(SEPARATOR_SLASH); } return paths[0]; +} + +export function writeFileSyncCaseAware(filePath: fs.PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: fs.WriteFileOptions): void { + // If filePath is not a file descriptor number (i.e., it's a file path) and the file at that path already exists, + // delete the existing file first to ensure the written file name matches the input. + if (typeof filePath !== 'number' && fs.existsSync(filePath)) { + fs.unlinkSync(filePath); + } + fs.writeFileSync(filePath, data, options); } \ No newline at end of file diff --git a/compiler/src/fast_build/ark_compiler/logger.ts b/compiler/src/fast_build/ark_compiler/logger.ts index 508727613..8374c98af 100644 --- a/compiler/src/fast_build/ark_compiler/logger.ts +++ b/compiler/src/fast_build/ark_compiler/logger.ts @@ -151,7 +151,7 @@ export class LogData { description: string, cause: string = '', position: string = '', - solutions: string[] = [ArkTSInternalErrorSolution] + solutions: string[] = [] ) { this.code = code; this.description = description; -- Gitee From 2d1196a832c6414adc3aad5bfe15c6de49608b05 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Mon, 12 May 2025 16:29:17 +0800 Subject: [PATCH 038/140] =?UTF-8?q?=E6=84=8F=E5=9B=BE=E6=A1=86=E6=9E=B6ut?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/test/transform_ut/ut_insight.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/test/transform_ut/ut_insight.test.ts b/compiler/test/transform_ut/ut_insight.test.ts index 6e8d2f4bd..61de212d0 100644 --- a/compiler/test/transform_ut/ut_insight.test.ts +++ b/compiler/test/transform_ut/ut_insight.test.ts @@ -39,7 +39,7 @@ import { resetGlobalProgram, resetMain, resources -} from '../../../../../yzhmaster/developtools_ace_ets2bundle/compiler/main'; +} from '../../main'; import { etsChecker } from '../../lib/fast_build/ets_ui/rollup-plugin-ets-checker'; @@ -49,11 +49,11 @@ import { import processStructComponentV2 from '../../lib/process_struct_componentV2'; import { RollUpPluginMock -} from '../../../../../yzhmaster/developtools_ace_ets2bundle/compiler/test/transform_ut/helpers/mockRollupContext'; +} from './helpers/mockRollupContext'; import { PartialUpdateConfig, ProjectConfig -} from '../../../../../yzhmaster/developtools_ace_ets2bundle/compiler/test/transform_ut/helpers/projectConfig'; +} from './helpers/projectConfig'; import { CACHE_PATH, UT_PAGES @@ -61,7 +61,7 @@ import { import { parseCode, sourceReplace -} from '../../../../../yzhmaster/developtools_ace_ets2bundle/compiler/test/transform_ut/helpers/parser'; +} from './helpers/parser'; const PROJECT_ROOT: string = path.resolve(__dirname, '../../test/transform_ut'); const DEFAULT_PROJECT: string = 'application'; -- Gitee From e108fab4d65dfe24a3e03ff8a41da3cfefd386ea Mon Sep 17 00:00:00 2001 From: liyancheng2 Date: Sat, 26 Apr 2025 12:25:23 +0800 Subject: [PATCH 039/140] add the switch of controlling the annotation Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IC43W4 Signed-off-by: liyancheng2 Change-Id: Icf048ae6fdb7fac73fb0d35121c9167288b675a4 --- compiler/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/main.js b/compiler/main.js index 4906a43af..bda903037 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -87,7 +87,7 @@ function initProjectConfig(projectConfig) { projectConfig.compileHar = false; projectConfig.compileShared = false; projectConfig.splitCommon = false; - projectConfig.allowEtsAnnotations = false; + projectConfig.allowEtsAnnotations = true; projectConfig.checkEntry = projectConfig.checkEntry || process.env.checkEntry; projectConfig.obfuscateHarType = projectConfig.obfuscateHarType || process.env.obfuscate; projectConfig.packageDir = 'node_modules'; -- Gitee From 74acb048767fe5b84fc6e18098d5054cf2d92f77 Mon Sep 17 00:00:00 2001 From: shanweiqian Date: Wed, 26 Mar 2025 16:35:37 +0800 Subject: [PATCH 040/140] Optimize createprogram Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IBV0LA Signed-off-by: shanweiqian Change-id: ied9af43281586a048da47383eb3503791a549767 --- compiler/src/ets_checker.ts | 29 ++++++++++++-- .../test/ark_compiler_ut/ets_checker.test.ts | 38 ++++++++++++++++++- 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index a9e35d4a4..a435addc4 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -114,6 +114,7 @@ export interface LanguageServiceCache { export const SOURCE_FILES: Map = new Map(); export let localPackageSet: Set = new Set(); export const TSC_SYSTEM_CODE = '105'; +export const fileCache: Map = new Map(); export const MAX_FLOW_DEPTH_DEFAULT_VALUE = 2000; export const MAX_FLOW_DEPTH_MAXIMUM_VALUE = 65535; @@ -292,12 +293,23 @@ function createHash(str: string): string { return hash.digest('hex'); } +export function getFileContentWithHash(fileName: string): string { + let fileContent: string | undefined = fileCache.get(fileName); + if (fileContent === undefined) { + fileContent = fs.readFileSync(fileName).toString(); + fileCache.set(fileName, fileContent); + // Provide the hash value for hvigor's remote cache, and let them handle the cleanup. + setHashValueByFilePath?.(fileName, createHash(fileContent)); + } + return fileContent; +} + export const fileHashScriptVersion: (fileName: string) => string = (fileName: string) => { if (!fs.existsSync(fileName)) { return '0'; } - let fileContent: string = fs.readFileSync(fileName).toString(); + let fileContent: string = getFileContentWithHash(fileName); let cacheInfo: CacheFileName = cache[path.resolve(fileName)]; // Error code corresponding to message `Cannot find module xx or its corresponding type declarations` @@ -307,8 +319,9 @@ export const fileHashScriptVersion: (fileName: string) => string = (fileName: st // If this file had errors that require recheck in the last compilation, // mark the file as modified by modifying its hash value, thereby triggering tsc to recheck. fileContent += Date.now().toString(); + return createHash(fileContent); } - return createHash(fileContent); + return getHashByFilePath?.(fileName) ?? createHash(fileContent); }; // Reuse the last language service when dependency in oh-package.json5 changes to enhance performance in incremental building. @@ -316,9 +329,13 @@ export const fileHashScriptVersion: (fileName: string) => string = (fileName: st const reuseLanguageServiceForDepChange: boolean = true; // When dependency changes and reusing the last language service, enable this flag to recheck code dependent on those dependencies. export let needReCheckForChangedDepUsers: boolean = false; +let setHashValueByFilePath: Function | undefined = undefined; +let getHashByFilePath: Function | undefined = undefined; export function createLanguageService(rootFileNames: string[], resolveModulePaths: string[], parentEvent?: CompileEvent, rollupShareObject?: any): ts.LanguageService { + setHashValueByFilePath = rollupShareObject?.setHashValueByFilePath; + getHashByFilePath = rollupShareObject?.getHashByFilePath; setCompilerOptions(resolveModulePaths); const servicesHost: ts.LanguageServiceHost = { getScriptFileNames: () => [...rootFileNames, ...readDeaclareFiles()], @@ -327,16 +344,17 @@ export function createLanguageService(rootFileNames: string[], resolveModulePath if (!fs.existsSync(fileName)) { return undefined; } + let fileContent: string = getFileContentWithHash(fileName); if (/(? process.cwd(), getCompilationSettings: () => compilerOptions, @@ -370,6 +388,9 @@ export function createLanguageService(rootFileNames: string[], resolveModulePath // TSC will re-do resolution if this callback return true. hasInvalidatedResolutions: (filePath: string): boolean => { return reuseLanguageServiceForDepChange && needReCheckForChangedDepUsers; + }, + clearFileCache: function() { + fileCache.clear(); } }; diff --git a/compiler/test/ark_compiler_ut/ets_checker.test.ts b/compiler/test/ark_compiler_ut/ets_checker.test.ts index d76aadf11..b46f43c04 100644 --- a/compiler/test/ark_compiler_ut/ets_checker.test.ts +++ b/compiler/test/ark_compiler_ut/ets_checker.test.ts @@ -17,6 +17,7 @@ import mocha from 'mocha'; import fs from 'fs'; import path from 'path'; import { expect } from 'chai'; +import * as sinon from 'sinon'; import * as ts from 'typescript'; import { EXPECT_INDEX_ETS } from './mock/rollup_mock/path_config'; @@ -29,7 +30,9 @@ import { resetEtsCheck, serviceChecker, getMaxFlowDepth, - MAX_FLOW_DEPTH_DEFAULT_VALUE + MAX_FLOW_DEPTH_DEFAULT_VALUE, + fileCache, + getFileContentWithHash } from '../../lib/ets_checker'; import { TS_BUILD_INFO_SUFFIX } from '../../lib/pre_define'; import { @@ -404,4 +407,37 @@ mocha.describe('deleteProgramSourceFiles', () => { const newFileSize: number = program.getSourceFiles().length; expect(origrinFileSize === newFileSize).to.be.true; }); +}); + +mocha.describe('optimize createProgram', () => { + const testFileName = 'test.txt'; + const testFileContent = 'Hello, world!'; + let readFileSyncStub: sinon.SinonStub; + + mocha.beforeEach(() => { + fileCache.clear(); + readFileSyncStub = sinon.stub(fs, 'readFileSync').returns(Buffer.from(testFileContent)); + }); + + mocha.afterEach(() => { + sinon.restore(); + }); + + mocha.it('1-1: test should return file content when file exists ', () => { + const result = getFileContentWithHash(testFileName); + expect(result).to.equal(testFileContent); + }); + + mocha.it('1-2: test should cache the file content after first read', () => { + // First call - should read from file system + const firstResult = getFileContentWithHash(testFileName); + expect(fileCache.has(testFileName)).to.be.true; + expect(fileCache.get(testFileName)).to.equal(testFileContent); + + // Second call - should use cache + readFileSyncStub.resetHistory(); + const secondResult = getFileContentWithHash(testFileName); + expect(readFileSyncStub.called).to.be.false; + expect(secondResult).to.equal(firstResult); + }); }); \ No newline at end of file -- Gitee From c2c8c8ae706cdfa7a2f7b7976eca269bd14c1567 Mon Sep 17 00:00:00 2001 From: maoruihao Date: Tue, 13 May 2025 16:40:28 +0800 Subject: [PATCH 041/140] Fix arkui dotting Signed-off-by: maoruihao --- compiler/src/performance.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/performance.ts b/compiler/src/performance.ts index 9486290ce..fea60b4ce 100644 --- a/compiler/src/performance.ts +++ b/compiler/src/performance.ts @@ -66,7 +66,7 @@ export function getHookEventFactory(share: Object, pluginName: string, hookName: export function createAndStartEvent(eventOrEventFactory: CompileEvent | undefined, eventName: string, isAsyncEvent = false): CompileEvent | undefined { - if (eventOrEventFactory === undefined) { + if (eventOrEventFactory === undefined || eventOrEventFactory === null) { return undefined; } let event: CompileEvent; @@ -88,7 +88,7 @@ function isSubEvent(event: CompileEvent): boolean { } export function stopEvent(event: CompileEvent | undefined, isAsyncEvent: boolean = false): void { - if (event === undefined) { + if (event === undefined || event === null) { return; } if (isAsyncEvent) { -- Gitee From 30c1a584ba31702f5804c4c832f6a7f32cfbea4f Mon Sep 17 00:00:00 2001 From: Bojiang Date: Wed, 14 May 2025 11:10:16 +0800 Subject: [PATCH 042/140] jiangbo91@huawei.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix @Styles 为空 stateStyles 使用 异常错误 Signed-off-by: Bojiang Change-Id: I6e0c9170a8532f0413dc8af3d4672ba30e302f90 --- compiler/src/process_component_build.ts | 3 + .../@styles/@stylesExport.js.sample | 115 +++++++++----- .../@styles/@stylesExport.ets | 147 ++++++++++++++---- 3 files changed, 200 insertions(+), 65 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index f30c90cd1..e3db625da 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -2154,6 +2154,9 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: isStylesAttr: boolean = false, newImmutableStatements: ts.Statement[] = null, isStyleFunction: boolean = false, componentAttrInfo: ComponentAttrInfo = null, isReusableV2NodeAttr: boolean = false): void { + if (!node) { + return; + } const isStylesUIComponent: boolean = validateStylesUIComponent(node, isStylesAttr); let temp = node.expression; const statements: ts.Statement[] = []; diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport.js.sample index 5131882fd..eb38c347a 100644 --- a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport.js.sample +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport.js.sample @@ -12,85 +12,130 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +"use strict"; if (!("finalizeConstruction" in ViewPU.prototype)) { Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); } -export class FancyUseExp extends ViewPU { +class MyComponent extends ViewPU { constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { super(parent, __localStorage, elmtId, extraInfo); if (typeof paramsLambda === "function") { this.paramsGenerator_ = paramsLambda; } - this.__enable = new ObservedPropertySimplePU(true, this, "enable"); this.setInitiallyProvidedValue(params); this.finalizeConstruction(); } setInitiallyProvidedValue(params) { - if (params.enable !== undefined) { - this.enable = params.enable; - } } updateStateVars(params) { } purgeVariableDependenciesOnElmtId(rmElmtId) { - this.__enable.purgeDependencyOnElmtId(rmElmtId); } aboutToBeDeleted() { - this.__enable.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } - get enable() { - return this.__enable.get(); - } - set enable(newValue) { - this.__enable.set(newValue); - } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create({ space: 10 }); + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create("Fancy"); + Text.create('Hello world - 0'); + ViewStackProcessor.visualState("focused"); + Text.backgroundColor("#ffffeef0"); + ViewStackProcessor.visualState("pressed"); + Text.backgroundColor("#ff707070"); + ViewStackProcessor.visualState("normal"); + ViewStackProcessor.visualState(); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Hello world - 1'); + Text.backgroundColor(Color.Red); + ViewStackProcessor.visualState("focused"); + Text.backgroundColor("#ffffeef0"); + ViewStackProcessor.visualState("pressed"); + Text.backgroundColor("#ff707070"); + ViewStackProcessor.visualState("normal"); Text.backgroundColor(Color.Red); - Text.width(100); - Text.height(100); + ViewStackProcessor.visualState(); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create("Fancy"); - Text.backgroundColor(Color.Blue); - Text.width(100); - Text.height(100); + Text.create('Hello world - 4'); + ViewStackProcessor.visualState("focused"); + Text.backgroundColor("#ffffeef0"); + ViewStackProcessor.visualState("pressed"); + Text.backgroundColor("#ff707070"); + ViewStackProcessor.visualState("normal"); + ViewStackProcessor.visualState(); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithChild(); - Button.enabled(this.enable); - Button.onClick(() => { - this.enable = false; - }); + Text.create('Hello world - 6'); + Text.backgroundColor(Color.Red); + ViewStackProcessor.visualState("focused"); + Text.backgroundColor("#ffffeef0"); + ViewStackProcessor.visualState("pressed"); + Text.backgroundColor("#ff707070"); ViewStackProcessor.visualState("normal"); - Button.backgroundColor(Color.Green); - ViewStackProcessor.visualState("disabled"); - Button.backgroundColor(Color.Blue); + Text.backgroundColor(Color.Red); + ViewStackProcessor.visualState(); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Hello world - 8'); + ViewStackProcessor.visualState("focused"); + Text.backgroundColor("#ffffeef0"); ViewStackProcessor.visualState("pressed"); - Button.backgroundColor(Color.Red); + Text.backgroundColor("#ff707070"); + ViewStackProcessor.visualState("normal"); + ViewStackProcessor.visualState(); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Hello world - 9'); + Text.backgroundColor(Color.Red); + ViewStackProcessor.visualState("focused"); + Text.backgroundColor("#ffffeef0"); + ViewStackProcessor.visualState("pressed"); + Text.backgroundColor("#ff707070"); + ViewStackProcessor.visualState("normal"); + Text.backgroundColor(Color.Red); + ViewStackProcessor.visualState(); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Hello world - 12'); + ViewStackProcessor.visualState("focused"); + Text.backgroundColor("#ffffeef0"); + ViewStackProcessor.visualState("pressed"); + Text.backgroundColor("#ff707070"); + ViewStackProcessor.visualState("normal"); ViewStackProcessor.visualState(); - }, Button); + }, Text); + Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create("Fancy"); + Text.create('Hello world - 13'); + Text.backgroundColor(Color.Red); + ViewStackProcessor.visualState("focused"); + Text.backgroundColor("#ffffeef0"); + ViewStackProcessor.visualState("pressed"); + Text.backgroundColor("#ff707070"); + ViewStackProcessor.visualState("normal"); + Text.backgroundColor(Color.Red); + ViewStackProcessor.visualState(); }, Text); Text.pop(); - Button.pop(); Column.pop(); } rerender() { this.updateDirtyElements(); } static getEntryName() { - return "FancyUseExp"; + return "MyComponent"; } + } -registerNamedRoute(() => new FancyUseExp(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/render_decorator/@styles/@stylesExport", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport", integratedHsp: "false", moduleType: "followWithHap" }); +registerNamedRoute(() => new MyComponent(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/render_decorator/@styles/@stylesExport", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport", integratedHsp: "false", moduleType: "followWithHap" }); //# sourceMappingURL=@stylesExport.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport.ets index 75cb63fd3..2350d5b6e 100644 --- a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport.ets +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@styles/@stylesExport.ets @@ -12,41 +12,128 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -@Styles function globalFancy() { - .backgroundColor(Color.Red) +@Styles function overallStyles() { + } +@Styles function overallStylesAttr() { + .backgroundColor(Color.Red) +} @Entry @Component -export struct FancyUseExp { - @State enable: boolean = true - @Styles componentFancy() { - .backgroundColor(Color.Blue) +struct MyComponent { + @Styles partStyles() { + + } + + @Styles partStylesAttr() { + .backgroundColor(Color.Red) } build() { - Column({ space: 10 }) { - Text("Fancy") - .globalFancy() - .width(100) - .height(100) - Text("Fancy") - .componentFancy() - .width(100) - .height(100) - Button() { - Text("Fancy") - } - .enabled(this.enable) - .onClick(() => { - this.enable = false - }) - .stateStyles({ - normal: { - .backgroundColor(Color.Green) - }, - disabled: this.componentFancy, - pressed: globalFancy - }) + Column() { + Text('Hello world - 0') + .partStyles() + .stateStyles({ + focused:{ + .backgroundColor("#ffffeef0") + }, + pressed: { + .backgroundColor("#ff707070") + }, + normal: this.partStyles + }) + Text('Hello world - 1') + .partStylesAttr() + .stateStyles({ + focused:{ + .backgroundColor("#ffffeef0") + }, + pressed: { + .backgroundColor("#ff707070") + }, + normal: this.partStylesAttr + }) + Text('Hello world - 4') + .overallStyles() + .stateStyles({ + focused:{ + .backgroundColor("#ffffeef0") + }, + pressed: { + .backgroundColor("#ff707070") + }, + normal: overallStyles + }) + Text('Hello world - 6') + .overallStylesAttr() + .stateStyles({ + focused:{ + .backgroundColor("#ffffeef0") + }, + pressed: { + .backgroundColor("#ff707070") + }, + normal: overallStylesAttr + }) + Text('Hello world - 8') + .lastPartStyles() + .stateStyles({ + focused:{ + .backgroundColor("#ffffeef0") + }, + pressed: { + .backgroundColor("#ff707070") + }, + normal: this.lastPartStyles + }) + Text('Hello world - 9') + .lastPartStylesAttr() + .stateStyles({ + focused:{ + .backgroundColor("#ffffeef0") + }, + pressed: { + .backgroundColor("#ff707070") + }, + normal: this.lastPartStylesAttr + }) + Text('Hello world - 12') + .lastOverallStyles() + .stateStyles({ + focused:{ + .backgroundColor("#ffffeef0") + }, + pressed: { + .backgroundColor("#ff707070") + }, + normal: lastOverallStyles + }) + Text('Hello world - 13') + .lastOverallStylesAttr() + .stateStyles({ + focused:{ + .backgroundColor("#ffffeef0") + }, + pressed: { + .backgroundColor("#ff707070") + }, + normal: lastOverallStylesAttr + }) } } -} \ No newline at end of file + @Styles lastPartStyles() { + + } + + @Styles lastPartStylesAttr() { + .backgroundColor(Color.Red) + } +} + +@Styles function lastOverallStyles() { + +} + +@Styles function lastOverallStylesAttr() { + .backgroundColor(Color.Red) +} -- Gitee From 36dfc540028c77480636eabf426bc43b6b617917 Mon Sep 17 00:00:00 2001 From: Yenan Date: Thu, 15 May 2025 16:54:40 +0800 Subject: [PATCH 043/140] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=93=BE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=97=AD=E6=BA=90=E7=BB=84=E4=BB=B6=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E7=99=BD=E5=90=8D=E5=8D=95=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/components/hdsnavdestination.json | 6 ------ compiler/components/hdsnavigation.json | 6 ------ compiler/tsconfig.esm.json | 18 ------------------ compiler/tsconfig.json | 18 ------------------ 4 files changed, 48 deletions(-) delete mode 100644 compiler/components/hdsnavdestination.json delete mode 100644 compiler/components/hdsnavigation.json diff --git a/compiler/components/hdsnavdestination.json b/compiler/components/hdsnavdestination.json deleted file mode 100644 index 64504cea2..000000000 --- a/compiler/components/hdsnavdestination.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "HdsNavDestination", - "attrs": ["titleBar", "hideTitleBar", "hideBackButton", "mode", "toolbarConfiguration", "hideToolBar", "onShown", - "onHidden", "onReady", "onWillAppear", "onWillDisappear", "onWillShow", "onWillHide", "ignoreLayoutSafeArea", - "systemBarStyle", "recoverable"] -} \ No newline at end of file diff --git a/compiler/components/hdsnavigation.json b/compiler/components/hdsnavigation.json deleted file mode 100644 index 1c39e6a9f..000000000 --- a/compiler/components/hdsnavigation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "HdsNavigation", - "attrs": ["titleBar", "titleMode", "toolbarConfiguration", "hideToolBar", "hideTitleBar", "hideBackButton", "navBarWidth", - "navBarPosition", "mode", "hideNavBar", "navDestination", "navBarWidthRange", "minContentWidth", "ignoreLayoutSafeArea", - "systemBarStyle", "recoverable", "onNavBarStateChange", "onNavigationModeChange"] -} \ No newline at end of file diff --git a/compiler/tsconfig.esm.json b/compiler/tsconfig.esm.json index 0725c43f7..aa05c22c4 100755 --- a/compiler/tsconfig.esm.json +++ b/compiler/tsconfig.esm.json @@ -284,9 +284,6 @@ "ArcSwiper", "ArcScrollBar", "ArcAlphabetIndexer", - "HdsNavigation", - "HdsNavDestination", - "HdsListItemCard" ], "extend": { "decorator": ["Extend", "AnimatableExtend"], @@ -556,16 +553,6 @@ "type": "NavDestinationAttribute", "instance": "NavDestinationInstance" }, - { - "name": "HdsNavDestination", - "type": "HdsNavDestinationAttribute", - "instance": "HdsNavDestinationInstance" - }, - { - "name": "HdsListItemCard", - "type": "HdsListItemCardAttribute", - "instance": "HdsListItemCardInstance" - }, { "name": "NavRouter", "type": "NavRouterAttribute", @@ -576,11 +563,6 @@ "type": "NavigationAttribute", "instance": "NavigationInstance" }, - { - "name": "HdsNavigation", - "type": "HdsNavigationAttribute", - "instance": "HdsNavigationInstance" - }, { "name": "Navigator", "type": "NavigatorAttribute", diff --git a/compiler/tsconfig.json b/compiler/tsconfig.json index da8bf0305..e66809120 100644 --- a/compiler/tsconfig.json +++ b/compiler/tsconfig.json @@ -292,9 +292,6 @@ "ArcSwiper", "ArcScrollBar", "ArcAlphabetIndexer", - "HdsNavigation", - "HdsNavDestination", - "HdsListItemCard" ], "extend": { "decorator": ["Extend", "AnimatableExtend"], @@ -579,16 +576,6 @@ "type": "NavDestinationAttribute", "instance": "NavDestinationInstance" }, - { - "name": "HdsNavDestination", - "type": "HdsNavDestinationAttribute", - "instance": "HdsNavDestinationInstance" - }, - { - "name": "HdsListItemCard", - "type": "HdsListItemCardAttribute", - "instance": "HdsListItemCardInstance" - }, { "name": "NavRouter", "type": "NavRouterAttribute", @@ -599,11 +586,6 @@ "type": "NavigationAttribute", "instance": "NavigationInstance" }, - { - "name": "HdsNavigation", - "type": "HdsNavigationAttribute", - "instance": "HdsNavigationInstance" - }, { "name": "Navigator", "type": "NavigatorAttribute", -- Gitee From fbdbee6762e4750df2f51c4a49e34b5c1bd43b04 Mon Sep 17 00:00:00 2001 From: yangbo_404 Date: Sat, 10 May 2025 10:15:01 +0800 Subject: [PATCH 044/140] add compatibleVersion check Signed-off-by: yangbo_404 --- compiler/src/ets_checker.ts | 4 +- .../fast_build/system_api/api_check_define.ts | 1 + .../fast_build/system_api/api_check_utils.ts | 150 +++++++++++++++--- 3 files changed, 132 insertions(+), 23 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 5f382fb94..3c7214469 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -359,8 +359,8 @@ export function createLanguageService(rootFileNames: string[], resolveModulePath currentFileName: containFilePath }; }, - getJsDocNodeConditionCheckedResult: (jsDocFileCheckedInfo: ts.FileCheckModuleInfo, jsDocs: ts.JsDocTagInfo[]) => { - return getJsDocNodeConditionCheckResult(jsDocFileCheckedInfo, jsDocs); + getJsDocNodeConditionCheckedResult: (jsDocFileCheckedInfo: ts.FileCheckModuleInfo, jsDocInfos: ts.JsDocTagInfo[], jsDocs?: ts.JSDoc[]) => { + return getJsDocNodeConditionCheckResult(jsDocFileCheckedInfo, jsDocInfos, jsDocs); }, uiProps: [], clearProps: function() { diff --git a/compiler/src/fast_build/system_api/api_check_define.ts b/compiler/src/fast_build/system_api/api_check_define.ts index 94df5966f..d4a8a9794 100644 --- a/compiler/src/fast_build/system_api/api_check_define.ts +++ b/compiler/src/fast_build/system_api/api_check_define.ts @@ -23,6 +23,7 @@ export const SYSCAP_TAG_CHECK_NAME: string = 'syscap'; export const SYSCAP_TAG_CHECK_WARNING: string = "The system capacity of this api '{0}' is not supported on all devices"; export const SYSCAP_TAG_CONDITION_CHECK_WARNING: string = 'The API is not supported on all devices. Use the canIUse condition to determine whether the API is supported.'; export const CANIUSE_FUNCTION_NAME: string = 'canIUse'; +export const VERSION_CHECK_FUNCTION_NAME: string = 'isApiVersionGreaterOrEqual'; export const RUNTIME_OS_OH: string = 'OpenHarmony'; export const FORM_TAG_CHECK_NAME: string = 'form'; export const FORM_TAG_CHECK_ERROR: string = "'{0}' can't support form application."; diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index da30bfff2..defceb491 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -68,7 +68,8 @@ import { CONSTANT_STEP_3, GLOBAL_DECLARE_WHITE_LIST, SINCE_TAG_NAME, - SINCE_TAG_CHECK_ERROER + SINCE_TAG_CHECK_ERROER, + VERSION_CHECK_FUNCTION_NAME } from './api_check_define'; import { JsDocCheckService } from './api_check_permission'; @@ -90,6 +91,10 @@ export interface CheckJsDocSpecialValidCallbackInterface { (jsDocTags: readonly ts.JSDocTag[], config: ts.JsDocNodeCheckConfigItem): boolean; } +export interface checkConditionValidCallbackInterface { + (node: ts.CallExpression, specifyFuncName: string, importSymbol: string, jsDocs?: ts.JSDoc[]): boolean; +} + interface HasJSDocNode extends ts.Node { jsDoc?: ts.JSDoc[]; } @@ -260,14 +265,16 @@ export function checkTypeReference(node: ts.TypeReferenceNode, transformLog: IFi * @param {string} message - error message * @param {ts.DiagnosticCategory} type - error type * @param {boolean} tagNameShouldExisted - tag is required - * @param {CheckValidCallbackInterface} [checkValidCallback] - * @param {CheckJsDocSpecialValidCallbackInterface} [checkJsDocSpecialValidCallback] + * @param {CheckValidCallbackInterface} checkValidCallback + * @param {CheckJsDocSpecialValidCallbackInterface} checkJsDocSpecialValidCallback + * @param {checkConditionValidCallbackInterface} checkConditionValidCallback * @returns {ts.JsDocNodeCheckConfigItem} */ function getJsDocNodeCheckConfigItem(tagName: string[], message: string, needConditionCheck: boolean, type: ts.DiagnosticCategory, specifyCheckConditionFuncName: string, tagNameShouldExisted: boolean, checkValidCallback?: CheckValidCallbackInterface, - checkJsDocSpecialValidCallback?: CheckJsDocSpecialValidCallbackInterface): ts.JsDocNodeCheckConfigItem { + checkJsDocSpecialValidCallback?: CheckJsDocSpecialValidCallbackInterface, + checkConditionValidCallback?: checkConditionValidCallbackInterface): ts.JsDocNodeCheckConfigItem { return { tagName: tagName, message: message, @@ -276,7 +283,8 @@ function getJsDocNodeCheckConfigItem(tagName: string[], message: string, needCon specifyCheckConditionFuncName: specifyCheckConditionFuncName, tagNameShouldExisted: tagNameShouldExisted, checkValidCallback: checkValidCallback, - checkJsDocSpecialValidCallback: checkJsDocSpecialValidCallback + checkJsDocSpecialValidCallback: checkJsDocSpecialValidCallback, + checkConditionValidCallback: checkConditionValidCallback }; } @@ -331,8 +339,8 @@ export function getJsDocNodeCheckConfig(fileName: string, sourceFileName: string checkConfigArray.push(getJsDocNodeCheckConfigItem([SYSTEM_API_TAG_CHECK_NAME], SYSTEM_API_TAG_CHECK_WARNING, false, ts.DiagnosticCategory.Warning, '', false)); checkConfigArray.push(getJsDocNodeCheckConfigItem([SINCE_TAG_NAME], - SINCE_TAG_CHECK_ERROER, false, ts.DiagnosticCategory.Warning, - '', false, undefined, checkSinceValue)); + SINCE_TAG_CHECK_ERROER, true, ts.DiagnosticCategory.Warning, + VERSION_CHECK_FUNCTION_NAME, false, undefined, checkSinceValue, checkVersionConditionValidCallback)); // TODO: the third param is to be opened checkConfigArray.push(getJsDocNodeCheckConfigItem([SYSCAP_TAG_CHECK_NAME], SYSCAP_TAG_CHECK_WARNING, false, ts.DiagnosticCategory.Warning, @@ -541,18 +549,11 @@ function checkSinceValue(jsDocTags: readonly ts.JSDocTag[], config: ts.JsDocNode if (!currentNode.jsDoc) { return false; } - let minSince: string = ''; - const hasSince: boolean = currentNode.jsDoc.some((doc: ts.JSDoc) => { - return doc.tags?.some((tag: ts.JSDocTag) => { - if (tag.tagName.escapedText.toString() === SINCE_TAG_NAME) { - minSince = tag.comment.toString(); - return true; - } - return false; - }); - }); - const compatibleSdkVersion: string = projectConfig.compatibleSdkVersion; - if (hasSince && Number(minSince) > Number(compatibleSdkVersion)) { + const minSince: string = getMinVersion(currentNode.jsDoc); + const hasSince: boolean = minSince !== ''; + + const compatibleSdkVersion: string = String(projectConfig.compatibleSdkVersion); + if (hasSince && comparePointVersion(compatibleSdkVersion.toString(), minSince) === -1) { config.message = SINCE_TAG_CHECK_ERROER.replace('$SINCE1', minSince).replace('$SINCE2', compatibleSdkVersion); return true; } @@ -633,11 +634,29 @@ export function checkPermissionValue(jsDocTags: readonly ts.JSDocTag[], config: /** * custom condition check * @param { ts.FileCheckModuleInfo } jsDocFileCheckedInfo - * @param { ts.JsDocTagInfo[] } jsDocs + * @param { ts.JsDocTagInfo[] } jsDocTagInfos + * @param { ?ts.JSDoc[] } jsDocs * @returns */ -export function getJsDocNodeConditionCheckResult(jsDocFileCheckedInfo: ts.FileCheckModuleInfo, jsDocs: ts.JsDocTagInfo[]): +export function getJsDocNodeConditionCheckResult(jsDocFileCheckedInfo: ts.FileCheckModuleInfo, jsDocTagInfos: ts.JsDocTagInfo[], jsDocs?: ts.JSDoc[]): ts.ConditionCheckResult { + let result: ts.ConditionCheckResult = { + valid: true + }; + if (jsDocFileCheckedInfo.tagName.includes(SYSCAP_TAG_CHECK_NAME)) { + result = checkSyscapCondition(jsDocTagInfos); + } else if (jsDocFileCheckedInfo.tagName.includes(SINCE_TAG_NAME) && jsDocs) { + result = checkSinceCondition(jsDocs); + } + return result; +} + +/** + * syscap condition check + * @param { ts.JSDoc[] } jsDocs + * @returns { ts.ConditionCheckResult } + */ +function checkSyscapCondition(jsDocs: ts.JsDocTagInfo[]): ts.ConditionCheckResult { const result: ts.ConditionCheckResult = { valid: true }; @@ -664,3 +683,92 @@ export function getJsDocNodeConditionCheckResult(jsDocFileCheckedInfo: ts.FileCh } return result; } + +/** + * version condition check + * @param { ts.JSDoc[] } jsDocs + * @returns { ts.ConditionCheckResult } + */ +function checkSinceCondition(jsDocs: ts.JSDoc[]): ts.ConditionCheckResult { + const result: ts.ConditionCheckResult = { + valid: true + }; + if (!jsDocs || !jsDocs[0]) { + return result; + } + const minVersion: string = getMinVersion(jsDocs); + const hasSince: boolean = minVersion !== ''; + + const compatibleSdkVersion: string = projectConfig.compatibleSdkVersion.toString(); + + if (hasSince && comparePointVersion(compatibleSdkVersion, minVersion) === -1) { + result.valid = false; + result.type = ts.DiagnosticCategory.Warning; + result.message = SINCE_TAG_CHECK_ERROER.replace('$SINCE1', minVersion).replace('$SINCE2', compatibleSdkVersion); + } + return result; +} + +/** + * version condition check, print error message + * @param { ts.CallExpression } node + * @param { string } specifyFuncName + * @param { string } targetVersion + * @param { ?ts.JSDoc[] } jsDocs + * @returns { boolean } + */ +function checkVersionConditionValidCallback(node: ts.CallExpression, specifyFuncName: string, targetVersion: string, jsDocs?: ts.JSDoc[]): boolean { + if (ts.isIdentifier(node.expression) && node.arguments.length === 1 && node.expression.escapedText.toString() === specifyFuncName) { + const expression = node.arguments[0]; + if (ts.isStringLiteral(expression) && jsDocs && comparePointVersion(expression.text.toString(), getMinVersion(jsDocs)) !== -1) { + return true; + } + } + return false; +} + + +/** + * get minversion + * @param { ts.JSDoc[] } jsDocs + * @returns string + */ +function getMinVersion(jsDocs: ts.JSDoc[]): string { + if (!jsDocs || !jsDocs[0]) { + return ''; + } + let minVersion: string = ''; + jsDocs.some((doc: ts.JSDoc) => { + return doc.tags?.some((tag: ts.JSDocTag) => { + if (tag.tagName.escapedText.toString() === SINCE_TAG_NAME) { + minVersion = tag.comment.toString(); + return true; + } + return false; + }); + }); + return minVersion; +} + +/** + * compare point version + * @param { string } firstVersion + * @param { string } secondVersion + * @returns { number } + */ +function comparePointVersion(firstVersion: string, secondVersion: string): number { + const firstPointVersion = firstVersion.split('.'); + const secondPointVersion = secondVersion.split('.'); + for (let i = 0; i < 3; i++) { + const part1 = parseInt(firstPointVersion[i] || '0', 10); + const part2 = parseInt(secondPointVersion[i] || '0', 10); + + if (part1 < part2) { + return -1; + } + if (part1 > part2) { + return 1; + } + } + return 0; +} \ No newline at end of file -- Gitee From 6a1bf7277a11d8bee21e78824b3217c112c89955 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Wed, 14 May 2025 20:32:52 +0800 Subject: [PATCH 045/140] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=84=8F?= =?UTF-8?q?=E5=9B=BE=E8=A3=85=E9=A5=B0=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/process_ui_syntax.ts | 4 + compiler/src/userIntents_parser/intentType.ts | 37 +++- .../userIntents_parser/parseUserIntents.ts | 186 +++++++++++------- 3 files changed, 146 insertions(+), 81 deletions(-) diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 9bb392e45..8770b4dea 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -300,7 +300,9 @@ export function processUISyntax(program: ts.Program, ut = false, processImport(node, pagesDir, transformLog.errors); } if (ts.isStructDeclaration(node)) { + const eventParseIntentTime: CompileEvent | undefined = createAndStartEvent(eventProcessUISyntax, 'pageParseIntentTime'); node = parseIntent.detectInsightIntent(node, metaInfo, filePath); + stopEvent(eventParseIntentTime); hasStruct = true; componentCollection.currentClassName = node.name.getText(); componentCollection.entryComponent === componentCollection.currentClassName && entryKeyNode(node); @@ -410,7 +412,9 @@ export function processUISyntax(program: ts.Program, ut = false, }); } } else if (ts.isClassDeclaration(node)) { + const eventParseIntentTime: CompileEvent | undefined = createAndStartEvent(eventProcessUISyntax, 'parseIntentTime'); node = parseIntent.detectInsightIntent(node, metaInfo, filePath); + stopEvent(eventParseIntentTime); if (hasDecorator(node, COMPONENT_SENDABLE_DECORATOR)) { if (projectConfig.compileHar && !projectConfig.useTsHar) { let warnMessage: string = 'If you use @Sendable in js har, an exception will occur during runtime.\n' + diff --git a/compiler/src/userIntents_parser/intentType.ts b/compiler/src/userIntents_parser/intentType.ts index 417462989..9f8323246 100644 --- a/compiler/src/userIntents_parser/intentType.ts +++ b/compiler/src/userIntents_parser/intentType.ts @@ -108,15 +108,15 @@ export class ParamChecker { } function validateRequiredString(v: ts.Expression): boolean { - return v !== null && ts.isStringLiteral(v) && v.text.trim() !== ''; + return v !== undefined && v !== null && ts.isStringLiteral(v) && v.text.trim() !== ''; } function validateOptionalString(v: ts.Expression): boolean { - return v !== null && ts.isStringLiteral(v); + return v !== undefined && v !== null && ts.isStringLiteral(v); } function validateIcon(v: ts.Expression): boolean { - return ts.isCallExpression(v) && v.expression.getText() === '$r'; + return v !== undefined && v !== null && ((ts.isCallExpression(v) && v.expression.getText() === '$r') || ts.isStringLiteral(v)); } function validateParameters(v: ts.Expression): boolean { @@ -131,6 +131,9 @@ function validateParameters(v: ts.Expression): boolean { } function validateKeywords(v: ts.Expression): boolean { + if (v === undefined || v === null) { + return false; + } if (!ts.isArrayLiteralExpression(v)) { return false; } @@ -138,7 +141,7 @@ function validateKeywords(v: ts.Expression): boolean { const element = ts.isIdentifier(ele) ? parseIntent.checker.getSymbolAtLocation(ele)?.valueDeclaration?.initializer : ele; - return ts.isStringLiteral(element) || ts.isNoSubstitutionTemplateLiteral(element); + return element !== undefined && (ts.isStringLiteral(element) || ts.isNoSubstitutionTemplateLiteral(element)); }); } @@ -165,7 +168,27 @@ IntentLinkInfoChecker.allowFields = new Set([ ]); IntentLinkInfoChecker.paramValidators = { parameters: validateParameters, - paramMappings: validateOptionalString, + paramMappings: (v: ts.Expression): boolean => { + if (v === null || v === undefined) { + return false; + } + if (!ts.isArrayLiteralExpression(v)) { + return false; + } + return v.elements.every(element => { + if (element.kind === ts.SyntaxKind.NullKeyword) { + return false; + } + if (element.kind === ts.SyntaxKind.UndefinedKeyword) { + return false; + } + if (ts.isIdentifier(element) && element.text === 'undefined') { + return false; + } + return true; + } + ); + }, keywords: validateKeywords, intentName: validateRequiredString, domain: validateRequiredString, @@ -192,7 +215,7 @@ intentEntryInfoChecker.paramValidators = { displayName: validateRequiredString, domain: validateRequiredString, executeMode(v: ts.Expression): boolean { - return ts.isArrayLiteralExpression(v) && + return v !== undefined && v !== null && ts.isArrayLiteralExpression(v) && v.elements.every(e => { const validModes = [ 'insightIntent.ExecuteMode.UI_ABILITY_FOREGROUND', @@ -207,7 +230,7 @@ intentEntryInfoChecker.paramValidators = { intentVersion: validateRequiredString, llmDescription: validateOptionalString }; -// todo 把下面的几个checker换成上面的格式! + export const intentMethodInfoChecker: ParamChecker = new ParamChecker(); intentMethodInfoChecker.requiredFields = [...BASE_REQUIRED as Array]; intentMethodInfoChecker.allowFields = new Set([ diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index f35c08424..93e4db7a8 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -55,7 +55,6 @@ import { COMPONENT_USER_INTENTS_DECORATOR_METHOD, COMPONENT_USER_INTENTS_DECORATOR_PAGE } from '../pre_define'; -import { hasDecorator } from '../utils'; type StaticValue = string | number | boolean | null | undefined | StaticValue[] | { [key: string]: StaticValue }; @@ -70,7 +69,7 @@ class ParseIntent { this.intentData = []; this.currentFilePath = ''; this.heritageClassSet = new Set(); - this.heritageClassSet.add('IntentEntity_sdk'); + this.heritageClassSet.add('InsightIntentEntryExecutor_sdk'); this.updatePageIntentObj = new Map(); } @@ -82,6 +81,22 @@ class ParseIntent { isUpdateCompile: boolean = false; isInitCache : boolean = false; + hasDecorator(node: ts.Node, decorators: string[]): boolean { + if (!node.modifiers) { + return false; + } + return node.modifiers.some(decorator => { + if (!ts.isDecorator(decorator)) { + return false; + } + let decoratorName: string | undefined; + if (ts.isCallExpression(decorator.expression)) { + decoratorName = '@' + decorator.expression.expression.getText(); + } + return decoratorName !== undefined && decorators.includes(decoratorName); + }); + } + detectInsightIntent(node: ts.ClassDeclaration, metaInfo: object, filePath: string): ts.Node { if (!this.isInitCache && projectConfig.cachePath) { const cacheSourceMapPath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); @@ -99,20 +114,21 @@ class ParseIntent { this.updatePageIntentObj.set(`@normalized:${recordName}`, []); } } - if (hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR) || hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR_ENTRY) || - hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR_FUNCTION) || hasDecorator(node, COMPONENT_USER_INTENTS_DECORATOR_PAGE)) { - const checker: TypeChecker = metaInfo.checker; - this.handleIntent(node, checker, filePath, metaInfo); - node = this.removeDecorator(node, [COMPONENT_USER_INTENTS_DECORATOR, COMPONENT_USER_INTENTS_DECORATOR_ENTRY, - COMPONENT_USER_INTENTS_DECORATOR_FUNCTION, COMPONENT_USER_INTENTS_DECORATOR_PAGE, COMPONENT_USER_INTENTS_DECORATOR_METHOD]); - } else { + const definedDecorators: string[] = [COMPONENT_USER_INTENTS_DECORATOR, COMPONENT_USER_INTENTS_DECORATOR_ENTRY, + COMPONENT_USER_INTENTS_DECORATOR_FUNCTION, COMPONENT_USER_INTENTS_DECORATOR_PAGE]; + if (ts.isClassDeclaration(node) && !this.hasDecorator(node, [COMPONENT_USER_INTENTS_DECORATOR_FUNCTION])) { node.members.forEach((member) => { if (ts.isMethodDeclaration(member) && this.hasModifier(member, ts.SyntaxKind.StaticKeyword) && - hasDecorator(member, COMPONENT_USER_INTENTS_DECORATOR_METHOD)) { - throw Error(`${DECORATOR_ILLEGAL_USE.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + this.hasDecorator(member, [COMPONENT_USER_INTENTS_DECORATOR_METHOD])) { + throw Error(`${DECORATOR_ILLEGAL_USE.toString()}, className: ${node.name.getText()}`); } }); } + if (this.hasDecorator(node, definedDecorators)) { + const checker: TypeChecker = metaInfo.checker; + this.handleIntent(node, checker, filePath, metaInfo); + node = this.removeDecorator(node, definedDecorators.concat(COMPONENT_USER_INTENTS_DECORATOR_METHOD)); + } return node; } @@ -131,6 +147,10 @@ class ParseIntent { if (!expr || !ts.isCallExpression(expr)) { return; } + const argumentKind: ts.SyntaxKin | undefined = expr.arguments[0]?.kind; + if (argumentKind && argumentKind === ts.SyntaxKind.NullKeyword || argumentKind && argumentKind === ts.SyntaxKind.UndefinedKeyword) { + return; + } const symbol: ts.Symbol = checker.getTypeAtLocation(decorator.expression.expression)?.getSymbol(); const declarations: ts.Declaration[] | undefined = symbol?.getDeclarations(); if (!declarations || declarations.length === 0) { @@ -151,7 +171,7 @@ class ParseIntent { 'decoratorFile': `@normalized:${recordName}`, 'decoratorClass': node.name.text }; - const originalDecorator: string = decorator.getText().replace(/\(.*\)$/, '').trim(); + const originalDecorator: string = '@' + decorator.expression.expression.getText(); if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR) { this.handleLinkDecorator(intentObj, node, decorator); } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_ENTRY) { @@ -174,8 +194,6 @@ class ParseIntent { 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_PAGE }); this.analyzeDecoratorArgs(args, intentObj, IntentPageInfoChecker); - const properties: Record = this.parsePageProperties(node); - this.schemaValidateSync(properties, intentObj.parameters); this.createObfuscation(node); this.transformPagePath(intentObj, pkgParams); if (this.isUpdateCompile) { @@ -208,9 +226,9 @@ class ParseIntent { const functionName: string = methodDecorator.functionName; const methodArgs: ts.NodeArray = methodDecorator.args; const properties: Record = methodDecorator.parameters; - const methodObj: object = Object.assign({}, intentObj, {functionName}); + const functionParamList: Array = Object.keys(properties); + const methodObj: object = Object.assign({}, intentObj, {functionName, 'functionParamList': functionParamList}); this.analyzeDecoratorArgs(methodArgs, methodObj, intentMethodInfoChecker); - this.schemaValidateSync(properties, methodObj.parameters); if (this.isUpdateCompile) { this.updatePageIntentObj.get(methodObj.decoratorFile).push(methodObj); } @@ -278,20 +296,6 @@ class ParseIntent { } } - parsePageProperties(node: ts.Node): Record { - const mergeObject: Record = {}; - node.members.forEach(member => { - if (ts.isPropertyDeclaration(member)) { - const symbol = this.checker.getSymbolAtLocation(member.name); - if (symbol) { - const objItem: Record = this.processProperty(symbol); - Object.assign(mergeObject, objItem); - } - } - }); - return mergeObject; - } - analyzeBaseClass(node: ts.ClassDeclaration, pkgParams: object, intentObj: object): void { const interfaces: ts.ExpressionWithTypeArguments[] = []; node.heritageClauses?.forEach(clause => { @@ -304,6 +308,9 @@ class ParseIntent { if (parentNode) { this.analyzeClassHeritage(parentNode, node, pkgParams, intentObj); } + } else { + throw Error(`${INVALID_BASE_CLASS_ERROR.toString()}, + The custom intent must be ultimately inherited to InsightIntentEntryExecutor, invalidDecoratorPath: ${this.currentFilePath}`); } } @@ -318,8 +325,14 @@ class ParseIntent { continue; } const decorator: boolean = member.modifiers?.find(m => { - const text = m.getText(); - return text.replace(/\(.*\)$/, '').trim() === decoratorType; + if (!ts.isDecorator(m)) { + return false; + } + let decoratorName: string | undefined; + if (ts.isCallExpression(m.expression)) { + decoratorName = '@' + m.expression.expression.getText(); + } + return decoratorName === decoratorType; }); if (decorator && ts.isCallExpression(decorator.expression)) { const parameters: Record = {}; @@ -346,7 +359,14 @@ class ParseIntent { parentNode: ts.ExpressionWithTypeArguments, node: ts.ClassDeclaration, pkgParams: object, intentObj: object ): void { const parentSymbol: ts.Symbol = this.checker.getTypeAtLocation(parentNode).getSymbol(); - const parentClassName: string = parentSymbol.getName(); + let parentClassName: string; + node.heritageClauses.forEach(clause => { + if (clause.token === ts.SyntaxKind.ExtendsKeyword) { + parentClassName = parentNode.expression.getText(); + } else if (clause.token === ts.SyntaxKind.ImplementsKeyword) { + parentClassName = parentSymbol.getName(); + } + }); const parentFilePath: string = parentSymbol.getDeclarations()?.[0].getSourceFile().fileName; const logger: IntentLogger = IntentLogger.getInstance(); const parentRecordName: string = getNormalizedOhmUrlByFilepath(parentFilePath, projectConfig, logger, pkgParams, null); @@ -360,8 +380,9 @@ class ParseIntent { }); const recordPath: string = isGlobalPath ? `sdk` : `@normalized:${parentRecordName}`; if (isGlobalPath) { - if (parentClassName !== 'IntentEntity') { - throw Error(`${INVALID_BASE_CLASS_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + if (parentClassName !== 'InsightIntentEntryExecutor') { + throw Error(`${INVALID_BASE_CLASS_ERROR.toString()}, + The custom intent must be ultimately inherited to InsightIntentEntryExecutor, invalidDecoratorPath: ${this.currentFilePath}`); } } this.heritageClassSet.add(baseClassName + '_' + `@normalized:${baseRecordName}`); @@ -391,10 +412,12 @@ class ParseIntent { const genericType: ts.Type = this.checker.getTypeAtLocation(arg); let genericName: string; let genericSource: string | undefined; + let recordGenericSource : string; const genericSymbol: ts.Symbol | undefined = genericType.getSymbol(); if (genericSymbol) { genericName = genericSymbol.getName(); genericSource = genericSymbol.declarations?.[0]?.getSourceFile().fileName; + recordGenericSource = path.relative(projectConfig.moduleName, genericSource).replace(/\\/g, '/'); } else { genericName = this.checker.typeToString(genericType); const parentTypeNode: ts.Node = arg.parent; @@ -404,13 +427,13 @@ class ParseIntent { genericSource = symbol?.declarations?.[0]?.getSourceFile().fileName; } if (!genericSource && this.isPrimitiveType(genericType)) { - genericSource = 'lib.es5.d.ts'; + recordGenericSource = 'lib.es5.d.ts'; } } Object.assign(generic, { 'typeName': genericName, - 'definitionFilePath': genericSource + 'definitionFilePath': recordGenericSource }); ClassInheritanceInfo.generics.push(generic); } @@ -424,16 +447,18 @@ class ParseIntent { } parseClassNode(node: ts.ClassDeclaration): Record { - const type: ts.Type = this.checker.getTypeAtLocation(node); const mergedObject: Record = {}; - this.checker.getPropertiesOfType(type) - .filter(prop => { - const declarations: Declaration[] | undefined = prop.getDeclarations(); - return declarations?.some(decl => - ts.isPropertyDeclaration(decl) - ); - }).forEach(prop => { - const objItem: Record = this.processProperty(prop); + node.members + .filter((member): member is ts.PropertyDeclaration => { + return ts.isPropertyDeclaration(member) && + member.parent === node; + }) + .forEach(propertyNode => { + const propSymbol = this.checker.getSymbolAtLocation(propertyNode.name); + if (!propSymbol) { + return; + } + const objItem: Record = this.processProperty(propSymbol); Object.assign(mergedObject, objItem); }); return mergedObject; @@ -486,14 +511,26 @@ class ParseIntent { removeDecorator(node: ts.ClassDeclaration, decoratorNames: string[]): ts.ClassDeclaration { const filteredModifiers: ts.ModifierLike[] = node.modifiers.filter(decorator => { - const originalDecortor: string = decorator.getText().replace(/\(.*\)$/, '').trim(); - return !decoratorNames.includes(originalDecortor); + if (!ts.isDecorator(decorator)) { + return true; + } + let decoratorName: string | undefined; + if (ts.isCallExpression(decorator.expression)) { + decoratorName = '@' + decorator.expression.expression.getText(); + } + return !decoratorNames.includes(decoratorName); }); const updatedMembers: ts.ClassElement[] = node.members.map(member => { if (ts.isMethodDeclaration(member) && this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { const memberModifiers: ts.ModifierLike[] = (member.modifiers ?? []).filter(decorator => { - const originalDecorator = decorator.getText().replace(/\(.*\)$/, '').trim(); - return originalDecorator !== COMPONENT_USER_INTENTS_DECORATOR_METHOD; + if (!ts.isDecorator(decorator)) { + return true; + } + let decoratorName: string | undefined; + if (ts.isCallExpression(decorator.expression)) { + decoratorName = '@' + decorator.expression.expression.getText(); + } + return decoratorName !== COMPONENT_USER_INTENTS_DECORATOR_METHOD; }); if (memberModifiers.length !== (member.modifiers?.length ?? 0)) { return ts.factory.updateMethodDeclaration( @@ -610,7 +647,7 @@ class ParseIntent { const declaration: ts.Declaration = symbol?.valueDeclaration; this.validateRequiredIntentLinkInfo(declaration.initializer, checker); } else { - this.validateRequiredIntentLinkInfo(elem.initializer, checker); + this.validateRequiredIntentLinkInfo(elem, checker); } }); } else if (ts.isIdentifier(prop)) { @@ -618,7 +655,7 @@ class ParseIntent { const declaration: ts.Declaration = symbol?.valueDeclaration; this.validateRequiredIntentLinkInfo(declaration.initializer, checker); } else { - this.validateRequiredIntentLinkInfo(prop.initializer, checker); + this.validateRequiredIntentLinkInfo(prop, checker); } } @@ -634,7 +671,7 @@ class ParseIntent { if (ts.isIdentifier(prop.initializer)) { const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(prop.initializer); const declaration: ts.Declaration = symbol?.valueDeclaration; - if (validator && !validator(declaration.initializer)) { + if (validator && !validator(declaration?.initializer)) { throw Error(`${INCORRECT_PARAM_TYPE_ERROR.toString()}, cause param: '${paramName.toString()}', invalidDecoratorPath: ${this.currentFilePath}`); } } else { @@ -815,27 +852,12 @@ class ParseIntent { `${intentObj.schema}_${intentObj.intentVersion}.json` ); if (fs.existsSync(schemaPath)) { - if (intentObj.parameters) { - throw Error(`${DISALLOWED_PARAM_ERROR.toString()}` + - `, the standard user intents does not allow passing the parameter 'parameter', invalidDecoratorPath: ${this.currentFilePath}`); - } - if (intentObj.keywords) { - throw Error(`${DISALLOWED_PARAM_ERROR.toString()}` + - `, the standard user intents does not allow passing the parameter 'keywords', invalidDecoratorPath: ${this.currentFilePath}`); - } - if (intentObj.llmDescription) { - throw Error(`${DISALLOWED_PARAM_ERROR.toString()}` + - `, the standard user intents does not allow passing the parameter 'llmDescription', invalidDecoratorPath: ${this.currentFilePath}`); - } const schemaContent: string = fs.readFileSync(schemaPath, 'utf-8'); const schemaObj: object = JSON.parse(schemaContent); intentObj.parameters = schemaObj.params; - if (schemaObj.llmDescription) { - intentObj.llmDescription = schemaObj.llmDescription; - } - if (schemaObj.keywords) { - intentObj.keywords = schemaObj.keywords; - } + intentObj.llmDescription = schemaObj.llmDescription; + intentObj.keywords = schemaObj.keywords; + intentObj.intentName = schemaObj.intentName; } } } @@ -916,6 +938,9 @@ class ParseIntent { if (!schemaObj) { return; } + if (schemaObj.additionalProperties === false) { + this.schemaAdditionalPropertiesValidation(schemaData, schemaObj.properties); + } if (schemaObj.items && schemaObj.items.type === 'array') { this.schemaValidateSync(schemaData, schemaObj.items.items); } @@ -923,7 +948,12 @@ class ParseIntent { throw Error(`${SCHEMA_ROOT_TYPE_MISMATCH_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); } if (schemaObj.properties) { - this.schemaPropertiesValidation(schemaData, schemaObj); + const items: string[] = Object.keys(schemaObj.properties); + if (items.length === 1 && items[0].type === 'array') { + this.schemaValidateSync(schemaData, items[0].items); + } else { + this.schemaPropertiesValidation(schemaData, schemaObj); + } } if (schemaObj.required) { this.schemaValidationRequiredRule(schemaData, schemaObj); @@ -931,7 +961,15 @@ class ParseIntent { this.schemaValidateRules(schemaData, schemaObj); } - writeUserIntentJsonFile(): void { + schemaAdditionalPropertiesValidation(schemaData, schemaProps): void { + for (const key of Object.keys(schemaData)) { + if (!schemaProps[key]) { + throw Error(`${SCHEMA_VALIDATE_TYPE_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + } + } + } + + writeUserIntentJsonFile(): void { if (!projectConfig.aceProfilePath) { throw Error(`${INTERNAL_ERROR.toString()}, aceProfilePath not found, invalidDecoratorPath: ${this.currentFilePath}`); } @@ -975,7 +1013,7 @@ class ParseIntent { const duplicates = new Set(); this.intentData.forEach(item => { if (duplicates.has(item.intentName)) { - throw Error(`${DECORATOR_DUPLICATE_INTENTNAME.toString()}, value : ${item.intentName}, invalidDecoratorPath: ${this.currentFilePath}`); + throw Error(`${DECORATOR_DUPLICATE_INTENTNAME.toString()}, value : ${item.intentName}`); } else { duplicates.add(item.intentName); } -- Gitee From 5dc4c2cbf82d0c8cd3c90d92be8c7889a9a55d09 Mon Sep 17 00:00:00 2001 From: zenghang Date: Fri, 16 May 2025 14:50:20 +0800 Subject: [PATCH 046/140] fix keep options Issue: IC8ASU Signed-off-by: zenghang Change-Id: I8fdef387aaff25c67aba772b19bfcc941d408173 --- .../ark_compiler/bytecode_obfuscator.ts | 19 +++++++++-- .../common/bytecode_obfuscatior.test.ts | 32 ++++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts index cae8b798d..096a58c63 100644 --- a/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts +++ b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts @@ -245,11 +245,12 @@ export class BytecodeObfuscator { public convertAbstractPathToRecordName(moduleInfos: Map): void { if (this.bytecodeObfuscateConfig.obfuscationRules.keepOptions && - this.bytecodeObfuscateConfig.obfuscationRules.keepOptions.keepPaths.length > 0) { + this.bytecodeObfuscateConfig.obfuscationRules.keepOptions.keepPaths.size > 0) { const convertedPath: Set = new Set(); this.bytecodeObfuscateConfig.obfuscationRules.keepOptions.keepPaths.forEach(path => { if (moduleInfos.get(path)) { convertedPath.add(moduleInfos.get(path).recordName); + this.bytecodeObfuscateConfig.removeKeepPaths(path); } }); this.bytecodeObfuscateConfig.addKeepPaths(convertedPath); @@ -524,7 +525,6 @@ export class BytecodeObfuscationConfig { universalReservedToplevelNames: new Set( universalReservedGlobalNames?.map(regexp => regexp.toString()) || [] ) - }, fileNameObfuscation: { enable: options.enableFileNameObfuscation, @@ -569,6 +569,21 @@ export class BytecodeObfuscationConfig { addKeepPaths(values: string | string[] | Set): void { this.addToSet(this.obfuscationRules.keepOptions.keepPaths, values); } + + removeKeepPaths(values: string | string[] | Set): void { + this.removeFromSet(this.obfuscationRules.keepOptions.keepPaths, values); + } + + removeFromSet( + set: Set, + values: string | string[] | Set + ): void { + if (typeof values === 'string') { + set.delete(values); + } else { + values.forEach((value) => set.delete(value)); + } + } } function processReservedFileNames(reservedFileNames: string[]): ReservedNameInfo { diff --git a/compiler/test/ark_compiler_ut/common/bytecode_obfuscatior.test.ts b/compiler/test/ark_compiler_ut/common/bytecode_obfuscatior.test.ts index 5a91d1aff..62208e383 100644 --- a/compiler/test/ark_compiler_ut/common/bytecode_obfuscatior.test.ts +++ b/compiler/test/ark_compiler_ut/common/bytecode_obfuscatior.test.ts @@ -19,7 +19,7 @@ import RollUpPluginMock from '../mock/rollup_mock/rollup_plugin_mock'; import { RELEASE } from '../../../lib/fast_build/ark_compiler/common/ark_define'; import { BytecodeObfuscator } from '../../../lib/fast_build/ark_compiler/bytecode_obfuscator'; import { OBFUSCATE_RULE_BYTECODE_OBFUSCATION_ENABLE_PATH } from '../mock/rollup_mock/path_config'; - +import { ModuleInfo } from '../../../lib/fast_build/ark_compiler/module/module_mode'; mocha.describe('test bytecodeObfuscator file api', function () { mocha.before(function () { @@ -161,4 +161,34 @@ mocha.describe('test bytecodeObfuscator file api', function () { expect(BytecodeObfuscator.getInstance().cmdArgs.includes('config.json')).to.be.true; BytecodeObfuscator.cleanBcObfuscatorObject(); }); + + mocha.it("4-1: test convertAbstractPathToRecordName successfully and remove originPath",function () { + this.rollup.share.arkProjectConfig.isArkguardEnabled = false; + this.rollup.share.arkProjectConfig.isBytecodeObfEnabled = true; + this.rollup.share.arkProjectConfig.obfuscationMergedObConfig.options.bytecodeObf.debugging = true; + const originPath = 'ProblemReproduction/oh_modules/.ohpm/reflect-metadata@0.2.1/oh_modules/reflect-metadata/Reflect.js'; + const recordName = '&reflect-meatadata|0.2.1|Reflect.js'; + this.rollup.share.arkProjectConfig.obfuscationMergedObConfig.keepSourceOfPaths = [originPath]; + BytecodeObfuscator.initForTest(this.rollup.share); + let moduleInfos: Map = new Map(); + moduleInfos.set( + originPath, + new ModuleInfo( + originPath, + 'oh_modules/reflect-metadata/Reflect.js', + true, + '&reflect-meatadata|0.2.1|Reflect.js', + 'Reflect.js', + 'reflect-metadata', + 'js' + ) + ); + BytecodeObfuscator.getInstance().convertAbstractPathToRecordName(moduleInfos); + const keepPaths = + BytecodeObfuscator.getInstance().bytecodeObfuscateConfig.obfuscationRules + .keepOptions.keepPaths; + expect(keepPaths.has(recordName)).to.be.true; + expect(keepPaths.has(originPath)).to.be.false; + BytecodeObfuscator.cleanBcObfuscatorObject(); + }); }); \ No newline at end of file -- Gitee From 173de490448c5ee125e22b52f5c4ec6be6ce8109 Mon Sep 17 00:00:00 2001 From: yangbo_404 Date: Sat, 17 May 2025 16:58:42 +0800 Subject: [PATCH 047/140] fix xts Signed-off-by: yangbo_404 --- compiler/src/fast_build/system_api/api_check_utils.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index defceb491..81b224eeb 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -132,6 +132,9 @@ function parseOhmBundle(modulePath: string): BundleInfo { * @returns {boolean} */ function checkBundleVersion(bundleVersion: string): boolean { + if (!projectConfig.compatibleSdkVersion) { + return true; + } const compatibleSdkVersion: string = projectConfig.compatibleSdkVersion; let bundleVersionNumber: number = 0; const bundleVersionArr = bundleVersion.match(/(?<=\().*(?=\))/g); @@ -542,7 +545,7 @@ function collectExternalSyscapInfos( * @returns */ function checkSinceValue(jsDocTags: readonly ts.JSDocTag[], config: ts.JsDocNodeCheckConfigItem): boolean { - if (!jsDocTags[0]?.parent?.parent) { + if (!jsDocTags[0]?.parent?.parent || !projectConfig.compatibleSdkVersion) { return false; } const currentNode: HasJSDocNode = jsDocTags[0].parent.parent as HasJSDocNode; @@ -552,7 +555,7 @@ function checkSinceValue(jsDocTags: readonly ts.JSDocTag[], config: ts.JsDocNode const minSince: string = getMinVersion(currentNode.jsDoc); const hasSince: boolean = minSince !== ''; - const compatibleSdkVersion: string = String(projectConfig.compatibleSdkVersion); + const compatibleSdkVersion: string = projectConfig.compatibleSdkVersion.toString(); if (hasSince && comparePointVersion(compatibleSdkVersion.toString(), minSince) === -1) { config.message = SINCE_TAG_CHECK_ERROER.replace('$SINCE1', minSince).replace('$SINCE2', compatibleSdkVersion); return true; @@ -693,7 +696,7 @@ function checkSinceCondition(jsDocs: ts.JSDoc[]): ts.ConditionCheckResult { const result: ts.ConditionCheckResult = { valid: true }; - if (!jsDocs || !jsDocs[0]) { + if (!jsDocs || !jsDocs[0] || !projectConfig.compatibleSdkVersion) { return result; } const minVersion: string = getMinVersion(jsDocs); -- Gitee From 809c487264a5a6417656657fcd24bb33d233f380 Mon Sep 17 00:00:00 2001 From: wuhailong Date: Thu, 15 May 2025 11:20:07 +0800 Subject: [PATCH 048/140] Fix the mock bug Issue: #IC8J8E Signed-off-by: wuhailong Change-Id: I39ead837c0de7d604f6dc1b7708cc1ef737b7b40 --- .../ark_compiler/module/module_source_file.ts | 15 ++++++++--- .../module/module_source_file.test.ts | 27 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index c2790540f..286023b88 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -206,9 +206,9 @@ export class ModuleSourceFile { let mockFilePath: string = `${toUnixPath(rollupObject.share.projectConfig.modulePath)}/${mockFile}`; let mockFileOhmUrl: string = ''; if (useNormalizedOHMUrl) { - // For file A that imports file B, the mock file of file B will be located in the same package of file A. So the - // moduleInfo for mock file should be the same with file A. - const targetModuleInfo: Object = rollupObject.getModuleInfo(importerFile); + // When using mock for related compilation in module A, only the mock file under module A can be used, + // so the moduleInfo of the mock file is the moduleInfo of module A (that is, the main moduleInfo in the compilation process) + const targetModuleInfo: Object = ModuleSourceFile.generateModuleInfoOfMockFile(rollupObject); mockFileOhmUrl = ModuleSourceFile.spliceNormalizedOhmurl(targetModuleInfo, mockFilePath, importerFile); } else { mockFileOhmUrl = getOhmUrlByFilepath(mockFilePath, @@ -223,6 +223,15 @@ export class ModuleSourceFile { ModuleSourceFile.addMockConfig(ModuleSourceFile.newMockConfigInfo, transKey, mockFileOhmUrl); } + static generateModuleInfoOfMockFile(rollupObject: Object): Object { + return { + meta: { + pkgName: rollupObject.share.projectConfig.entryPackageName, + pkgPath: rollupObject.share.projectConfig.modulePath + } + } + } + static isMockFile(file: string, rollupObject: Object): boolean { if (!ModuleSourceFile.needProcessMock) { return false; diff --git a/compiler/test/ark_compiler_ut/module/module_source_file.test.ts b/compiler/test/ark_compiler_ut/module/module_source_file.test.ts index 5828a78f8..d0b3cd0e7 100644 --- a/compiler/test/ark_compiler_ut/module/module_source_file.test.ts +++ b/compiler/test/ark_compiler_ut/module/module_source_file.test.ts @@ -967,6 +967,33 @@ mocha.describe('test module_source_file file api', function () { expect(ModuleSourceFile.newMockConfigInfo).to.deep.equal(EXPECT_NEW_MOCK_INFO); }); + mocha.it('5-5: test generateNewMockInfo under LocalTest mode (useNormalizedOHMUrl is true)', function () { + this.rollup.share.projectConfig.isLocalTest = true; + this.rollup.share.projectConfig.useNormalizedOHMUrl = true; + ModuleSourceFile.projectConfig.pkgContextInfo = { + 'entry': { + 'packageName': 'entry', + 'bundleName': '', + 'moduleName': '', + 'version': '', + 'entryPath': 'Index.ets', + 'isSO': false + } + } + ModuleSourceFile.mockConfigInfo = { + "@ohos.utils": { + "source": "src/mock/utilsMock.ts" + }, + } + let originKey = "@ohos.utils"; + let transKey = "@ohos:utils"; + ModuleSourceFile.generateNewMockInfo(originKey, transKey, this.rollup, ''); + let expectOHMUrl: string = "@normalized:N&&&entry/src/mock/utilsMock&"; + expect(ModuleSourceFile.newMockConfigInfo[transKey].source === expectOHMUrl).to.be.true; + this.rollup.share.projectConfig.useNormalizedOHMUrl = false; + ModuleSourceFile.projectConfig.pkgContextInfo = {}; + }); + mocha.it('5-5: test isMockFile under LocalTest mode', function () { ModuleSourceFile.needProcessMock = true; -- Gitee From 466802df0b66d71e3bad4c7f74f780d19310d4f0 Mon Sep 17 00:00:00 2001 From: yangbo_404 Date: Sat, 17 May 2025 21:05:08 +0800 Subject: [PATCH 049/140] xts Signed-off-by: yangbo_404 --- compiler/src/fast_build/system_api/api_check_utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index 81b224eeb..b9ac28090 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -342,8 +342,8 @@ export function getJsDocNodeCheckConfig(fileName: string, sourceFileName: string checkConfigArray.push(getJsDocNodeCheckConfigItem([SYSTEM_API_TAG_CHECK_NAME], SYSTEM_API_TAG_CHECK_WARNING, false, ts.DiagnosticCategory.Warning, '', false)); checkConfigArray.push(getJsDocNodeCheckConfigItem([SINCE_TAG_NAME], - SINCE_TAG_CHECK_ERROER, true, ts.DiagnosticCategory.Warning, - VERSION_CHECK_FUNCTION_NAME, false, undefined, checkSinceValue, checkVersionConditionValidCallback)); + SINCE_TAG_CHECK_ERROER, false, ts.DiagnosticCategory.Warning, + VERSION_CHECK_FUNCTION_NAME, false, undefined, checkSinceValue)); // TODO: the third param is to be opened checkConfigArray.push(getJsDocNodeCheckConfigItem([SYSCAP_TAG_CHECK_NAME], SYSCAP_TAG_CHECK_WARNING, false, ts.DiagnosticCategory.Warning, -- Gitee From 7b02c265e6fc297db9f6f3a5746fd999571536f9 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Sat, 17 May 2025 12:23:12 +0800 Subject: [PATCH 050/140] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BE=B5=E5=85=A5?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/process_ui_syntax.ts | 10 +- compiler/src/userIntents_parser/intentType.ts | 10 -- .../userIntents_parser/parseUserIntents.ts | 106 +++++++++++------- 3 files changed, 69 insertions(+), 57 deletions(-) diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 8770b4dea..9b9e46459 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -300,9 +300,8 @@ export function processUISyntax(program: ts.Program, ut = false, processImport(node, pagesDir, transformLog.errors); } if (ts.isStructDeclaration(node)) { - const eventParseIntentTime: CompileEvent | undefined = createAndStartEvent(eventProcessUISyntax, 'pageParseIntentTime'); - node = parseIntent.detectInsightIntent(node, metaInfo, filePath); - stopEvent(eventParseIntentTime); + // This processing aims to parse InsightIntentDecorator. + node = parseIntent.detectInsightIntent(node, metaInfo, filePath, eventProcessUISyntax); hasStruct = true; componentCollection.currentClassName = node.name.getText(); componentCollection.entryComponent === componentCollection.currentClassName && entryKeyNode(node); @@ -412,9 +411,8 @@ export function processUISyntax(program: ts.Program, ut = false, }); } } else if (ts.isClassDeclaration(node)) { - const eventParseIntentTime: CompileEvent | undefined = createAndStartEvent(eventProcessUISyntax, 'parseIntentTime'); - node = parseIntent.detectInsightIntent(node, metaInfo, filePath); - stopEvent(eventParseIntentTime); + // This processing aims to parse InsightIntentDecorator. + node = parseIntent.detectInsightIntent(node, metaInfo, filePath, eventProcessUISyntax); if (hasDecorator(node, COMPONENT_SENDABLE_DECORATOR)) { if (projectConfig.compileHar && !projectConfig.useTsHar) { let warnMessage: string = 'If you use @Sendable in js har, an exception will occur during runtime.\n' + diff --git a/compiler/src/userIntents_parser/intentType.ts b/compiler/src/userIntents_parser/intentType.ts index 9f8323246..6a380506b 100644 --- a/compiler/src/userIntents_parser/intentType.ts +++ b/compiler/src/userIntents_parser/intentType.ts @@ -95,16 +95,6 @@ export class ParamChecker { set paramValidators(value: Record boolean>) { this._paramValidators = value; } - - clean(): void { - this._requiredFields = []; - - this._allowFields = new Set(); - - this._paramValidators = {} as Record boolean>; - - this._nestedCheckers = new Map>(); - } } function validateRequiredString(v: ts.Expression): boolean { diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index 93e4db7a8..d4c384e4b 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -55,6 +55,11 @@ import { COMPONENT_USER_INTENTS_DECORATOR_METHOD, COMPONENT_USER_INTENTS_DECORATOR_PAGE } from '../pre_define'; +import { + CompileEvent, + createAndStartEvent, + stopEvent +} from '../performance'; type StaticValue = string | number | boolean | null | undefined | StaticValue[] | { [key: string]: StaticValue }; @@ -97,7 +102,8 @@ class ParseIntent { }); } - detectInsightIntent(node: ts.ClassDeclaration, metaInfo: object, filePath: string): ts.Node { + detectInsightIntent(node: ts.ClassDeclaration, metaInfo: object, filePath: string, eventOrEventFactory: CompileEvent | undefined): ts.Node { + const eventParseIntentTime: CompileEvent | undefined = createAndStartEvent(eventOrEventFactory, 'parseIntentTime'); if (!this.isInitCache && projectConfig.cachePath) { const cacheSourceMapPath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); this.isUpdateCompile = fs.existsSync(cacheSourceMapPath); @@ -129,6 +135,7 @@ class ParseIntent { this.handleIntent(node, checker, filePath, metaInfo); node = this.removeDecorator(node, definedDecorators.concat(COMPONENT_USER_INTENTS_DECORATOR_METHOD)); } + stopEvent(eventParseIntentTime); return node; } @@ -521,32 +528,7 @@ class ParseIntent { return !decoratorNames.includes(decoratorName); }); const updatedMembers: ts.ClassElement[] = node.members.map(member => { - if (ts.isMethodDeclaration(member) && this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { - const memberModifiers: ts.ModifierLike[] = (member.modifiers ?? []).filter(decorator => { - if (!ts.isDecorator(decorator)) { - return true; - } - let decoratorName: string | undefined; - if (ts.isCallExpression(decorator.expression)) { - decoratorName = '@' + decorator.expression.expression.getText(); - } - return decoratorName !== COMPONENT_USER_INTENTS_DECORATOR_METHOD; - }); - if (memberModifiers.length !== (member.modifiers?.length ?? 0)) { - return ts.factory.updateMethodDeclaration( - member, - memberModifiers, - member.asteriskToken, - member.name, - member.questionToken, - member.typeParameters, - member.parameters, - member.type, - member.body! - ); - } - } - return member; + return this.reduceMembers(member); }); return ts.factory.updateClassDeclaration( node, @@ -558,6 +540,35 @@ class ParseIntent { ); } + reduceMembers(member : ts.ClassElement): ts.ClassElement { + if (ts.isMethodDeclaration(member) && this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { + const memberModifiers: ts.ModifierLike[] = (member.modifiers ?? []).filter(decorator => { + if (!ts.isDecorator(decorator)) { + return true; + } + let decoratorName: string | undefined; + if (ts.isCallExpression(decorator.expression)) { + decoratorName = '@' + decorator.expression.expression.getText(); + } + return decoratorName !== COMPONENT_USER_INTENTS_DECORATOR_METHOD; + }); + if (memberModifiers.length !== (member.modifiers?.length ?? 0)) { + return ts.factory.updateMethodDeclaration( + member, + memberModifiers, + member.asteriskToken, + member.name, + member.questionToken, + member.typeParameters, + member.parameters, + member.type, + member.body! + ); + } + } + return member; + } + isSymbolConstant(symbol: ts.Symbol): boolean { const declaration: Declaration = symbol.valueDeclaration; @@ -836,10 +847,10 @@ class ParseIntent { intentObj.executeMode[index] = 'background'; } if (item === 2) { - intentObj.executeMode[index] = 'insightIntent.ExecuteMode.UI_EXTENSION_ABILITY'; + intentObj.executeMode[index] = 'uiextension'; } if (item === 3) { - intentObj.executeMode[index] = 'insightIntent.ExecuteMode.SERVICE_EXTENSION_ABILITY'; + intentObj.executeMode[index] = 'serviceextension'; } }); } @@ -969,11 +980,11 @@ class ParseIntent { } } - writeUserIntentJsonFile(): void { + writeUserIntentJsonFile(): void { if (!projectConfig.aceProfilePath) { throw Error(`${INTERNAL_ERROR.toString()}, aceProfilePath not found, invalidDecoratorPath: ${this.currentFilePath}`); } - const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'extract_insight_intent.json'); + const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'insight_intent.json'); const cachePath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); if (!fs.existsSync(projectConfig.aceProfilePath)) { fs.mkdirSync(projectConfig.aceProfilePath, {recursive: true}); @@ -981,7 +992,7 @@ class ParseIntent { if (this.isUpdateCompile) { const cacheData: string = fs.readFileSync(cachePath, 'utf8'); const cacheDataObj: object = JSON.parse(cacheData); - const insightIntents: object[] = cacheDataObj.insightIntents.filter(insightIntent => { + const insightIntents: object[] = cacheDataObj.extractInsightIntents.filter(insightIntent => { return !this.updatePageIntentObj.has(insightIntent.decoratorFile); }); this.updatePageIntentObj.forEach(insightIntent => { @@ -989,10 +1000,23 @@ class ParseIntent { }); this.intentData = insightIntents; } - this.validateIntentIntentName(); + let writeJsonData: object = {}; + if (fs.existsSync(cacheSourceMapPath)) { + const originIntents: string = fs.readFileSync(cacheSourceMapPath, 'utf8'); + const jsonData: object = JSON.parse(originIntents); + Object.assign(jsonData, { + 'extractInsightIntents': this.intentData + }); + writeJsonData = jsonData; + } else { + Object.assign(writeJsonData, { + 'extractInsightIntents': this.intentData + }); + } + this.validateIntentIntentName(writeJsonData); if (this.intentData.length > 0) { - fs.writeFileSync(cacheSourceMapPath, JSON.stringify({'insightIntents': this.intentData}, null, 2), 'utf-8'); - fs.writeFileSync(cachePath, JSON.stringify({'insightIntents': this.intentData}, null, 2), 'utf-8'); + fs.writeFileSync(cacheSourceMapPath, JSON.stringify(writeJsonData, null, 2), 'utf-8'); + fs.writeFileSync(cachePath, JSON.stringify({'extractInsightIntents': this.intentData}, null, 2), 'utf-8'); } else if (fs.existsSync(cacheSourceMapPath)) { fs.unlinkSync(cacheSourceMapPath); } @@ -1009,9 +1033,12 @@ class ParseIntent { } } - validateIntentIntentName(): void { + validateIntentIntentName(writeJsonData: object): void { const duplicates = new Set(); - this.intentData.forEach(item => { + writeJsonData.insightIntents?.forEach(insightIntent => { + duplicates.add(insightIntent.intentName); + }); + writeJsonData.extractInsightIntents.forEach(item => { if (duplicates.has(item.intentName)) { throw Error(`${DECORATOR_DUPLICATE_INTENTNAME.toString()}, value : ${item.intentName}`); } else { @@ -1024,11 +1051,8 @@ class ParseIntent { this.intentData = []; this.checker = null; this.currentFilePath = ''; - IntentLinkInfoChecker.clean(); - intentEntryInfoChecker.clean(); - intentMethodInfoChecker.clean(); - intentMethodInfoChecker.clean(); this.heritageClassSet = new Set(); + this.heritageClassSet.add('InsightIntentEntryExecutor_sdk'); this.isInitCache = false; this.isUpdateCompile = false; this.updatePageIntentObj = new Map(); -- Gitee From cfeb67eabaf37fbecd490bd8048a72b11e559469 Mon Sep 17 00:00:00 2001 From: c30058867 Date: Sun, 18 May 2025 20:10:39 +0800 Subject: [PATCH 051/140] Fix arkTSVersion_1_0 Issue:https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IC8LHT Signed-off-by: caiy --- compiler/src/do_arkTS_linter.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/do_arkTS_linter.ts b/compiler/src/do_arkTS_linter.ts index fbf62788f..ac1fac71a 100644 --- a/compiler/src/do_arkTS_linter.ts +++ b/compiler/src/do_arkTS_linter.ts @@ -65,8 +65,8 @@ export function doArkTSLinter(arkTSVersion: ArkTSVersion, arkTSMode: ArkTSLinter } let diagnostics: ts.Diagnostic[] = []; - - if (arkTSVersion === ArkTSVersion.ArkTS_1_0) { + const isOldVersion = arkTSVersion === ArkTSVersion.ArkTS_1_0; + if (isOldVersion) { diagnostics = ts.ArkTSLinter_1_0.runArkTSLinter(builderProgram, /*srcFile*/ undefined, buildInfoWriteFile, getArkTSVersionString(arkTSVersion)); } else { @@ -82,7 +82,7 @@ export function doArkTSLinter(arkTSVersion: ArkTSVersion, arkTSMode: ArkTSLinter if (arkTSMode === ArkTSLinterMode.COMPATIBLE_MODE) { processArkTSLinterReportAsWarning(diagnostics, printDiagnostic, shouldWriteFile); } else { - processArkTSLinterReportAsError(diagnostics, printDiagnostic, errorCodeLogger); + processArkTSLinterReportAsError(diagnostics, printDiagnostic, isOldVersion ? undefined : errorCodeLogger); } return diagnostics; -- Gitee From 4386f3e64c61d67d10bdaa727232f64e339992ac Mon Sep 17 00:00:00 2001 From: shitao Date: Thu, 13 Mar 2025 20:50:48 +0800 Subject: [PATCH 052/140] In hotreload only modify non entry will crash Issue: IBT7W4 Signed-off-by: shitao Change-Id: I97f94f1b016fdfe22faa1d2c0d4403954642b705 --- .../ark_compiler/module/module_hotreload_mode.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts index a56654b20..f6275d1f8 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts @@ -129,6 +129,15 @@ export class ModuleHotreloadMode extends ModuleMode { return; } + // The process of '--remove-redundant-file' use filesInfos.txt and compileContextInfo.json to get compile list. + // In non first build hot reload, filesInfos.txt only contian modified files, could cause loss of compile list. + // When useNormalizedOHMUrl is true, project could import from bytecode har, it will cause crash. + // So recreate the entry list for compileContextInfo.json in non first build. + if (this.useNormalizedOHMUrl) { + this.projectConfig.entryObj = changedFileListInAbsolutePath; + this.compileContextInfoPath = this.generateCompileContextInfo(rollupObject); + } + const eventCollectModuleFileList = createAndStartEvent(parentEvent, 'collect module file list'); this.collectModuleFileList(rollupObject, changedFileListInAbsolutePath[Symbol.iterator]()); stopEvent(eventCollectModuleFileList); -- Gitee From 9f91f9d91e2db5237cc745df95c4acc8fd47dc89 Mon Sep 17 00:00:00 2001 From: Yenan Date: Mon, 19 May 2025 11:32:51 +0800 Subject: [PATCH 053/140] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=93=BE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=97=AD=E6=BA=90=E7=BB=84=E4=BB=B6=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/src/component_map.ts | 34 ++++++++- compiler/src/ets_checker.ts | 12 ++- compiler/src/external_component_map.ts | 73 +++++++++++++++++++ .../ets_ui/rollup-plugin-ets-typescript.ts | 16 +++- compiler/src/pre_define.ts | 7 ++ compiler/src/process_component_build.ts | 15 +++- compiler/src/process_visual.ts | 16 +++- 7 files changed, 164 insertions(+), 9 deletions(-) create mode 100644 compiler/src/external_component_map.ts diff --git a/compiler/src/component_map.ts b/compiler/src/component_map.ts index 96e1eb2af..5e577f4a8 100644 --- a/compiler/src/component_map.ts +++ b/compiler/src/component_map.ts @@ -16,15 +16,22 @@ const fs = require('fs'); const path = require('path'); import ts from 'typescript'; - +import { + WHITELISTNEW, + readExternalComponents +} from './external_component_map'; const COMPONENTS = 'components'; const FORM_COMPONENTS = 'form_components'; export const COMPONENT_MAP: any = {}; export const FORM_MAP: any = {}; +let EXTERNAL_COMPONENT_MAP: undefined | object = {}; +export let EXT_WHITE_LIST: Array = []; export let COMMON_ATTRS: Set = new Set([]); (function readComponents(): void { + EXTERNAL_COMPONENT_MAP = readExternalComponents(); + EXT_WHITE_LIST = WHITELISTNEW; const componentPath: Map = new Map([ [`${COMPONENTS}`, `../${COMPONENTS}`], [`${FORM_COMPONENTS}`, `../${FORM_COMPONENTS}`] @@ -53,8 +60,29 @@ export let COMMON_ATTRS: Set = new Set([]); } }); } + addExternalComponents(); })(); +function addExternalComponents(): void { + const componentMapKeys = new Set(Object.keys(COMPONENT_MAP)); + const extComponentSet: Set = new Set(EXTERNAL_COMPONENT_MAP ? + Object.keys(EXTERNAL_COMPONENT_MAP) : []); + const extComponentKeys: Array = Array.from(extComponentSet); + if (!extComponentKeys.length) { + return; + } + extComponentKeys.forEach((extCompName: string) => { + if (componentMapKeys.has(extCompName) && COMPONENT_MAP[extCompName].parents && + EXTERNAL_COMPONENT_MAP[extCompName].parents) { + const newParents: Array = Array.from(new Set([...COMPONENT_MAP[extCompName].parents, + ...EXTERNAL_COMPONENT_MAP[extCompName].parents])); + COMPONENT_MAP[extCompName].parents = newParents; + } else { + COMPONENT_MAP[extCompName] = EXTERNAL_COMPONENT_MAP[extCompName]; + } + }) +} + const TRANSITION_COMMON_ATTRS: Set = new Set([ 'slide', 'translate', 'scale', 'opacity' ]); @@ -166,3 +194,7 @@ export function resetComponentMap(): void { EXTEND_ATTRIBUTE.clear(); STYLES_ATTRIBUTE.clear(); } + +export function resetExtContent(): void { + EXT_WHITE_LIST = []; +} diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 6ca848622..ad1e0e3d7 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -102,6 +102,7 @@ import { } from './hvigor_error_code/hvigor_error_info'; import { ErrorCodeModule } from './hvigor_error_code/const/error_code_module'; import { buildErrorInfoFromDiagnostic } from './hvigor_error_code/utils'; +import { concatenateEtsOptions, getExternalComponentPaths } from './external_component_map'; export interface LanguageServiceCache { service?: ts.LanguageService; @@ -141,8 +142,17 @@ const buildInfoWriteFile: ts.WriteFileCallback = (fileName: string, data: string // The collection records the file name and the corresponding version, where the version is the hash value of the text in last compilation. const filesBuildInfo: Map = new Map(); -export const compilerOptions: ts.CompilerOptions = ts.readConfigFile( +export let compilerOptions = ts.readConfigFile( path.resolve(__dirname, '../tsconfig.json'), ts.sys.readFile).config.compilerOptions; +const componentPaths: string[] | undefined = getExternalComponentPaths(); +if (componentPaths) { + for (const componentPath of componentPaths) { + const externalCompilerOptions: ts.CompilerOptions = ts.readConfigFile( + path.resolve(componentPath, 'externalconfig.json'), ts.sys.readFile + ).config.compilerOptions; + concatenateEtsOptions(compilerOptions, externalCompilerOptions); + } +} function setCompilerOptions(resolveModulePaths: string[]): void { const allPath: Array = ['*']; const basePath: string = path.resolve(projectConfig.projectPath); diff --git a/compiler/src/external_component_map.ts b/compiler/src/external_component_map.ts new file mode 100644 index 000000000..7e22e979f --- /dev/null +++ b/compiler/src/external_component_map.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 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 * as ts from 'typescript'; +import fs from 'fs'; +import path from 'path'; + +export const WHITELIST: string = 'whiteList'; +export const extConfig: string = 'externalconfig'; + +export let WHITELISTNEW: Array = []; + +const COMPONENT_PATH = './build-tools/ets-loader/components'; + +export function readExternalComponents(): object | undefined { + const EXT_COMPONENT_MAP: object | undefined = {}; + const componentPaths: string[] | undefined = getExternalComponentPaths(); + if (!componentPaths) { + return EXT_COMPONENT_MAP; + } + for (const componentPath of componentPaths) { + const files: string[] = fs.readdirSync(componentPath); + files.forEach(function (item) { + const fPath: string = path.join(componentPath, item); + const json: any = require(fPath); + const stat: any = fs.statSync(fPath); + if (stat.isFile()) { + if (json.name) { + const compName: string = json.name; + delete json.name; + EXT_COMPONENT_MAP[compName] = json; + } else { + WHITELISTNEW = Array.from(new Set(json.extWhiteList)); + } + } + }); + } + return EXT_COMPONENT_MAP; +} + +export function getExternalComponentPaths(): string[] | undefined { + const externalComponentsPath: string[] = []; + if (process.env.externalApiPaths) { + const externalApiPaths = process.env.externalApiPaths.split(path.delimiter); + externalApiPaths.forEach(sdkPath => { + externalComponentsPath.push(path.resolve(sdkPath, COMPONENT_PATH)); + }); + return externalComponentsPath; + } + return undefined; +} + +export function concatenateEtsOptions(outOptions: ts.CompilerOptions, extOptions: ts.CompilerOptions): void { + const tempComponents: Array = Array.from(new Set([...outOptions.ets.components, + ...extOptions.ets.components])); + const tempExtendComponents: Array<{ name: string; type: string; instance: string; }> = + Array.from(new Set([...outOptions.ets.extend.components, + ...extOptions.ets.extend.components])); + outOptions.ets.components = tempComponents; + outOptions.ets.extend.components = tempExtendComponents; +} \ No newline at end of file diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index 9ea3c0acc..a6a6a7338 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -80,7 +80,8 @@ import { INNER_CUSTOM_BUILDER_METHOD, resetComponentMap, INNER_CUSTOM_LOCALBUILDER_METHOD, - EXTEND_ATTRIBUTE + EXTEND_ATTRIBUTE, + resetExtContent } from '../../component_map'; import { kitTransformLog, @@ -113,6 +114,7 @@ import { ModuleSourceFile } from '../ark_compiler/module/module_source_file'; import { ARKUI_SUBSYSTEM_CODE } from '../../../lib/hvigor_error_code/hvigor_error_info'; import { ProjectCollections } from 'arkguard'; import parseIntent from '../../userIntents_parser/parseUserIntents'; +import { concatenateEtsOptions, getExternalComponentPaths } from '../../external_component_map'; let switchTsAst: boolean = true; @@ -292,6 +294,7 @@ export function etsTransform() { resetValidateUiSyntax(); resetObfuscation(); parseIntent.clear(); + resetExtContent(); } }; } @@ -384,8 +387,17 @@ async function transform(code: string, id: string) { if (projectConfig.compileMode !== 'esmodule') { const eventEtsTransformForJsbundle = createAndStartEvent(hookEventFactory, 'transform for jsbundle'); - const compilerOptions = ts.readConfigFile( + let compilerOptions = ts.readConfigFile( path.resolve(__dirname, '../../../tsconfig.json'), ts.sys.readFile).config.compilerOptions; + const componentPaths: string[] | undefined = getExternalComponentPaths(); + if (componentPaths) { + for (const componentPath of componentPaths) { + const externalCompilerOptions: ts.CompilerOptions = ts.readConfigFile( + path.resolve(componentPath, 'externalconfig.json'), ts.sys.readFile + ).config.compilerOptions; + concatenateEtsOptions(compilerOptions, externalCompilerOptions); + } + } compilerOptions.moduleResolution = 'nodenext'; compilerOptions.module = 'es2020'; const newContent: string = jsBundlePreProcess(code, id, this.getModuleInfo(id).isEntry, logger, hvigorLogger); diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 8c50d7646..b8881db67 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -14,6 +14,7 @@ */ import path from 'path'; +import { EXT_WHITE_LIST } from './component_map'; export const NATIVE_MODULE: Set = new Set( ['system.app', 'ohos.app', 'system.router', 'system.curves', 'ohos.curves', 'system.matrix4', 'ohos.matrix4']); @@ -602,6 +603,12 @@ export const CARD_ENABLE_COMPONENTS: Set = new Set([ ]); export const TabContentAndNavDestination: Set = new Set(['TabContent', 'NavDestination']); +if (EXT_WHITE_LIST.length && EXT_WHITE_LIST[1]) { + for (const compName of EXT_WHITE_LIST) { + CREATE_ROUTER_COMPONENT_COLLECT.add(compName); + } + TabContentAndNavDestination.add(EXT_WHITE_LIST[1]); +} export const CARD_LOG_TYPE_DECORATORS = 1; export const CARD_LOG_TYPE_COMPONENTS = 2; export const CARD_LOG_TYPE_IMPORT = 3; diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index e3db625da..7f4b912b9 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -196,6 +196,10 @@ import { regularCollection, getSymbolIfAliased } from './validate_ui_syntax'; import { contextStackPushOrPop } from './process_component_class'; import processStructComponentV2, { StructInfo } from './process_struct_componentV2'; import logMessageCollection from './log_message_collection'; +import { + concatenateEtsOptions, + getExternalComponentPaths +} from './external_component_map'; export function processComponentBuild(node: ts.MethodDeclaration, log: LogInfo[]): ts.MethodDeclaration { @@ -450,8 +454,17 @@ export function processComponentChild(node: ts.Block | ts.SourceFile, newStateme isInRepeatTemplate: boolean = false): void { if (supplement.isAcceleratePreview) { newsupplement = supplement; - const compilerOptions = ts.readConfigFile( + let compilerOptions = ts.readConfigFile( path.resolve(__dirname, '../tsconfig.json'), ts.sys.readFile).config.compilerOptions; + const componentPaths: string[] | undefined = getExternalComponentPaths(); + if (componentPaths) { + for (const componentPath of componentPaths) { + const externalCompilerOptions: ts.CompilerOptions = ts.readConfigFile( + path.resolve(componentPath, 'externalconfig.json'), ts.sys.readFile + ).config.compilerOptions; + concatenateEtsOptions(compilerOptions, externalCompilerOptions); + } + } Object.assign(compilerOptions, { 'sourceMap': false }); diff --git a/compiler/src/process_visual.ts b/compiler/src/process_visual.ts index 968dfe76d..084b3deab 100644 --- a/compiler/src/process_visual.ts +++ b/compiler/src/process_visual.ts @@ -39,6 +39,7 @@ import { import { projectConfig } from '../main.js'; import { genETS } from '../codegen/codegen_ets.js'; +import { concatenateEtsOptions, getExternalComponentPaths } from './external_component_map'; const visualMap: Map = new Map(); const slotMap: Map = new Map(); @@ -46,10 +47,17 @@ const slotMap: Map = new Map(); const red: string = '\u001b[31m'; const reset: string = '\u001b[39m'; -const compilerOptions = ts.readConfigFile( - path.resolve(__dirname, '../tsconfig.json'), - ts.sys.readFile -).config.compilerOptions; +let compilerOptions = ts.readConfigFile( + path.resolve(__dirname, '../tsconfig.json'), ts.sys.readFile).config.compilerOptions; +const componentPaths: string[] | undefined = getExternalComponentPaths(); +if (componentPaths) { + for (const componentPath of componentPaths) { + const externalCompilerOptions: ts.CompilerOptions = ts.readConfigFile( + path.resolve(componentPath, 'externalconfig.json'), ts.sys.readFile + ).config.compilerOptions; + concatenateEtsOptions(compilerOptions, externalCompilerOptions); + } +} compilerOptions.sourceMap = false; export function visualTransform(code: string, id: string, logger: any) { -- Gitee From bf5ea4f2a931b00e3f59089f3414ecb17d40bd9c Mon Sep 17 00:00:00 2001 From: ah Date: Sat, 17 May 2025 21:32:17 +0800 Subject: [PATCH 054/140] Fix the ohmurlbymoduleRequest Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IC8JCW Signed-off-by: ah --- compiler/src/ark_utils.ts | 39 +++++++-- .../ark_compiler/module/module_source_file.ts | 14 ++-- .../ark_compiler_ut/mock/rollup_mock/share.ts | 21 +++++ .../module/ohmUrl/ohmUrl.test.ts | 81 +++++++++++++++---- 4 files changed, 126 insertions(+), 29 deletions(-) diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index c67aa2545..e4f845ac0 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -130,7 +130,7 @@ export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: O 'Failed to resolve OhmUrl. ' + `Failed to get a resolved OhmUrl for "${filePath}" imported by "${importerFile}".`, '', - [`Check whether the "${pkgName}" module which ${filePath} belongs to is correctly configured.`, + [`Check whether the "${pkgName}" module which ${filePath} belongs to is correctly configured.`, 'Check the corresponding file name is correct(including case-sensitivity).'] ); logger.printError(errInfo); @@ -230,7 +230,7 @@ function processPackageDir(params: Object): string { 'Failed to resolve OhmUrl. ' + `Failed to get a resolved OhmUrl for "${originalFilePath}" imported by "${importerFile}".`, '', - [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, + [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, 'Check the corresponding file name is correct(including case-sensitivity).'] ); logger.printError(errInfo); @@ -269,7 +269,7 @@ function processPackageDir(params: Object): string { 'Failed to resolve OhmUrl. ' + `Failed to get a resolved OhmUrl for "${originalFilePath}" imported by "${importerFile}".`, '', - [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, + [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, 'Check the corresponding file name is correct(including case-sensitivity).'] ); logger.printError(errInfo); @@ -306,7 +306,7 @@ export function getOhmUrlBySystemApiOrLibRequest(moduleRequest: string, config?: if (REG_LIB_SO.test(moduleRequest.trim())) { if (useNormalizedOHMUrl) { const pkgInfo = config.pkgContextInfo[moduleRequest]; - if (pkgInfo === undefined) { + if (!pkgInfo) { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_UNABLE_TO_GET_PKG_CONTENT_INFO, ArkTSInternalErrorDescription, @@ -314,6 +314,7 @@ export function getOhmUrlBySystemApiOrLibRequest(moduleRequest: string, config?: `which being imported by '${importerFile}'` ); logger?.printError(errInfo); + return moduleRequest; } const isSo = pkgInfo.isSO ? 'Y' : 'N'; return `@normalized:${isSo}&${pkgInfo.moduleName}&${pkgInfo.bundleName}&${moduleRequest}&${pkgInfo.version}`; @@ -392,6 +393,24 @@ function removeSuffix(filePath: string): string { return filePath.split(path.sep).join('/').replace(SUFFIX_REG, ''); } +export function getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequets: Object, projectConfig: Object, + logger?: Object): string { + const normalizedPath = toUnixPath(moduleInfoByModuleRequets.normalizedPath); + const pkgName = moduleInfoByModuleRequets.packageName; + const pkgInfo: Object = projectConfig.pkgContextInfo[pkgName]; + if (!pkgInfo) { + const errInfo: LogData = LogDataFactory.newInstance( + ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, + ArkTSInternalErrorDescription, + `Failed to find package '${pkgName}'. ` + + `Failed to obtain package '${pkgName}' from the package context information.` + ); + logger.printError(errInfo); + } + const isSo = pkgInfo.isSO ? 'Y' : 'N'; + return `@normalized:${isSo}&${pkgInfo.moduleName}&${pkgInfo.bundleName}&${normalizedPath}&${pkgInfo.version}`; +} + export function getNormalizedOhmUrlByAliasName(aliasName: string, projectConfig: Object, logger?: Object, filePath?: string): string { let pkgName: string = aliasName; @@ -430,9 +449,13 @@ export function getNormalizedOhmUrlByAliasName(aliasName: string, projectConfig: return `@normalized:${isSo}&${pkgInfo.moduleName}&${pkgInfo.bundleName}&${normalizedPath}&${pkgInfo.version}`; } -export function getOhmUrlByByteCodeHar(moduleRequest: string, projectConfig: Object, logger?: Object): +export function getOhmUrlByByteCodeHar(moduleRequest: string, projectConfig: Object, rollupObject: Object, logger?: Object): string | undefined { if (projectConfig.byteCodeHarInfo) { + const moduleInfoByModuleRequets: Object = rollupObject.share?.importResolver(moduleRequest); + if (moduleInfoByModuleRequets) { + return getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequets, projectConfig, logger); + } let aliasName: string = getAliasNameFromPackageMap(projectConfig.byteCodeHarInfo, moduleRequest); if (aliasName) { return getNormalizedOhmUrlByAliasName(aliasName, projectConfig, logger); @@ -467,11 +490,15 @@ function getAliasNameFromPackageMap(externalPkgMap: Object, moduleRequest: strin return undefined; } -export function getOhmUrlByExternalPackage(moduleRequest: string, projectConfig: Object, logger?: Object, +export function getOhmUrlByExternalPackage(moduleRequest: string, projectConfig: Object, rollupObject: Object, logger?: Object, useNormalizedOHMUrl: boolean = false): string | undefined { // The externalPkgMap store the ohmurl with the alias of hsp package and the hars depended on bytecode har. let externalPkgMap: Object = Object.assign({}, projectConfig.hspNameOhmMap, projectConfig.harNameOhmMap); if (Object.keys(externalPkgMap).length !== 0) { + const moduleInfoByModuleRequets: Object = rollupObject.share?.importResolver(moduleRequest); + if (useNormalizedOHMUrl && moduleInfoByModuleRequets) { + return getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequets, projectConfig, logger); + } let aliasName: string = getAliasNameFromPackageMap(externalPkgMap, moduleRequest); if (aliasName) { if (useNormalizedOHMUrl) { diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index c2790540f..9c074224d 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -62,12 +62,12 @@ import { } from 'arkguard'; import { MemoryMonitor } from '../../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../../meomry_monitor/memory_define'; -import { +import { CommonLogger, LogData, LogDataFactory } from '../logger'; -import { +import { ArkTSInternalErrorDescription, ErrorCode } from '../error_code'; @@ -161,7 +161,7 @@ export class ModuleSourceFile { if (!!rollupObject.share.projectConfig.useNormalizedOHMUrl) { useNormalizedOHMUrl = rollupObject.share.projectConfig.useNormalizedOHMUrl; } - let transformedMockTarget: string | undefined = getOhmUrlByExternalPackage(originKey, ModuleSourceFile.projectConfig, + let transformedMockTarget: string | undefined = getOhmUrlByExternalPackage(originKey, ModuleSourceFile.projectConfig, rollupObject, ModuleSourceFile.logger, useNormalizedOHMUrl); if (transformedMockTarget !== undefined) { ModuleSourceFile.addMockConfig(ModuleSourceFile.transformedHarOrHspMockConfigInfo, transformedMockTarget, src); @@ -330,7 +330,7 @@ export class ModuleSourceFile { } ModuleSourceFile.isEnvInitialized = true; } - + if (ModuleSourceFile.moduleIdMap.has(moduleId)) { let moduleSourceFile = ModuleSourceFile.moduleIdMap.get(moduleId); ModuleSourceFile.moduleIdMap.delete(moduleId); @@ -349,7 +349,7 @@ export class ModuleSourceFile { await moduleSourceFile.writeSourceFile(eventWriteSourceFile); stopEvent(eventWriteSourceFile); } - } + } static async processModuleSourceFiles(rollupObject: Object, parentEvent: CompileEvent | undefined): Promise { this.initPluginEnv(rollupObject); @@ -432,14 +432,14 @@ export class ModuleSourceFile { return systemOrLibOhmUrl; } const externalPkgOhmurl: string | undefined = getOhmUrlByExternalPackage(moduleRequest, - ModuleSourceFile.projectConfig, ModuleSourceFile.logger, useNormalizedOHMUrl); + ModuleSourceFile.projectConfig, rollupObject, ModuleSourceFile.logger, useNormalizedOHMUrl); if (externalPkgOhmurl !== undefined) { if (ModuleSourceFile.needProcessMock) { ModuleSourceFile.generateNewMockInfo(moduleRequest, externalPkgOhmurl, rollupObject, importerFile); } return externalPkgOhmurl; } - const byteCodeHarOhmurl: string | undefined = getOhmUrlByByteCodeHar(moduleRequest, ModuleSourceFile.projectConfig, + const byteCodeHarOhmurl: string | undefined = getOhmUrlByByteCodeHar(moduleRequest, ModuleSourceFile.projectConfig, rollupObject, ModuleSourceFile.logger); if (byteCodeHarOhmurl !== undefined) { if (ModuleSourceFile.needProcessMock) { diff --git a/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts b/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts index b46b194f9..308633119 100644 --- a/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts +++ b/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts @@ -183,6 +183,27 @@ class Share { return logger; } + public importResolver (moduleRequest: string): Object | undefined { + if (moduleRequest === "@ohos/library////\\\\/") { + return { + normalizedPath: "@ohos/library/Index", + packageName: "@ohos/library" + } + } + if (moduleRequest === "@ohos/library/src/main/ets////") { + return { + normalizedPath: "@ohos/library/src/main/ets/Index", + packageName: "@ohos/library" + } + } + if (moduleRequest === "bytecode_alias_oh///\\\/") { + return { + normalizedPath: "bytecode_alias_oh/Index", + packageName: "bytecode_alias_oh" + } + } + return undefined; + } public scan(testcase: string) { if (!testcase) { return; diff --git a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts index 7f09e32a6..bef4a1866 100644 --- a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts +++ b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts @@ -22,7 +22,8 @@ import { getOhmUrlByExternalPackage, getOhmUrlBySystemApiOrLibRequest, getNormalizedOhmUrlByFilepath, - getNormalizedOhmUrlByAliasName + getNormalizedOhmUrlByAliasName, + getNormalizedOhmUrlByModuleRequest } from '../../../../lib/ark_utils'; import { PACKAGES } from '../../../../lib/pre_define'; import projectConfig from '../../utils/processProjectConfig'; @@ -118,22 +119,32 @@ mocha.describe('generate ohmUrl', function () { }); mocha.it('shared library', function () { + this.rollup.build(); const sharedLibraryPackageName: string = "@ohos/sharedLibrary"; const sharedLibraryPackageNameSlashes: string = "@ohos/library///"; const sharedLibraryPage: string = "@ohos/sharedLibrary/src/main/ets/pages/page1"; const errorSharedLibrary: string = "@ohos/staticLibrary"; - const sharedLibraryPackageNameOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageName, projectConfig); - const sharedLibraryPackageNameSlashesOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageNameSlashes, projectConfig, ModuleSourceFile.logger, true); - const sharedLibraryPageOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPage, projectConfig); - const errorSharedLibraryOhmUrl = getOhmUrlByExternalPackage(errorSharedLibrary, projectConfig); + const sharedLibraryModuleRequest = "@ohos/library////\\\\/"; + const sharedLibraryModuleRequestByPath = "@ohos/library/src/main/ets////"; + const sharedLibraryPackageNameOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageName, projectConfig, this.rollup); + const sharedLibraryPackageNameSlashesOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageNameSlashes, projectConfig, this.rollup, ModuleSourceFile.logger, true); + const sharedLibraryPageOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPage, projectConfig, this.rollup); + const errorSharedLibraryOhmUrl = getOhmUrlByExternalPackage(errorSharedLibrary, projectConfig, this.rollup); + const sharedLibraryModuleRequestOhmUrl = getOhmUrlByExternalPackage(sharedLibraryModuleRequest, projectConfig, this.rollup, ModuleSourceFile.logger, true); + const sharedLibraryModuleRequestByPathOhmUrl = getOhmUrlByExternalPackage(sharedLibraryModuleRequestByPath, projectConfig, this.rollup, ModuleSourceFile.logger, true); const expectedSharedLibraryOhmUrl: string = "@bundle:UtTestApplication/sharedLibrary/ets/index"; const expectedSharedLibrarySlashesOhmUrl: string = "@normalized:N&&&@ohos/library/Index&1.0.0"; const expectedSharedLibraryPageOhmUrl: string = "@bundle:UtTestApplication/sharedLibrary/ets/pages/page1"; const expectedErrorSharedLibraryOhmUrl = undefined; + const expectsharedLibraryModuleRequestOhmUrl = "@normalized:N&&&@ohos/library/Index&1.0.0"; + const expectsharedLibraryModuleRequestByPathOhmUrl = "@normalized:N&&&@ohos/library/src/main/ets/Index&1.0.0"; expect(sharedLibraryPackageNameOhmUrl == expectedSharedLibraryOhmUrl).to.be.true; expect(sharedLibraryPackageNameSlashesOhmUrl == expectedSharedLibrarySlashesOhmUrl).to.be.true; expect(sharedLibraryPageOhmUrl == expectedSharedLibraryPageOhmUrl).to.be.true; expect(errorSharedLibraryOhmUrl == expectedErrorSharedLibraryOhmUrl).to.be.true; + expect(sharedLibraryModuleRequestOhmUrl == expectsharedLibraryModuleRequestOhmUrl).to.be.true; + expect(sharedLibraryModuleRequestByPathOhmUrl == expectsharedLibraryModuleRequestByPathOhmUrl).to.be.true; + }); mocha.it('project module', function () { @@ -237,7 +248,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, ArkTSErrorDescription, - 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + + 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + '"/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', @@ -261,7 +272,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, ArkTSErrorDescription, - 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + + 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + '"/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', @@ -495,7 +506,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -573,7 +584,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -652,7 +663,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -730,7 +741,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -1113,7 +1124,7 @@ mocha.describe('generate ohmUrl', function () { mockConfigPath: `${projectConfig.projectRootPath}/entry/src/mock/mock-config.json5` } this.rollup.share.projectConfig.entryModuleName = 'entry'; - + const importerFile: string = `${projectConfig.projectRootPath}/entry/src/main/ets/pages/index.ets`; const moduleInfo = { id: importerFile, @@ -1124,7 +1135,7 @@ mocha.describe('generate ohmUrl', function () { } } this.rollup.moduleInfos.push(moduleInfo); - + for (let moduleRequest in PRVIEW_MOCK_CONFIG) { let mockPath = PRVIEW_MOCK_CONFIG[moduleRequest] let filePath: string; @@ -1197,13 +1208,14 @@ mocha.describe('generate ohmUrl', function () { } } const filePath: string = 'bytecode_alias/src/main/ets/utils/Calc'; - const indexFilePath: string = 'bytecode_alias'; + const indexFilePath: string = 'bytecode_alias'; const importerFile: string = '/testHap/entry/src/main/ets/pages/index.ets' const importByPkgName = 'bytecode_alias'; const standardImportPath: string = 'bytecode_alias/src/main/ets/utils/Calc'; const importByPkgNameSlashes = 'bytecode_alias///'; const importByPkgNameSlashesOh = 'bytecode_alias_oh///'; + const importModuleRequets = 'bytecode_alias_oh///\\\/' const moduleSourceFile: string = new ModuleSourceFile(); ModuleSourceFile.initPluginEnv(this.rollup); const importByPkgNameOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, importByPkgName, indexFilePath, importerFile); @@ -1211,14 +1223,17 @@ mocha.describe('generate ohmUrl', function () { importerFile); const importByPkgNameOhmUrlSlashes = moduleSourceFile.getOhmUrl(this.rollup, importByPkgNameSlashes, indexFilePath, importerFile); const importByPkgNameOhmUrlSlashesOh = moduleSourceFile.getOhmUrl(this.rollup, importByPkgNameSlashesOh, indexFilePath, importerFile); + const importModuleRequetsOhmUrlSlashesOh = moduleSourceFile.getOhmUrl(this.rollup, importModuleRequets, indexFilePath, importerFile); const importByPkgNameNormalizedOhmUrl: string = '@normalized:N&&&bytecode_har/Index&1.0.0'; const standardImportPathNormalizedOhmUrl: string = '@normalized:N&&&bytecode_har/src/main/ets/utils/Calc&1.0.0'; const importByPkgNameNormalizedOhmUrlSlashes: string = '@normalized:N&&&bytecode_har/Index&1.0.0'; const importByPkgNameNormalizedOhmUrlSlashesOh: string = '@normalized:N&&&bytecode_alias_oh/Index&1.0.0'; + const importModuleRequetsNormalizedOhmUrlSlashesOh: string = '@normalized:N&&&bytecode_alias_oh/Index&1.0.0'; expect(importByPkgNameOhmUrl == importByPkgNameNormalizedOhmUrl).to.be.true; expect(standardImportPathOhmUrl == standardImportPathNormalizedOhmUrl).to.be.true; expect(importByPkgNameOhmUrlSlashes == importByPkgNameNormalizedOhmUrlSlashes).to.be.true; expect(importByPkgNameOhmUrlSlashesOh == importByPkgNameNormalizedOhmUrlSlashesOh).to.be.true; + expect(importModuleRequetsOhmUrlSlashesOh == importModuleRequetsNormalizedOhmUrlSlashesOh).to.be.true; }); mocha.it('useNormalizedOHMUrl app builtins error message', function () { @@ -1274,6 +1289,40 @@ mocha.describe('generate ohmUrl', function () { loggerStub.restore(); }); + mocha.it('the error message of getNormalizedOhmUrlByModuleRequest', function () { + const moduleInfoByModuleRequets = { + normalizedPath: "bytecode_module/Index", + packageName: "bytecode_module" + }; + this.rollup.build(); + this.rollup.share.projectConfig.useNormalizedOHMUrl = true; + this.rollup.share.projectConfig.pkgContextInfo = { + 'bytecode_module1': { + 'packageName': 'bytecode_module1', + 'bundleName': '', + 'moduleName': '', + 'version': '1.0.0', + 'entryPath': 'Index.ets', + 'isSO': false + } + } + const errInfo: LogData = LogDataFactory.newInstance( + ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, + ArkTSInternalErrorDescription, + "Failed to find package 'bytecode_module'. Failed to obtain package 'bytecode_module' " + + "from the package context information." + ); + const logger = CommonLogger.getInstance(this.rollup); + const loggerStub = sinon.stub(logger.getLoggerFromErrorCode(errInfo.code), 'printError'); + try { + delete this.rollup.share.projectConfig.pkgContextInfo['bytecode_module']; + getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequets, this.rollup.share.projectConfig, logger); + } catch (e) { + } + expect(loggerStub.getCall(0).calledWithMatch(errInfo)).to.be.true; + loggerStub.restore(); + }); + mocha.it('the error message of getNormalizedOhmUrlByAliasName', function () { this.rollup.build(); this.rollup.share.projectConfig.useNormalizedOHMUrl = true; @@ -1321,7 +1370,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo1: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, ArkTSInternalErrorDescription, - "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + + "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + "from the package context information." ); expect(loggerStub.getCall(1).calledWithMatch(errInfo1)).to.be.true; @@ -1379,7 +1428,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo1: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, ArkTSInternalErrorDescription, - "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + + "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + "from the package context information." ); expect(loggerStub.getCall(1).calledWithMatch(errInfo1.toString())).to.be.true; -- Gitee From 318a42b9d6e9f0e8c41f91b235a68e0edecdfd43 Mon Sep 17 00:00:00 2001 From: zhanghang Date: Mon, 19 May 2025 17:13:48 +0800 Subject: [PATCH 055/140] Add focus wrap mode for grid tools Signed-off-by: zhanghang --- compiler/components/grid.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/components/grid.json b/compiler/components/grid.json index 4e78a5ad2..c7a84af18 100644 --- a/compiler/components/grid.json +++ b/compiler/components/grid.json @@ -9,6 +9,6 @@ "onScrollBarUpdate", "enableScrollInteraction", "fadingEdge", "onScrollStart", "onScroll", "onScrollStop", "onWillScroll", "onDidScroll", "cachedCount", "nestedScroll", "friction", "alignItems", "onReachStart", "onReachEnd", "onScrollFrameBegin", "flingSpeedLimit", - "clipContent", "backToTop" + "clipContent", "backToTop", "focusWrapMode" ] } -- Gitee From f67d721cb62f3535f5841f873dff5d4e80626655 Mon Sep 17 00:00:00 2001 From: liyancheng2 Date: Tue, 20 May 2025 09:53:10 +0800 Subject: [PATCH 056/140] fix annotation test cases Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IC8Z3A Signed-off-by: liyancheng2 Change-Id: I56f023be48418ab8c20dd1aad6fe4a0a18213aaa --- compiler/test/ut/annotations/annotationApplication1.ts | 2 +- compiler/test/ut/annotations/annotationApplication2.ts | 2 +- compiler/test/ut/annotations/annotationApplication3.ts | 2 +- compiler/test/ut/annotations/annotationApplication4.ts | 4 ++-- compiler/test/ut/annotations/annotationApplication5.ts | 2 +- compiler/test/ut/annotations/annotationApplication6.ts | 2 +- compiler/test/ut/annotations/annotationDeclaration1.ts | 2 +- compiler/test/ut/annotations/annotationDeclaration2.ts | 2 +- compiler/test/ut/annotations/annotationDeclaration3.ts | 2 +- compiler/test/ut/annotations/annotationDeclaration4.ts | 2 +- compiler/test/ut/annotations/annotationDeclaration5.ts | 2 +- compiler/test/ut/annotations/annotationDeclaration6.ts | 2 +- .../ut/annotations/annotationDeclarationFieldInitializer1.ts | 2 +- .../ut/annotations/annotationDeclarationFieldInitializer2.ts | 2 +- .../ut/annotations/annotationDeclarationFieldInitializer3.ts | 2 +- .../ut/annotations/annotationDeclarationFieldInitializer4.ts | 2 +- .../ut/annotations/annotationDeclarationFieldInitializer5.ts | 2 +- .../ut/annotations/annotationDeclarationFieldInitializer6.ts | 2 +- .../test/ut/annotations/annotationDeclarationFieldType1.ts | 2 +- .../test/ut/annotations/annotationDeclarationFieldType2.ts | 2 +- .../test/ut/annotations/annotationDeclarationFieldType3.ts | 2 +- compiler/test/ut/annotations/annotations.ts | 2 +- 22 files changed, 23 insertions(+), 23 deletions(-) diff --git a/compiler/test/ut/annotations/annotationApplication1.ts b/compiler/test/ut/annotations/annotationApplication1.ts index 11dd5c2b4..a3d8dbba7 100644 --- a/compiler/test/ut/annotations/annotationApplication1.ts +++ b/compiler/test/ut/annotations/annotationApplication1.ts @@ -29,7 +29,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationApplication1_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number = 10; } @__$$ETS_ANNOTATION$$__Anno({ a: 10 }) diff --git a/compiler/test/ut/annotations/annotationApplication2.ts b/compiler/test/ut/annotations/annotationApplication2.ts index 704ea63b8..86e7705e9 100644 --- a/compiler/test/ut/annotations/annotationApplication2.ts +++ b/compiler/test/ut/annotations/annotationApplication2.ts @@ -32,7 +32,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationApplication2_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number = 10; } @__$$ETS_ANNOTATION$$__Anno({ a: 10 }) diff --git a/compiler/test/ut/annotations/annotationApplication3.ts b/compiler/test/ut/annotations/annotationApplication3.ts index 4ff289f90..e8cb331b6 100644 --- a/compiler/test/ut/annotations/annotationApplication3.ts +++ b/compiler/test/ut/annotations/annotationApplication3.ts @@ -33,7 +33,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationApplication3_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string; b: number; } diff --git a/compiler/test/ut/annotations/annotationApplication4.ts b/compiler/test/ut/annotations/annotationApplication4.ts index 89ad32d95..b429c19f1 100644 --- a/compiler/test/ut/annotations/annotationApplication4.ts +++ b/compiler/test/ut/annotations/annotationApplication4.ts @@ -34,11 +34,11 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationApplication4_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string; b: number; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string; } @__$$ETS_ANNOTATION$$__Anno({ a: "a", b: 10 }) diff --git a/compiler/test/ut/annotations/annotationApplication5.ts b/compiler/test/ut/annotations/annotationApplication5.ts index d1e29348b..355062937 100644 --- a/compiler/test/ut/annotations/annotationApplication5.ts +++ b/compiler/test/ut/annotations/annotationApplication5.ts @@ -32,7 +32,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationApplication5_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number = 10; } @__$$ETS_ANNOTATION$$__Anno({ a: 10 }) diff --git a/compiler/test/ut/annotations/annotationApplication6.ts b/compiler/test/ut/annotations/annotationApplication6.ts index bd4ee84dd..29a424f51 100644 --- a/compiler/test/ut/annotations/annotationApplication6.ts +++ b/compiler/test/ut/annotations/annotationApplication6.ts @@ -29,7 +29,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationApplication6_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[] = [1, 2]; } @__$$ETS_ANNOTATION$$__Anno({ a: [1, 2] }) diff --git a/compiler/test/ut/annotations/annotationDeclaration1.ts b/compiler/test/ut/annotations/annotationDeclaration1.ts index 8b1b4ab50..2ecf0d81b 100644 --- a/compiler/test/ut/annotations/annotationDeclaration1.ts +++ b/compiler/test/ut/annotations/annotationDeclaration1.ts @@ -24,6 +24,6 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclaration1_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { } ` \ No newline at end of file diff --git a/compiler/test/ut/annotations/annotationDeclaration2.ts b/compiler/test/ut/annotations/annotationDeclaration2.ts index 132b98ff3..29531e55c 100644 --- a/compiler/test/ut/annotations/annotationDeclaration2.ts +++ b/compiler/test/ut/annotations/annotationDeclaration2.ts @@ -24,6 +24,6 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclaration2_" + ++__generate__Id; } -export @interface Anno { +export @interface __$$ETS_ANNOTATION$$__Anno { } ` \ No newline at end of file diff --git a/compiler/test/ut/annotations/annotationDeclaration3.ts b/compiler/test/ut/annotations/annotationDeclaration3.ts index 671c720f3..65d2866d4 100644 --- a/compiler/test/ut/annotations/annotationDeclaration3.ts +++ b/compiler/test/ut/annotations/annotationDeclaration3.ts @@ -26,7 +26,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclaration3_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number; } ` \ No newline at end of file diff --git a/compiler/test/ut/annotations/annotationDeclaration4.ts b/compiler/test/ut/annotations/annotationDeclaration4.ts index 412294d02..19cce1a4c 100644 --- a/compiler/test/ut/annotations/annotationDeclaration4.ts +++ b/compiler/test/ut/annotations/annotationDeclaration4.ts @@ -28,7 +28,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclaration4_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number = 42; b: boolean = false; c: string = "abc"; diff --git a/compiler/test/ut/annotations/annotationDeclaration5.ts b/compiler/test/ut/annotations/annotationDeclaration5.ts index 11a033f11..682d34a94 100644 --- a/compiler/test/ut/annotations/annotationDeclaration5.ts +++ b/compiler/test/ut/annotations/annotationDeclaration5.ts @@ -28,7 +28,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclaration5_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number = 42; b: boolean = true; c: string = "abc"; diff --git a/compiler/test/ut/annotations/annotationDeclaration6.ts b/compiler/test/ut/annotations/annotationDeclaration6.ts index b1983dfaf..946cc7b8a 100644 --- a/compiler/test/ut/annotations/annotationDeclaration6.ts +++ b/compiler/test/ut/annotations/annotationDeclaration6.ts @@ -26,7 +26,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclaration6_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[] = [1, 2]; } ` \ No newline at end of file diff --git a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer1.ts b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer1.ts index de85925c5..67b3828af 100644 --- a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer1.ts +++ b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer1.ts @@ -52,7 +52,7 @@ function generateId(): string { } const a = 1; const b = 2; -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { d: boolean = false; e: number = 3; f: number = 0; diff --git a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer2.ts b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer2.ts index f81fad152..c74d10503 100644 --- a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer2.ts +++ b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer2.ts @@ -36,7 +36,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclarationFieldInitializer2_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { d: boolean = false; q: string = "ab"; r: string = "b"; diff --git a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer3.ts b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer3.ts index 01f6afd43..ec86f0855 100644 --- a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer3.ts +++ b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer3.ts @@ -40,7 +40,7 @@ function generateId(): string { } const a = "a"; const b = "b"; -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { d: boolean = false; r: string = "b"; s: string = "a"; diff --git a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer4.ts b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer4.ts index 4cf59a0b7..a07c4f36a 100644 --- a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer4.ts +++ b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer4.ts @@ -35,7 +35,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclarationFieldInitializer4_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { d: boolean = true; r: boolean = false; s: boolean = true; diff --git a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer5.ts b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer5.ts index 4716471df..b2efdb80b 100644 --- a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer5.ts +++ b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer5.ts @@ -40,7 +40,7 @@ function generateId(): string { } const a = true; const b = false; -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { d: boolean = false; r: boolean = false; s: boolean = true; diff --git a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer6.ts b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer6.ts index 9bff08d8e..63ea786cb 100644 --- a/compiler/test/ut/annotations/annotationDeclarationFieldInitializer6.ts +++ b/compiler/test/ut/annotations/annotationDeclarationFieldInitializer6.ts @@ -59,7 +59,7 @@ const enum E { A = 0, B = 1 } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number = 0; b: number = 0; c: number = -1; diff --git a/compiler/test/ut/annotations/annotationDeclarationFieldType1.ts b/compiler/test/ut/annotations/annotationDeclarationFieldType1.ts index f4b1e82ef..feae6c1a9 100644 --- a/compiler/test/ut/annotations/annotationDeclarationFieldType1.ts +++ b/compiler/test/ut/annotations/annotationDeclarationFieldType1.ts @@ -26,7 +26,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclarationFieldType1_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number; } ` \ No newline at end of file diff --git a/compiler/test/ut/annotations/annotationDeclarationFieldType2.ts b/compiler/test/ut/annotations/annotationDeclarationFieldType2.ts index 95ba6c0f0..c15e9b035 100644 --- a/compiler/test/ut/annotations/annotationDeclarationFieldType2.ts +++ b/compiler/test/ut/annotations/annotationDeclarationFieldType2.ts @@ -26,7 +26,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclarationFieldType2_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string; } ` \ No newline at end of file diff --git a/compiler/test/ut/annotations/annotationDeclarationFieldType3.ts b/compiler/test/ut/annotations/annotationDeclarationFieldType3.ts index aa1df0364..135814c7a 100644 --- a/compiler/test/ut/annotations/annotationDeclarationFieldType3.ts +++ b/compiler/test/ut/annotations/annotationDeclarationFieldType3.ts @@ -26,7 +26,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotationDeclarationFieldType3_" + ++__generate__Id; } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean; } ` \ No newline at end of file diff --git a/compiler/test/ut/annotations/annotations.ts b/compiler/test/ut/annotations/annotations.ts index 738be1187..d6b072572 100644 --- a/compiler/test/ut/annotations/annotations.ts +++ b/compiler/test/ut/annotations/annotations.ts @@ -25,7 +25,7 @@ exports.expectResult = `let __generate__Id: number = 0; function generateId(): string { return "annotations_" + ++__generate__Id; } -@interface MyAnno { +@interface __$$ETS_ANNOTATION$$__MyAnno { x: number = 2; } ` -- Gitee From 97b6e0735badd95fd2f9b7b2ce397f11421907ef Mon Sep 17 00:00:00 2001 From: oh_ci Date: Tue, 20 May 2025 02:07:03 +0000 Subject: [PATCH 057/140] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20?= =?UTF-8?q?!4702=20:=20Fix=20the=20ohmurlbymoduleRequest'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compiler/src/ark_utils.ts | 39 ++------- .../ark_compiler/module/module_source_file.ts | 14 ++-- .../ark_compiler_ut/mock/rollup_mock/share.ts | 21 ----- .../module/ohmUrl/ohmUrl.test.ts | 81 ++++--------------- 4 files changed, 29 insertions(+), 126 deletions(-) diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index e4f845ac0..c67aa2545 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -130,7 +130,7 @@ export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: O 'Failed to resolve OhmUrl. ' + `Failed to get a resolved OhmUrl for "${filePath}" imported by "${importerFile}".`, '', - [`Check whether the "${pkgName}" module which ${filePath} belongs to is correctly configured.`, + [`Check whether the "${pkgName}" module which ${filePath} belongs to is correctly configured.`, 'Check the corresponding file name is correct(including case-sensitivity).'] ); logger.printError(errInfo); @@ -230,7 +230,7 @@ function processPackageDir(params: Object): string { 'Failed to resolve OhmUrl. ' + `Failed to get a resolved OhmUrl for "${originalFilePath}" imported by "${importerFile}".`, '', - [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, + [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, 'Check the corresponding file name is correct(including case-sensitivity).'] ); logger.printError(errInfo); @@ -269,7 +269,7 @@ function processPackageDir(params: Object): string { 'Failed to resolve OhmUrl. ' + `Failed to get a resolved OhmUrl for "${originalFilePath}" imported by "${importerFile}".`, '', - [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, + [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, 'Check the corresponding file name is correct(including case-sensitivity).'] ); logger.printError(errInfo); @@ -306,7 +306,7 @@ export function getOhmUrlBySystemApiOrLibRequest(moduleRequest: string, config?: if (REG_LIB_SO.test(moduleRequest.trim())) { if (useNormalizedOHMUrl) { const pkgInfo = config.pkgContextInfo[moduleRequest]; - if (!pkgInfo) { + if (pkgInfo === undefined) { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_UNABLE_TO_GET_PKG_CONTENT_INFO, ArkTSInternalErrorDescription, @@ -314,7 +314,6 @@ export function getOhmUrlBySystemApiOrLibRequest(moduleRequest: string, config?: `which being imported by '${importerFile}'` ); logger?.printError(errInfo); - return moduleRequest; } const isSo = pkgInfo.isSO ? 'Y' : 'N'; return `@normalized:${isSo}&${pkgInfo.moduleName}&${pkgInfo.bundleName}&${moduleRequest}&${pkgInfo.version}`; @@ -393,24 +392,6 @@ function removeSuffix(filePath: string): string { return filePath.split(path.sep).join('/').replace(SUFFIX_REG, ''); } -export function getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequets: Object, projectConfig: Object, - logger?: Object): string { - const normalizedPath = toUnixPath(moduleInfoByModuleRequets.normalizedPath); - const pkgName = moduleInfoByModuleRequets.packageName; - const pkgInfo: Object = projectConfig.pkgContextInfo[pkgName]; - if (!pkgInfo) { - const errInfo: LogData = LogDataFactory.newInstance( - ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, - ArkTSInternalErrorDescription, - `Failed to find package '${pkgName}'. ` + - `Failed to obtain package '${pkgName}' from the package context information.` - ); - logger.printError(errInfo); - } - const isSo = pkgInfo.isSO ? 'Y' : 'N'; - return `@normalized:${isSo}&${pkgInfo.moduleName}&${pkgInfo.bundleName}&${normalizedPath}&${pkgInfo.version}`; -} - export function getNormalizedOhmUrlByAliasName(aliasName: string, projectConfig: Object, logger?: Object, filePath?: string): string { let pkgName: string = aliasName; @@ -449,13 +430,9 @@ export function getNormalizedOhmUrlByAliasName(aliasName: string, projectConfig: return `@normalized:${isSo}&${pkgInfo.moduleName}&${pkgInfo.bundleName}&${normalizedPath}&${pkgInfo.version}`; } -export function getOhmUrlByByteCodeHar(moduleRequest: string, projectConfig: Object, rollupObject: Object, logger?: Object): +export function getOhmUrlByByteCodeHar(moduleRequest: string, projectConfig: Object, logger?: Object): string | undefined { if (projectConfig.byteCodeHarInfo) { - const moduleInfoByModuleRequets: Object = rollupObject.share?.importResolver(moduleRequest); - if (moduleInfoByModuleRequets) { - return getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequets, projectConfig, logger); - } let aliasName: string = getAliasNameFromPackageMap(projectConfig.byteCodeHarInfo, moduleRequest); if (aliasName) { return getNormalizedOhmUrlByAliasName(aliasName, projectConfig, logger); @@ -490,15 +467,11 @@ function getAliasNameFromPackageMap(externalPkgMap: Object, moduleRequest: strin return undefined; } -export function getOhmUrlByExternalPackage(moduleRequest: string, projectConfig: Object, rollupObject: Object, logger?: Object, +export function getOhmUrlByExternalPackage(moduleRequest: string, projectConfig: Object, logger?: Object, useNormalizedOHMUrl: boolean = false): string | undefined { // The externalPkgMap store the ohmurl with the alias of hsp package and the hars depended on bytecode har. let externalPkgMap: Object = Object.assign({}, projectConfig.hspNameOhmMap, projectConfig.harNameOhmMap); if (Object.keys(externalPkgMap).length !== 0) { - const moduleInfoByModuleRequets: Object = rollupObject.share?.importResolver(moduleRequest); - if (useNormalizedOHMUrl && moduleInfoByModuleRequets) { - return getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequets, projectConfig, logger); - } let aliasName: string = getAliasNameFromPackageMap(externalPkgMap, moduleRequest); if (aliasName) { if (useNormalizedOHMUrl) { diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 9c074224d..c2790540f 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -62,12 +62,12 @@ import { } from 'arkguard'; import { MemoryMonitor } from '../../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../../meomry_monitor/memory_define'; -import { +import { CommonLogger, LogData, LogDataFactory } from '../logger'; -import { +import { ArkTSInternalErrorDescription, ErrorCode } from '../error_code'; @@ -161,7 +161,7 @@ export class ModuleSourceFile { if (!!rollupObject.share.projectConfig.useNormalizedOHMUrl) { useNormalizedOHMUrl = rollupObject.share.projectConfig.useNormalizedOHMUrl; } - let transformedMockTarget: string | undefined = getOhmUrlByExternalPackage(originKey, ModuleSourceFile.projectConfig, rollupObject, + let transformedMockTarget: string | undefined = getOhmUrlByExternalPackage(originKey, ModuleSourceFile.projectConfig, ModuleSourceFile.logger, useNormalizedOHMUrl); if (transformedMockTarget !== undefined) { ModuleSourceFile.addMockConfig(ModuleSourceFile.transformedHarOrHspMockConfigInfo, transformedMockTarget, src); @@ -330,7 +330,7 @@ export class ModuleSourceFile { } ModuleSourceFile.isEnvInitialized = true; } - + if (ModuleSourceFile.moduleIdMap.has(moduleId)) { let moduleSourceFile = ModuleSourceFile.moduleIdMap.get(moduleId); ModuleSourceFile.moduleIdMap.delete(moduleId); @@ -349,7 +349,7 @@ export class ModuleSourceFile { await moduleSourceFile.writeSourceFile(eventWriteSourceFile); stopEvent(eventWriteSourceFile); } - } + } static async processModuleSourceFiles(rollupObject: Object, parentEvent: CompileEvent | undefined): Promise { this.initPluginEnv(rollupObject); @@ -432,14 +432,14 @@ export class ModuleSourceFile { return systemOrLibOhmUrl; } const externalPkgOhmurl: string | undefined = getOhmUrlByExternalPackage(moduleRequest, - ModuleSourceFile.projectConfig, rollupObject, ModuleSourceFile.logger, useNormalizedOHMUrl); + ModuleSourceFile.projectConfig, ModuleSourceFile.logger, useNormalizedOHMUrl); if (externalPkgOhmurl !== undefined) { if (ModuleSourceFile.needProcessMock) { ModuleSourceFile.generateNewMockInfo(moduleRequest, externalPkgOhmurl, rollupObject, importerFile); } return externalPkgOhmurl; } - const byteCodeHarOhmurl: string | undefined = getOhmUrlByByteCodeHar(moduleRequest, ModuleSourceFile.projectConfig, rollupObject, + const byteCodeHarOhmurl: string | undefined = getOhmUrlByByteCodeHar(moduleRequest, ModuleSourceFile.projectConfig, ModuleSourceFile.logger); if (byteCodeHarOhmurl !== undefined) { if (ModuleSourceFile.needProcessMock) { diff --git a/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts b/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts index 308633119..b46b194f9 100644 --- a/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts +++ b/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts @@ -183,27 +183,6 @@ class Share { return logger; } - public importResolver (moduleRequest: string): Object | undefined { - if (moduleRequest === "@ohos/library////\\\\/") { - return { - normalizedPath: "@ohos/library/Index", - packageName: "@ohos/library" - } - } - if (moduleRequest === "@ohos/library/src/main/ets////") { - return { - normalizedPath: "@ohos/library/src/main/ets/Index", - packageName: "@ohos/library" - } - } - if (moduleRequest === "bytecode_alias_oh///\\\/") { - return { - normalizedPath: "bytecode_alias_oh/Index", - packageName: "bytecode_alias_oh" - } - } - return undefined; - } public scan(testcase: string) { if (!testcase) { return; diff --git a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts index bef4a1866..7f09e32a6 100644 --- a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts +++ b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts @@ -22,8 +22,7 @@ import { getOhmUrlByExternalPackage, getOhmUrlBySystemApiOrLibRequest, getNormalizedOhmUrlByFilepath, - getNormalizedOhmUrlByAliasName, - getNormalizedOhmUrlByModuleRequest + getNormalizedOhmUrlByAliasName } from '../../../../lib/ark_utils'; import { PACKAGES } from '../../../../lib/pre_define'; import projectConfig from '../../utils/processProjectConfig'; @@ -119,32 +118,22 @@ mocha.describe('generate ohmUrl', function () { }); mocha.it('shared library', function () { - this.rollup.build(); const sharedLibraryPackageName: string = "@ohos/sharedLibrary"; const sharedLibraryPackageNameSlashes: string = "@ohos/library///"; const sharedLibraryPage: string = "@ohos/sharedLibrary/src/main/ets/pages/page1"; const errorSharedLibrary: string = "@ohos/staticLibrary"; - const sharedLibraryModuleRequest = "@ohos/library////\\\\/"; - const sharedLibraryModuleRequestByPath = "@ohos/library/src/main/ets////"; - const sharedLibraryPackageNameOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageName, projectConfig, this.rollup); - const sharedLibraryPackageNameSlashesOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageNameSlashes, projectConfig, this.rollup, ModuleSourceFile.logger, true); - const sharedLibraryPageOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPage, projectConfig, this.rollup); - const errorSharedLibraryOhmUrl = getOhmUrlByExternalPackage(errorSharedLibrary, projectConfig, this.rollup); - const sharedLibraryModuleRequestOhmUrl = getOhmUrlByExternalPackage(sharedLibraryModuleRequest, projectConfig, this.rollup, ModuleSourceFile.logger, true); - const sharedLibraryModuleRequestByPathOhmUrl = getOhmUrlByExternalPackage(sharedLibraryModuleRequestByPath, projectConfig, this.rollup, ModuleSourceFile.logger, true); + const sharedLibraryPackageNameOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageName, projectConfig); + const sharedLibraryPackageNameSlashesOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageNameSlashes, projectConfig, ModuleSourceFile.logger, true); + const sharedLibraryPageOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPage, projectConfig); + const errorSharedLibraryOhmUrl = getOhmUrlByExternalPackage(errorSharedLibrary, projectConfig); const expectedSharedLibraryOhmUrl: string = "@bundle:UtTestApplication/sharedLibrary/ets/index"; const expectedSharedLibrarySlashesOhmUrl: string = "@normalized:N&&&@ohos/library/Index&1.0.0"; const expectedSharedLibraryPageOhmUrl: string = "@bundle:UtTestApplication/sharedLibrary/ets/pages/page1"; const expectedErrorSharedLibraryOhmUrl = undefined; - const expectsharedLibraryModuleRequestOhmUrl = "@normalized:N&&&@ohos/library/Index&1.0.0"; - const expectsharedLibraryModuleRequestByPathOhmUrl = "@normalized:N&&&@ohos/library/src/main/ets/Index&1.0.0"; expect(sharedLibraryPackageNameOhmUrl == expectedSharedLibraryOhmUrl).to.be.true; expect(sharedLibraryPackageNameSlashesOhmUrl == expectedSharedLibrarySlashesOhmUrl).to.be.true; expect(sharedLibraryPageOhmUrl == expectedSharedLibraryPageOhmUrl).to.be.true; expect(errorSharedLibraryOhmUrl == expectedErrorSharedLibraryOhmUrl).to.be.true; - expect(sharedLibraryModuleRequestOhmUrl == expectsharedLibraryModuleRequestOhmUrl).to.be.true; - expect(sharedLibraryModuleRequestByPathOhmUrl == expectsharedLibraryModuleRequestByPathOhmUrl).to.be.true; - }); mocha.it('project module', function () { @@ -248,7 +237,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, ArkTSErrorDescription, - 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + + 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + '"/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', @@ -272,7 +261,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, ArkTSErrorDescription, - 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + + 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + '"/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', @@ -506,7 +495,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -584,7 +573,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -663,7 +652,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -741,7 +730,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -1124,7 +1113,7 @@ mocha.describe('generate ohmUrl', function () { mockConfigPath: `${projectConfig.projectRootPath}/entry/src/mock/mock-config.json5` } this.rollup.share.projectConfig.entryModuleName = 'entry'; - + const importerFile: string = `${projectConfig.projectRootPath}/entry/src/main/ets/pages/index.ets`; const moduleInfo = { id: importerFile, @@ -1135,7 +1124,7 @@ mocha.describe('generate ohmUrl', function () { } } this.rollup.moduleInfos.push(moduleInfo); - + for (let moduleRequest in PRVIEW_MOCK_CONFIG) { let mockPath = PRVIEW_MOCK_CONFIG[moduleRequest] let filePath: string; @@ -1208,14 +1197,13 @@ mocha.describe('generate ohmUrl', function () { } } const filePath: string = 'bytecode_alias/src/main/ets/utils/Calc'; - const indexFilePath: string = 'bytecode_alias'; + const indexFilePath: string = 'bytecode_alias'; const importerFile: string = '/testHap/entry/src/main/ets/pages/index.ets' const importByPkgName = 'bytecode_alias'; const standardImportPath: string = 'bytecode_alias/src/main/ets/utils/Calc'; const importByPkgNameSlashes = 'bytecode_alias///'; const importByPkgNameSlashesOh = 'bytecode_alias_oh///'; - const importModuleRequets = 'bytecode_alias_oh///\\\/' const moduleSourceFile: string = new ModuleSourceFile(); ModuleSourceFile.initPluginEnv(this.rollup); const importByPkgNameOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, importByPkgName, indexFilePath, importerFile); @@ -1223,17 +1211,14 @@ mocha.describe('generate ohmUrl', function () { importerFile); const importByPkgNameOhmUrlSlashes = moduleSourceFile.getOhmUrl(this.rollup, importByPkgNameSlashes, indexFilePath, importerFile); const importByPkgNameOhmUrlSlashesOh = moduleSourceFile.getOhmUrl(this.rollup, importByPkgNameSlashesOh, indexFilePath, importerFile); - const importModuleRequetsOhmUrlSlashesOh = moduleSourceFile.getOhmUrl(this.rollup, importModuleRequets, indexFilePath, importerFile); const importByPkgNameNormalizedOhmUrl: string = '@normalized:N&&&bytecode_har/Index&1.0.0'; const standardImportPathNormalizedOhmUrl: string = '@normalized:N&&&bytecode_har/src/main/ets/utils/Calc&1.0.0'; const importByPkgNameNormalizedOhmUrlSlashes: string = '@normalized:N&&&bytecode_har/Index&1.0.0'; const importByPkgNameNormalizedOhmUrlSlashesOh: string = '@normalized:N&&&bytecode_alias_oh/Index&1.0.0'; - const importModuleRequetsNormalizedOhmUrlSlashesOh: string = '@normalized:N&&&bytecode_alias_oh/Index&1.0.0'; expect(importByPkgNameOhmUrl == importByPkgNameNormalizedOhmUrl).to.be.true; expect(standardImportPathOhmUrl == standardImportPathNormalizedOhmUrl).to.be.true; expect(importByPkgNameOhmUrlSlashes == importByPkgNameNormalizedOhmUrlSlashes).to.be.true; expect(importByPkgNameOhmUrlSlashesOh == importByPkgNameNormalizedOhmUrlSlashesOh).to.be.true; - expect(importModuleRequetsOhmUrlSlashesOh == importModuleRequetsNormalizedOhmUrlSlashesOh).to.be.true; }); mocha.it('useNormalizedOHMUrl app builtins error message', function () { @@ -1289,40 +1274,6 @@ mocha.describe('generate ohmUrl', function () { loggerStub.restore(); }); - mocha.it('the error message of getNormalizedOhmUrlByModuleRequest', function () { - const moduleInfoByModuleRequets = { - normalizedPath: "bytecode_module/Index", - packageName: "bytecode_module" - }; - this.rollup.build(); - this.rollup.share.projectConfig.useNormalizedOHMUrl = true; - this.rollup.share.projectConfig.pkgContextInfo = { - 'bytecode_module1': { - 'packageName': 'bytecode_module1', - 'bundleName': '', - 'moduleName': '', - 'version': '1.0.0', - 'entryPath': 'Index.ets', - 'isSO': false - } - } - const errInfo: LogData = LogDataFactory.newInstance( - ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, - ArkTSInternalErrorDescription, - "Failed to find package 'bytecode_module'. Failed to obtain package 'bytecode_module' " + - "from the package context information." - ); - const logger = CommonLogger.getInstance(this.rollup); - const loggerStub = sinon.stub(logger.getLoggerFromErrorCode(errInfo.code), 'printError'); - try { - delete this.rollup.share.projectConfig.pkgContextInfo['bytecode_module']; - getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequets, this.rollup.share.projectConfig, logger); - } catch (e) { - } - expect(loggerStub.getCall(0).calledWithMatch(errInfo)).to.be.true; - loggerStub.restore(); - }); - mocha.it('the error message of getNormalizedOhmUrlByAliasName', function () { this.rollup.build(); this.rollup.share.projectConfig.useNormalizedOHMUrl = true; @@ -1370,7 +1321,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo1: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, ArkTSInternalErrorDescription, - "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + + "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + "from the package context information." ); expect(loggerStub.getCall(1).calledWithMatch(errInfo1)).to.be.true; @@ -1428,7 +1379,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo1: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, ArkTSInternalErrorDescription, - "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + + "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + "from the package context information." ); expect(loggerStub.getCall(1).calledWithMatch(errInfo1.toString())).to.be.true; -- Gitee From c0b8295fd645088b0fef6411d7b33bfee7033921 Mon Sep 17 00:00:00 2001 From: Yenan Date: Tue, 20 May 2025 14:54:01 +0800 Subject: [PATCH 058/140] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=93=BE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=97=AD=E6=BA=90=E7=BB=84=E4=BB=B6=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B7=AF=E5=BE=84=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/src/ets_checker.ts | 3 +++ compiler/src/external_component_map.ts | 3 +++ compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts | 3 +++ compiler/src/process_component_build.ts | 3 +++ compiler/src/process_visual.ts | 3 +++ 5 files changed, 15 insertions(+) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index ad1e0e3d7..923cfead1 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -147,6 +147,9 @@ export let compilerOptions = ts.readConfigFile( const componentPaths: string[] | undefined = getExternalComponentPaths(); if (componentPaths) { for (const componentPath of componentPaths) { + if (!fs.existsSync(componentPath)) { + continue; + } const externalCompilerOptions: ts.CompilerOptions = ts.readConfigFile( path.resolve(componentPath, 'externalconfig.json'), ts.sys.readFile ).config.compilerOptions; diff --git a/compiler/src/external_component_map.ts b/compiler/src/external_component_map.ts index 7e22e979f..51b94a2e4 100644 --- a/compiler/src/external_component_map.ts +++ b/compiler/src/external_component_map.ts @@ -31,6 +31,9 @@ export function readExternalComponents(): object | undefined { return EXT_COMPONENT_MAP; } for (const componentPath of componentPaths) { + if(!fs.existsSync(componentPath)){ + continue; + } const files: string[] = fs.readdirSync(componentPath); files.forEach(function (item) { const fPath: string = path.join(componentPath, item); diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index a6a6a7338..5658f3b98 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -392,6 +392,9 @@ async function transform(code: string, id: string) { const componentPaths: string[] | undefined = getExternalComponentPaths(); if (componentPaths) { for (const componentPath of componentPaths) { + if (!fs.existsSync(componentPath)) { + continue; + } const externalCompilerOptions: ts.CompilerOptions = ts.readConfigFile( path.resolve(componentPath, 'externalconfig.json'), ts.sys.readFile ).config.compilerOptions; diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 7f4b912b9..0a4ff7a72 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -459,6 +459,9 @@ export function processComponentChild(node: ts.Block | ts.SourceFile, newStateme const componentPaths: string[] | undefined = getExternalComponentPaths(); if (componentPaths) { for (const componentPath of componentPaths) { + if (!fs.existsSync(componentPath)) { + continue; + } const externalCompilerOptions: ts.CompilerOptions = ts.readConfigFile( path.resolve(componentPath, 'externalconfig.json'), ts.sys.readFile ).config.compilerOptions; diff --git a/compiler/src/process_visual.ts b/compiler/src/process_visual.ts index 084b3deab..edac0a583 100644 --- a/compiler/src/process_visual.ts +++ b/compiler/src/process_visual.ts @@ -52,6 +52,9 @@ let compilerOptions = ts.readConfigFile( const componentPaths: string[] | undefined = getExternalComponentPaths(); if (componentPaths) { for (const componentPath of componentPaths) { + if (!fs.existsSync(componentPath)) { + continue; + } const externalCompilerOptions: ts.CompilerOptions = ts.readConfigFile( path.resolve(componentPath, 'externalconfig.json'), ts.sys.readFile ).config.compilerOptions; -- Gitee From b3ed3dc4b09e83a38062ed65f9f81c0e70b9df2f Mon Sep 17 00:00:00 2001 From: Yenan Date: Tue, 20 May 2025 17:20:32 +0800 Subject: [PATCH 059/140] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/src/process_component_build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index f30c90cd1..71becbadc 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -15,7 +15,7 @@ import ts from 'typescript'; import path from 'path'; - +import fs from 'fs'; import { COMPONENT_RENDER_FUNCTION, COMPONENT_CREATE_FUNCTION, -- Gitee From 46ca3c693ce9f316c6496df3b798ac60f9194caa Mon Sep 17 00:00:00 2001 From: snowman-drunk-tea Date: Tue, 20 May 2025 17:16:08 +0800 Subject: [PATCH 060/140] =?UTF-8?q?=E6=96=B0=E5=A2=9EHdsTabs=E7=AD=89?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BE=9D=E8=B5=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: snowman-drunk-tea --- compiler/components/audiowave.json | 5 +++++ compiler/components/hds_tabs.json | 12 ++++++++++++ compiler/components/hdsvisualcomponent.json | 4 ++++ compiler/components/tab_content.json | 2 +- compiler/tsconfig.esm.json | 18 ++++++++++++++++++ compiler/tsconfig.json | 18 ++++++++++++++++++ 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 compiler/components/audiowave.json create mode 100644 compiler/components/hds_tabs.json create mode 100644 compiler/components/hdsvisualcomponent.json diff --git a/compiler/components/audiowave.json b/compiler/components/audiowave.json new file mode 100644 index 000000000..c74512f3d --- /dev/null +++ b/compiler/components/audiowave.json @@ -0,0 +1,5 @@ +{ + "name": "AudioWave", + "atomic": true, + "attrs": [] +} \ No newline at end of file diff --git a/compiler/components/hds_tabs.json b/compiler/components/hds_tabs.json new file mode 100644 index 000000000..a90e9fe22 --- /dev/null +++ b/compiler/components/hds_tabs.json @@ -0,0 +1,12 @@ +{ + "name": "HdsTabs", + "children": ["TabContent"], + "attrs": [ + "vertical", "scrollable", "barMode", "barWidth", "barHeight", "animationDuration", + "onChange", "onAnimationStart", "onAnimationEnd", "onGestureSwipe", + "barPosition", "barOverlap", "barBackgroundColor", "customContentTransition", "barBackgroundBlurStyle", + "onContentWillChange", "animationMode", "edgeEffect", "onTabBarClick", "fadingEdge", "divider", + "barGridAlign", "barBackgroundEffect", "pageFlipMode", "onSelected", "onUnselected", "cachedMaxCount", + "animationCurve", "barBackgroundStyle" + ] + } \ No newline at end of file diff --git a/compiler/components/hdsvisualcomponent.json b/compiler/components/hdsvisualcomponent.json new file mode 100644 index 000000000..0ab0cb95b --- /dev/null +++ b/compiler/components/hdsvisualcomponent.json @@ -0,0 +1,4 @@ +{ + "name": "HdsVisualComponent", + "attrs": ["scene"] +} \ No newline at end of file diff --git a/compiler/components/tab_content.json b/compiler/components/tab_content.json index 91d53fefc..75f087e92 100644 --- a/compiler/components/tab_content.json +++ b/compiler/components/tab_content.json @@ -1,6 +1,6 @@ { "name": "TabContent", - "parents": ["Tabs"], + "parents": ["Tabs", "HdsTabs"], "attrs": [ "tabBar", "onWillShow", diff --git a/compiler/tsconfig.esm.json b/compiler/tsconfig.esm.json index aa05c22c4..68829bc64 100755 --- a/compiler/tsconfig.esm.json +++ b/compiler/tsconfig.esm.json @@ -284,6 +284,9 @@ "ArcSwiper", "ArcScrollBar", "ArcAlphabetIndexer", + "HdsTabs", + "AudioWave", + "HdsVisualComponent", ], "extend": { "decorator": ["Extend", "AnimatableExtend"], @@ -907,6 +910,21 @@ "name": "ArcAlphabetIndexer", "type": "ArcAlphabetIndexerAttribute", "instance": "ArcAlphabetIndexerInstance" + }, + { + "name": "HdsTabs", + "type": "HdsTabsAttribute", + "instance": "HdsTabsInstance" + }, + { + "name": "AudioWave", + "type": "AudioWaveAttribute", + "instance": "AudioWaveInstance" + }, + { + "name": "HdsVisualComponent", + "type": "HdsVisualComponentAttribute", + "instance": "HdsVisualComponentInstance" } ] }, diff --git a/compiler/tsconfig.json b/compiler/tsconfig.json index b956fcb70..25a384bdb 100644 --- a/compiler/tsconfig.json +++ b/compiler/tsconfig.json @@ -293,6 +293,9 @@ "ArcSwiper", "ArcScrollBar", "ArcAlphabetIndexer", + "HdsTabs", + "AudioWave", + "HdsVisualComponent", ], "extend": { "decorator": ["Extend", "AnimatableExtend"], @@ -956,6 +959,21 @@ "name": "ArcAlphabetIndexer", "type": "ArcAlphabetIndexerAttribute", "instance": "ArcAlphabetIndexerInstance" + }, + { + "name": "HdsTabs", + "type": "HdsTabsAttribute", + "instance": "HdsTabsInstance" + }, + { + "name": "AudioWave", + "type": "AudioWaveAttribute", + "instance": "AudioWaveInstance" + }, + { + "name": "HdsVisualComponent", + "type": "HdsVisualComponentAttribute", + "instance": "HdsVisualComponentInstance" } ] }, -- Gitee From 04329ebe65e88f06da224712448e1987b8f27384 Mon Sep 17 00:00:00 2001 From: ah Date: Tue, 20 May 2025 11:42:35 +0800 Subject: [PATCH 061/140] Fix the ohmurlbymoduleRequest Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IC91KT Signed-off-by: ah --- compiler/src/ark_utils.ts | 40 +++++++-- .../ark_compiler/module/module_mode.ts | 12 +-- .../ark_compiler/module/module_source_file.ts | 14 ++-- .../ark_compiler_ut/mock/rollup_mock/share.ts | 21 +++++ .../module/ohmUrl/ohmUrl.test.ts | 81 +++++++++++++++---- 5 files changed, 133 insertions(+), 35 deletions(-) diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index c67aa2545..a9f1f4eae 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -130,7 +130,7 @@ export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: O 'Failed to resolve OhmUrl. ' + `Failed to get a resolved OhmUrl for "${filePath}" imported by "${importerFile}".`, '', - [`Check whether the "${pkgName}" module which ${filePath} belongs to is correctly configured.`, + [`Check whether the "${pkgName}" module which ${filePath} belongs to is correctly configured.`, 'Check the corresponding file name is correct(including case-sensitivity).'] ); logger.printError(errInfo); @@ -230,7 +230,7 @@ function processPackageDir(params: Object): string { 'Failed to resolve OhmUrl. ' + `Failed to get a resolved OhmUrl for "${originalFilePath}" imported by "${importerFile}".`, '', - [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, + [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, 'Check the corresponding file name is correct(including case-sensitivity).'] ); logger.printError(errInfo); @@ -269,7 +269,7 @@ function processPackageDir(params: Object): string { 'Failed to resolve OhmUrl. ' + `Failed to get a resolved OhmUrl for "${originalFilePath}" imported by "${importerFile}".`, '', - [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, + [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, 'Check the corresponding file name is correct(including case-sensitivity).'] ); logger.printError(errInfo); @@ -306,7 +306,7 @@ export function getOhmUrlBySystemApiOrLibRequest(moduleRequest: string, config?: if (REG_LIB_SO.test(moduleRequest.trim())) { if (useNormalizedOHMUrl) { const pkgInfo = config.pkgContextInfo[moduleRequest]; - if (pkgInfo === undefined) { + if (!pkgInfo) { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_UNABLE_TO_GET_PKG_CONTENT_INFO, ArkTSInternalErrorDescription, @@ -314,6 +314,7 @@ export function getOhmUrlBySystemApiOrLibRequest(moduleRequest: string, config?: `which being imported by '${importerFile}'` ); logger?.printError(errInfo); + return moduleRequest; } const isSo = pkgInfo.isSO ? 'Y' : 'N'; return `@normalized:${isSo}&${pkgInfo.moduleName}&${pkgInfo.bundleName}&${moduleRequest}&${pkgInfo.version}`; @@ -392,6 +393,25 @@ function removeSuffix(filePath: string): string { return filePath.split(path.sep).join('/').replace(SUFFIX_REG, ''); } +export function getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequest: Object, projectConfig: Object, + logger?: Object): string { + const normalizedPath = moduleInfoByModuleRequest.normalizedPath; + const pkgName = moduleInfoByModuleRequest.packageName; + const pkgInfo: Object = projectConfig.pkgContextInfo[pkgName]; + if (!normalizedPath || !pkgName || !pkgInfo) { + const errInfo: LogData = LogDataFactory.newInstance( + ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, + ArkTSInternalErrorDescription, + `Failed to find package '${pkgName}'. ` + + `Failed to obtain package '${pkgName}' from the package context information.` + ); + logger?.printError(errInfo); + return normalizedPath; + } + const isSo = pkgInfo.isSO ? 'Y' : 'N'; + return `@normalized:${isSo}&${pkgInfo.moduleName}&${pkgInfo.bundleName}&${toUnixPath(normalizedPath)}&${pkgInfo.version}`; +} + export function getNormalizedOhmUrlByAliasName(aliasName: string, projectConfig: Object, logger?: Object, filePath?: string): string { let pkgName: string = aliasName; @@ -430,9 +450,13 @@ export function getNormalizedOhmUrlByAliasName(aliasName: string, projectConfig: return `@normalized:${isSo}&${pkgInfo.moduleName}&${pkgInfo.bundleName}&${normalizedPath}&${pkgInfo.version}`; } -export function getOhmUrlByByteCodeHar(moduleRequest: string, projectConfig: Object, logger?: Object): +export function getOhmUrlByByteCodeHar(moduleRequest: string, projectConfig: Object, rollupObject: Object, logger?: Object): string | undefined { if (projectConfig.byteCodeHarInfo) { + const moduleInfoByModuleRequest: Object = rollupObject.share?.importResolver?.(moduleRequest); + if (moduleInfoByModuleRequest) { + return getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequest, projectConfig, logger); + } let aliasName: string = getAliasNameFromPackageMap(projectConfig.byteCodeHarInfo, moduleRequest); if (aliasName) { return getNormalizedOhmUrlByAliasName(aliasName, projectConfig, logger); @@ -467,11 +491,15 @@ function getAliasNameFromPackageMap(externalPkgMap: Object, moduleRequest: strin return undefined; } -export function getOhmUrlByExternalPackage(moduleRequest: string, projectConfig: Object, logger?: Object, +export function getOhmUrlByExternalPackage(moduleRequest: string, projectConfig: Object, rollupObject?: Object, logger?: Object, useNormalizedOHMUrl: boolean = false): string | undefined { // The externalPkgMap store the ohmurl with the alias of hsp package and the hars depended on bytecode har. let externalPkgMap: Object = Object.assign({}, projectConfig.hspNameOhmMap, projectConfig.harNameOhmMap); if (Object.keys(externalPkgMap).length !== 0) { + const moduleInfoByModuleRequest: Object = rollupObject?.share?.importResolver?.(moduleRequest); + if (useNormalizedOHMUrl && moduleInfoByModuleRequest) { + return getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequest, projectConfig, logger); + } let aliasName: string = getAliasNameFromPackageMap(externalPkgMap, moduleRequest); if (aliasName) { if (useNormalizedOHMUrl) { diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index 94b827a6c..e1591666a 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -105,7 +105,7 @@ import { import { SourceMapGenerator } from '../generate_sourcemap'; import { MemoryMonitor } from '../../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../../meomry_monitor/memory_define'; -import { +import { ArkTSInternalErrorDescription, ArkTSErrorDescription, ErrorCode @@ -234,7 +234,7 @@ export class ModuleMode extends CommonMode { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_MODULE_INFO_NOT_FOUND, ArkTSInternalErrorDescription, - 'Failed to find module info. ' + + 'Failed to find module info. ' + `Failed to find module info with '${moduleId}' from the context information.` ); this.logger.printErrorAndExit(errInfo); @@ -244,7 +244,7 @@ export class ModuleMode extends CommonMode { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_META_INFO_NOT_FOUND, ArkTSInternalErrorDescription, - 'Failed to find meta info. ' + + 'Failed to find meta info. ' + `Failed to find meta info with '${moduleId}' from the module info.` ); this.logger.printErrorAndExit(errInfo); @@ -357,7 +357,7 @@ export class ModuleMode extends CommonMode { this.updatePkgEntryInfos(pkgEntryInfos, pkgName, ohmurl); continue; } - let hspOhmurl: string | undefined = getOhmUrlByExternalPackage(pkgName, this.projectConfig, this.logger, + let hspOhmurl: string | undefined = getOhmUrlByExternalPackage(pkgName, this.projectConfig, undefined, this.logger, this.useNormalizedOHMUrl); if (hspOhmurl !== undefined) { hspOhmurl = hspOhmurl.replace(/^@(\w+):(.*)/, '@$1.$2'); @@ -652,7 +652,7 @@ export class ModuleMode extends CommonMode { // Generate cache file path for bytecode har private genAbcCacheFilePath(abcPath: string): string { /** - * The projectTopDir is the path of the main project, the projectRootPath is the project path to which it belongs, + * The projectTopDir is the path of the main project, the projectRootPath is the project path to which it belongs, * and the path of bytecode har is within the main project. Therefore, the projectTopDir is used to intercept the * relative path of bytecodehar. */ @@ -978,7 +978,7 @@ export class ModuleMode extends CommonMode { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_INVALID_COMPILE_MODE, ArkTSInternalErrorDescription, - 'Invalid compilation mode. ' + + 'Invalid compilation mode. ' + `ProjectConfig.pandaMode should be either ${TS2ABC} or ${ES2ABC}.` ); this.logger.printErrorAndExit(errInfo); diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index c2790540f..9c074224d 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -62,12 +62,12 @@ import { } from 'arkguard'; import { MemoryMonitor } from '../../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../../meomry_monitor/memory_define'; -import { +import { CommonLogger, LogData, LogDataFactory } from '../logger'; -import { +import { ArkTSInternalErrorDescription, ErrorCode } from '../error_code'; @@ -161,7 +161,7 @@ export class ModuleSourceFile { if (!!rollupObject.share.projectConfig.useNormalizedOHMUrl) { useNormalizedOHMUrl = rollupObject.share.projectConfig.useNormalizedOHMUrl; } - let transformedMockTarget: string | undefined = getOhmUrlByExternalPackage(originKey, ModuleSourceFile.projectConfig, + let transformedMockTarget: string | undefined = getOhmUrlByExternalPackage(originKey, ModuleSourceFile.projectConfig, rollupObject, ModuleSourceFile.logger, useNormalizedOHMUrl); if (transformedMockTarget !== undefined) { ModuleSourceFile.addMockConfig(ModuleSourceFile.transformedHarOrHspMockConfigInfo, transformedMockTarget, src); @@ -330,7 +330,7 @@ export class ModuleSourceFile { } ModuleSourceFile.isEnvInitialized = true; } - + if (ModuleSourceFile.moduleIdMap.has(moduleId)) { let moduleSourceFile = ModuleSourceFile.moduleIdMap.get(moduleId); ModuleSourceFile.moduleIdMap.delete(moduleId); @@ -349,7 +349,7 @@ export class ModuleSourceFile { await moduleSourceFile.writeSourceFile(eventWriteSourceFile); stopEvent(eventWriteSourceFile); } - } + } static async processModuleSourceFiles(rollupObject: Object, parentEvent: CompileEvent | undefined): Promise { this.initPluginEnv(rollupObject); @@ -432,14 +432,14 @@ export class ModuleSourceFile { return systemOrLibOhmUrl; } const externalPkgOhmurl: string | undefined = getOhmUrlByExternalPackage(moduleRequest, - ModuleSourceFile.projectConfig, ModuleSourceFile.logger, useNormalizedOHMUrl); + ModuleSourceFile.projectConfig, rollupObject, ModuleSourceFile.logger, useNormalizedOHMUrl); if (externalPkgOhmurl !== undefined) { if (ModuleSourceFile.needProcessMock) { ModuleSourceFile.generateNewMockInfo(moduleRequest, externalPkgOhmurl, rollupObject, importerFile); } return externalPkgOhmurl; } - const byteCodeHarOhmurl: string | undefined = getOhmUrlByByteCodeHar(moduleRequest, ModuleSourceFile.projectConfig, + const byteCodeHarOhmurl: string | undefined = getOhmUrlByByteCodeHar(moduleRequest, ModuleSourceFile.projectConfig, rollupObject, ModuleSourceFile.logger); if (byteCodeHarOhmurl !== undefined) { if (ModuleSourceFile.needProcessMock) { diff --git a/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts b/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts index b46b194f9..308633119 100644 --- a/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts +++ b/compiler/test/ark_compiler_ut/mock/rollup_mock/share.ts @@ -183,6 +183,27 @@ class Share { return logger; } + public importResolver (moduleRequest: string): Object | undefined { + if (moduleRequest === "@ohos/library////\\\\/") { + return { + normalizedPath: "@ohos/library/Index", + packageName: "@ohos/library" + } + } + if (moduleRequest === "@ohos/library/src/main/ets////") { + return { + normalizedPath: "@ohos/library/src/main/ets/Index", + packageName: "@ohos/library" + } + } + if (moduleRequest === "bytecode_alias_oh///\\\/") { + return { + normalizedPath: "bytecode_alias_oh/Index", + packageName: "bytecode_alias_oh" + } + } + return undefined; + } public scan(testcase: string) { if (!testcase) { return; diff --git a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts index 7f09e32a6..2e6514a7e 100644 --- a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts +++ b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts @@ -22,7 +22,8 @@ import { getOhmUrlByExternalPackage, getOhmUrlBySystemApiOrLibRequest, getNormalizedOhmUrlByFilepath, - getNormalizedOhmUrlByAliasName + getNormalizedOhmUrlByAliasName, + getNormalizedOhmUrlByModuleRequest } from '../../../../lib/ark_utils'; import { PACKAGES } from '../../../../lib/pre_define'; import projectConfig from '../../utils/processProjectConfig'; @@ -118,22 +119,32 @@ mocha.describe('generate ohmUrl', function () { }); mocha.it('shared library', function () { + this.rollup.build(); const sharedLibraryPackageName: string = "@ohos/sharedLibrary"; const sharedLibraryPackageNameSlashes: string = "@ohos/library///"; const sharedLibraryPage: string = "@ohos/sharedLibrary/src/main/ets/pages/page1"; const errorSharedLibrary: string = "@ohos/staticLibrary"; - const sharedLibraryPackageNameOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageName, projectConfig); - const sharedLibraryPackageNameSlashesOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageNameSlashes, projectConfig, ModuleSourceFile.logger, true); - const sharedLibraryPageOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPage, projectConfig); - const errorSharedLibraryOhmUrl = getOhmUrlByExternalPackage(errorSharedLibrary, projectConfig); + const sharedLibraryModuleRequest = "@ohos/library////\\\\/"; + const sharedLibraryModuleRequestByPath = "@ohos/library/src/main/ets////"; + const sharedLibraryPackageNameOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageName, projectConfig, this.rollup); + const sharedLibraryPackageNameSlashesOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPackageNameSlashes, projectConfig, this.rollup, ModuleSourceFile.logger, true); + const sharedLibraryPageOhmUrl: string = getOhmUrlByExternalPackage(sharedLibraryPage, projectConfig, this.rollup); + const errorSharedLibraryOhmUrl = getOhmUrlByExternalPackage(errorSharedLibrary, projectConfig, this.rollup); + const sharedLibraryModuleRequestOhmUrl = getOhmUrlByExternalPackage(sharedLibraryModuleRequest, projectConfig, this.rollup, ModuleSourceFile.logger, true); + const sharedLibraryModuleRequestByPathOhmUrl = getOhmUrlByExternalPackage(sharedLibraryModuleRequestByPath, projectConfig, this.rollup, ModuleSourceFile.logger, true); const expectedSharedLibraryOhmUrl: string = "@bundle:UtTestApplication/sharedLibrary/ets/index"; const expectedSharedLibrarySlashesOhmUrl: string = "@normalized:N&&&@ohos/library/Index&1.0.0"; const expectedSharedLibraryPageOhmUrl: string = "@bundle:UtTestApplication/sharedLibrary/ets/pages/page1"; const expectedErrorSharedLibraryOhmUrl = undefined; + const expectsharedLibraryModuleRequestOhmUrl = "@normalized:N&&&@ohos/library/Index&1.0.0"; + const expectsharedLibraryModuleRequestByPathOhmUrl = "@normalized:N&&&@ohos/library/src/main/ets/Index&1.0.0"; expect(sharedLibraryPackageNameOhmUrl == expectedSharedLibraryOhmUrl).to.be.true; expect(sharedLibraryPackageNameSlashesOhmUrl == expectedSharedLibrarySlashesOhmUrl).to.be.true; expect(sharedLibraryPageOhmUrl == expectedSharedLibraryPageOhmUrl).to.be.true; expect(errorSharedLibraryOhmUrl == expectedErrorSharedLibraryOhmUrl).to.be.true; + expect(sharedLibraryModuleRequestOhmUrl == expectsharedLibraryModuleRequestOhmUrl).to.be.true; + expect(sharedLibraryModuleRequestByPathOhmUrl == expectsharedLibraryModuleRequestByPathOhmUrl).to.be.true; + }); mocha.it('project module', function () { @@ -237,7 +248,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, ArkTSErrorDescription, - 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + + 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + '"/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', @@ -261,7 +272,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, ArkTSErrorDescription, - 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + + 'Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for ' + '"/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', @@ -495,7 +506,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -573,7 +584,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -652,7 +663,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -730,7 +741,7 @@ mocha.describe('generate ohmUrl', function () { const etsBasedAbsolutePath: string = 'ets/utils/Calc'; const standardImportPath: string = 'pkghar/src/main/ets/utils/Calc'; const moduleSourceFile: string = new ModuleSourceFile(); - ModuleSourceFile.initPluginEnv(this.rollup); + ModuleSourceFile.initPluginEnv(this.rollup); const relativePathOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, relativePath, filePath, importerFile); const etsBasedAbsolutePathOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, etsBasedAbsolutePath, filePath, importerFile); @@ -1113,7 +1124,7 @@ mocha.describe('generate ohmUrl', function () { mockConfigPath: `${projectConfig.projectRootPath}/entry/src/mock/mock-config.json5` } this.rollup.share.projectConfig.entryModuleName = 'entry'; - + const importerFile: string = `${projectConfig.projectRootPath}/entry/src/main/ets/pages/index.ets`; const moduleInfo = { id: importerFile, @@ -1124,7 +1135,7 @@ mocha.describe('generate ohmUrl', function () { } } this.rollup.moduleInfos.push(moduleInfo); - + for (let moduleRequest in PRVIEW_MOCK_CONFIG) { let mockPath = PRVIEW_MOCK_CONFIG[moduleRequest] let filePath: string; @@ -1197,13 +1208,14 @@ mocha.describe('generate ohmUrl', function () { } } const filePath: string = 'bytecode_alias/src/main/ets/utils/Calc'; - const indexFilePath: string = 'bytecode_alias'; + const indexFilePath: string = 'bytecode_alias'; const importerFile: string = '/testHap/entry/src/main/ets/pages/index.ets' const importByPkgName = 'bytecode_alias'; const standardImportPath: string = 'bytecode_alias/src/main/ets/utils/Calc'; const importByPkgNameSlashes = 'bytecode_alias///'; const importByPkgNameSlashesOh = 'bytecode_alias_oh///'; + const importModuleRequets = 'bytecode_alias_oh///\\\/' const moduleSourceFile: string = new ModuleSourceFile(); ModuleSourceFile.initPluginEnv(this.rollup); const importByPkgNameOhmUrl = moduleSourceFile.getOhmUrl(this.rollup, importByPkgName, indexFilePath, importerFile); @@ -1211,14 +1223,17 @@ mocha.describe('generate ohmUrl', function () { importerFile); const importByPkgNameOhmUrlSlashes = moduleSourceFile.getOhmUrl(this.rollup, importByPkgNameSlashes, indexFilePath, importerFile); const importByPkgNameOhmUrlSlashesOh = moduleSourceFile.getOhmUrl(this.rollup, importByPkgNameSlashesOh, indexFilePath, importerFile); + const importModuleRequetsOhmUrlSlashesOh = moduleSourceFile.getOhmUrl(this.rollup, importModuleRequets, indexFilePath, importerFile); const importByPkgNameNormalizedOhmUrl: string = '@normalized:N&&&bytecode_har/Index&1.0.0'; const standardImportPathNormalizedOhmUrl: string = '@normalized:N&&&bytecode_har/src/main/ets/utils/Calc&1.0.0'; const importByPkgNameNormalizedOhmUrlSlashes: string = '@normalized:N&&&bytecode_har/Index&1.0.0'; const importByPkgNameNormalizedOhmUrlSlashesOh: string = '@normalized:N&&&bytecode_alias_oh/Index&1.0.0'; + const importModuleRequetsNormalizedOhmUrlSlashesOh: string = '@normalized:N&&&bytecode_alias_oh/Index&1.0.0'; expect(importByPkgNameOhmUrl == importByPkgNameNormalizedOhmUrl).to.be.true; expect(standardImportPathOhmUrl == standardImportPathNormalizedOhmUrl).to.be.true; expect(importByPkgNameOhmUrlSlashes == importByPkgNameNormalizedOhmUrlSlashes).to.be.true; expect(importByPkgNameOhmUrlSlashesOh == importByPkgNameNormalizedOhmUrlSlashesOh).to.be.true; + expect(importModuleRequetsOhmUrlSlashesOh == importModuleRequetsNormalizedOhmUrlSlashesOh).to.be.true; }); mocha.it('useNormalizedOHMUrl app builtins error message', function () { @@ -1274,6 +1289,40 @@ mocha.describe('generate ohmUrl', function () { loggerStub.restore(); }); + mocha.it('the error message of getNormalizedOhmUrlByModuleRequest', function () { + const moduleInfoByModuleRequest = { + normalizedPath: "bytecode_module/Index", + packageName: "bytecode_module" + }; + this.rollup.build(); + this.rollup.share.projectConfig.useNormalizedOHMUrl = true; + this.rollup.share.projectConfig.pkgContextInfo = { + 'bytecode_module1': { + 'packageName': 'bytecode_module1', + 'bundleName': '', + 'moduleName': '', + 'version': '1.0.0', + 'entryPath': 'Index.ets', + 'isSO': false + } + } + const errInfo: LogData = LogDataFactory.newInstance( + ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, + ArkTSInternalErrorDescription, + "Failed to find package 'bytecode_module'. Failed to obtain package 'bytecode_module' " + + "from the package context information." + ); + const logger = CommonLogger.getInstance(this.rollup); + const loggerStub = sinon.stub(logger.getLoggerFromErrorCode(errInfo.code), 'printError'); + try { + delete this.rollup.share.projectConfig.pkgContextInfo['bytecode_module']; + getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequest, this.rollup.share.projectConfig, logger); + } catch (e) { + } + expect(loggerStub.getCall(0).calledWithMatch(errInfo)).to.be.true; + loggerStub.restore(); + }); + mocha.it('the error message of getNormalizedOhmUrlByAliasName', function () { this.rollup.build(); this.rollup.share.projectConfig.useNormalizedOHMUrl = true; @@ -1321,7 +1370,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo1: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, ArkTSInternalErrorDescription, - "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + + "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + "from the package context information." ); expect(loggerStub.getCall(1).calledWithMatch(errInfo1)).to.be.true; @@ -1379,7 +1428,7 @@ mocha.describe('generate ohmUrl', function () { const errInfo1: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_PACKAGE_NOT_FOUND_IN_CONTEXT_INFO, ArkTSInternalErrorDescription, - "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + + "Failed to find package 'bytecode_har'. Failed to obtain package 'bytecode_har' " + "from the package context information." ); expect(loggerStub.getCall(1).calledWithMatch(errInfo1.toString())).to.be.true; -- Gitee From 5d30bcb563dde2a4d367d2726ddaf7ed40741714 Mon Sep 17 00:00:00 2001 From: maoruihao Date: Tue, 20 May 2025 22:28:20 +0800 Subject: [PATCH 062/140] Optimize redundant checker Signed-off-by: maoruihao --- .../ets_ui/rollup-plugin-ets-typescript.ts | 6 ++- .../fast_build/system_api/api_check_utils.ts | 5 +- compiler/src/process_component_build.ts | 34 ++++++++---- compiler/src/process_component_member.ts | 26 +++++++--- compiler/src/process_custom_component.ts | 8 +-- compiler/src/process_import.ts | 11 ++-- compiler/src/utils.ts | 52 +++++++++++++++++++ compiler/src/validate_ui_syntax.ts | 23 +++++--- 8 files changed, 128 insertions(+), 37 deletions(-) diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index a6a6a7338..331bc8e79 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -39,7 +39,8 @@ import { resetUtils, getResolveModules, toUnixPath, - getBelongModuleInfo + getBelongModuleInfo, + CurrentProcessFile } from '../../utils'; import { preprocessExtend, @@ -375,6 +376,7 @@ function getArkoalaTsProgram(program: ts.Program): ts.Program { } async function transform(code: string, id: string) { + CurrentProcessFile.setIsProcessingFileETS(id); const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsTransform', 'transform'); if (!filter(id)) { return null; @@ -502,7 +504,7 @@ async function transform(code: string, id: string) { } else { const uiKitrecordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_UI_KIT); const eventTransformNodes = createAndStartEvent(eventTsProgramEmit, 'transformNodes'); - const emitResolver: ts.EmitResolver = globalProgram.checker.getEmitResolver(outFile(tsProgram.getCompilerOptions()) ? + const emitResolver: ts.EmitResolver | undefined = CurrentProcessFile.getChecker()?.getEmitResolver(outFile(tsProgram.getCompilerOptions()) ? undefined : targetSourceFile, undefined); metaInfo.checker = tsProgram.getTypeChecker(); transformResult = ts.transformNodes(emitResolver, tsProgram.getEmitHost?.(), ts.factory, diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index b9ac28090..14d9ef9ef 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -29,7 +29,8 @@ import { import { LogType, LogInfo, - IFileLog + IFileLog, + CurrentProcessFile } from '../../utils'; import { type ResolveModuleInfo } from '../../ets_checker'; import { @@ -225,7 +226,7 @@ export function checkTypeReference(node: ts.TypeReferenceNode, transformLog: IFi const fileName: string = transformLog.sourceFile.fileName; const currentTypeName: string = node.getText(); if (/(?= 11 && ts.isPropertyAccessExpression(node) && - node.name && ts.isIdentifier(node.name) && node.name.escapedText.toString() === WRAPBUILDER_BUILDERPROP && - typeAtLocation && typeAtLocation.symbol && typeAtLocation.symbol.escapedName === WRAPPEDBUILDER_CLASS) { - return true; + if (!( + projectConfig.minAPIVersion >= 11 && + ts.isPropertyAccessExpression(node) && + node.name && ts.isIdentifier(node.name) && + node.name.escapedText.toString() === WRAPBUILDER_BUILDERPROP + )) { + return false; + } + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (checker) { + const type: ts.Type | ts.Type[] = + findNonNullType(checker.getTypeAtLocation(node.expression)); + if (Array.isArray(type)) { + return false; + } + return type.symbol && type.symbol.escapedName === WRAPPEDBUILDER_CLASS; } return false; } @@ -2910,8 +2923,9 @@ function isRegularAttrNode(node: ts.Expression): boolean { if (enumCollection.has(node.expression.escapedText.toString())) { return true; } - if (globalProgram.checker) { - const type: ts.Type = globalProgram.checker.getTypeAtLocation(node); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (checker) { + const type: ts.Type = checker.getTypeAtLocation(node); /* Enum */ if (type.flags & (32 | 1024)) { return true; @@ -3414,7 +3428,7 @@ function isWrappedBuilderExpression(node: ts.ExpressionStatement): boolean { function judgeBuilderType(node: ts.ExpressionStatement): boolean { let checker: ts.TypeChecker; if (globalProgram.program) { - checker = globalProgram.program.getTypeChecker(); + checker = CurrentProcessFile.getChecker(globalProgram.program); } else if (globalProgram.watchProgram) { checker = globalProgram.watchProgram.getCurrentProgram().getProgram().getTypeChecker(); } diff --git a/compiler/src/process_component_member.ts b/compiler/src/process_component_member.ts index 9bd793f75..1935519bc 100644 --- a/compiler/src/process_component_member.ts +++ b/compiler/src/process_component_member.ts @@ -95,7 +95,9 @@ import { LogType, LogInfo, componentInfo, - storedFileInfo + storedFileInfo, + findNonNullType, + CurrentProcessFile } from './utils'; import { createReference, @@ -979,8 +981,9 @@ function manageLocalStorageComponents(node: ts.CallExpression, argumentsArray: t } export function isLocalStorageParameter(node: ts.CallExpression): boolean { - const resolvedSignature = globalProgram.checker?.getResolvedSignature ? - globalProgram.checker.getResolvedSignature(node) : undefined; + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const resolvedSignature = checker?.getResolvedSignature ? + checker.getResolvedSignature(node) : undefined; return resolvedSignature && resolvedSignature.parameters && resolvedSignature.parameters.length === 1 && resolvedSignature.parameters[0].escapedName === '##storage'; } @@ -1101,11 +1104,11 @@ export function isSimpleType(typeNode: ts.TypeNode, program: ts.Program, log?: L typeNode = typeNode || ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword); let checker: ts.TypeChecker; if (globalProgram.program) { - checker = globalProgram.program.getTypeChecker(); + checker = CurrentProcessFile.getChecker(globalProgram.program); } else if (globalProgram.watchProgram) { checker = globalProgram.watchProgram.getCurrentProgram().getProgram().getTypeChecker(); } else if (program) { - checker = program.getTypeChecker(); + checker = CurrentProcessFile.getChecker(program); } return getDeclarationType(typeNode, checker, log); } @@ -1375,11 +1378,18 @@ function updateSynchedPropertyNesedObjectPU(nameIdentifier: ts.Identifier, // check @ObjectLink type Non basic types and @Observedv2. function checkObjectLinkType(typeNode: ts.TypeNode): boolean { - if (globalProgram.checker) { - const type: ts.Type = globalProgram.checker.getTypeFromTypeNode(typeNode); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (checker) { + const type: ts.Type | ts.Type[] = findNonNullType(checker.getTypeFromTypeNode(typeNode)); const isPropertyDeclaration: boolean = typeNode.parent && ts.isPropertyDeclaration(typeNode.parent); if (isPropertyDeclaration) { - if (type.types && type.types.length) { + if (Array.isArray(type)) { + let res = true; + for (let i = 0; i < type.length; i++) { + res = res && checkTypes(type[i]); + } + return res; + } else if (type.types && type.types.length) { return checkTypes(type); } else { return !(isObservedV2(type) || isAllowedTypeForBasic(type.flags) || isFunctionType(type)); diff --git a/compiler/src/process_custom_component.ts b/compiler/src/process_custom_component.ts index 62d7629af..7aaec808e 100644 --- a/compiler/src/process_custom_component.ts +++ b/compiler/src/process_custom_component.ts @@ -100,7 +100,8 @@ import { LogType, LogInfo, componentInfo, - storedFileInfo + storedFileInfo, + CurrentProcessFile } from './utils'; import { bindComponentAttr, @@ -485,9 +486,10 @@ function isForbiddenTypeToComponentV1(type: ts.Type): boolean { function isForbiddenAssignToComponentV2(item: ts.PropertyAssignment, itemName: string, info: ChildAndParentComponentInfo): boolean { + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); if (!info.parentStructInfo.isComponentV2 && info.updatePropsDecoratorsV2.includes(itemName) && - isObervedProperty(item.initializer, info) && globalProgram.strictChecker) { - const type: ts.Type = globalProgram.strictChecker.getTypeAtLocation(item.initializer); + isObervedProperty(item.initializer, info) && checker) { + const type: ts.Type = checker.getTypeAtLocation(item.initializer); return !(isAllowedTypeToComponentV2(type) || isForbiddenTypeToComponentV1(type) || !(isObservedV2(type) || isFunctionType(type))); } return false; diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index bdfbb6886..2eac04c54 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -63,6 +63,7 @@ import { regularStaticCollection } from './validate_ui_syntax'; import { + CurrentProcessFile, getExtensionIfUnfullySpecifiedFilepath, hasDecorator, LogInfo, @@ -789,9 +790,10 @@ export function processImportModule(node: ts.ImportDeclaration, pageFile: string function getDefinedNode(importSymbol: ts.Symbol, realSymbol: ts.Symbol, originNode: ts.Node, usedNode: ts.Identifier, pageInfo: PageInfo, share: object = null): void { - importSymbol = globalProgram.checker.getSymbolAtLocation(usedNode); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + importSymbol = checker?.getSymbolAtLocation(usedNode); if (importSymbol) { - realSymbol = globalProgram.checker.getAliasedSymbol(importSymbol); + realSymbol = checker?.getAliasedSymbol(importSymbol); } else { realSymbol = null; } @@ -817,7 +819,7 @@ function getIntegrationNodeInfo(originNode: ts.Node, usedNode: ts.Identifier, ex pageInfo: PageInfo, share: object = null): void { for (const usedSymbol of exportsMap) { try { - originNode = globalProgram.checker.getAliasedSymbol(usedSymbol[1]).declarations[0]; + originNode = CurrentProcessFile.getChecker()?.getAliasedSymbol(usedSymbol[1]).declarations[0]; } catch (e) { if (usedSymbol[1] && usedSymbol[1].declarations) { for (let i = 0; i < usedSymbol[1].declarations.length; i++) { @@ -834,7 +836,8 @@ function getIntegrationNodeInfo(originNode: ts.Node, usedNode: ts.Identifier, ex function exportAllManage(originNode: ts.Node, usedNode: ts.Identifier, pageInfo: PageInfo, share: object = null): void { let exportOriginNode: ts.Node; if (!originNode.exportClause && originNode.moduleSpecifier && ts.isStringLiteral(originNode.moduleSpecifier)) { - const exportSymbol: ts.Symbol = globalProgram.checker.getSymbolAtLocation(originNode.moduleSpecifier); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const exportSymbol: ts.Symbol = checker?.getSymbolAtLocation(originNode.moduleSpecifier); if (exportSymbol && exportSymbol.declarations) { exportOriginNode = exportSymbol.declarations[0]; } else { diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 1cf080059..7b0a287a9 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -1332,4 +1332,56 @@ export function getBelongModuleInfo(filePath: string, modulePathMap: Object, pro moduleName: '', belongModulePath: projectRootPath }; +} + +/** + * Eliminate null in type + * + * @param { ts.Type } type + * @returns { ts.Type | ts.Type[] } + */ +export function findNonNullType(type: ts.Type): ts.Type | ts.Type[] { + if (!type.isUnion() || !(type.types && type.types.length)) { + return type; + } + const filteredTypes: ts.Type[] = type.types.filter((t) => { + return t.flags && !(t.flags & ts.TypeFlags.Nullable); + }); + if (filteredTypes.length === 1) { + return filteredTypes[0]; + } + return filteredTypes; +} + +/** + * Manage File type and checker + */ +export class CurrentProcessFile { + private static isProcessingFileETS: boolean = false; + + /** + * Get checker according to file type + * + * @param { ts.Program? } program + * @returns { ts.TypeChecker | undefined } + */ + static getChecker(program?: ts.Program): ts.TypeChecker | undefined { + if (CurrentProcessFile.isProcessingFileETS) { + return (program ?? globalProgram.program)?.getLinterTypeChecker(); + } + return (program ?? globalProgram.program)?.getTypeChecker(); + } + + /** + * Record current file type + * + * @param { string } id + */ + static setIsProcessingFileETS(id: string): void { + CurrentProcessFile.isProcessingFileETS = CurrentProcessFile.isETSFile(id); + } + + private static isETSFile(id: string): boolean { + return !!(path.extname(id)?.endsWith('ets')); + } } \ No newline at end of file diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 10bc7a70b..0bbca9308 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -91,7 +91,8 @@ import { addLog, hasDecorator, storedFileInfo, - ExtendResult + ExtendResult, + CurrentProcessFile } from './utils'; import { globalProgram, projectConfig, abilityPagesFullPath } from '../main'; import { @@ -517,7 +518,8 @@ function validatePropertyInStruct(structContext: boolean, decoratorNode: ts.Iden } const classResult: ClassDecoratorResult = new ClassDecoratorResult(); const propertyNode: ts.PropertyDeclaration = getPropertyNodeByDecorator(decoratorNode); - if (propertyNode && propertyNode.type && globalProgram.checker) { + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (propertyNode && propertyNode.type && checker) { validatePropertyType(propertyNode.type, classResult); } let message: string; @@ -547,7 +549,8 @@ function validatePropertyType(node: ts.TypeNode, classResult: ClassDecoratorResu }); } if (ts.isTypeReferenceNode(node) && node.typeName) { - const typeNode: ts.Type = globalProgram.checker.getTypeAtLocation(node.typeName); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const typeNode: ts.Type = checker?.getTypeAtLocation(node.typeName); parsePropertyType(typeNode, classResult); } } @@ -774,7 +777,8 @@ const classMemberDecorators: string[] = [CLASS_TRACK_DECORATOR, CLASS_MIN_TRACK_ function validTypeCallback(node: ts.Identifier): boolean { let isSdkPath: boolean = true; - if (globalProgram.checker && process.env.compileTool === 'rollup') { + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (checker && process.env.compileTool === 'rollup') { const symbolObj: ts.Symbol = getSymbolIfAliased(node); const fileName: string = symbolObj?.valueDeclaration?.getSourceFile()?.fileName; isSdkPath = /@ohos.arkui.*/.test(fileName); @@ -896,7 +900,8 @@ function validateMutilObserved(node: ts.ClassDeclaration, classResult: ClassDeco function parseInheritClass(node: ts.ClassDeclaration, childClassResult: ClassDecoratorResult, sourceFileNode: ts.SourceFile, log: LogInfo[]): void { - if (globalProgram.checker && process.env.compileTool === 'rollup' && node.heritageClauses) { + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (checker && process.env.compileTool === 'rollup' && node.heritageClauses) { for (const heritageClause of node.heritageClauses) { if (heritageClause.token === ts.SyntaxKind.ExtendsKeyword && heritageClause.types && heritageClause.types.length) { @@ -927,16 +932,18 @@ function getClassNode(parentType: ts.Node, childClassResult: ClassDecoratorResul function parseShorthandPropertyForClass(node: ts.ShorthandPropertyAssignment, childClassResult: ClassDecoratorResult, childClass: ts.ClassDeclaration, sourceFileNode: ts.SourceFile, log: LogInfo[]): void { - const shortSymbol: ts.Symbol = globalProgram.checker.getShorthandAssignmentValueSymbol(node); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const shortSymbol: ts.Symbol = checker?.getShorthandAssignmentValueSymbol(node); if (shortSymbol && shortSymbol.valueDeclaration && ts.isClassDeclaration(shortSymbol.valueDeclaration)) { validateInheritClassDecorator(shortSymbol.valueDeclaration, childClassResult, childClass, sourceFileNode, log); } } export function getSymbolIfAliased(node: ts.Node): ts.Symbol { - const symbol: ts.Symbol = globalProgram.checker.getSymbolAtLocation(node); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const symbol: ts.Symbol = checker?.getSymbolAtLocation(node); if (symbol && (symbol.getFlags() & ts.SymbolFlags.Alias) !== 0) { - return globalProgram.checker.getAliasedSymbol(symbol); + return checker?.getAliasedSymbol(symbol); } return symbol; } -- Gitee From 422feda567dd41b1245c0e495136a4003a298de1 Mon Sep 17 00:00:00 2001 From: shitao Date: Wed, 21 May 2025 10:15:11 +0800 Subject: [PATCH 063/140] Write sourcemap by line Issue: IC9AT7 Signed-off-by: shitao Change-Id: I2fa937b99fdb067797886e9feb9d2b25dcfff8ba --- .../ark_compiler/bytecode_obfuscator.ts | 7 +- .../ark_compiler/generate_module_abc.ts | 4 +- .../ark_compiler/generate_sourcemap.ts | 307 +++++++++++++++--- .../ark_compiler/module/module_source_file.ts | 1 + .../mock/class_mock/module_mode_mock.ts | 19 +- .../module/module_mode.test.ts | 8 + 6 files changed, 292 insertions(+), 54 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts index 096a58c63..7b9cc6fb2 100644 --- a/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts +++ b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts @@ -64,6 +64,7 @@ import { FileKeepInfo, FileReservedInfo } from 'arkguard/lib/utils/ProjectCollections'; +import { SourceMapGenerator } from './generate_sourcemap'; const FILE_NAME_CACHE: string = 'FileNameCache'; const OBF_NAME_MAP: string = 'ObfNameMap'; @@ -308,7 +309,7 @@ export class BytecodeObfuscator { const nameMapping: Map = generateMapping(nameCache); const sourceMapUpdated: Object = updateSourceMap(sourceMap, nameMapping); fs.writeFileSync(sourceMapPath, JSON.stringify(sourceMapUpdated, null, 2)); - fs.writeFileSync(souceMapJsonPath, JSON.stringify(sourceMapUpdated, null, 2)); + fs.writeFileSync(souceMapJsonPath, SourceMapGenerator.getInstance().convertSourceMapToCache(sourceMapUpdated)); const nameCacheUpdated: Object = this.bytecodeObfuscateConfig.obfuscationRules.compact ? nameCache : processNameCache(nameCache, sourceMap); fs.writeFileSync(this.nameCachePath, JSON.stringify(nameCacheUpdated, null, 2)); @@ -375,9 +376,9 @@ export class BytecodeObfuscator { if (rules.enableDecoratorObfuscation) { const reservedNames = this.bytecodeObfuscateConfig.getReservedNames(); structProperties = new Set( - Array.from(structProperties || []).filter(item => reservedNames?.has(item)) + Array.from(structProperties || []).filter(item => reservedNames?.has(item)) ); - } + } const arrayProperties = [ keepSymbol?.propertyNames, diff --git a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts index 2df6115ed..1053a7cf9 100644 --- a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts +++ b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts @@ -47,9 +47,9 @@ export async function generateModuleAbc(error) { await ModuleSourceFile.processModuleSourceFiles(this, hookEventFactory); } if (this.share.projectConfig.compileHar) { - SourceMapGenerator.getInstance().buildModuleSourceMapInfo(hookEventFactory); - // compileHar: compile har of project, which convert .ets to .d.ts and js if (!this.share.projectConfig.byteCodeHar) { + // compileHar: compile har of project, which convert .ets to .d.ts and js + SourceMapGenerator.getInstance().buildModuleSourceMapInfo(hookEventFactory); return; } } diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index 00ab52a52..c442ef9d8 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -21,7 +21,6 @@ import { EXTNAME_TS, EXTNAME_MJS, EXTNAME_CJS, - GEN_ABC_PLUGIN_NAME, SOURCEMAPS, SOURCEMAPS_JSON, yellow, @@ -46,7 +45,7 @@ import { } from './common/ob_config_resolver'; import { MemoryMonitor } from '../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../meomry_monitor/memory_define'; -import { +import { ArkTSInternalErrorDescription, ErrorCode } from './error_code'; @@ -61,6 +60,9 @@ import { stopEvent } from '../../performance'; import { BytecodeObfuscator } from './bytecode_obfuscator'; +import { createInterface } from 'readline'; + +let isShouldSourceMap: boolean = true; export class SourceMapGenerator { private static instance: SourceMapGenerator | undefined = undefined; @@ -68,19 +70,26 @@ export class SourceMapGenerator { private projectConfig: Object; private sourceMapPath: string; + private sourceMapPathTmp: string; private cacheSourceMapPath: string; private triggerAsync: Object; private triggerEndSignal: Object; private sourceMaps: Object = {}; + private sourceMapKeys: Set = new Set([]); private isNewSourceMap: boolean = true; private keyCache: Map = new Map(); private logger: CommonLogger; + private isFirstAppend: boolean = true; + private isCompileSingle: boolean = false; + private originFd: number; + private tempFd: number; public sourceMapKeyMappingForObf: Map = new Map(); constructor(rollupObject: Object) { this.projectConfig = Object.assign(rollupObject.share.arkProjectConfig, rollupObject.share.projectConfig); this.sourceMapPath = this.getSourceMapSavePath(); + this.sourceMapPathTmp = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON + '.tmp'); this.cacheSourceMapPath = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON); this.triggerAsync = rollupObject.async; this.triggerEndSignal = rollupObject.signal; @@ -94,7 +103,40 @@ export class SourceMapGenerator { // adapt compatibility with hvigor if (!SourceMapGenerator.instance.projectConfig.entryPackageName || !SourceMapGenerator.instance.projectConfig.entryModuleVersion) { - SourceMapGenerator.instance.isNewSourceMap = false; + SourceMapGenerator.instance.isNewSourceMap = false; + } + + if ((SourceMapGenerator.instance.projectConfig.hotReload && + SourceMapGenerator.instance.projectConfig.watchMode !== 'true') || + (SourceMapGenerator.instance.projectConfig.coldReload)) { + isShouldSourceMap = this.projectConfig.isFirstBuild; + } + + SourceMapGenerator.instance.isCompileSingle = SourceMapGenerator.instance.isNewSourceMap && + SourceMapGenerator.instance.projectConfig.singleFileEmit && isShouldSourceMap; + + if (isShouldSourceMap && SourceMapGenerator.instance.isNewSourceMap) { + if (fs.existsSync(SourceMapGenerator.instance.sourceMapPath)) { + fs.unlinkSync(SourceMapGenerator.instance.sourceMapPath); + } + if (fs.existsSync(SourceMapGenerator.instance.sourceMapPathTmp)) { + fs.unlinkSync(SourceMapGenerator.instance.sourceMapPathTmp); + } + + const sourceMapPathDir: string = path.dirname(SourceMapGenerator.instance.sourceMapPath); + if (!fs.existsSync(sourceMapPathDir)) { + fs.mkdirSync(sourceMapPathDir, { recursive: true }); + } + SourceMapGenerator.instance.originFd = fs.openSync(SourceMapGenerator.instance.sourceMapPath, 'a'); + const sourceMapPathTmpDir: string = path.dirname(SourceMapGenerator.instance.sourceMapPathTmp); + if (!fs.existsSync(sourceMapPathTmpDir)) { + fs.mkdirSync(sourceMapPathTmpDir, { recursive: true }); + } + SourceMapGenerator.instance.tempFd = fs.openSync(SourceMapGenerator.instance.sourceMapPathTmp, 'a'); + } + + if (SourceMapGenerator.instance.projectConfig.hotReload) { + isShouldSourceMap = false; } } @@ -195,7 +237,148 @@ export class SourceMapGenerator { path.join(this.projectConfig.cachePath, SOURCEMAPS); } + async *readLines(filePath: string): AsyncGenerator { + const fileStream = fs.createReadStream(filePath, { encoding: 'utf8' }); + const rl = createInterface({ + input: fileStream, + crlfDelay: Infinity + }); + + try { + for await (const line of rl) { + yield line; + } + } finally { + rl.close(); + fileStream.close(); + } + } + + public formatOrigin(key: string, val: object): string { + return ` "${key}": ${JSON.stringify(val, null, 2).replaceAll('\n', '\n ')}`; + } + + public formatTemp(key: string, val: object): string { + return `{"key": "${key}", "val": ${JSON.stringify(val)}}`; + } + + public writeOrigin(content: string): void { + fs.appendFileSync(this.originFd, content, { encoding: 'utf8' }); + } + + public writetTemp(content: string): void { + fs.appendFileSync(this.tempFd, content, { encoding: 'utf8' }); + } + + public closeFd(): void { + if (this.originFd) { + fs.closeSync(this.originFd); + this.originFd = undefined; + } + if (this.tempFd) { + fs.closeSync(this.tempFd); + this.tempFd = undefined; + } + } + + public convertSourceMapToCache(maps: Object): string { + let isFirstLine: boolean = true; + let cacheContent: string = ''; + Object.keys(maps).forEach(key => { + let contentTmp: string = this.formatTemp(key, maps[key]); + if (isFirstLine) { + isFirstLine = false; + cacheContent = contentTmp; + } else { + cacheContent += `\n${contentTmp}`; + } + }); + return cacheContent; + } + + public writeModifiedSourceMapToFile(parentEvent: CompileEvent | undefined): void { + const eventWriteCachedSourceMaps = createAndStartEvent(parentEvent, 'write source maps'); + Object.keys(this.sourceMaps).forEach(key => { + let keyChanged: string = ''; + if (this.sourceMapKeyMappingForObf.has(key)) { + keyChanged = this.sourceMapKeyMappingForObf.get(key); + } else { + keyChanged = key; + } + this.sourceMapKeys.add(keyChanged); + + let contentJson: string = this.formatOrigin(keyChanged, this.sourceMaps[key]); + let contentTmp: string = this.formatTemp(keyChanged, this.sourceMaps[key]); + if (this.isFirstAppend) { + this.isFirstAppend = false; + this.writeOrigin(`{\n${contentJson}`); + this.writetTemp(`${contentTmp}`); + } else { + this.writeOrigin(`,\n${contentJson}`); + this.writetTemp(`\n${contentTmp}`); + } + }); + this.sourceMaps = {}; + this.sourceMapKeyMappingForObf.clear(); + stopEvent(eventWriteCachedSourceMaps); + } + + public async writeUsedAndUnmodifiedSourceMapToFile(parentEvent: CompileEvent | undefined): Promise { + const eventMergeCachedSourceMaps = createAndStartEvent(parentEvent, 'merge cached source maps'); + let cacheSourceMapInfo: Object = this.getCacheSourceMapInfo(); + if (!cacheSourceMapInfo.exist) { + if (!this.isFirstAppend) { + this.writeOrigin('\n}'); + } + this.closeFd(); + fs.renameSync(this.sourceMapPathTmp, this.cacheSourceMapPath); + stopEvent(eventMergeCachedSourceMaps); + return; + } + + await (async (): Promise => { + let compileFileList: Set = this.getCompileFileList(); + for await (const line of this.readLines(cacheSourceMapInfo.path)) { + if (line.trim() === '') { + continue; + } + let smObj: Object = JSON.parse(line.trim()); + if (!compileFileList.has(smObj.key) || this.sourceMapKeys.has(smObj.key)) { + // skip unuse or uncompile in cache + continue; + } + this.writeOrigin(`,\n${this.formatOrigin(smObj.key, smObj.val)}`); + this.writetTemp(`\n${this.formatTemp(smObj.key, smObj.val)}`); + } + if (!this.isFirstAppend) { + this.writeOrigin('\n}'); + } + this.closeFd(); + fs.unlinkSync(this.cacheSourceMapPath); + fs.renameSync(this.sourceMapPathTmp, this.cacheSourceMapPath); + })(); + stopEvent(eventMergeCachedSourceMaps); + } + + public buildModuleSourceMapInfoSingle(parentEvent: CompileEvent | undefined): void { + if (!this.isCompileSingle) { + return; + } + if (Object.keys(this.sourceMaps).length === 0) { + return; + } + this.writeModifiedSourceMapToFile(parentEvent); + } + public buildModuleSourceMapInfo(parentEvent: CompileEvent | undefined): void { + if (this.isCompileSingle) { + this.writeUsedAndUnmodifiedSourceMapToFile(parentEvent); + } else { + this.buildModuleSourceMapInfoAll(parentEvent); + } + } + + public buildModuleSourceMapInfoAll(parentEvent: CompileEvent | undefined): void { if (this.projectConfig.widgetCompile) { return; } @@ -215,6 +398,13 @@ export class SourceMapGenerator { } }); } + + if (this.isNewSourceMap) { + this.writeModifiedSourceMapToFile(parentEvent); + this.writeUsedAndUnmodifiedSourceMapToFile(parentEvent); + return; + } + const updateSourceRecordInfo = MemoryMonitor.recordStage(MemoryDefine.UPDATE_SOURCE_MAPS); const cacheSourceMapObject: Object = this.updateCachedSourceMaps(); MemoryMonitor.stopRecordStage(updateSourceRecordInfo); @@ -239,57 +429,52 @@ export class SourceMapGenerator { }); } + public isEmptyFile(filePath: string): boolean { + const stats = fs.statSync(filePath); + return stats.size === 0; + } + + public getCacheSourceMapInfo(): Object { + let existCacheSourceMap: boolean = false; + let cacheSourceMapPath: string = ''; + let cacheSourceMapPathTmp: string = ''; + /** + * bytecode obfuscation requires that the input sourceMap must be unobfuscated, + * the sourceMap will be saved in the cache directory before the first bytecode obfuscation, + * and it will as the input for merging sourceMap during incremental compilation. + */ + if (BytecodeObfuscator.enable) { + cacheSourceMapPathTmp = BytecodeObfuscator.getInstance().getBackupSourceMapPath(); + if (fs.existsSync(cacheSourceMapPathTmp) && !this.isEmptyFile(cacheSourceMapPathTmp)) { + existCacheSourceMap = true; + cacheSourceMapPath = cacheSourceMapPathTmp; + } + } + + cacheSourceMapPathTmp = this.cacheSourceMapPath; + if (!existCacheSourceMap && fs.existsSync(cacheSourceMapPathTmp) && !this.isEmptyFile(cacheSourceMapPathTmp)) { + existCacheSourceMap = true; + cacheSourceMapPath = cacheSourceMapPathTmp; + } + + return { exist: existCacheSourceMap, path: cacheSourceMapPath }; + } + //update cache sourcemap object public updateCachedSourceMaps(): Object { if (!this.isNewSourceMap) { this.modifySourceMapKeyToCachePath(this.sourceMaps); } - let cacheSourceMapObject: Object; - if (!fs.existsSync(this.cacheSourceMapPath)) { + let cacheSourceMapObject: Object = null; + let cacheSourceMapInfo: Object = this.getCacheSourceMapInfo(); + if (!cacheSourceMapInfo.exist) { cacheSourceMapObject = this.sourceMaps; } else { - /** - * bytecode obfuscation requires that the input sourceMap must be unobfuscated, - * the sourceMap will be saved in the cache directory before the first bytecode obfuscation, - * and it will as the input for merging sourceMap during incremental compilation. - */ - if (BytecodeObfuscator.enable && fs.existsSync(BytecodeObfuscator.getInstance().getBackupSourceMapPath())) { - cacheSourceMapObject = JSON.parse(fs.readFileSync(BytecodeObfuscator.getInstance().getBackupSourceMapPath()).toString()); - } else { - cacheSourceMapObject = JSON.parse(fs.readFileSync(this.cacheSourceMapPath).toString()); - } + cacheSourceMapObject = JSON.parse(fs.readFileSync(cacheSourceMapInfo.path).toString().trim()); // remove unused source files's sourceMap let unusedFiles = []; - let compileFileList: Set = new Set(); - for (let moduleId of SourceMapGenerator.rollupObject.getModuleIds()) { - // exclude .dts|.d.ets file - if (isCommonJsPluginVirtualFile(moduleId) || !isCurrentProjectFiles(moduleId, this.projectConfig)) { - continue; - } - - if (this.isNewSourceMap) { - const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); - if (enableObfuscateFileName(isPackageModules, this.projectConfig)){ - compileFileList.add(this.genKey(moduleId, true)); - } else { - compileFileList.add(this.genKey(moduleId)); - } - continue; - } - - // adapt compatibilty with hvigor - const projectRootPath = getProjectRootPath(moduleId, this.projectConfig, this.projectConfig?.rootPathSet); - let cacheModuleId = this.getIntermediateModuleId(toUnixPath(moduleId)) - .replace(toUnixPath(projectRootPath), toUnixPath(this.projectConfig.cachePath)); - - const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); - if (enableObfuscateFileName(isPackageModules, this.projectConfig)) { - compileFileList.add(mangleFilePath(cacheModuleId)); - } else { - compileFileList.add(cacheModuleId); - } - } + let compileFileList: Set = this.getCompileFileList(); Object.keys(cacheSourceMapObject).forEach(key => { let newkeyOrOldCachePath = key; @@ -316,6 +501,39 @@ export class SourceMapGenerator { return cacheSourceMapObject; } + public getCompileFileList(): Set { + let compileFileList: Set = new Set(); + for (let moduleId of SourceMapGenerator.rollupObject.getModuleIds()) { + // exclude .dts|.d.ets file + if (isCommonJsPluginVirtualFile(moduleId) || !isCurrentProjectFiles(moduleId, this.projectConfig)) { + continue; + } + + if (this.isNewSourceMap) { + const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); + if (enableObfuscateFileName(isPackageModules, this.projectConfig)) { + compileFileList.add(this.genKey(moduleId, true)); + } else { + compileFileList.add(this.genKey(moduleId)); + } + continue; + } + + // adapt compatibilty with hvigor + const projectRootPath = getProjectRootPath(moduleId, this.projectConfig, this.projectConfig?.rootPathSet); + let cacheModuleId = this.getIntermediateModuleId(toUnixPath(moduleId)) + .replace(toUnixPath(projectRootPath), toUnixPath(this.projectConfig.cachePath)); + + const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); + if (enableObfuscateFileName(isPackageModules, this.projectConfig)) { + compileFileList.add(mangleFilePath(cacheModuleId)); + } else { + compileFileList.add(cacheModuleId); + } + } + return compileFileList; + } + public getSourceMaps(): Object { return this.sourceMaps; } @@ -410,6 +628,7 @@ export class SourceMapGenerator { public static cleanSourceMapObject(): void { if (this.instance) { + this.instance.closeFd(); this.instance.keyCache.clear(); this.instance.sourceMaps = undefined; this.instance = undefined; diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 9c074224d..97bd16399 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -347,6 +347,7 @@ export class ModuleSourceFile { } const eventWriteSourceFile = createAndStartEvent(parentEvent, 'write source file'); await moduleSourceFile.writeSourceFile(eventWriteSourceFile); + SourceMapGenerator.getInstance().buildModuleSourceMapInfoSingle(eventWriteSourceFile); stopEvent(eventWriteSourceFile); } } diff --git a/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts b/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts index dbc7a1b15..c7a1964bb 100644 --- a/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts +++ b/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts @@ -260,14 +260,23 @@ class ModuleModeMock extends ModuleMode { } checkModuleSourceMapInfoMock(): boolean { - const readSourceMap = fs.readFileSync(this.sourceMapPath, 'utf-8'); - const readCacheSourceMap = fs.readFileSync(this.cacheSourceMapPath, 'utf-8'); + const readSourceMap: string = fs.readFileSync(this.sourceMapPath, 'utf-8'); + const readCacheSourceMap: string = fs.readFileSync(this.cacheSourceMapPath, 'utf-8'); if (readSourceMap.length == 0 && readCacheSourceMap.length == 0) { return true; - } else if (readSourceMap === readCacheSourceMap) { - return true; } else { - return false; + const sourcemapObj: Object = JSON.parse(readSourceMap); + const cacheArrayStr: string = "[" + readCacheSourceMap.replaceAll("\n", ",") + "]"; + const cacheArray: Array = JSON.parse(cacheArrayStr); + for (const item of cacheArray) { + if (!sourcemapObj.hasOwnProperty(item.key)) { + return false; + } + if (JSON.stringify(sourcemapObj[item.key]) != JSON.stringify(item.val)) { + return false; + } + } + return true; } } diff --git a/compiler/test/ark_compiler_ut/module/module_mode.test.ts b/compiler/test/ark_compiler_ut/module/module_mode.test.ts index 42364286d..42a075b89 100644 --- a/compiler/test/ark_compiler_ut/module/module_mode.test.ts +++ b/compiler/test/ark_compiler_ut/module/module_mode.test.ts @@ -1416,6 +1416,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1440,6 +1441,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1462,6 +1464,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1486,6 +1489,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1508,6 +1512,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1532,6 +1537,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1554,6 +1560,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1578,6 +1585,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); -- Gitee From 6a11cb8afbfbe8f02a3973d1bcd6867375792b63 Mon Sep 17 00:00:00 2001 From: yangbo_404 Date: Wed, 21 May 2025 10:02:34 +0800 Subject: [PATCH 064/140] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B7=A8=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E5=91=8A=E8=AD=A6=E6=A0=A1=E9=AA=8C=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangbo_404 --- compiler/main.js | 2 ++ compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts | 3 ++- compiler/src/fast_build/system_api/api_check_utils.ts | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/main.js b/compiler/main.js index bda903037..fe52a7825 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -111,6 +111,7 @@ function initProjectConfig(projectConfig) { projectConfig.updateVersionInfo = undefined; projectConfig.allowEmptyBundleName = false; projectConfig.uiTransformOptimization = false; + projectConfig.ignoreCrossplatformCheck = false; } function initProjectPathConfig(projectConfig) { @@ -1124,6 +1125,7 @@ function resetProjectConfig() { projectConfig.removeChangedFileListInSdk = false; projectConfig.allowEmptyBundleName = false; projectConfig.uiTransformOptimization = false; + projectConfig.ignoreCrossplatformCheck = false; const props = ['projectPath', 'buildPath', 'aceModuleBuild', 'manifestFilePath', 'aceProfilePath', 'aceModuleJsonPath', 'aceSuperVisualPath', 'hashProjectPath', 'aceBuildJson', 'cachePath', 'aceSoPath', 'localPropertiesPath', 'projectProfilePath', 'isPreview', 'compileMode', 'runtimeOS', diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts index b58ff1fb6..24e3276e7 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts @@ -97,7 +97,8 @@ export function etsChecker() { deviceTypesMessage: projectConfig.deviceTypesMessage, compileSdkVersion: projectConfig.compileSdkVersion, compatibleSdkVersion: projectConfig.compatibleSdkVersion, - runtimeOS: projectConfig.runtimeOS + runtimeOS: projectConfig.runtimeOS, + ignoreCrossplatformCheck: projectConfig.ignoreCrossplatformCheck }); const logger = this.share.getLogger('etsChecker'); const rootFileNames: string[] = []; diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index b9ac28090..3d8c49a80 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -366,8 +366,10 @@ export function getJsDocNodeCheckConfig(fileName: string, sourceFileName: string } if (projectConfig.isCrossplatform) { needCheckResult = true; + const logType: ts.DiagnosticCategory = !projectConfig.ignoreCrossplatformCheck ? ts.DiagnosticCategory.Error : + ts.DiagnosticCategory.Warning; checkConfigArray.push(getJsDocNodeCheckConfigItem([CROSSPLATFORM_TAG_CHECK_NAME], CROSSPLATFORM_TAG_CHECK_ERROER, - false, ts.DiagnosticCategory.Error, '', true)); + false, logType, '', true)); } if (process.env.compileMode === STAGE_COMPILE_MODE) { needCheckResult = true; -- Gitee From e2dba04856e007c3e93feb5605c309954c6e6fb3 Mon Sep 17 00:00:00 2001 From: oh_ci Date: Wed, 21 May 2025 12:21:27 +0000 Subject: [PATCH 065/140] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20?= =?UTF-8?q?!4714=20:=20Optimize=20redundant=20checker'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets_ui/rollup-plugin-ets-typescript.ts | 6 +-- .../fast_build/system_api/api_check_utils.ts | 5 +- compiler/src/process_component_build.ts | 34 ++++-------- compiler/src/process_component_member.ts | 26 +++------- compiler/src/process_custom_component.ts | 8 ++- compiler/src/process_import.ts | 11 ++-- compiler/src/utils.ts | 52 ------------------- compiler/src/validate_ui_syntax.ts | 23 +++----- 8 files changed, 37 insertions(+), 128 deletions(-) diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index 847580a73..5658f3b98 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -39,8 +39,7 @@ import { resetUtils, getResolveModules, toUnixPath, - getBelongModuleInfo, - CurrentProcessFile + getBelongModuleInfo } from '../../utils'; import { preprocessExtend, @@ -376,7 +375,6 @@ function getArkoalaTsProgram(program: ts.Program): ts.Program { } async function transform(code: string, id: string) { - CurrentProcessFile.setIsProcessingFileETS(id); const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsTransform', 'transform'); if (!filter(id)) { return null; @@ -507,7 +505,7 @@ async function transform(code: string, id: string) { } else { const uiKitrecordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_UI_KIT); const eventTransformNodes = createAndStartEvent(eventTsProgramEmit, 'transformNodes'); - const emitResolver: ts.EmitResolver | undefined = CurrentProcessFile.getChecker()?.getEmitResolver(outFile(tsProgram.getCompilerOptions()) ? + const emitResolver: ts.EmitResolver = globalProgram.checker.getEmitResolver(outFile(tsProgram.getCompilerOptions()) ? undefined : targetSourceFile, undefined); metaInfo.checker = tsProgram.getTypeChecker(); transformResult = ts.transformNodes(emitResolver, tsProgram.getEmitHost?.(), ts.factory, diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index 14d9ef9ef..b9ac28090 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -29,8 +29,7 @@ import { import { LogType, LogInfo, - IFileLog, - CurrentProcessFile + IFileLog } from '../../utils'; import { type ResolveModuleInfo } from '../../ets_checker'; import { @@ -226,7 +225,7 @@ export function checkTypeReference(node: ts.TypeReferenceNode, transformLog: IFi const fileName: string = transformLog.sourceFile.fileName; const currentTypeName: string = node.getText(); if (/(?= 11 && - ts.isPropertyAccessExpression(node) && - node.name && ts.isIdentifier(node.name) && - node.name.escapedText.toString() === WRAPBUILDER_BUILDERPROP - )) { - return false; - } - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - if (checker) { - const type: ts.Type | ts.Type[] = - findNonNullType(checker.getTypeAtLocation(node.expression)); - if (Array.isArray(type)) { - return false; - } - return type.symbol && type.symbol.escapedName === WRAPPEDBUILDER_CLASS; + const typeAtLocation = globalProgram.checker.getTypeAtLocation(node.expression); + if (projectConfig.minAPIVersion >= 11 && ts.isPropertyAccessExpression(node) && + node.name && ts.isIdentifier(node.name) && node.name.escapedText.toString() === WRAPBUILDER_BUILDERPROP && + typeAtLocation && typeAtLocation.symbol && typeAtLocation.symbol.escapedName === WRAPPEDBUILDER_CLASS) { + return true; } return false; } @@ -2926,9 +2913,8 @@ function isRegularAttrNode(node: ts.Expression): boolean { if (enumCollection.has(node.expression.escapedText.toString())) { return true; } - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - if (checker) { - const type: ts.Type = checker.getTypeAtLocation(node); + if (globalProgram.checker) { + const type: ts.Type = globalProgram.checker.getTypeAtLocation(node); /* Enum */ if (type.flags & (32 | 1024)) { return true; @@ -3431,7 +3417,7 @@ function isWrappedBuilderExpression(node: ts.ExpressionStatement): boolean { function judgeBuilderType(node: ts.ExpressionStatement): boolean { let checker: ts.TypeChecker; if (globalProgram.program) { - checker = CurrentProcessFile.getChecker(globalProgram.program); + checker = globalProgram.program.getTypeChecker(); } else if (globalProgram.watchProgram) { checker = globalProgram.watchProgram.getCurrentProgram().getProgram().getTypeChecker(); } diff --git a/compiler/src/process_component_member.ts b/compiler/src/process_component_member.ts index 1935519bc..9bd793f75 100644 --- a/compiler/src/process_component_member.ts +++ b/compiler/src/process_component_member.ts @@ -95,9 +95,7 @@ import { LogType, LogInfo, componentInfo, - storedFileInfo, - findNonNullType, - CurrentProcessFile + storedFileInfo } from './utils'; import { createReference, @@ -981,9 +979,8 @@ function manageLocalStorageComponents(node: ts.CallExpression, argumentsArray: t } export function isLocalStorageParameter(node: ts.CallExpression): boolean { - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - const resolvedSignature = checker?.getResolvedSignature ? - checker.getResolvedSignature(node) : undefined; + const resolvedSignature = globalProgram.checker?.getResolvedSignature ? + globalProgram.checker.getResolvedSignature(node) : undefined; return resolvedSignature && resolvedSignature.parameters && resolvedSignature.parameters.length === 1 && resolvedSignature.parameters[0].escapedName === '##storage'; } @@ -1104,11 +1101,11 @@ export function isSimpleType(typeNode: ts.TypeNode, program: ts.Program, log?: L typeNode = typeNode || ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword); let checker: ts.TypeChecker; if (globalProgram.program) { - checker = CurrentProcessFile.getChecker(globalProgram.program); + checker = globalProgram.program.getTypeChecker(); } else if (globalProgram.watchProgram) { checker = globalProgram.watchProgram.getCurrentProgram().getProgram().getTypeChecker(); } else if (program) { - checker = CurrentProcessFile.getChecker(program); + checker = program.getTypeChecker(); } return getDeclarationType(typeNode, checker, log); } @@ -1378,18 +1375,11 @@ function updateSynchedPropertyNesedObjectPU(nameIdentifier: ts.Identifier, // check @ObjectLink type Non basic types and @Observedv2. function checkObjectLinkType(typeNode: ts.TypeNode): boolean { - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - if (checker) { - const type: ts.Type | ts.Type[] = findNonNullType(checker.getTypeFromTypeNode(typeNode)); + if (globalProgram.checker) { + const type: ts.Type = globalProgram.checker.getTypeFromTypeNode(typeNode); const isPropertyDeclaration: boolean = typeNode.parent && ts.isPropertyDeclaration(typeNode.parent); if (isPropertyDeclaration) { - if (Array.isArray(type)) { - let res = true; - for (let i = 0; i < type.length; i++) { - res = res && checkTypes(type[i]); - } - return res; - } else if (type.types && type.types.length) { + if (type.types && type.types.length) { return checkTypes(type); } else { return !(isObservedV2(type) || isAllowedTypeForBasic(type.flags) || isFunctionType(type)); diff --git a/compiler/src/process_custom_component.ts b/compiler/src/process_custom_component.ts index 7aaec808e..62d7629af 100644 --- a/compiler/src/process_custom_component.ts +++ b/compiler/src/process_custom_component.ts @@ -100,8 +100,7 @@ import { LogType, LogInfo, componentInfo, - storedFileInfo, - CurrentProcessFile + storedFileInfo } from './utils'; import { bindComponentAttr, @@ -486,10 +485,9 @@ function isForbiddenTypeToComponentV1(type: ts.Type): boolean { function isForbiddenAssignToComponentV2(item: ts.PropertyAssignment, itemName: string, info: ChildAndParentComponentInfo): boolean { - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); if (!info.parentStructInfo.isComponentV2 && info.updatePropsDecoratorsV2.includes(itemName) && - isObervedProperty(item.initializer, info) && checker) { - const type: ts.Type = checker.getTypeAtLocation(item.initializer); + isObervedProperty(item.initializer, info) && globalProgram.strictChecker) { + const type: ts.Type = globalProgram.strictChecker.getTypeAtLocation(item.initializer); return !(isAllowedTypeToComponentV2(type) || isForbiddenTypeToComponentV1(type) || !(isObservedV2(type) || isFunctionType(type))); } return false; diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index 2eac04c54..bdfbb6886 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -63,7 +63,6 @@ import { regularStaticCollection } from './validate_ui_syntax'; import { - CurrentProcessFile, getExtensionIfUnfullySpecifiedFilepath, hasDecorator, LogInfo, @@ -790,10 +789,9 @@ export function processImportModule(node: ts.ImportDeclaration, pageFile: string function getDefinedNode(importSymbol: ts.Symbol, realSymbol: ts.Symbol, originNode: ts.Node, usedNode: ts.Identifier, pageInfo: PageInfo, share: object = null): void { - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - importSymbol = checker?.getSymbolAtLocation(usedNode); + importSymbol = globalProgram.checker.getSymbolAtLocation(usedNode); if (importSymbol) { - realSymbol = checker?.getAliasedSymbol(importSymbol); + realSymbol = globalProgram.checker.getAliasedSymbol(importSymbol); } else { realSymbol = null; } @@ -819,7 +817,7 @@ function getIntegrationNodeInfo(originNode: ts.Node, usedNode: ts.Identifier, ex pageInfo: PageInfo, share: object = null): void { for (const usedSymbol of exportsMap) { try { - originNode = CurrentProcessFile.getChecker()?.getAliasedSymbol(usedSymbol[1]).declarations[0]; + originNode = globalProgram.checker.getAliasedSymbol(usedSymbol[1]).declarations[0]; } catch (e) { if (usedSymbol[1] && usedSymbol[1].declarations) { for (let i = 0; i < usedSymbol[1].declarations.length; i++) { @@ -836,8 +834,7 @@ function getIntegrationNodeInfo(originNode: ts.Node, usedNode: ts.Identifier, ex function exportAllManage(originNode: ts.Node, usedNode: ts.Identifier, pageInfo: PageInfo, share: object = null): void { let exportOriginNode: ts.Node; if (!originNode.exportClause && originNode.moduleSpecifier && ts.isStringLiteral(originNode.moduleSpecifier)) { - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - const exportSymbol: ts.Symbol = checker?.getSymbolAtLocation(originNode.moduleSpecifier); + const exportSymbol: ts.Symbol = globalProgram.checker.getSymbolAtLocation(originNode.moduleSpecifier); if (exportSymbol && exportSymbol.declarations) { exportOriginNode = exportSymbol.declarations[0]; } else { diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 7b0a287a9..1cf080059 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -1332,56 +1332,4 @@ export function getBelongModuleInfo(filePath: string, modulePathMap: Object, pro moduleName: '', belongModulePath: projectRootPath }; -} - -/** - * Eliminate null in type - * - * @param { ts.Type } type - * @returns { ts.Type | ts.Type[] } - */ -export function findNonNullType(type: ts.Type): ts.Type | ts.Type[] { - if (!type.isUnion() || !(type.types && type.types.length)) { - return type; - } - const filteredTypes: ts.Type[] = type.types.filter((t) => { - return t.flags && !(t.flags & ts.TypeFlags.Nullable); - }); - if (filteredTypes.length === 1) { - return filteredTypes[0]; - } - return filteredTypes; -} - -/** - * Manage File type and checker - */ -export class CurrentProcessFile { - private static isProcessingFileETS: boolean = false; - - /** - * Get checker according to file type - * - * @param { ts.Program? } program - * @returns { ts.TypeChecker | undefined } - */ - static getChecker(program?: ts.Program): ts.TypeChecker | undefined { - if (CurrentProcessFile.isProcessingFileETS) { - return (program ?? globalProgram.program)?.getLinterTypeChecker(); - } - return (program ?? globalProgram.program)?.getTypeChecker(); - } - - /** - * Record current file type - * - * @param { string } id - */ - static setIsProcessingFileETS(id: string): void { - CurrentProcessFile.isProcessingFileETS = CurrentProcessFile.isETSFile(id); - } - - private static isETSFile(id: string): boolean { - return !!(path.extname(id)?.endsWith('ets')); - } } \ No newline at end of file diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 0bbca9308..10bc7a70b 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -91,8 +91,7 @@ import { addLog, hasDecorator, storedFileInfo, - ExtendResult, - CurrentProcessFile + ExtendResult } from './utils'; import { globalProgram, projectConfig, abilityPagesFullPath } from '../main'; import { @@ -518,8 +517,7 @@ function validatePropertyInStruct(structContext: boolean, decoratorNode: ts.Iden } const classResult: ClassDecoratorResult = new ClassDecoratorResult(); const propertyNode: ts.PropertyDeclaration = getPropertyNodeByDecorator(decoratorNode); - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - if (propertyNode && propertyNode.type && checker) { + if (propertyNode && propertyNode.type && globalProgram.checker) { validatePropertyType(propertyNode.type, classResult); } let message: string; @@ -549,8 +547,7 @@ function validatePropertyType(node: ts.TypeNode, classResult: ClassDecoratorResu }); } if (ts.isTypeReferenceNode(node) && node.typeName) { - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - const typeNode: ts.Type = checker?.getTypeAtLocation(node.typeName); + const typeNode: ts.Type = globalProgram.checker.getTypeAtLocation(node.typeName); parsePropertyType(typeNode, classResult); } } @@ -777,8 +774,7 @@ const classMemberDecorators: string[] = [CLASS_TRACK_DECORATOR, CLASS_MIN_TRACK_ function validTypeCallback(node: ts.Identifier): boolean { let isSdkPath: boolean = true; - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - if (checker && process.env.compileTool === 'rollup') { + if (globalProgram.checker && process.env.compileTool === 'rollup') { const symbolObj: ts.Symbol = getSymbolIfAliased(node); const fileName: string = symbolObj?.valueDeclaration?.getSourceFile()?.fileName; isSdkPath = /@ohos.arkui.*/.test(fileName); @@ -900,8 +896,7 @@ function validateMutilObserved(node: ts.ClassDeclaration, classResult: ClassDeco function parseInheritClass(node: ts.ClassDeclaration, childClassResult: ClassDecoratorResult, sourceFileNode: ts.SourceFile, log: LogInfo[]): void { - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - if (checker && process.env.compileTool === 'rollup' && node.heritageClauses) { + if (globalProgram.checker && process.env.compileTool === 'rollup' && node.heritageClauses) { for (const heritageClause of node.heritageClauses) { if (heritageClause.token === ts.SyntaxKind.ExtendsKeyword && heritageClause.types && heritageClause.types.length) { @@ -932,18 +927,16 @@ function getClassNode(parentType: ts.Node, childClassResult: ClassDecoratorResul function parseShorthandPropertyForClass(node: ts.ShorthandPropertyAssignment, childClassResult: ClassDecoratorResult, childClass: ts.ClassDeclaration, sourceFileNode: ts.SourceFile, log: LogInfo[]): void { - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - const shortSymbol: ts.Symbol = checker?.getShorthandAssignmentValueSymbol(node); + const shortSymbol: ts.Symbol = globalProgram.checker.getShorthandAssignmentValueSymbol(node); if (shortSymbol && shortSymbol.valueDeclaration && ts.isClassDeclaration(shortSymbol.valueDeclaration)) { validateInheritClassDecorator(shortSymbol.valueDeclaration, childClassResult, childClass, sourceFileNode, log); } } export function getSymbolIfAliased(node: ts.Node): ts.Symbol { - const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); - const symbol: ts.Symbol = checker?.getSymbolAtLocation(node); + const symbol: ts.Symbol = globalProgram.checker.getSymbolAtLocation(node); if (symbol && (symbol.getFlags() & ts.SymbolFlags.Alias) !== 0) { - return checker?.getAliasedSymbol(symbol); + return globalProgram.checker.getAliasedSymbol(symbol); } return symbol; } -- Gitee From d20d1f9655c32eec26456b8e9ae1e354a692d8f2 Mon Sep 17 00:00:00 2001 From: Yenan Date: Wed, 21 May 2025 20:24:29 +0800 Subject: [PATCH 066/140] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=93=BE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=97=AD=E6=BA=90=E7=BB=84=E4=BB=B6navigation?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/src/component_map.ts | 2 +- compiler/src/external_component_map.ts | 6 ++-- compiler/src/pre_define.ts | 4 ++- compiler/src/process_component_build.ts | 37 +++++++++++++++++-------- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/compiler/src/component_map.ts b/compiler/src/component_map.ts index 5e577f4a8..df454e9f7 100644 --- a/compiler/src/component_map.ts +++ b/compiler/src/component_map.ts @@ -25,7 +25,7 @@ const FORM_COMPONENTS = 'form_components'; export const COMPONENT_MAP: any = {}; export const FORM_MAP: any = {}; -let EXTERNAL_COMPONENT_MAP: undefined | object = {}; +let EXTERNAL_COMPONENT_MAP: object = {}; export let EXT_WHITE_LIST: Array = []; export let COMMON_ATTRS: Set = new Set([]); diff --git a/compiler/src/external_component_map.ts b/compiler/src/external_component_map.ts index 51b94a2e4..89b4f0924 100644 --- a/compiler/src/external_component_map.ts +++ b/compiler/src/external_component_map.ts @@ -24,8 +24,8 @@ export let WHITELISTNEW: Array = []; const COMPONENT_PATH = './build-tools/ets-loader/components'; -export function readExternalComponents(): object | undefined { - const EXT_COMPONENT_MAP: object | undefined = {}; +export function readExternalComponents(): object { + const EXT_COMPONENT_MAP: object = {}; const componentPaths: string[] | undefined = getExternalComponentPaths(); if (!componentPaths) { return EXT_COMPONENT_MAP; @@ -45,7 +45,7 @@ export function readExternalComponents(): object | undefined { delete json.name; EXT_COMPONENT_MAP[compName] = json; } else { - WHITELISTNEW = Array.from(new Set(json.extWhiteList)); + WHITELISTNEW = Array.from(new Set(json.extWhiteList ? json.extWhiteList : [])); } } }); diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index b8881db67..7b041ad59 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -603,10 +603,12 @@ export const CARD_ENABLE_COMPONENTS: Set = new Set([ ]); export const TabContentAndNavDestination: Set = new Set(['TabContent', 'NavDestination']); -if (EXT_WHITE_LIST.length && EXT_WHITE_LIST[1]) { +if (EXT_WHITE_LIST.length) { for (const compName of EXT_WHITE_LIST) { CREATE_ROUTER_COMPONENT_COLLECT.add(compName); } +} +if (EXT_WHITE_LIST.length >= 2) { TabContentAndNavDestination.add(EXT_WHITE_LIST[1]); } export const CARD_LOG_TYPE_DECORATORS = 1; diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 42cbb11f5..7988c80bc 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -160,7 +160,8 @@ import { SPECIFIC_PARENT_COMPONENT, STYLES_ATTRIBUTE, INNER_CUSTOM_LOCALBUILDER_METHOD, - COMMON_ATTRS + COMMON_ATTRS, + EXT_WHITE_LIST } from './component_map'; import { componentCollection, @@ -1498,15 +1499,18 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. false, parent, undefined, isGlobalBuilder, false, builderParamsResult, isInRepeatTemplate); const navDestinationCallback: (ts.ArrowFunction | ts.NewExpression | ts.ObjectLiteralExpression)[] = [ts.factory.createArrowFunction(undefined, undefined, [], undefined, - ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), - ts.factory.createBlock([...newTabContentChildren], true))]; + ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), + ts.factory.createBlock([...newTabContentChildren], true))]; if (name === NAV_DESTINATION) { navDestinationCallback.push(...navigationCreateParam(NAV_DESTINATION, COMPONENT_CREATE_FUNCTION, undefined, true)); } + if (equalToHiddenNavDes(name)) { + navDestinationCallback.push(...navigationCreateParam(EXT_WHITE_LIST[1], COMPONENT_CREATE_FUNCTION, undefined, true)); + } tabContentCreation = ts.factory.createExpressionStatement( ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression( ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), - undefined, navDestinationCallback)); + undefined, navDestinationCallback)); bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); processInnerCompStatements( innerCompStatements, [tabContentCreation, ...tabAttrs], node, isGlobalBuilder, false, @@ -1516,7 +1520,8 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. tabContentCreation = ts.factory.createExpressionStatement(ts.factory.createCallExpression( ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, - name === NAV_DESTINATION ? navigationCreateParam(NAV_DESTINATION, COMPONENT_CREATE_FUNCTION) : [])); + name === NAV_DESTINATION ? navigationCreateParam(NAV_DESTINATION, COMPONENT_CREATE_FUNCTION) : + (equalToHiddenNavDes(name) ? navigationCreateParam(EXT_WHITE_LIST[1], COMPONENT_CREATE_FUNCTION) : []))); bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); processInnerCompStatements( innerCompStatements, [tabContentCreation, ...tabAttrs], node, isGlobalBuilder, false, @@ -3595,7 +3600,8 @@ export function createFunction(node: ts.Identifier, attrNode: ts.Identifier, if (checkCreateArgumentBuilder(node, attrNode)) { argumentsArr = transformBuilder(argumentsArr); } - if (compName === NAVIGATION && type === COMPONENT_CREATE_FUNCTION && partialUpdateConfig.partialUpdateMode) { + if (((compName === NAVIGATION) || equalToHiddenNav(compName)) && + type === COMPONENT_CREATE_FUNCTION && partialUpdateConfig.partialUpdateMode) { // @ts-ignore argumentsArr = navigationCreateParam(compName, type, argumentsArr); } @@ -3635,12 +3641,13 @@ function navigationCreateParam(compName: string, type: string, // @ts-ignore navigationOrNavDestination.push(...argumentsArr); } else if (partialUpdateMode && isCreate) { - if (compName === NAVIGATION) { + if ((compName === NAVIGATION) || equalToHiddenNav(compName)) { isHaveParam = false; navigationOrNavDestination.push(ts.factory.createNewExpression( ts.factory.createIdentifier(NAV_PATH_STACK), undefined, [] )); - } else if (compName === NAV_DESTINATION && !isNavDestinationCallback) { + } else if (((compName === NAV_DESTINATION) || equalToHiddenNavDes(compName)) && + !isNavDestinationCallback) { navigationOrNavDestination.push(ts.factory.createArrowFunction( undefined, undefined, [], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), @@ -3649,7 +3656,7 @@ function navigationCreateParam(compName: string, type: string, false ) )); - } + } } if (CREATE_ROUTER_COMPONENT_COLLECT.has(compName) && isCreate && partialUpdateMode) { navigationOrNavDestination.push(ts.factory.createObjectLiteralExpression( @@ -3672,8 +3679,8 @@ function navigationOrNavDestinationCreateContent(compName: string, isHaveParam: projectConfig.compileHar ? '' : path.relative(projectConfig.projectRootPath || '', resourceFileName).replace(/\\/g, '/').replace(/\.ets$/, '') ) - )); - if (compName === NAVIGATION) { + )); + if ((compName === NAVIGATION) || equalToHiddenNav(compName)) { navigationOrNavDestinationContent.push(ts.factory.createPropertyAssignment( ts.factory.createIdentifier(IS_USER_CREATE_STACK), isHaveParam ? ts.factory.createTrue() : ts.factory.createFalse() @@ -3722,3 +3729,11 @@ function checkNonspecificParents(node: ts.ExpressionStatement, name: string, sav } } } + +function equalToHiddenNav(componentName: string): boolean { + return (EXT_WHITE_LIST.length >= 2) && (componentName === EXT_WHITE_LIST[0]); +} + +function equalToHiddenNavDes(componentName: string): boolean { + return (EXT_WHITE_LIST.length >= 2) && (componentName === EXT_WHITE_LIST[1]); +} \ No newline at end of file -- Gitee From 3a33deec24dd6a8d4d03018c974dbf2574495a0e Mon Sep 17 00:00:00 2001 From: oh_ci Date: Thu, 22 May 2025 06:25:40 +0000 Subject: [PATCH 067/140] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20?= =?UTF-8?q?!4729=20:=20Write=20sourcemap=20by=20line'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ark_compiler/bytecode_obfuscator.ts | 7 +- .../ark_compiler/generate_module_abc.ts | 4 +- .../ark_compiler/generate_sourcemap.ts | 307 +++--------------- .../ark_compiler/module/module_source_file.ts | 1 - .../mock/class_mock/module_mode_mock.ts | 19 +- .../module/module_mode.test.ts | 8 - 6 files changed, 54 insertions(+), 292 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts index 7b9cc6fb2..096a58c63 100644 --- a/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts +++ b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts @@ -64,7 +64,6 @@ import { FileKeepInfo, FileReservedInfo } from 'arkguard/lib/utils/ProjectCollections'; -import { SourceMapGenerator } from './generate_sourcemap'; const FILE_NAME_CACHE: string = 'FileNameCache'; const OBF_NAME_MAP: string = 'ObfNameMap'; @@ -309,7 +308,7 @@ export class BytecodeObfuscator { const nameMapping: Map = generateMapping(nameCache); const sourceMapUpdated: Object = updateSourceMap(sourceMap, nameMapping); fs.writeFileSync(sourceMapPath, JSON.stringify(sourceMapUpdated, null, 2)); - fs.writeFileSync(souceMapJsonPath, SourceMapGenerator.getInstance().convertSourceMapToCache(sourceMapUpdated)); + fs.writeFileSync(souceMapJsonPath, JSON.stringify(sourceMapUpdated, null, 2)); const nameCacheUpdated: Object = this.bytecodeObfuscateConfig.obfuscationRules.compact ? nameCache : processNameCache(nameCache, sourceMap); fs.writeFileSync(this.nameCachePath, JSON.stringify(nameCacheUpdated, null, 2)); @@ -376,9 +375,9 @@ export class BytecodeObfuscator { if (rules.enableDecoratorObfuscation) { const reservedNames = this.bytecodeObfuscateConfig.getReservedNames(); structProperties = new Set( - Array.from(structProperties || []).filter(item => reservedNames?.has(item)) + Array.from(structProperties || []).filter(item => reservedNames?.has(item)) ); - } + } const arrayProperties = [ keepSymbol?.propertyNames, diff --git a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts index 1053a7cf9..2df6115ed 100644 --- a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts +++ b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts @@ -47,9 +47,9 @@ export async function generateModuleAbc(error) { await ModuleSourceFile.processModuleSourceFiles(this, hookEventFactory); } if (this.share.projectConfig.compileHar) { + SourceMapGenerator.getInstance().buildModuleSourceMapInfo(hookEventFactory); + // compileHar: compile har of project, which convert .ets to .d.ts and js if (!this.share.projectConfig.byteCodeHar) { - // compileHar: compile har of project, which convert .ets to .d.ts and js - SourceMapGenerator.getInstance().buildModuleSourceMapInfo(hookEventFactory); return; } } diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index c442ef9d8..00ab52a52 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -21,6 +21,7 @@ import { EXTNAME_TS, EXTNAME_MJS, EXTNAME_CJS, + GEN_ABC_PLUGIN_NAME, SOURCEMAPS, SOURCEMAPS_JSON, yellow, @@ -45,7 +46,7 @@ import { } from './common/ob_config_resolver'; import { MemoryMonitor } from '../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../meomry_monitor/memory_define'; -import { +import { ArkTSInternalErrorDescription, ErrorCode } from './error_code'; @@ -60,9 +61,6 @@ import { stopEvent } from '../../performance'; import { BytecodeObfuscator } from './bytecode_obfuscator'; -import { createInterface } from 'readline'; - -let isShouldSourceMap: boolean = true; export class SourceMapGenerator { private static instance: SourceMapGenerator | undefined = undefined; @@ -70,26 +68,19 @@ export class SourceMapGenerator { private projectConfig: Object; private sourceMapPath: string; - private sourceMapPathTmp: string; private cacheSourceMapPath: string; private triggerAsync: Object; private triggerEndSignal: Object; private sourceMaps: Object = {}; - private sourceMapKeys: Set = new Set([]); private isNewSourceMap: boolean = true; private keyCache: Map = new Map(); private logger: CommonLogger; - private isFirstAppend: boolean = true; - private isCompileSingle: boolean = false; - private originFd: number; - private tempFd: number; public sourceMapKeyMappingForObf: Map = new Map(); constructor(rollupObject: Object) { this.projectConfig = Object.assign(rollupObject.share.arkProjectConfig, rollupObject.share.projectConfig); this.sourceMapPath = this.getSourceMapSavePath(); - this.sourceMapPathTmp = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON + '.tmp'); this.cacheSourceMapPath = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON); this.triggerAsync = rollupObject.async; this.triggerEndSignal = rollupObject.signal; @@ -103,40 +94,7 @@ export class SourceMapGenerator { // adapt compatibility with hvigor if (!SourceMapGenerator.instance.projectConfig.entryPackageName || !SourceMapGenerator.instance.projectConfig.entryModuleVersion) { - SourceMapGenerator.instance.isNewSourceMap = false; - } - - if ((SourceMapGenerator.instance.projectConfig.hotReload && - SourceMapGenerator.instance.projectConfig.watchMode !== 'true') || - (SourceMapGenerator.instance.projectConfig.coldReload)) { - isShouldSourceMap = this.projectConfig.isFirstBuild; - } - - SourceMapGenerator.instance.isCompileSingle = SourceMapGenerator.instance.isNewSourceMap && - SourceMapGenerator.instance.projectConfig.singleFileEmit && isShouldSourceMap; - - if (isShouldSourceMap && SourceMapGenerator.instance.isNewSourceMap) { - if (fs.existsSync(SourceMapGenerator.instance.sourceMapPath)) { - fs.unlinkSync(SourceMapGenerator.instance.sourceMapPath); - } - if (fs.existsSync(SourceMapGenerator.instance.sourceMapPathTmp)) { - fs.unlinkSync(SourceMapGenerator.instance.sourceMapPathTmp); - } - - const sourceMapPathDir: string = path.dirname(SourceMapGenerator.instance.sourceMapPath); - if (!fs.existsSync(sourceMapPathDir)) { - fs.mkdirSync(sourceMapPathDir, { recursive: true }); - } - SourceMapGenerator.instance.originFd = fs.openSync(SourceMapGenerator.instance.sourceMapPath, 'a'); - const sourceMapPathTmpDir: string = path.dirname(SourceMapGenerator.instance.sourceMapPathTmp); - if (!fs.existsSync(sourceMapPathTmpDir)) { - fs.mkdirSync(sourceMapPathTmpDir, { recursive: true }); - } - SourceMapGenerator.instance.tempFd = fs.openSync(SourceMapGenerator.instance.sourceMapPathTmp, 'a'); - } - - if (SourceMapGenerator.instance.projectConfig.hotReload) { - isShouldSourceMap = false; + SourceMapGenerator.instance.isNewSourceMap = false; } } @@ -237,148 +195,7 @@ export class SourceMapGenerator { path.join(this.projectConfig.cachePath, SOURCEMAPS); } - async *readLines(filePath: string): AsyncGenerator { - const fileStream = fs.createReadStream(filePath, { encoding: 'utf8' }); - const rl = createInterface({ - input: fileStream, - crlfDelay: Infinity - }); - - try { - for await (const line of rl) { - yield line; - } - } finally { - rl.close(); - fileStream.close(); - } - } - - public formatOrigin(key: string, val: object): string { - return ` "${key}": ${JSON.stringify(val, null, 2).replaceAll('\n', '\n ')}`; - } - - public formatTemp(key: string, val: object): string { - return `{"key": "${key}", "val": ${JSON.stringify(val)}}`; - } - - public writeOrigin(content: string): void { - fs.appendFileSync(this.originFd, content, { encoding: 'utf8' }); - } - - public writetTemp(content: string): void { - fs.appendFileSync(this.tempFd, content, { encoding: 'utf8' }); - } - - public closeFd(): void { - if (this.originFd) { - fs.closeSync(this.originFd); - this.originFd = undefined; - } - if (this.tempFd) { - fs.closeSync(this.tempFd); - this.tempFd = undefined; - } - } - - public convertSourceMapToCache(maps: Object): string { - let isFirstLine: boolean = true; - let cacheContent: string = ''; - Object.keys(maps).forEach(key => { - let contentTmp: string = this.formatTemp(key, maps[key]); - if (isFirstLine) { - isFirstLine = false; - cacheContent = contentTmp; - } else { - cacheContent += `\n${contentTmp}`; - } - }); - return cacheContent; - } - - public writeModifiedSourceMapToFile(parentEvent: CompileEvent | undefined): void { - const eventWriteCachedSourceMaps = createAndStartEvent(parentEvent, 'write source maps'); - Object.keys(this.sourceMaps).forEach(key => { - let keyChanged: string = ''; - if (this.sourceMapKeyMappingForObf.has(key)) { - keyChanged = this.sourceMapKeyMappingForObf.get(key); - } else { - keyChanged = key; - } - this.sourceMapKeys.add(keyChanged); - - let contentJson: string = this.formatOrigin(keyChanged, this.sourceMaps[key]); - let contentTmp: string = this.formatTemp(keyChanged, this.sourceMaps[key]); - if (this.isFirstAppend) { - this.isFirstAppend = false; - this.writeOrigin(`{\n${contentJson}`); - this.writetTemp(`${contentTmp}`); - } else { - this.writeOrigin(`,\n${contentJson}`); - this.writetTemp(`\n${contentTmp}`); - } - }); - this.sourceMaps = {}; - this.sourceMapKeyMappingForObf.clear(); - stopEvent(eventWriteCachedSourceMaps); - } - - public async writeUsedAndUnmodifiedSourceMapToFile(parentEvent: CompileEvent | undefined): Promise { - const eventMergeCachedSourceMaps = createAndStartEvent(parentEvent, 'merge cached source maps'); - let cacheSourceMapInfo: Object = this.getCacheSourceMapInfo(); - if (!cacheSourceMapInfo.exist) { - if (!this.isFirstAppend) { - this.writeOrigin('\n}'); - } - this.closeFd(); - fs.renameSync(this.sourceMapPathTmp, this.cacheSourceMapPath); - stopEvent(eventMergeCachedSourceMaps); - return; - } - - await (async (): Promise => { - let compileFileList: Set = this.getCompileFileList(); - for await (const line of this.readLines(cacheSourceMapInfo.path)) { - if (line.trim() === '') { - continue; - } - let smObj: Object = JSON.parse(line.trim()); - if (!compileFileList.has(smObj.key) || this.sourceMapKeys.has(smObj.key)) { - // skip unuse or uncompile in cache - continue; - } - this.writeOrigin(`,\n${this.formatOrigin(smObj.key, smObj.val)}`); - this.writetTemp(`\n${this.formatTemp(smObj.key, smObj.val)}`); - } - if (!this.isFirstAppend) { - this.writeOrigin('\n}'); - } - this.closeFd(); - fs.unlinkSync(this.cacheSourceMapPath); - fs.renameSync(this.sourceMapPathTmp, this.cacheSourceMapPath); - })(); - stopEvent(eventMergeCachedSourceMaps); - } - - public buildModuleSourceMapInfoSingle(parentEvent: CompileEvent | undefined): void { - if (!this.isCompileSingle) { - return; - } - if (Object.keys(this.sourceMaps).length === 0) { - return; - } - this.writeModifiedSourceMapToFile(parentEvent); - } - public buildModuleSourceMapInfo(parentEvent: CompileEvent | undefined): void { - if (this.isCompileSingle) { - this.writeUsedAndUnmodifiedSourceMapToFile(parentEvent); - } else { - this.buildModuleSourceMapInfoAll(parentEvent); - } - } - - public buildModuleSourceMapInfoAll(parentEvent: CompileEvent | undefined): void { if (this.projectConfig.widgetCompile) { return; } @@ -398,13 +215,6 @@ export class SourceMapGenerator { } }); } - - if (this.isNewSourceMap) { - this.writeModifiedSourceMapToFile(parentEvent); - this.writeUsedAndUnmodifiedSourceMapToFile(parentEvent); - return; - } - const updateSourceRecordInfo = MemoryMonitor.recordStage(MemoryDefine.UPDATE_SOURCE_MAPS); const cacheSourceMapObject: Object = this.updateCachedSourceMaps(); MemoryMonitor.stopRecordStage(updateSourceRecordInfo); @@ -429,52 +239,57 @@ export class SourceMapGenerator { }); } - public isEmptyFile(filePath: string): boolean { - const stats = fs.statSync(filePath); - return stats.size === 0; - } - - public getCacheSourceMapInfo(): Object { - let existCacheSourceMap: boolean = false; - let cacheSourceMapPath: string = ''; - let cacheSourceMapPathTmp: string = ''; - /** - * bytecode obfuscation requires that the input sourceMap must be unobfuscated, - * the sourceMap will be saved in the cache directory before the first bytecode obfuscation, - * and it will as the input for merging sourceMap during incremental compilation. - */ - if (BytecodeObfuscator.enable) { - cacheSourceMapPathTmp = BytecodeObfuscator.getInstance().getBackupSourceMapPath(); - if (fs.existsSync(cacheSourceMapPathTmp) && !this.isEmptyFile(cacheSourceMapPathTmp)) { - existCacheSourceMap = true; - cacheSourceMapPath = cacheSourceMapPathTmp; - } - } - - cacheSourceMapPathTmp = this.cacheSourceMapPath; - if (!existCacheSourceMap && fs.existsSync(cacheSourceMapPathTmp) && !this.isEmptyFile(cacheSourceMapPathTmp)) { - existCacheSourceMap = true; - cacheSourceMapPath = cacheSourceMapPathTmp; - } - - return { exist: existCacheSourceMap, path: cacheSourceMapPath }; - } - //update cache sourcemap object public updateCachedSourceMaps(): Object { if (!this.isNewSourceMap) { this.modifySourceMapKeyToCachePath(this.sourceMaps); } - let cacheSourceMapObject: Object = null; - let cacheSourceMapInfo: Object = this.getCacheSourceMapInfo(); - if (!cacheSourceMapInfo.exist) { + let cacheSourceMapObject: Object; + if (!fs.existsSync(this.cacheSourceMapPath)) { cacheSourceMapObject = this.sourceMaps; } else { - cacheSourceMapObject = JSON.parse(fs.readFileSync(cacheSourceMapInfo.path).toString().trim()); + /** + * bytecode obfuscation requires that the input sourceMap must be unobfuscated, + * the sourceMap will be saved in the cache directory before the first bytecode obfuscation, + * and it will as the input for merging sourceMap during incremental compilation. + */ + if (BytecodeObfuscator.enable && fs.existsSync(BytecodeObfuscator.getInstance().getBackupSourceMapPath())) { + cacheSourceMapObject = JSON.parse(fs.readFileSync(BytecodeObfuscator.getInstance().getBackupSourceMapPath()).toString()); + } else { + cacheSourceMapObject = JSON.parse(fs.readFileSync(this.cacheSourceMapPath).toString()); + } // remove unused source files's sourceMap let unusedFiles = []; - let compileFileList: Set = this.getCompileFileList(); + let compileFileList: Set = new Set(); + for (let moduleId of SourceMapGenerator.rollupObject.getModuleIds()) { + // exclude .dts|.d.ets file + if (isCommonJsPluginVirtualFile(moduleId) || !isCurrentProjectFiles(moduleId, this.projectConfig)) { + continue; + } + + if (this.isNewSourceMap) { + const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); + if (enableObfuscateFileName(isPackageModules, this.projectConfig)){ + compileFileList.add(this.genKey(moduleId, true)); + } else { + compileFileList.add(this.genKey(moduleId)); + } + continue; + } + + // adapt compatibilty with hvigor + const projectRootPath = getProjectRootPath(moduleId, this.projectConfig, this.projectConfig?.rootPathSet); + let cacheModuleId = this.getIntermediateModuleId(toUnixPath(moduleId)) + .replace(toUnixPath(projectRootPath), toUnixPath(this.projectConfig.cachePath)); + + const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); + if (enableObfuscateFileName(isPackageModules, this.projectConfig)) { + compileFileList.add(mangleFilePath(cacheModuleId)); + } else { + compileFileList.add(cacheModuleId); + } + } Object.keys(cacheSourceMapObject).forEach(key => { let newkeyOrOldCachePath = key; @@ -501,39 +316,6 @@ export class SourceMapGenerator { return cacheSourceMapObject; } - public getCompileFileList(): Set { - let compileFileList: Set = new Set(); - for (let moduleId of SourceMapGenerator.rollupObject.getModuleIds()) { - // exclude .dts|.d.ets file - if (isCommonJsPluginVirtualFile(moduleId) || !isCurrentProjectFiles(moduleId, this.projectConfig)) { - continue; - } - - if (this.isNewSourceMap) { - const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); - if (enableObfuscateFileName(isPackageModules, this.projectConfig)) { - compileFileList.add(this.genKey(moduleId, true)); - } else { - compileFileList.add(this.genKey(moduleId)); - } - continue; - } - - // adapt compatibilty with hvigor - const projectRootPath = getProjectRootPath(moduleId, this.projectConfig, this.projectConfig?.rootPathSet); - let cacheModuleId = this.getIntermediateModuleId(toUnixPath(moduleId)) - .replace(toUnixPath(projectRootPath), toUnixPath(this.projectConfig.cachePath)); - - const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); - if (enableObfuscateFileName(isPackageModules, this.projectConfig)) { - compileFileList.add(mangleFilePath(cacheModuleId)); - } else { - compileFileList.add(cacheModuleId); - } - } - return compileFileList; - } - public getSourceMaps(): Object { return this.sourceMaps; } @@ -628,7 +410,6 @@ export class SourceMapGenerator { public static cleanSourceMapObject(): void { if (this.instance) { - this.instance.closeFd(); this.instance.keyCache.clear(); this.instance.sourceMaps = undefined; this.instance = undefined; diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 2152ebdfe..f71b125ba 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -356,7 +356,6 @@ export class ModuleSourceFile { } const eventWriteSourceFile = createAndStartEvent(parentEvent, 'write source file'); await moduleSourceFile.writeSourceFile(eventWriteSourceFile); - SourceMapGenerator.getInstance().buildModuleSourceMapInfoSingle(eventWriteSourceFile); stopEvent(eventWriteSourceFile); } } diff --git a/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts b/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts index c7a1964bb..dbc7a1b15 100644 --- a/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts +++ b/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts @@ -260,23 +260,14 @@ class ModuleModeMock extends ModuleMode { } checkModuleSourceMapInfoMock(): boolean { - const readSourceMap: string = fs.readFileSync(this.sourceMapPath, 'utf-8'); - const readCacheSourceMap: string = fs.readFileSync(this.cacheSourceMapPath, 'utf-8'); + const readSourceMap = fs.readFileSync(this.sourceMapPath, 'utf-8'); + const readCacheSourceMap = fs.readFileSync(this.cacheSourceMapPath, 'utf-8'); if (readSourceMap.length == 0 && readCacheSourceMap.length == 0) { return true; - } else { - const sourcemapObj: Object = JSON.parse(readSourceMap); - const cacheArrayStr: string = "[" + readCacheSourceMap.replaceAll("\n", ",") + "]"; - const cacheArray: Array = JSON.parse(cacheArrayStr); - for (const item of cacheArray) { - if (!sourcemapObj.hasOwnProperty(item.key)) { - return false; - } - if (JSON.stringify(sourcemapObj[item.key]) != JSON.stringify(item.val)) { - return false; - } - } + } else if (readSourceMap === readCacheSourceMap) { return true; + } else { + return false; } } diff --git a/compiler/test/ark_compiler_ut/module/module_mode.test.ts b/compiler/test/ark_compiler_ut/module/module_mode.test.ts index 42a075b89..42364286d 100644 --- a/compiler/test/ark_compiler_ut/module/module_mode.test.ts +++ b/compiler/test/ark_compiler_ut/module/module_mode.test.ts @@ -1416,7 +1416,6 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); - sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1441,7 +1440,6 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); - sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1464,7 +1462,6 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); - sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1489,7 +1486,6 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); - sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1512,7 +1508,6 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); - sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1537,7 +1532,6 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); - sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1560,7 +1554,6 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); - sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1585,7 +1578,6 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); - sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); -- Gitee From f38f721c0a164cdf23a515171069a2a9882e244d Mon Sep 17 00:00:00 2001 From: Yenan Date: Thu, 22 May 2025 16:48:27 +0800 Subject: [PATCH 068/140] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=93=BE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=97=AD=E6=BA=90=E7=BB=84=E4=BB=B6=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E7=99=BD=E5=90=8D=E5=8D=95=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E5=86=85=E5=AE=B92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/components/audiowave.json | 5 ---- compiler/components/hds_tabs.json | 12 --------- compiler/components/hdsvisualcomponent.json | 4 --- compiler/components/tab_content.json | 2 +- compiler/tsconfig.esm.json | 30 --------------------- compiler/tsconfig.json | 30 --------------------- 6 files changed, 1 insertion(+), 82 deletions(-) delete mode 100644 compiler/components/audiowave.json delete mode 100644 compiler/components/hds_tabs.json delete mode 100644 compiler/components/hdsvisualcomponent.json diff --git a/compiler/components/audiowave.json b/compiler/components/audiowave.json deleted file mode 100644 index c74512f3d..000000000 --- a/compiler/components/audiowave.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "AudioWave", - "atomic": true, - "attrs": [] -} \ No newline at end of file diff --git a/compiler/components/hds_tabs.json b/compiler/components/hds_tabs.json deleted file mode 100644 index a90e9fe22..000000000 --- a/compiler/components/hds_tabs.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "HdsTabs", - "children": ["TabContent"], - "attrs": [ - "vertical", "scrollable", "barMode", "barWidth", "barHeight", "animationDuration", - "onChange", "onAnimationStart", "onAnimationEnd", "onGestureSwipe", - "barPosition", "barOverlap", "barBackgroundColor", "customContentTransition", "barBackgroundBlurStyle", - "onContentWillChange", "animationMode", "edgeEffect", "onTabBarClick", "fadingEdge", "divider", - "barGridAlign", "barBackgroundEffect", "pageFlipMode", "onSelected", "onUnselected", "cachedMaxCount", - "animationCurve", "barBackgroundStyle" - ] - } \ No newline at end of file diff --git a/compiler/components/hdsvisualcomponent.json b/compiler/components/hdsvisualcomponent.json deleted file mode 100644 index 0ab0cb95b..000000000 --- a/compiler/components/hdsvisualcomponent.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "HdsVisualComponent", - "attrs": ["scene"] -} \ No newline at end of file diff --git a/compiler/components/tab_content.json b/compiler/components/tab_content.json index 75f087e92..91d53fefc 100644 --- a/compiler/components/tab_content.json +++ b/compiler/components/tab_content.json @@ -1,6 +1,6 @@ { "name": "TabContent", - "parents": ["Tabs", "HdsTabs"], + "parents": ["Tabs"], "attrs": [ "tabBar", "onWillShow", diff --git a/compiler/tsconfig.esm.json b/compiler/tsconfig.esm.json index 68829bc64..2e20f130e 100755 --- a/compiler/tsconfig.esm.json +++ b/compiler/tsconfig.esm.json @@ -183,7 +183,6 @@ "DataPanel", "DatePicker", "Divider", - "DotMatrix", "EffectComponent", "Ellipse", "EmbeddedComponent", @@ -210,7 +209,6 @@ "Menu", "MenuItem", "MenuItemGroup", - "Metaball", "NavDestination", "NavRouter", "Navigation", @@ -284,9 +282,6 @@ "ArcSwiper", "ArcScrollBar", "ArcAlphabetIndexer", - "HdsTabs", - "AudioWave", - "HdsVisualComponent", ], "extend": { "decorator": ["Extend", "AnimatableExtend"], @@ -411,11 +406,6 @@ "type": "DividerAttribute", "instance": "DividerInstance" }, - { - "name": "DotMatrix", - "type": "DotMatrixAttribute", - "instance": "DotMatrixInstance" - }, { "name": "EffectComponent", "type": "EffectComponentAttribute", @@ -546,11 +536,6 @@ "type": "MenuItemGroupAttribute", "instance": "MenuItemGroupInstance" }, - { - "name": "Metaball", - "type": "MetaballAttribute", - "instance": "MetaballInstance" - }, { "name": "NavDestination", "type": "NavDestinationAttribute", @@ -911,21 +896,6 @@ "type": "ArcAlphabetIndexerAttribute", "instance": "ArcAlphabetIndexerInstance" }, - { - "name": "HdsTabs", - "type": "HdsTabsAttribute", - "instance": "HdsTabsInstance" - }, - { - "name": "AudioWave", - "type": "AudioWaveAttribute", - "instance": "AudioWaveInstance" - }, - { - "name": "HdsVisualComponent", - "type": "HdsVisualComponentAttribute", - "instance": "HdsVisualComponentInstance" - } ] }, "styles": { diff --git a/compiler/tsconfig.json b/compiler/tsconfig.json index 25a384bdb..96c81984e 100644 --- a/compiler/tsconfig.json +++ b/compiler/tsconfig.json @@ -184,7 +184,6 @@ "DataPanel", "DatePicker", "Divider", - "DotMatrix", "EffectComponent", "Ellipse", "EmbeddedComponent", @@ -213,7 +212,6 @@ "Menu", "MenuItem", "MenuItemGroup", - "Metaball", "MovingPhotoView", "NavDestination", "NavRouter", @@ -293,9 +291,6 @@ "ArcSwiper", "ArcScrollBar", "ArcAlphabetIndexer", - "HdsTabs", - "AudioWave", - "HdsVisualComponent", ], "extend": { "decorator": ["Extend", "AnimatableExtend"], @@ -420,11 +415,6 @@ "type": "DividerAttribute", "instance": "DividerInstance" }, - { - "name": "DotMatrix", - "type": "DotMatrixAttribute", - "instance": "DotMatrixInstance" - }, { "name": "EffectComponent", "type": "EffectComponentAttribute", @@ -565,11 +555,6 @@ "type": "MenuItemGroupAttribute", "instance": "MenuItemGroupInstance" }, - { - "name": "Metaball", - "type": "MetaballAttribute", - "instance": "MetaballInstance" - }, { "name": "MovingPhotoView", "type": "MovingPhotoViewAttribute", @@ -960,21 +945,6 @@ "type": "ArcAlphabetIndexerAttribute", "instance": "ArcAlphabetIndexerInstance" }, - { - "name": "HdsTabs", - "type": "HdsTabsAttribute", - "instance": "HdsTabsInstance" - }, - { - "name": "AudioWave", - "type": "AudioWaveAttribute", - "instance": "AudioWaveInstance" - }, - { - "name": "HdsVisualComponent", - "type": "HdsVisualComponentAttribute", - "instance": "HdsVisualComponentInstance" - } ] }, "styles": { -- Gitee From 5d030646356d475e5dcba70b03d286182e83f255 Mon Sep 17 00:00:00 2001 From: zju_wyx Date: Wed, 5 Mar 2025 18:57:05 +0800 Subject: [PATCH 069/140] Add strategy of triggering GC actively in transform Signed-off-by: zju_wyx Change-Id: Ie35cf1770435ce1f3d99faf724c4a28f3a6bb2f2 --- compiler/src/ets_checker.ts | 3 +++ .../src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 923cfead1..31c906433 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -540,6 +540,7 @@ export const warnCheckerResult: WarnCheckerResult = { count: 0 }; export let languageService: ts.LanguageService = null; let tsImportSendable: boolean = false; let skipOhModulesLint: boolean = false; +export let maxMemoryInServiceChecker: number = 0; export function serviceChecker(rootFileNames: string[], newLogger: Object = null, resolveModulePaths: string[] = null, parentEvent?: CompileEvent, rollupShareObject?: Object): void { fastBuildLogger = newLogger; @@ -600,6 +601,7 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null MemoryMonitor.stopRecordStage(processBuildHaprrecordInfo); } + maxMemoryInServiceChecker = process.memoryUsage().heapUsed; // Release the typeChecker early and perform GC in the following scenarios: // In memory-priority mode or default mode, when the preview mode is disabled in a full compilation scenario, // and it is not a preview, hot reload, or cold reload scenario. The typeChecker is not released early in performance-priority mode. @@ -1865,4 +1867,5 @@ export function resetEtsCheck(): void { dirExistsCache.clear(); targetESVersionChanged = false; fileToIgnoreDiagnostics = undefined; + maxMemoryInServiceChecker = 0; } diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index 5658f3b98..343f71de7 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -72,7 +72,8 @@ import { resetEtsCheck, collectAllFiles, allModuleIds, - resetEtsCheckTypeScript + resetEtsCheckTypeScript, + maxMemoryInServiceChecker } from '../../ets_checker'; import { CUSTOM_BUILDER_METHOD, @@ -169,6 +170,10 @@ export function etsTransform() { if (!!this.cache.get('enableDebugLine') !== projectConfig.enableDebugLine) { ShouldEnableDebugLine.enableDebugLine = true; } + // Initialize the baseline of trggering GC by the maxMemory at the end of serviceChecker. + // In etsTransform plugin, if the memory after transforming a file exceeds the baseline, + // trigger GC and update a new baseline. + ts.MemoryUtils.initializeBaseMemory(maxMemoryInServiceChecker); stopEvent(eventEtsTransformBuildStart); }, load(id: string) { @@ -524,6 +529,7 @@ async function transform(code: string, id: string) { tsProgram.getCompilerOptions().noEmit = true; } + ts.MemoryUtils.tryGC(); resetCollection(); processStructComponentV2.resetStructMapInEts(); if (((transformLog && transformLog.errors.length) || (kitTransformLog && kitTransformLog.errors.length)) && -- Gitee From ccd433bf4a333beacd689a87bc75210bd6dce98a Mon Sep 17 00:00:00 2001 From: shitao Date: Thu, 22 May 2025 17:14:31 +0800 Subject: [PATCH 070/140] Write sourcemap by line Issue: IC9SC9 Signed-off-by: shitao Change-Id: Ic6bff793b940c23d31eed23b24e944541d6471f8 --- .../ark_compiler/bytecode_obfuscator.ts | 7 +- .../ark_compiler/generate_module_abc.ts | 4 +- .../ark_compiler/generate_sourcemap.ts | 312 +++++++++++++++--- .../ark_compiler/module/module_source_file.ts | 1 + .../mock/class_mock/module_mode_mock.ts | 26 +- .../module/module_mode.test.ts | 8 + 6 files changed, 304 insertions(+), 54 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts index 096a58c63..7b9cc6fb2 100644 --- a/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts +++ b/compiler/src/fast_build/ark_compiler/bytecode_obfuscator.ts @@ -64,6 +64,7 @@ import { FileKeepInfo, FileReservedInfo } from 'arkguard/lib/utils/ProjectCollections'; +import { SourceMapGenerator } from './generate_sourcemap'; const FILE_NAME_CACHE: string = 'FileNameCache'; const OBF_NAME_MAP: string = 'ObfNameMap'; @@ -308,7 +309,7 @@ export class BytecodeObfuscator { const nameMapping: Map = generateMapping(nameCache); const sourceMapUpdated: Object = updateSourceMap(sourceMap, nameMapping); fs.writeFileSync(sourceMapPath, JSON.stringify(sourceMapUpdated, null, 2)); - fs.writeFileSync(souceMapJsonPath, JSON.stringify(sourceMapUpdated, null, 2)); + fs.writeFileSync(souceMapJsonPath, SourceMapGenerator.getInstance().convertSourceMapToCache(sourceMapUpdated)); const nameCacheUpdated: Object = this.bytecodeObfuscateConfig.obfuscationRules.compact ? nameCache : processNameCache(nameCache, sourceMap); fs.writeFileSync(this.nameCachePath, JSON.stringify(nameCacheUpdated, null, 2)); @@ -375,9 +376,9 @@ export class BytecodeObfuscator { if (rules.enableDecoratorObfuscation) { const reservedNames = this.bytecodeObfuscateConfig.getReservedNames(); structProperties = new Set( - Array.from(structProperties || []).filter(item => reservedNames?.has(item)) + Array.from(structProperties || []).filter(item => reservedNames?.has(item)) ); - } + } const arrayProperties = [ keepSymbol?.propertyNames, diff --git a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts index 2df6115ed..1053a7cf9 100644 --- a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts +++ b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts @@ -47,9 +47,9 @@ export async function generateModuleAbc(error) { await ModuleSourceFile.processModuleSourceFiles(this, hookEventFactory); } if (this.share.projectConfig.compileHar) { - SourceMapGenerator.getInstance().buildModuleSourceMapInfo(hookEventFactory); - // compileHar: compile har of project, which convert .ets to .d.ts and js if (!this.share.projectConfig.byteCodeHar) { + // compileHar: compile har of project, which convert .ets to .d.ts and js + SourceMapGenerator.getInstance().buildModuleSourceMapInfo(hookEventFactory); return; } } diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index 00ab52a52..bedcb3db9 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -21,7 +21,6 @@ import { EXTNAME_TS, EXTNAME_MJS, EXTNAME_CJS, - GEN_ABC_PLUGIN_NAME, SOURCEMAPS, SOURCEMAPS_JSON, yellow, @@ -46,7 +45,7 @@ import { } from './common/ob_config_resolver'; import { MemoryMonitor } from '../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../meomry_monitor/memory_define'; -import { +import { ArkTSInternalErrorDescription, ErrorCode } from './error_code'; @@ -61,6 +60,9 @@ import { stopEvent } from '../../performance'; import { BytecodeObfuscator } from './bytecode_obfuscator'; +import { createInterface } from 'readline'; + +let isShouldSourceMap: boolean = true; export class SourceMapGenerator { private static instance: SourceMapGenerator | undefined = undefined; @@ -68,19 +70,26 @@ export class SourceMapGenerator { private projectConfig: Object; private sourceMapPath: string; + private sourceMapPathTmp: string; private cacheSourceMapPath: string; private triggerAsync: Object; private triggerEndSignal: Object; private sourceMaps: Object = {}; + private sourceMapKeys: Set = new Set([]); private isNewSourceMap: boolean = true; private keyCache: Map = new Map(); private logger: CommonLogger; + private isFirstAppend: boolean = true; + private isCompileSingle: boolean = false; + private originFd: number; + private tempFd: number; public sourceMapKeyMappingForObf: Map = new Map(); constructor(rollupObject: Object) { this.projectConfig = Object.assign(rollupObject.share.arkProjectConfig, rollupObject.share.projectConfig); this.sourceMapPath = this.getSourceMapSavePath(); + this.sourceMapPathTmp = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON + '.tmp'); this.cacheSourceMapPath = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON); this.triggerAsync = rollupObject.async; this.triggerEndSignal = rollupObject.signal; @@ -94,7 +103,39 @@ export class SourceMapGenerator { // adapt compatibility with hvigor if (!SourceMapGenerator.instance.projectConfig.entryPackageName || !SourceMapGenerator.instance.projectConfig.entryModuleVersion) { - SourceMapGenerator.instance.isNewSourceMap = false; + SourceMapGenerator.instance.isNewSourceMap = false; + } + + if ((SourceMapGenerator.instance.projectConfig.hotReload && + SourceMapGenerator.instance.projectConfig.watchMode !== 'true') || + (SourceMapGenerator.instance.projectConfig.coldReload)) { + isShouldSourceMap = this.projectConfig.isFirstBuild; + } + + SourceMapGenerator.instance.isCompileSingle = SourceMapGenerator.instance.isNewSourceMap && + SourceMapGenerator.instance.projectConfig.singleFileEmit && isShouldSourceMap; + + if (isShouldSourceMap && SourceMapGenerator.instance.isNewSourceMap) { + if (fs.existsSync(SourceMapGenerator.instance.sourceMapPath)) { + fs.unlinkSync(SourceMapGenerator.instance.sourceMapPath); + } + if (fs.existsSync(SourceMapGenerator.instance.sourceMapPathTmp)) { + fs.unlinkSync(SourceMapGenerator.instance.sourceMapPathTmp); + } + + const sourceMapPathDir: string = path.dirname(SourceMapGenerator.instance.sourceMapPath); + if (!fs.existsSync(sourceMapPathDir)) { + fs.mkdirSync(sourceMapPathDir, { recursive: true }); + } + + const sourceMapPathTmpDir: string = path.dirname(SourceMapGenerator.instance.sourceMapPathTmp); + if (!fs.existsSync(sourceMapPathTmpDir)) { + fs.mkdirSync(sourceMapPathTmpDir, { recursive: true }); + } + } + + if (SourceMapGenerator.instance.projectConfig.hotReload) { + isShouldSourceMap = false; } } @@ -195,7 +236,154 @@ export class SourceMapGenerator { path.join(this.projectConfig.cachePath, SOURCEMAPS); } + async *readLines(filePath: string): AsyncGenerator { + const fileStream = fs.createReadStream(filePath, { encoding: 'utf8' }); + const rl = createInterface({ + input: fileStream, + crlfDelay: Infinity + }); + + try { + for await (const line of rl) { + yield line; + } + } finally { + rl.close(); + fileStream.close(); + } + } + + public formatOrigin(key: string, val: object): string { + return ` "${key}": ${JSON.stringify(val, null, 2).replace(/\n/g, '\n ')}`; + } + + public formatTemp(key: string, val: object): string { + return `{"key": "${key}", "val": ${JSON.stringify(val)}}`; + } + + public writeOrigin(content: string): void { + if (!this.originFd) { + this.originFd = fs.openSync(this.sourceMapPath, 'a'); + } + fs.appendFileSync(this.originFd, content, { encoding: 'utf8' }); + } + + public writeTemp(content: string): void { + if (!this.tempFd) { + this.tempFd = fs.openSync(this.sourceMapPathTmp, 'a'); + } + fs.appendFileSync(this.tempFd, content, { encoding: 'utf8' }); + } + + public closeFd(): void { + if (this.originFd) { + fs.closeSync(this.originFd); + this.originFd = undefined; + } + if (this.tempFd) { + fs.closeSync(this.tempFd); + this.tempFd = undefined; + } + } + + public convertSourceMapToCache(maps: Object): string { + let isFirstLine: boolean = true; + let cacheContent: string = ''; + Object.keys(maps).forEach(key => { + let contentTmp: string = this.formatTemp(key, maps[key]); + if (isFirstLine) { + isFirstLine = false; + cacheContent = contentTmp; + } else { + cacheContent += `\n${contentTmp}`; + } + }); + return cacheContent; + } + + public writeModifiedSourceMapToFile(parentEvent: CompileEvent | undefined): void { + const eventWriteCachedSourceMaps = createAndStartEvent(parentEvent, 'write source maps'); + Object.keys(this.sourceMaps).forEach(key => { + let keyChanged: string = ''; + if (this.sourceMapKeyMappingForObf.has(key)) { + keyChanged = this.sourceMapKeyMappingForObf.get(key); + } else { + keyChanged = key; + } + this.sourceMapKeys.add(keyChanged); + + let contentJson: string = this.formatOrigin(keyChanged, this.sourceMaps[key]); + let contentTmp: string = this.formatTemp(keyChanged, this.sourceMaps[key]); + if (this.isFirstAppend) { + this.isFirstAppend = false; + this.writeOrigin(`{\n${contentJson}`); + this.writeTemp(`${contentTmp}`); + } else { + this.writeOrigin(`,\n${contentJson}`); + this.writeTemp(`\n${contentTmp}`); + } + }); + this.sourceMaps = {}; + this.sourceMapKeyMappingForObf.clear(); + stopEvent(eventWriteCachedSourceMaps); + } + + public async writeUsedAndUnmodifiedSourceMapToFile(parentEvent: CompileEvent | undefined): Promise { + const eventMergeCachedSourceMaps = createAndStartEvent(parentEvent, 'merge cached source maps'); + let cacheSourceMapInfo: Object = this.getCacheSourceMapInfo(); + if (!cacheSourceMapInfo.exist) { + if (!this.isFirstAppend) { + this.writeOrigin('\n}'); + } + this.closeFd(); + fs.renameSync(this.sourceMapPathTmp, this.cacheSourceMapPath); + stopEvent(eventMergeCachedSourceMaps); + return; + } + + await (async (): Promise => { + let compileFileList: Set = this.getCompileFileList(); + for await (const line of this.readLines(cacheSourceMapInfo.path)) { + if (line.trim() === '') { + continue; + } + let smObj: Object = JSON.parse(line.trim()); + if (!compileFileList.has(smObj.key) || this.sourceMapKeys.has(smObj.key)) { + // skip unuse or uncompile in cache + continue; + } + this.writeOrigin(`,\n${this.formatOrigin(smObj.key, smObj.val)}`); + this.writeTemp(`\n${this.formatTemp(smObj.key, smObj.val)}`); + } + if (!this.isFirstAppend) { + this.writeOrigin('\n}'); + } + this.closeFd(); + fs.unlinkSync(this.cacheSourceMapPath); + fs.renameSync(this.sourceMapPathTmp, this.cacheSourceMapPath); + })(); + stopEvent(eventMergeCachedSourceMaps); + } + + public buildModuleSourceMapInfoSingle(parentEvent: CompileEvent | undefined): void { + if (!this.isCompileSingle) { + return; + } + if (Object.keys(this.sourceMaps).length === 0) { + return; + } + this.writeModifiedSourceMapToFile(parentEvent); + } + public buildModuleSourceMapInfo(parentEvent: CompileEvent | undefined): void { + if (this.isCompileSingle) { + this.writeUsedAndUnmodifiedSourceMapToFile(parentEvent); + } else { + this.buildModuleSourceMapInfoAll(parentEvent); + } + } + + public buildModuleSourceMapInfoAll(parentEvent: CompileEvent | undefined): void { if (this.projectConfig.widgetCompile) { return; } @@ -215,6 +403,13 @@ export class SourceMapGenerator { } }); } + + if (this.isNewSourceMap) { + this.writeModifiedSourceMapToFile(parentEvent); + this.writeUsedAndUnmodifiedSourceMapToFile(parentEvent); + return; + } + const updateSourceRecordInfo = MemoryMonitor.recordStage(MemoryDefine.UPDATE_SOURCE_MAPS); const cacheSourceMapObject: Object = this.updateCachedSourceMaps(); MemoryMonitor.stopRecordStage(updateSourceRecordInfo); @@ -239,57 +434,52 @@ export class SourceMapGenerator { }); } + public isEmptyFile(filePath: string): boolean { + const stats = fs.statSync(filePath); + return stats.size === 0; + } + + public getCacheSourceMapInfo(): Object { + let existCacheSourceMap: boolean = false; + let cacheSourceMapPath: string = ''; + let cacheSourceMapPathTmp: string = ''; + /** + * bytecode obfuscation requires that the input sourceMap must be unobfuscated, + * the sourceMap will be saved in the cache directory before the first bytecode obfuscation, + * and it will as the input for merging sourceMap during incremental compilation. + */ + if (BytecodeObfuscator.enable) { + cacheSourceMapPathTmp = BytecodeObfuscator.getInstance().getBackupSourceMapPath(); + if (fs.existsSync(cacheSourceMapPathTmp) && !this.isEmptyFile(cacheSourceMapPathTmp)) { + existCacheSourceMap = true; + cacheSourceMapPath = cacheSourceMapPathTmp; + } + } + + cacheSourceMapPathTmp = this.cacheSourceMapPath; + if (!existCacheSourceMap && fs.existsSync(cacheSourceMapPathTmp) && !this.isEmptyFile(cacheSourceMapPathTmp)) { + existCacheSourceMap = true; + cacheSourceMapPath = cacheSourceMapPathTmp; + } + + return { exist: existCacheSourceMap, path: cacheSourceMapPath }; + } + //update cache sourcemap object public updateCachedSourceMaps(): Object { if (!this.isNewSourceMap) { this.modifySourceMapKeyToCachePath(this.sourceMaps); } - let cacheSourceMapObject: Object; - if (!fs.existsSync(this.cacheSourceMapPath)) { + let cacheSourceMapObject: Object = null; + let cacheSourceMapInfo: Object = this.getCacheSourceMapInfo(); + if (!cacheSourceMapInfo.exist) { cacheSourceMapObject = this.sourceMaps; } else { - /** - * bytecode obfuscation requires that the input sourceMap must be unobfuscated, - * the sourceMap will be saved in the cache directory before the first bytecode obfuscation, - * and it will as the input for merging sourceMap during incremental compilation. - */ - if (BytecodeObfuscator.enable && fs.existsSync(BytecodeObfuscator.getInstance().getBackupSourceMapPath())) { - cacheSourceMapObject = JSON.parse(fs.readFileSync(BytecodeObfuscator.getInstance().getBackupSourceMapPath()).toString()); - } else { - cacheSourceMapObject = JSON.parse(fs.readFileSync(this.cacheSourceMapPath).toString()); - } + cacheSourceMapObject = JSON.parse(fs.readFileSync(cacheSourceMapInfo.path).toString().trim()); // remove unused source files's sourceMap let unusedFiles = []; - let compileFileList: Set = new Set(); - for (let moduleId of SourceMapGenerator.rollupObject.getModuleIds()) { - // exclude .dts|.d.ets file - if (isCommonJsPluginVirtualFile(moduleId) || !isCurrentProjectFiles(moduleId, this.projectConfig)) { - continue; - } - - if (this.isNewSourceMap) { - const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); - if (enableObfuscateFileName(isPackageModules, this.projectConfig)){ - compileFileList.add(this.genKey(moduleId, true)); - } else { - compileFileList.add(this.genKey(moduleId)); - } - continue; - } - - // adapt compatibilty with hvigor - const projectRootPath = getProjectRootPath(moduleId, this.projectConfig, this.projectConfig?.rootPathSet); - let cacheModuleId = this.getIntermediateModuleId(toUnixPath(moduleId)) - .replace(toUnixPath(projectRootPath), toUnixPath(this.projectConfig.cachePath)); - - const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); - if (enableObfuscateFileName(isPackageModules, this.projectConfig)) { - compileFileList.add(mangleFilePath(cacheModuleId)); - } else { - compileFileList.add(cacheModuleId); - } - } + let compileFileList: Set = this.getCompileFileList(); Object.keys(cacheSourceMapObject).forEach(key => { let newkeyOrOldCachePath = key; @@ -316,6 +506,39 @@ export class SourceMapGenerator { return cacheSourceMapObject; } + public getCompileFileList(): Set { + let compileFileList: Set = new Set(); + for (let moduleId of SourceMapGenerator.rollupObject.getModuleIds()) { + // exclude .dts|.d.ets file + if (isCommonJsPluginVirtualFile(moduleId) || !isCurrentProjectFiles(moduleId, this.projectConfig)) { + continue; + } + + if (this.isNewSourceMap) { + const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); + if (enableObfuscateFileName(isPackageModules, this.projectConfig)) { + compileFileList.add(this.genKey(moduleId, true)); + } else { + compileFileList.add(this.genKey(moduleId)); + } + continue; + } + + // adapt compatibilty with hvigor + const projectRootPath = getProjectRootPath(moduleId, this.projectConfig, this.projectConfig?.rootPathSet); + let cacheModuleId = this.getIntermediateModuleId(toUnixPath(moduleId)) + .replace(toUnixPath(projectRootPath), toUnixPath(this.projectConfig.cachePath)); + + const isPackageModules = isPackageModulesFile(moduleId, this.projectConfig); + if (enableObfuscateFileName(isPackageModules, this.projectConfig)) { + compileFileList.add(mangleFilePath(cacheModuleId)); + } else { + compileFileList.add(cacheModuleId); + } + } + return compileFileList; + } + public getSourceMaps(): Object { return this.sourceMaps; } @@ -410,6 +633,7 @@ export class SourceMapGenerator { public static cleanSourceMapObject(): void { if (this.instance) { + this.instance.closeFd(); this.instance.keyCache.clear(); this.instance.sourceMaps = undefined; this.instance = undefined; diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index f71b125ba..2152ebdfe 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -356,6 +356,7 @@ export class ModuleSourceFile { } const eventWriteSourceFile = createAndStartEvent(parentEvent, 'write source file'); await moduleSourceFile.writeSourceFile(eventWriteSourceFile); + SourceMapGenerator.getInstance().buildModuleSourceMapInfoSingle(eventWriteSourceFile); stopEvent(eventWriteSourceFile); } } diff --git a/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts b/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts index dbc7a1b15..1bb0f2fa4 100644 --- a/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts +++ b/compiler/test/ark_compiler_ut/mock/class_mock/module_mode_mock.ts @@ -260,14 +260,30 @@ class ModuleModeMock extends ModuleMode { } checkModuleSourceMapInfoMock(): boolean { - const readSourceMap = fs.readFileSync(this.sourceMapPath, 'utf-8'); - const readCacheSourceMap = fs.readFileSync(this.cacheSourceMapPath, 'utf-8'); + let readSourceMap: string = ''; + if (fs.existsSync(this.sourceMapPath)) { + readSourceMap = fs.readFileSync(this.sourceMapPath, 'utf-8'); + } + let readCacheSourceMap: string = ''; + if (fs.existsSync(this.cacheSourceMapPath)) { + readCacheSourceMap = fs.readFileSync(this.cacheSourceMapPath, 'utf-8'); + } + if (readSourceMap.length == 0 && readCacheSourceMap.length == 0) { return true; - } else if (readSourceMap === readCacheSourceMap) { - return true; } else { - return false; + const sourcemapObj: Object = JSON.parse(readSourceMap); + const cacheArrayStr: string = '[' + readCacheSourceMap.replace(/\n/g, ',') + ']'; + const cacheArray: Array = JSON.parse(cacheArrayStr); + for (const item of cacheArray) { + if (!sourcemapObj.hasOwnProperty(item.key)) { + return false; + } + if (JSON.stringify(sourcemapObj[item.key]) != JSON.stringify(item.val)) { + return false; + } + } + return true; } } diff --git a/compiler/test/ark_compiler_ut/module/module_mode.test.ts b/compiler/test/ark_compiler_ut/module/module_mode.test.ts index 42364286d..42a075b89 100644 --- a/compiler/test/ark_compiler_ut/module/module_mode.test.ts +++ b/compiler/test/ark_compiler_ut/module/module_mode.test.ts @@ -1416,6 +1416,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1440,6 +1441,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1462,6 +1464,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1486,6 +1489,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1508,6 +1512,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1532,6 +1537,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1554,6 +1560,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger.getLoggerFromErrorCode(errInfo.code), 'printErrorAndExit'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); @@ -1578,6 +1585,7 @@ mocha.describe('test module_mode file api', function () { const moduleMode = new ModuleModeMock(this.rollup); const stub = sinon.stub(sourceMapGenerator.logger, 'throwArkTsCompilerError'); const copyFileSyncStub = sinon.stub(fs, 'copyFileSync').returns(undefined); + sourceMapGenerator.setNewSoureMaps(false); sourceMapGenerator.setSourceMapPath(''); moduleMode.buildModuleSourceMapInfoMock(sourceMapGenerator); await sleep(100); -- Gitee From fbe5fd83bf9db440a2c442edeeaadc6eb3dbd0f8 Mon Sep 17 00:00:00 2001 From: wuhailong Date: Tue, 13 May 2025 15:44:07 +0800 Subject: [PATCH 071/140] filesInfo Performance Optimization Issue: #ICAAIT Signed-off-by: wuhailong Change-Id: Id78b80498d4690bf50a07effcc6025b147860164 --- .../src/fast_build/ark_compiler/module/module_build_mode.ts | 1 + .../fast_build/ark_compiler/module/module_coldreload_mode.ts | 1 + .../src/fast_build/ark_compiler/module/module_hotfix_mode.ts | 1 + .../fast_build/ark_compiler/module/module_hotreload_mode.ts | 1 + compiler/src/fast_build/ark_compiler/module/module_mode.ts | 1 - .../src/fast_build/ark_compiler/module/module_preview_mode.ts | 1 + compiler/test/ark_compiler_ut/module/module_mode.test.ts | 3 ++- 7 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/module/module_build_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_build_mode.ts index 7e9c0bb57..86929075d 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_build_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_build_mode.ts @@ -39,6 +39,7 @@ export class ModuleBuildMode extends ModuleMode { } generateAbc(rollupObject: Object, parentEvent: CompileEvent): void { + this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); this.prepareForCompilation(rollupObject, parentEvent); SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); this.executeArkCompiler(parentEvent); diff --git a/compiler/src/fast_build/ark_compiler/module/module_coldreload_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_coldreload_mode.ts index d72d7e007..2efe3f1fe 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_coldreload_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_coldreload_mode.ts @@ -85,6 +85,7 @@ export class ModuleColdreloadMode extends ModuleMode { } private compileAllFiles(rollupObject: Object, parentEvent: CompileEvent): void { + this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); this.prepareForCompilation(rollupObject, parentEvent); SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); this.generateAbcByEs2abc(parentEvent, !!this.projectConfig.byteCodeHarInfo); diff --git a/compiler/src/fast_build/ark_compiler/module/module_hotfix_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_hotfix_mode.ts index 385d5e709..b14d3faf7 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_hotfix_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_hotfix_mode.ts @@ -37,6 +37,7 @@ export class ModuleHotfixMode extends ModuleMode { this.patch = this.projectConfig.patch || false; this.inOldSymbolTablePath = this.projectConfig.inOldSymbolTablePath || this.projectConfig.projectRootPath; this.enableMap = this.projectConfig.enableMap || false; + this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); this.prepareForCompilation(rollupObject, parentEvent); SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); diff --git a/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts index f6275d1f8..24618d53b 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_hotreload_mode.ts @@ -94,6 +94,7 @@ export class ModuleHotreloadMode extends ModuleMode { } private compileAllFiles(rollupObject: Object, parentEvent: CompileEvent): void { + this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); this.prepareForCompilation(rollupObject, parentEvent); SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); this.generateAbcByEs2abc(parentEvent, !!this.projectConfig.byteCodeHarInfo); diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index e1591666a..42cdd20dc 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -307,7 +307,6 @@ export class ModuleMode extends CommonMode { prepareForCompilation(rollupObject: Object, parentEvent: CompileEvent): void { const eventPrepareForCompilation = createAndStartEvent(parentEvent, 'preparation for compilation'); - this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); this.removeCacheInfo(rollupObject); stopEvent(eventPrepareForCompilation); } diff --git a/compiler/src/fast_build/ark_compiler/module/module_preview_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_preview_mode.ts index 727e1a9f3..0ca8cf7ce 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_preview_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_preview_mode.ts @@ -39,6 +39,7 @@ export class ModulePreviewMode extends ModuleMode { } generateAbc(rollupObject: Object, parentEvent: CompileEvent): void { + this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); this.prepareForCompilation(rollupObject, parentEvent); SourceMapGenerator.getInstance().buildModuleSourceMapInfo(parentEvent); this.executeArkCompiler(parentEvent); diff --git a/compiler/test/ark_compiler_ut/module/module_mode.test.ts b/compiler/test/ark_compiler_ut/module/module_mode.test.ts index 42a075b89..0d8d380e5 100644 --- a/compiler/test/ark_compiler_ut/module/module_mode.test.ts +++ b/compiler/test/ark_compiler_ut/module/module_mode.test.ts @@ -1023,7 +1023,7 @@ mocha.describe('test module_mode file api', function () { this.rollup.build(); SourceMapGenerator.initInstance(this.rollup); const moduleMode = new ModuleMode(this.rollup); - moduleMode.prepareForCompilation(this.rollup); + moduleMode.collectModuleFileList(this.rollup, this.rollup.getModuleIds()); this.rollup.share.allFiles.add(jsonFilePath); moduleMode.generateCompileFilesInfo(false); @@ -1035,6 +1035,7 @@ mocha.describe('test module_mode file api', function () { expect(filesInfoLines[3].endsWith('ets')).to.be.true; SourceMapGenerator.cleanSourceMapObject(); + this.rollup.share.allFiles.delete(jsonFilePath); fs.unlinkSync(jsonFilePath); }); -- Gitee From 986fa469083866bfecf1e04ed4ff553dcac44adb Mon Sep 17 00:00:00 2001 From: Bojiang Date: Mon, 26 May 2025 15:16:13 +0800 Subject: [PATCH 072/140] jiangbo91@huawei.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix 三目运算符编译源码报错 Signed-off-by: Bojiang Change-Id: I95c0e046accf60b894ae2c2e53bb56465c5dac2b --- compiler/src/process_component_build.ts | 3 +- .../attrs/bindSheet.js.sample | 69 +++++++++++++++++++ .../attrs/bindSheet.ets | 33 +++++++++ .../test/transform_ut/helpers/pathConfig.ts | 1 + 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.js.sample create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.ets diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 5d71ae934..7ff4035c5 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -2565,7 +2565,8 @@ function processConditionalBuilder(initializer: ts.ConditionalExpression, identi if (isBuilderChangeNode(initializer.whenFalse, identifierNode, propertyName)) { whenFalse = parseBuilderNode(initializer.whenFalse, propertyName); } - return ts.factory.createConditionalExpression( + return ts.factory.updateConditionalExpression( + initializer, initializer.condition, initializer.questionToken, whenTrue, diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.js.sample new file mode 100644 index 000000000..146ca3c8a --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.js.sample @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022-2025 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. + */ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { +var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; +if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); +else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; +return c > 3 && r && Object.defineProperty(target, key, r), r; +}; + +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +class BottomSheet extends ViewV2 { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda, extraInfo) { + super(parent, elmtId, extraInfo); + this.initParam("title", (params && "title" in params) ? params.title : undefined); + this.finalizeConstruction(); + } + resetStateVarsOnReuse(params) { + this.resetParam("title", (params && "title" in params) ? params.title : undefined); + } + sheetBuilder(parent = null) { + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Blank.create(); + Blank.bindSheet(this.title ? true : false, { builder: () => { + this.sheetBuilder.call(this); + } }, {}); + }, Blank); + Blank.pop(); + Row.pop(); + } + updateStateVars(params) { + if (params === undefined) { + return; + } + if ("title" in params) { + this.updateParam("title", params.title); + } + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName() { + return "BottomSheet"; + } +} +__decorate([ + Param +], BottomSheet.prototype, "title", void 0); +registerNamedRoute(() => new BottomSheet(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet", integratedHsp: "false", moduleType: "followWithHap" }); +//# sourceMappingURL=bindSheet.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.ets new file mode 100644 index 000000000..b99e3b42b --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 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. + */ + +@Entry +@ComponentV2 +struct BottomSheet { + @Param @Require title?:ResourceStr; + @Builder sheetBuilder() { + + } + build() { + Row() { + Blank() + .bindSheet( + this.title? true: false, + this.sheetBuilder(), + {} + ) + } + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/pathConfig.ts b/compiler/test/transform_ut/helpers/pathConfig.ts index ca5aa605f..50a2b87f6 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -88,6 +88,7 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'inner_component_transform/$$_component/$$_componentCheck7', 'inner_component_transform/$$_component/$$_componentCheck8', 'inner_component_transform/$$_component/$$_componentCheck9', + 'inner_component_transform/attrs/bindSheet', 'inner_component_transform/$$_component/$$_if_elseIf_else', 'inner_component_transform/custom_component/component_object', 'inner_component_transform/custom_component/custom_component', -- Gitee From a225dd7793d6b4b8ad73415716053765ceb63273 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Sat, 24 May 2025 16:12:02 +0800 Subject: [PATCH 073/140] =?UTF-8?q?=E6=84=8F=E5=9B=BE=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E6=98=93=E7=94=A8=E6=80=A7=E6=95=B4=E6=94=B9=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/userIntents_parser/intentType.ts | 20 ++++++++++-- .../userIntents_parser/parseUserIntents.ts | 32 +++++++++++-------- .../@InsightIntentEntry.js.sample | 18 ++--------- .../@InsightIntentEntry.ets | 30 ++++++++--------- 4 files changed, 51 insertions(+), 49 deletions(-) diff --git a/compiler/src/userIntents_parser/intentType.ts b/compiler/src/userIntents_parser/intentType.ts index 6a380506b..bfe00c16e 100644 --- a/compiler/src/userIntents_parser/intentType.ts +++ b/compiler/src/userIntents_parser/intentType.ts @@ -30,6 +30,8 @@ export interface IntentInfo { llmDescription: string; keywords: string[]; parameters: object; + result: object; + example: string; } export interface LinkIntentParamMapping { @@ -136,7 +138,7 @@ function validateKeywords(v: ts.Expression): boolean { } const BASE_REQUIRED = ['intentName', 'domain', 'intentVersion', 'displayName']; -const BASE_ALLOW = ['displayDescription', 'schema', 'icon', 'llmDescription', 'keywords', 'parameters', ...BASE_REQUIRED]; +const BASE_ALLOW = ['displayDescription', 'schema', 'icon', 'llmDescription', 'keywords', 'parameters', 'result', 'example', ...BASE_REQUIRED]; const IntentLinkParamsChecker: ParamChecker = new ParamChecker(); IntentLinkParamsChecker.requiredFields = ['paramName']; @@ -144,7 +146,11 @@ IntentLinkParamsChecker.allowFields = new Set([ 'paramName', 'paramMappingName', 'paramCategory' ]); IntentLinkParamsChecker.paramValidators = { - paramCategory: validateOptionalString, + paramCategory(v: ts.Expression): boolean { + const enumValue: string = v?.getText().split('.').pop(); + const allowedEnumFields: string[] = ['link', 'want', 'LINK', 'WANT']; + return (allowedEnumFields.includes(enumValue)); + }, paramMappingName: validateOptionalString, paramName: validateRequiredString }; @@ -157,6 +163,8 @@ IntentLinkInfoChecker.allowFields = new Set([ 'paramMappings' ]); IntentLinkInfoChecker.paramValidators = { + example: validateOptionalString, + result: validateParameters, parameters: validateParameters, paramMappings: (v: ts.Expression): boolean => { if (v === null || v === undefined) { @@ -193,9 +201,11 @@ IntentLinkInfoChecker.paramValidators = { IntentLinkInfoChecker.nestedCheckers = new Map([['paramMappings', IntentLinkParamsChecker]]); export const intentEntryInfoChecker: ParamChecker = new ParamChecker(); -intentEntryInfoChecker.requiredFields = [...BASE_REQUIRED as Array, 'abilityName']; +intentEntryInfoChecker.requiredFields = [...BASE_REQUIRED as Array, 'abilityName', 'executeMode']; intentEntryInfoChecker.allowFields = new Set([...BASE_ALLOW as Array, 'abilityName', 'executeMode']); intentEntryInfoChecker.paramValidators = { + example: validateOptionalString, + result: validateParameters, parameters: validateParameters, icon: validateIcon, keywords: validateKeywords, @@ -228,6 +238,8 @@ intentMethodInfoChecker.allowFields = new Set([ ]); intentMethodInfoChecker.paramValidators = { + example: validateOptionalString, + result: validateParameters, parameters: validateParameters, icon: validateIcon, keywords: validateKeywords, @@ -251,6 +263,8 @@ IntentPageInfoChecker.allowFields = new Set([ ]); IntentPageInfoChecker.paramValidators = { + example: validateOptionalString, + result: validateParameters, parameters: validateParameters, icon: validateIcon, keywords: validateKeywords, diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index d4c384e4b..081f3234c 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -218,8 +218,7 @@ class ParseIntent { Object.assign(intentObj, { 'bundleName': projectConfig.bundleName, 'moduleName': projectConfig.moduleName, - 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_METHOD, - 'intentType': 'function' + 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_METHOD }); interface methodParametersInfo { @@ -773,15 +772,20 @@ class ParseIntent { throw Error(`${UNSUPPORTED_PARSE_ERROR.toString()}, cause param: '${node.text}', invalidDecoratorPath: ${this.currentFilePath}`); } - processEnumElement(node: ts.PropertyAccessExpression): number { - const enumValue: string = node.getText(); - const executeModeEnum: Map = new Map(); - executeModeEnum.set('insightIntent.ExecuteMode.UI_ABILITY_FOREGROUND', 0); - executeModeEnum.set('insightIntent.ExecuteMode.UI_ABILITY_BACKGROUND', 1); - executeModeEnum.set('insightIntent.ExecuteMode.UI_EXTENSION_ABILITY', 2); - executeModeEnum.set('insightIntent.ExecuteMode.SERVICE_EXTENSION_ABILITY', 3); + processEnumElement(node: ts.PropertyAccessExpression): string { + const enumValue: string = node?.getText().split('.').pop(); + const executeModeEnum: Map = new Map(); + executeModeEnum.set('UI_ABILITY_FOREGROUND', '0'); + executeModeEnum.set('UI_ABILITY_BACKGROUND', '1'); + executeModeEnum.set('UI_EXTENSION_ABILITY', '2'); + executeModeEnum.set('SERVICE_EXTENSION_ABILITY', '3'); + const paramCategoryEnum: Map = new Map(); + paramCategoryEnum.set('LINK', 'link'); + paramCategoryEnum.set('WANT', 'want'); if (executeModeEnum.has(enumValue)) { return executeModeEnum.get(enumValue); + } else if (paramCategoryEnum.has(enumValue)) { + return paramCategoryEnum.get(enumValue); } else { throw Error(`${UNSUPPORTED_PARSE_ERROR.toString()}, cause param: '${node.text}', invalidDecoratorPath: ${this.currentFilePath}`); } @@ -839,17 +843,17 @@ class ParseIntent { processExecuteModeParam(intentObj: object): void { if (intentObj.executeMode) { - intentObj.executeMode.forEach((item: number, index: number) => { - if (item === 0) { + intentObj.executeMode.forEach((item: string, index: number) => { + if (item === '0') { intentObj.executeMode[index] = 'foreground'; } - if (item === 1) { + if (item === '1') { intentObj.executeMode[index] = 'background'; } - if (item === 2) { + if (item === '2') { intentObj.executeMode[index] = 'uiextension'; } - if (item === 3) { + if (item === '3') { intentObj.executeMode[index] = 'serviceextension'; } }); diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.js.sample index 2767d6d83..c9f0933e9 100644 --- a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.js.sample +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.js.sample @@ -17,21 +17,7 @@ let __generate__Id = 0; function generateId() { return "@InsightIntentEntry_" + ++__generate__Id; } -import { InsightIntentEntry } from "@ohos.app.ability.InsightIntentDecorator"; -const validDataEntry2 = { - abilityName: "EntryAbility", - intentName: "Heeloeqasd155", - keywords: ['123234345', '12345654321'], - domain: "music", - intentVersion: "100000", - displayName: "Home", - icon: $r('app.media.startIcon'), - llmDescription: '123111321', - schema: "work", -}; -class aaaa { - constructor() { - this.entityId = ""; - } +import { InsightIntentEntryExecutor, InsightIntentEntry } from '@ohos.app.ability.InsightIntentDecorator'; +export default class PlayMusicDemo extends InsightIntentEntryExecutor { } //# sourceMappingURL=@InsightIntentEntry.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.ets index db529c4dc..8e6a3bc2c 100644 --- a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.ets +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntry/@InsightIntentEntry.ets @@ -13,22 +13,20 @@ * limitations under the License. */ -import { EntryIntentDecoratorInfo,InsightIntentEntry } from "@ohos.app.ability.InsightIntentDecorator"; -import { insightIntent } from "@kit.AbilityKit"; +import { InsightIntentEntryExecutor,InsightIntentEntry } from '@ohos.app.ability.InsightIntentDecorator'; -const validDataEntry2: EntryIntentDecoratorInfo = { - abilityName : "EntryAbility", - intentName: "Heeloeqasd155", - keywords: ['123234345', '12345654321'], - domain: "music", - intentVersion: "100000", - displayName: "Home", - icon: $r('app.media.startIcon'), - llmDescription: '123111321', - schema: "work", -}; +@InsightIntentEntry({ + intentName: 'PlayMusic', + domain: 'MusicDomain', + intentVersion: '1.0.1', + displayName: '播放歌曲', + displayDescription: '播放音乐意图', + icon: $r("app.media.app_icon"), + llmDescription: '支持传递歌曲名称,播放音乐', + keywords: ['音乐播放', '播放歌曲', 'PlayMusic'], + abilityName: "EntryAbility", + executeMode: [1], +}) -@InsightIntentEntry(validDataEntry2) -class aaaa implements insightIntent.IntentEntity{ - entityId: string = ""; +export default class PlayMusicDemo extends InsightIntentEntryExecutor { } \ No newline at end of file -- Gitee From fa2c8043bed129977623b94b55a7181150b192bb Mon Sep 17 00:00:00 2001 From: zhanghang Date: Mon, 26 May 2025 20:32:20 +0800 Subject: [PATCH 074/140] Add focus wrap mode for list tools Signed-off-by: zhanghang --- compiler/components/list.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/components/list.json b/compiler/components/list.json index d29633431..eaf8e120e 100644 --- a/compiler/components/list.json +++ b/compiler/components/list.json @@ -9,6 +9,6 @@ "alignListItem", "nestedScroll", "friction", "contentStartOffset", "contentEndOffset", "childrenMainSize", "maintainVisibleContentPosition", "onScrollFrameBegin", "onScrollStart", "onScrollVisibleContentChange", "flingSpeedLimit", "clipContent", "onWillScroll", "onDidScroll", "scrollBarColor", "scrollBarWidth", "backToTop", - "stackFromEnd" + "stackFromEnd", "focusWrapMode" ] } -- Gitee From c6e8e57f1adc2e9242860994baf251900b4035d9 Mon Sep 17 00:00:00 2001 From: shixiaowei4 Date: Tue, 27 May 2025 10:18:59 +0800 Subject: [PATCH 075/140] Fix warnings Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/ICAQKI Signed-off-by: shixiaowei4 Change-Id: I308dd15b9128e6872a7b10e6b2c32b4a9f284d79 --- compiler/src/fast_build/ark_compiler/module/module_mode.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index 42cdd20dc..a619cb2ef 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -142,7 +142,7 @@ export class ModuleInfo { this.isCommonJs = isCommonJs; this.sourceFile = sourceFile; this.packageName = packageName; - this.originSourceLang = originSourceLang + this.originSourceLang = originSourceLang; } } @@ -482,7 +482,7 @@ export class ModuleMode extends CommonMode { } private addModuleInfoItem(originalFilePath: string, isCommonJs: boolean, extName: string, - metaInfo: Object, moduleInfos: Map, originSourceLang: string = ""): void { + metaInfo: Object, moduleInfos: Map, originSourceLang: string = ''): void { const sourceMapGenerator: SourceMapGenerator = SourceMapGenerator.getInstance(); const isPackageModules = isPackageModulesFile(originalFilePath, this.projectConfig); let filePath: string = originalFilePath; -- Gitee From e032a23e171a7ea17f71e55c585bd5c3c96003ff Mon Sep 17 00:00:00 2001 From: wangcaoyu Date: Wed, 28 May 2025 20:27:04 +0800 Subject: [PATCH 076/140] add error since check Signed-off-by: wangcaoyu --- .../fast_build/system_api/api_check_utils.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index 3d8c49a80..979b04909 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -558,12 +558,32 @@ function checkSinceValue(jsDocTags: readonly ts.JSDocTag[], config: ts.JsDocNode const hasSince: boolean = minSince !== ''; const compatibleSdkVersion: string = projectConfig.compatibleSdkVersion.toString(); + if (!isCompliantSince(minSince) || !isCompliantSince(compatibleSdkVersion)) { + return false; + } if (hasSince && comparePointVersion(compatibleSdkVersion.toString(), minSince) === -1) { config.message = SINCE_TAG_CHECK_ERROER.replace('$SINCE1', minSince).replace('$SINCE2', compatibleSdkVersion); return true; } return false; } + +/** + * Confirm compliance since + * Only major version can be passed in, such as "19"; + * major and minor version can be passed in, such as "19.1"; major minor and patch + * patch version can be passed in, such as "19.1.2" + * the major version be from 1-999 + * the minor version be from 0-999 + * the patch version be from 0-999 + * + * @param {string} since + * @return {boolean} + */ +function isCompliantSince(since: string): boolean { + return /^(?!0\d)[1-9]\d{0,2}(?:\.[1-9]\d{0,2}|\.0){0,2}$\d{0,2}$/.test(since); +} + /** * Determine the necessity of syscap check. * @param jsDocTags -- Gitee From 70da60df1beae9af677609f206c54dd1fa57d54e Mon Sep 17 00:00:00 2001 From: maoruihao Date: Sun, 25 May 2025 10:43:57 +0800 Subject: [PATCH 077/140] Optimize redundant checker for ArkUI Signed-off-by: maoruihao --- .../ets_ui/rollup-plugin-ets-typescript.ts | 6 +- .../fast_build/system_api/api_check_utils.ts | 5 +- compiler/src/process_component_build.ts | 34 ++++++--- compiler/src/process_component_member.ts | 76 +++++++++++++------ compiler/src/process_custom_component.ts | 8 +- compiler/src/process_import.ts | 11 ++- compiler/src/utils.ts | 52 +++++++++++++ compiler/src/validate_ui_syntax.ts | 23 ++++-- .../@objectLink/@objectLink.js.sample | 25 +++++- .../@state/@state.js.sample | 16 ++++ .../@objectLink/@objectLink.ets | 12 +++ .../@state/@state.ets | 2 + 12 files changed, 217 insertions(+), 53 deletions(-) diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index 5658f3b98..847580a73 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -39,7 +39,8 @@ import { resetUtils, getResolveModules, toUnixPath, - getBelongModuleInfo + getBelongModuleInfo, + CurrentProcessFile } from '../../utils'; import { preprocessExtend, @@ -375,6 +376,7 @@ function getArkoalaTsProgram(program: ts.Program): ts.Program { } async function transform(code: string, id: string) { + CurrentProcessFile.setIsProcessingFileETS(id); const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsTransform', 'transform'); if (!filter(id)) { return null; @@ -505,7 +507,7 @@ async function transform(code: string, id: string) { } else { const uiKitrecordInfo = MemoryMonitor.recordStage(MemoryDefine.GLOBAL_PROGRAM_UI_KIT); const eventTransformNodes = createAndStartEvent(eventTsProgramEmit, 'transformNodes'); - const emitResolver: ts.EmitResolver = globalProgram.checker.getEmitResolver(outFile(tsProgram.getCompilerOptions()) ? + const emitResolver: ts.EmitResolver | undefined = CurrentProcessFile.getChecker()?.getEmitResolver(outFile(tsProgram.getCompilerOptions()) ? undefined : targetSourceFile, undefined); metaInfo.checker = tsProgram.getTypeChecker(); transformResult = ts.transformNodes(emitResolver, tsProgram.getEmitHost?.(), ts.factory, diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index 3d8c49a80..984265d39 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -29,7 +29,8 @@ import { import { LogType, LogInfo, - IFileLog + IFileLog, + CurrentProcessFile } from '../../utils'; import { type ResolveModuleInfo } from '../../ets_checker'; import { @@ -225,7 +226,7 @@ export function checkTypeReference(node: ts.TypeReferenceNode, transformLog: IFi const fileName: string = transformLog.sourceFile.fileName; const currentTypeName: string = node.getText(); if (/(?= 11 && ts.isPropertyAccessExpression(node) && - node.name && ts.isIdentifier(node.name) && node.name.escapedText.toString() === WRAPBUILDER_BUILDERPROP && - typeAtLocation && typeAtLocation.symbol && typeAtLocation.symbol.escapedName === WRAPPEDBUILDER_CLASS) { - return true; + if (!( + projectConfig.minAPIVersion >= 11 && + ts.isPropertyAccessExpression(node) && + node.name && ts.isIdentifier(node.name) && + node.name.escapedText.toString() === WRAPBUILDER_BUILDERPROP + )) { + return false; + } + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (checker) { + const type: ts.Type | ts.Type[] = + findNonNullType(checker.getTypeAtLocation(node.expression)); + if (Array.isArray(type)) { + return false; + } + return type.symbol && type.symbol.escapedName === WRAPPEDBUILDER_CLASS; } return false; } @@ -2918,8 +2931,9 @@ function isRegularAttrNode(node: ts.Expression): boolean { if (enumCollection.has(node.expression.escapedText.toString())) { return true; } - if (globalProgram.checker) { - const type: ts.Type = globalProgram.checker.getTypeAtLocation(node); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (checker) { + const type: ts.Type = checker.getTypeAtLocation(node); /* Enum */ if (type.flags & (32 | 1024)) { return true; @@ -3422,7 +3436,7 @@ function isWrappedBuilderExpression(node: ts.ExpressionStatement): boolean { function judgeBuilderType(node: ts.ExpressionStatement): boolean { let checker: ts.TypeChecker; if (globalProgram.program) { - checker = globalProgram.program.getTypeChecker(); + checker = CurrentProcessFile.getChecker(globalProgram.program); } else if (globalProgram.watchProgram) { checker = globalProgram.watchProgram.getCurrentProgram().getProgram().getTypeChecker(); } diff --git a/compiler/src/process_component_member.ts b/compiler/src/process_component_member.ts index 9bd793f75..dc65a1c1c 100644 --- a/compiler/src/process_component_member.ts +++ b/compiler/src/process_component_member.ts @@ -95,7 +95,9 @@ import { LogType, LogInfo, componentInfo, - storedFileInfo + storedFileInfo, + findNonNullType, + CurrentProcessFile } from './utils'; import { createReference, @@ -979,8 +981,9 @@ function manageLocalStorageComponents(node: ts.CallExpression, argumentsArray: t } export function isLocalStorageParameter(node: ts.CallExpression): boolean { - const resolvedSignature = globalProgram.checker?.getResolvedSignature ? - globalProgram.checker.getResolvedSignature(node) : undefined; + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const resolvedSignature = checker?.getResolvedSignature ? + checker.getResolvedSignature(node) : undefined; return resolvedSignature && resolvedSignature.parameters && resolvedSignature.parameters.length === 1 && resolvedSignature.parameters[0].escapedName === '##storage'; } @@ -1101,11 +1104,11 @@ export function isSimpleType(typeNode: ts.TypeNode, program: ts.Program, log?: L typeNode = typeNode || ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword); let checker: ts.TypeChecker; if (globalProgram.program) { - checker = globalProgram.program.getTypeChecker(); + checker = CurrentProcessFile.getChecker(globalProgram.program); } else if (globalProgram.watchProgram) { checker = globalProgram.watchProgram.getCurrentProgram().getProgram().getTypeChecker(); } else if (program) { - checker = program.getTypeChecker(); + checker = CurrentProcessFile.getChecker(program); } return getDeclarationType(typeNode, checker, log); } @@ -1118,28 +1121,42 @@ function getDeclarationType(typeNode: ts.TypeNode, checker: ts.TypeChecker, log: enumCollection.has(typeNode.typeName.escapedText.toString())) { return true; } - if (checker) { - const type: ts.Type = checker.getTypeFromTypeNode(typeNode); + if (!checker) { + return false; + } + const type: ts.Type | ts.Type[] = findNonNullType(checker.getTypeFromTypeNode(typeNode)); + if (!Array.isArray(type)) { /* Enum */ if (type.flags & (32 | 1024)) { return true; } - // @ts-ignore if (type.types && type.types.length) { - // @ts-ignore const types = type.types; let referenceType: boolean = false; for (let i = 0; i < types.length; i++) { - if (!isBasicType(types[i].flags)) { - referenceType = true; - } + referenceType = referenceType || !isBasicType(types[i].flags); + } + return !referenceType; + } + return false; + } + for (let i = 0; i < type.length; i++) { + if (isBasicType(type[i].flags)) { + continue; + } + if (type[i].types && type[i].types.length) { + const types = type[i].types; + let referenceType: boolean = false; + for (let j = 0; j < types.length; j++) { + referenceType = referenceType || !isBasicType(types[j].flags); } if (!referenceType) { - return true; + continue; } } + return false; } - return false; + return true; } export function isBasicType(flags: number): boolean { @@ -1375,18 +1392,31 @@ function updateSynchedPropertyNesedObjectPU(nameIdentifier: ts.Identifier, // check @ObjectLink type Non basic types and @Observedv2. function checkObjectLinkType(typeNode: ts.TypeNode): boolean { - if (globalProgram.checker) { - const type: ts.Type = globalProgram.checker.getTypeFromTypeNode(typeNode); - const isPropertyDeclaration: boolean = typeNode.parent && ts.isPropertyDeclaration(typeNode.parent); - if (isPropertyDeclaration) { - if (type.types && type.types.length) { - return checkTypes(type); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (!checker) { + return false; + } + const isPropertyDeclaration: boolean = typeNode.parent && ts.isPropertyDeclaration(typeNode.parent); + if (!isPropertyDeclaration) { + return false; + } + const type: ts.Type | ts.Type[] = findNonNullType(checker.getTypeFromTypeNode(typeNode)); + if (Array.isArray(type)) { + let res = true; + for (let i = 0; i < type.length; i++) { + if (type[i].types && type[i].types.length) { + res = res && checkTypes(type[i]); } else { - return !(isObservedV2(type) || isAllowedTypeForBasic(type.flags) || isFunctionType(type)); - } + res = res && (!(isObservedV2(type[i]) || isAllowedTypeForBasic(type[i].flags) || isFunctionType(type[i]))); + } } + return res; + } + if (type.types && type.types.length) { + return checkTypes(type); + } else { + return !(isObservedV2(type) || isAllowedTypeForBasic(type.flags) || isFunctionType(type)); } - return false; } // check union type. diff --git a/compiler/src/process_custom_component.ts b/compiler/src/process_custom_component.ts index 62d7629af..7aaec808e 100644 --- a/compiler/src/process_custom_component.ts +++ b/compiler/src/process_custom_component.ts @@ -100,7 +100,8 @@ import { LogType, LogInfo, componentInfo, - storedFileInfo + storedFileInfo, + CurrentProcessFile } from './utils'; import { bindComponentAttr, @@ -485,9 +486,10 @@ function isForbiddenTypeToComponentV1(type: ts.Type): boolean { function isForbiddenAssignToComponentV2(item: ts.PropertyAssignment, itemName: string, info: ChildAndParentComponentInfo): boolean { + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); if (!info.parentStructInfo.isComponentV2 && info.updatePropsDecoratorsV2.includes(itemName) && - isObervedProperty(item.initializer, info) && globalProgram.strictChecker) { - const type: ts.Type = globalProgram.strictChecker.getTypeAtLocation(item.initializer); + isObervedProperty(item.initializer, info) && checker) { + const type: ts.Type = checker.getTypeAtLocation(item.initializer); return !(isAllowedTypeToComponentV2(type) || isForbiddenTypeToComponentV1(type) || !(isObservedV2(type) || isFunctionType(type))); } return false; diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index bdfbb6886..2eac04c54 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -63,6 +63,7 @@ import { regularStaticCollection } from './validate_ui_syntax'; import { + CurrentProcessFile, getExtensionIfUnfullySpecifiedFilepath, hasDecorator, LogInfo, @@ -789,9 +790,10 @@ export function processImportModule(node: ts.ImportDeclaration, pageFile: string function getDefinedNode(importSymbol: ts.Symbol, realSymbol: ts.Symbol, originNode: ts.Node, usedNode: ts.Identifier, pageInfo: PageInfo, share: object = null): void { - importSymbol = globalProgram.checker.getSymbolAtLocation(usedNode); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + importSymbol = checker?.getSymbolAtLocation(usedNode); if (importSymbol) { - realSymbol = globalProgram.checker.getAliasedSymbol(importSymbol); + realSymbol = checker?.getAliasedSymbol(importSymbol); } else { realSymbol = null; } @@ -817,7 +819,7 @@ function getIntegrationNodeInfo(originNode: ts.Node, usedNode: ts.Identifier, ex pageInfo: PageInfo, share: object = null): void { for (const usedSymbol of exportsMap) { try { - originNode = globalProgram.checker.getAliasedSymbol(usedSymbol[1]).declarations[0]; + originNode = CurrentProcessFile.getChecker()?.getAliasedSymbol(usedSymbol[1]).declarations[0]; } catch (e) { if (usedSymbol[1] && usedSymbol[1].declarations) { for (let i = 0; i < usedSymbol[1].declarations.length; i++) { @@ -834,7 +836,8 @@ function getIntegrationNodeInfo(originNode: ts.Node, usedNode: ts.Identifier, ex function exportAllManage(originNode: ts.Node, usedNode: ts.Identifier, pageInfo: PageInfo, share: object = null): void { let exportOriginNode: ts.Node; if (!originNode.exportClause && originNode.moduleSpecifier && ts.isStringLiteral(originNode.moduleSpecifier)) { - const exportSymbol: ts.Symbol = globalProgram.checker.getSymbolAtLocation(originNode.moduleSpecifier); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const exportSymbol: ts.Symbol = checker?.getSymbolAtLocation(originNode.moduleSpecifier); if (exportSymbol && exportSymbol.declarations) { exportOriginNode = exportSymbol.declarations[0]; } else { diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 1cf080059..7b0a287a9 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -1332,4 +1332,56 @@ export function getBelongModuleInfo(filePath: string, modulePathMap: Object, pro moduleName: '', belongModulePath: projectRootPath }; +} + +/** + * Eliminate null in type + * + * @param { ts.Type } type + * @returns { ts.Type | ts.Type[] } + */ +export function findNonNullType(type: ts.Type): ts.Type | ts.Type[] { + if (!type.isUnion() || !(type.types && type.types.length)) { + return type; + } + const filteredTypes: ts.Type[] = type.types.filter((t) => { + return t.flags && !(t.flags & ts.TypeFlags.Nullable); + }); + if (filteredTypes.length === 1) { + return filteredTypes[0]; + } + return filteredTypes; +} + +/** + * Manage File type and checker + */ +export class CurrentProcessFile { + private static isProcessingFileETS: boolean = false; + + /** + * Get checker according to file type + * + * @param { ts.Program? } program + * @returns { ts.TypeChecker | undefined } + */ + static getChecker(program?: ts.Program): ts.TypeChecker | undefined { + if (CurrentProcessFile.isProcessingFileETS) { + return (program ?? globalProgram.program)?.getLinterTypeChecker(); + } + return (program ?? globalProgram.program)?.getTypeChecker(); + } + + /** + * Record current file type + * + * @param { string } id + */ + static setIsProcessingFileETS(id: string): void { + CurrentProcessFile.isProcessingFileETS = CurrentProcessFile.isETSFile(id); + } + + private static isETSFile(id: string): boolean { + return !!(path.extname(id)?.endsWith('ets')); + } } \ No newline at end of file diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 10bc7a70b..0bbca9308 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -91,7 +91,8 @@ import { addLog, hasDecorator, storedFileInfo, - ExtendResult + ExtendResult, + CurrentProcessFile } from './utils'; import { globalProgram, projectConfig, abilityPagesFullPath } from '../main'; import { @@ -517,7 +518,8 @@ function validatePropertyInStruct(structContext: boolean, decoratorNode: ts.Iden } const classResult: ClassDecoratorResult = new ClassDecoratorResult(); const propertyNode: ts.PropertyDeclaration = getPropertyNodeByDecorator(decoratorNode); - if (propertyNode && propertyNode.type && globalProgram.checker) { + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (propertyNode && propertyNode.type && checker) { validatePropertyType(propertyNode.type, classResult); } let message: string; @@ -547,7 +549,8 @@ function validatePropertyType(node: ts.TypeNode, classResult: ClassDecoratorResu }); } if (ts.isTypeReferenceNode(node) && node.typeName) { - const typeNode: ts.Type = globalProgram.checker.getTypeAtLocation(node.typeName); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const typeNode: ts.Type = checker?.getTypeAtLocation(node.typeName); parsePropertyType(typeNode, classResult); } } @@ -774,7 +777,8 @@ const classMemberDecorators: string[] = [CLASS_TRACK_DECORATOR, CLASS_MIN_TRACK_ function validTypeCallback(node: ts.Identifier): boolean { let isSdkPath: boolean = true; - if (globalProgram.checker && process.env.compileTool === 'rollup') { + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (checker && process.env.compileTool === 'rollup') { const symbolObj: ts.Symbol = getSymbolIfAliased(node); const fileName: string = symbolObj?.valueDeclaration?.getSourceFile()?.fileName; isSdkPath = /@ohos.arkui.*/.test(fileName); @@ -896,7 +900,8 @@ function validateMutilObserved(node: ts.ClassDeclaration, classResult: ClassDeco function parseInheritClass(node: ts.ClassDeclaration, childClassResult: ClassDecoratorResult, sourceFileNode: ts.SourceFile, log: LogInfo[]): void { - if (globalProgram.checker && process.env.compileTool === 'rollup' && node.heritageClauses) { + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + if (checker && process.env.compileTool === 'rollup' && node.heritageClauses) { for (const heritageClause of node.heritageClauses) { if (heritageClause.token === ts.SyntaxKind.ExtendsKeyword && heritageClause.types && heritageClause.types.length) { @@ -927,16 +932,18 @@ function getClassNode(parentType: ts.Node, childClassResult: ClassDecoratorResul function parseShorthandPropertyForClass(node: ts.ShorthandPropertyAssignment, childClassResult: ClassDecoratorResult, childClass: ts.ClassDeclaration, sourceFileNode: ts.SourceFile, log: LogInfo[]): void { - const shortSymbol: ts.Symbol = globalProgram.checker.getShorthandAssignmentValueSymbol(node); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const shortSymbol: ts.Symbol = checker?.getShorthandAssignmentValueSymbol(node); if (shortSymbol && shortSymbol.valueDeclaration && ts.isClassDeclaration(shortSymbol.valueDeclaration)) { validateInheritClassDecorator(shortSymbol.valueDeclaration, childClassResult, childClass, sourceFileNode, log); } } export function getSymbolIfAliased(node: ts.Node): ts.Symbol { - const symbol: ts.Symbol = globalProgram.checker.getSymbolAtLocation(node); + const checker: ts.TypeChecker | undefined = CurrentProcessFile.getChecker(); + const symbol: ts.Symbol = checker?.getSymbolAtLocation(node); if (symbol && (symbol.getFlags() & ts.SymbolFlags.Alias) !== 0) { - return globalProgram.checker.getAliasedSymbol(symbol); + return checker?.getAliasedSymbol(symbol); } return symbol; } diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.js.sample index 247628574..231f33b7d 100644 --- a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.js.sample +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.js.sample @@ -34,6 +34,17 @@ let Model = class Model { Model = __decorate([ Observed ], Model); +let ModelEx = class ModelEx { + constructor(t, c) { + this.text = ''; + this.color = '#00ff00'; + this.text = t; + this.color = c; + } +}; +ModelEx = __decorate([ + Observed +], ModelEx); class CustomText extends ViewPU { constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { super(parent, __localStorage, elmtId, extraInfo); @@ -41,26 +52,34 @@ class CustomText extends ViewPU { this.paramsGenerator_ = paramsLambda; } this.__model = new SynchedPropertyNesedObjectPU(params.model, this, "model"); + this.__modelEx = new SynchedPropertyNesedObjectPU(params.modelEx, this, "modelEx"); this.setInitiallyProvidedValue(params); this.finalizeConstruction(); } setInitiallyProvidedValue(params) { this.__model.set(params.model); + this.__modelEx.set(params.modelEx); } updateStateVars(params) { this.__model.set(params.model); + this.__modelEx.set(params.modelEx); } purgeVariableDependenciesOnElmtId(rmElmtId) { this.__model.purgeDependencyOnElmtId(rmElmtId); + this.__modelEx.purgeDependencyOnElmtId(rmElmtId); } aboutToBeDeleted() { this.__model.aboutToBeDeleted(); + this.__modelEx.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } get model() { return this.__model.get(); } + get modelEx() { + return this.__modelEx.get(); + } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); @@ -69,6 +88,10 @@ class CustomText extends ViewPU { Text.create(this.model.text); }, Text); Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.modelEx.text); + }, Text); + Text.pop(); Row.pop(); } rerender() { @@ -121,7 +144,7 @@ class Parent extends ViewPU { { this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { - let componentCall = new CustomText(this, { model: item }, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ets", line: 44, col: 11 }); + let componentCall = new CustomText(this, { model: item }, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ets", line: 56, col: 11 }); ViewPU.create(componentCall); let paramsLambda = () => { return { diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.js.sample index 1fbe4cce2..f28e2326c 100644 --- a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.js.sample +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.js.sample @@ -23,6 +23,7 @@ class StatePage extends ViewPU { this.paramsGenerator_ = paramsLambda; } this.__counter = new ObservedPropertySimplePU(0, this, "counter"); + this.__counterEx = new ObservedPropertyObjectPU(0, this, "counterEx"); this.setInitiallyProvidedValue(params); this.finalizeConstruction(); } @@ -30,14 +31,19 @@ class StatePage extends ViewPU { if (params.counter !== undefined) { this.counter = params.counter; } + if (params.counterEx !== undefined) { + this.counterEx = params.counterEx; + } } updateStateVars(params) { } purgeVariableDependenciesOnElmtId(rmElmtId) { this.__counter.purgeDependencyOnElmtId(rmElmtId); + this.__counterEx.purgeDependencyOnElmtId(rmElmtId); } aboutToBeDeleted() { this.__counter.aboutToBeDeleted(); + this.__counterEx.aboutToBeDeleted(); SubscriberManager.Get().delete(this.id__()); this.aboutToBeDeletedInternal(); } @@ -47,6 +53,12 @@ class StatePage extends ViewPU { set counter(newValue) { this.__counter.set(newValue); } + get counterEx() { + return this.__counterEx.get(); + } + set counterEx(newValue) { + this.__counterEx.set(newValue); + } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); @@ -55,6 +67,10 @@ class StatePage extends ViewPU { Text.create("counter:" + this.counter); }, Text); Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create("counterEx:" + this.counterEx); + }, Text); + Text.pop(); Column.pop(); } rerender() { diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ets index aaa69b773..c870aef1b 100644 --- a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ets +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ets @@ -23,12 +23,24 @@ class Model { } } +@Observed +class ModelEx { + text : string = ''; + color: string = '#00ff00'; + constructor(t: string, c: string) { + this.text = t; + this.color = c; + } +} + @Component struct CustomText { @ObjectLink model: Model; + @ObjectLink modelEx: Model | ModelEx | undefined | null; build() { Row() { Text(this.model.text) + Text(this.modelEx.text) } } } diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ets index 9cb4b1343..762a2087d 100644 --- a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ets +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ets @@ -16,9 +16,11 @@ @Component struct StatePage { @State counter: number = 0; + @State counterEx: number | undefined | null = 0; build() { Column() { Text("counter:" + this.counter) + Text("counterEx:" + this.counterEx) } } } \ No newline at end of file -- Gitee From 6030d5617770397d2a15b58cafac767772602d8c Mon Sep 17 00:00:00 2001 From: yangbo_404 Date: Thu, 29 May 2025 20:35:05 +0800 Subject: [PATCH 078/140] =?UTF-8?q?=E5=AF=B9=E5=AD=97=E6=AE=B5=E5=81=9A?= =?UTF-8?q?=E9=9D=9E=E6=B3=95=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangbo_404 --- compiler/src/fast_build/system_api/api_check_utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/fast_build/system_api/api_check_utils.ts b/compiler/src/fast_build/system_api/api_check_utils.ts index fe3c6fde4..64c268fa3 100644 --- a/compiler/src/fast_build/system_api/api_check_utils.ts +++ b/compiler/src/fast_build/system_api/api_check_utils.ts @@ -367,7 +367,7 @@ export function getJsDocNodeCheckConfig(fileName: string, sourceFileName: string } if (projectConfig.isCrossplatform) { needCheckResult = true; - const logType: ts.DiagnosticCategory = !projectConfig.ignoreCrossplatformCheck ? ts.DiagnosticCategory.Error : + const logType: ts.DiagnosticCategory = projectConfig.ignoreCrossplatformCheck !== true ? ts.DiagnosticCategory.Error : ts.DiagnosticCategory.Warning; checkConfigArray.push(getJsDocNodeCheckConfigItem([CROSSPLATFORM_TAG_CHECK_NAME], CROSSPLATFORM_TAG_CHECK_ERROER, false, logType, '', true)); -- Gitee From e3dbd2a035f78891c952a7b6712c83eef9f0bcaa Mon Sep 17 00:00:00 2001 From: Bojiang Date: Wed, 28 May 2025 16:42:35 +0800 Subject: [PATCH 079/140] jiangbo91@huawei.com Signed-off-by: Bojiang Change-Id: If8e047bdb7b06f9828fca4fb063136d5949d693e --- compiler/src/process_ui_syntax.ts | 30 +++++++---- .../animatableExtend.js.sample | 7 +++ .../@extend/@extend.js.sample | 36 +++++++++++-- .../@AnimatableExtend/animatableExtend.ets | 14 ++++++ .../render_decorator/@extend/@extend.ets | 50 +++++++++++++++++-- 5 files changed, 119 insertions(+), 18 deletions(-) diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 9b9e46459..745b53a78 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -1015,12 +1015,12 @@ function processExtend(node: ts.FunctionDeclaration, log: LogInfo[], node.parameters, ts.factory.createToken(ts.SyntaxKind.VoidKeyword), isOriginalExtend(node.body) ? ts.factory.updateBlock(node.body, statementArray) : bodynode); } - if (componentName && node.body && node.body.statements.length) { + if (componentName && node.body) { const statementArray: ts.Statement[] = []; let bodynode: ts.Block; if (decoratorName === COMPONENT_EXTEND_DECORATOR) { - const attrSet: ts.CallExpression = node.body.statements[0].expression; - if (isOriginalExtend(node.body)) { + if (isOriginalExtend(node.body) && node.body.statements.length) { + const attrSet: ts.CallExpression = node.body.statements[0].expression; const changeCompName: ts.ExpressionStatement = ts.factory.createExpressionStatement(processExtendBody(attrSet)); bindComponentAttr(changeCompName as ts.ExpressionStatement, ts.factory.createIdentifier(componentName), statementArray, log); @@ -1040,15 +1040,10 @@ function processExtend(node: ts.FunctionDeclaration, log: LogInfo[], ts.factory.updateBlock(node.body, statementArray) : bodynode); } if (decoratorName === COMPONENT_ANIMATABLE_EXTEND_DECORATOR) { - bindComponentAttr(node.body.statements[0], - ts.factory.createIdentifier(componentName), statementArray, log); - return ts.factory.updateFunctionDeclaration(node, ts.getModifiers(node), node.asteriskToken, - node.name, node.typeParameters, - [...node.parameters, ...createAnimatableParameterNode()], ts.factory.createToken(ts.SyntaxKind.VoidKeyword), - ts.factory.updateBlock(node.body, createAnimatableBody(componentName, node.name, - node.parameters, statementArray))); + return processAnimatableExtend(node, statementArray, componentName, log); } } + function traverseExtendExpression(node: ts.Node): ts.Node { if (ts.isExpressionStatement(node) && isDollarNode(node, componentName)) { const changeCompName: ts.ExpressionStatement = @@ -1062,6 +1057,21 @@ function processExtend(node: ts.FunctionDeclaration, log: LogInfo[], return undefined; } +// builder AnimatableExtend function content. +function processAnimatableExtend(node: ts.FunctionDeclaration, statementArray: ts.Statement[], componentName: string, log: LogInfo[]): ts.FunctionDeclaration { + if (node.body.statements.length) { + bindComponentAttr(node.body.statements[0], + ts.factory.createIdentifier(componentName), statementArray, log); + } + return ts.factory.updateFunctionDeclaration(node, ts.getModifiers(node), node.asteriskToken, + node.name, node.typeParameters, + [...node.parameters, ...createAnimatableParameterNode()], + ts.factory.createToken(ts.SyntaxKind.VoidKeyword), + ts.factory.updateBlock(node.body, + node.body.statements.length ? createAnimatableBody(componentName, node.name, node.parameters, statementArray) : [] + )); +} + function createAnimatableParameterNode(): ts.ParameterDeclaration[] { return [ ts.factory.createParameterDeclaration( diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.js.sample index 3e88d1457..9413e0169 100644 --- a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.js.sample +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.js.sample @@ -16,6 +16,7 @@ if (!("finalizeConstruction" in ViewPU.prototype)) { Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); } +// @AnimatableExtend base use case function animatablePoints(points, elmtId, isInitialRender, parent) { if (isInitialRender) { Polyline.createAnimatableProperty("animatablePoints", points, (points) => { @@ -33,6 +34,8 @@ function animatablePoints(points, elmtId, isInitialRender, parent) { Polyline.updateAnimatableProperty("animatablePoints", points); } } +function animatablePointsEmpty(points, elmtId, isInitialRender, parent) { +} function attributeExtend(elmtId, isInitialRender, parent) { if (isInitialRender) { Text.createAnimatableProperty("attributeExtend", () => { @@ -48,6 +51,8 @@ function attributeExtend(elmtId, isInitialRender, parent) { Text.updateAnimatableProperty("attributeExtend"); } } +function attributeExtendEmpty(elmtId, isInitialRender, parent) { +} class HomeComponent extends ViewPU { constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { super(parent, __localStorage, elmtId, extraInfo); @@ -78,6 +83,7 @@ class HomeComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Polyline.create(); animatablePoints(this.points, elmtId, isInitialRender, this); + animatablePointsEmpty(this.points, elmtId, isInitialRender, this); Polyline.strokeWidth(3); Polyline.height(100); Polyline.width(100); @@ -85,6 +91,7 @@ class HomeComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hello"); attributeExtend(elmtId, isInitialRender, this); + attributeExtendEmpty(elmtId, isInitialRender, this); }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@extend/@extend.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@extend/@extend.js.sample index 343862355..604c62acf 100644 --- a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@extend/@extend.js.sample +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@extend/@extend.js.sample @@ -16,6 +16,7 @@ if (!("finalizeConstruction" in ViewPU.prototype)) { Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); } +// @Extend base use case function __Text__fancy(color) { Text.backgroundColor(color); } @@ -23,13 +24,24 @@ function __Text__superFancy(size) { Text.fontSize(size); __Text__fancy(Color.Red); } -function __Button__fancybut(color) { +function __Button__fancybutParam(color) { Button.backgroundColor(color); Button.height(100); ViewStackProcessor.visualState("normal"); Button.width(200); ViewStackProcessor.visualState(); } +function __Button__fancybut() { + Button.backgroundColor('red'); + Button.height(100); + ViewStackProcessor.visualState("normal"); + Button.width(200); + ViewStackProcessor.visualState(); +} +function __Button__fancybutParamEmpty(color) { +} +function __Button__fancybutEmpty() { +} class FancyUse extends ViewPU { constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { super(parent, __localStorage, elmtId, extraInfo); @@ -68,7 +80,10 @@ class FancyUse extends ViewPU { Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("Fancy Button"); - __Button__fancybut(Color.Green); + __Button__fancybutParam(Color.Green); + __Button__fancybut(); + __Button__fancybutParamEmpty(Color.Green); + __Button__fancybutEmpty(); }, Button); Button.pop(); Row.pop(); @@ -77,7 +92,10 @@ class FancyUse extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - __Text__fancytext(24); + __Text__fancytextParam(24); + __Text__fancytextParamEmpty(24); + __Text__fancytext(); + __Text__fancytextEmpty(); }, Text); Text.pop(); Row.pop(); @@ -90,10 +108,20 @@ class FancyUse extends ViewPU { return "FancyUse"; } } -function __Text__fancytext(fontSize) { +function __Text__fancytextParam(fontSize) { Text.fontColor(Color.Red); Text.fontSize(fontSize); Text.fontStyle(FontStyle.Italic); } +function __Text__fancytextParamEmpty(fontSize) { +} +function __Text__fancytext() { + Text.fontColor(Color.Red); + Text.fontSize(30); + Text.fontStyle(FontStyle.Italic); +} +function __Text__fancytextEmpty() { +} + registerNamedRoute(() => new FancyUse(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/render_decorator/@extend/@extend", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@extend/@extend", integratedHsp: "false", moduleType: "followWithHap" }); //# sourceMappingURL=@extend.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ets index 2d57055a3..2d85919cf 100644 --- a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ets +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ets @@ -12,17 +12,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +// @AnimatableExtend base use case @AnimatableExtend(Polyline) function animatablePoints(points: number) { .strokeOpacity(points) .backgroundColor(Color.Red) } +@AnimatableExtend(Polyline) +function animatablePointsEmpty(points: number) { + +} + @AnimatableExtend(Text) function attributeExtend() { .fontSize(50) } +@AnimatableExtend(Text) +function attributeExtendEmpty() { + +} + @Entry @Component struct HomeComponent { @@ -32,11 +44,13 @@ struct HomeComponent { Column() { Polyline() .animatablePoints(this.points) + .animatablePointsEmpty(this.points) .strokeWidth(3) .height(100) .width(100) Text("hello") .attributeExtend() + .attributeExtendEmpty() } } } \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@extend/@extend.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@extend/@extend.ets index 9c09e2ad9..f988256d3 100644 --- a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@extend/@extend.ets +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/render_decorator/@extend/@extend.ets @@ -12,6 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +// @Extend base use case @Extend Text.fancy(color:string){ .backgroundColor(color) } @@ -21,7 +23,7 @@ .fancy(Color.Red) } -@Extend(Button) function fancybut(color:string|Color){ +@Extend(Button) function fancybutParam(color:string|Color){ .backgroundColor(color) .height(100) .stateStyles({ @@ -31,6 +33,24 @@ }) } +@Extend(Button) function fancybut(){ + .backgroundColor('red') + .height(100) + .stateStyles({ + normal: { + .width(200) + } + }) +} + +@Extend(Button) function fancybutParamEmpty(color:string|Color){ + +} + +@Extend(Button) function fancybutEmpty(){ + +} + @Entry @Component struct FancyUse { @@ -39,18 +59,40 @@ struct FancyUse { Row() { Text("Just Fancy").fancy(Color.Yellow) Text("Super Fancy Text").superFancy(24) - Button("Fancy Button").fancybut(Color.Green) + Button("Fancy Button") + .fancybutParam(Color.Green) + .fancybut() + .fancybutParamEmpty(Color.Green) + .fancybutEmpty() + } Row({ space: 10 }) { Text("Fancy") - .fancytext(24) + .fancytextParam(24) + .fancytextParamEmpty(24) + .fancytext() + .fancytextEmpty() } } } } -@Extend(Text) function fancytext(fontSize: number) { +@Extend(Text) function fancytextParam(fontSize: number) { .fontColor(Color.Red) .fontSize(fontSize) .fontStyle(FontStyle.Italic) +} + +@Extend(Text) function fancytextParamEmpty(fontSize: number) { + +} + +@Extend(Text) function fancytext() { + .fontColor(Color.Red) + .fontSize(30) + .fontStyle(FontStyle.Italic) +} + +@Extend(Text) function fancytextEmpty() { + } \ No newline at end of file -- Gitee From cd43f4a5a39c6724bab9d77838048425f2102d50 Mon Sep 17 00:00:00 2001 From: sunyichen Date: Fri, 30 May 2025 14:48:13 +0800 Subject: [PATCH 080/140] Handle outside module imports for singlefile emit Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/ICAKFP Signed-off-by: sunyichen Change-Id: I3952702d6968719cdb6697bc3b647f397576b5eb --- compiler/src/ark_utils.ts | 6 +++--- .../ark_compiler/rollup-plugin-gen-abc.ts | 14 ++++++++++---- .../ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts | 12 ++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index a9f1f4eae..52bba5f82 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -131,7 +131,7 @@ export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: O `Failed to get a resolved OhmUrl for "${filePath}" imported by "${importerFile}".`, '', [`Check whether the "${pkgName}" module which ${filePath} belongs to is correctly configured.`, - 'Check the corresponding file name is correct(including case-sensitivity).'] + `Check if the corresponding file name "${filePath}" is correct(including case-sensitivity).`] ); logger.printError(errInfo); return filePath; @@ -231,7 +231,7 @@ function processPackageDir(params: Object): string { `Failed to get a resolved OhmUrl for "${originalFilePath}" imported by "${importerFile}".`, '', [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, - 'Check the corresponding file name is correct(including case-sensitivity).'] + `Check if the corresponding file name "${originalFilePath}" is correct(including case-sensitivity).`] ); logger.printError(errInfo); return originalFilePath; @@ -270,7 +270,7 @@ function processPackageDir(params: Object): string { `Failed to get a resolved OhmUrl for "${originalFilePath}" imported by "${importerFile}".`, '', [`Check whether the module which ${originalFilePath} belongs to is correctly configured.`, - 'Check the corresponding file name is correct(including case-sensitivity).'] + `Check if the corresponding file name "${originalFilePath}" is correct(including case-sensitivity).`] ); logger.printError(errInfo); return originalFilePath; diff --git a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts index c537de191..fcda45826 100644 --- a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts +++ b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts @@ -47,11 +47,17 @@ export function genAbc() { shouldInvalidCache: shouldInvalidCache, transform: transformForModule, moduleParsed(moduleInfo: moduleInfoType): void { - // process single ModuleSourceFile - if (this.share.projectConfig.singleFileEmit) { - const hookEventFactory: CompileEvent | undefined = getHookEventFactory(this.share, 'genAbc', 'moduleParsed'); - ModuleSourceFile.processSingleModuleSourceFile(this, moduleInfo.id, hookEventFactory); + // Process single ModuleSourceFile + if (!this.share.projectConfig.singleFileEmit) { + return; } + // Skip processing if a module outside the project is referenced but not configured in build_config.json; + // Hvigor will report the error at beforeBuildEnd. + if (moduleInfo?.meta?.outsideModuleImports && Array.isArray(moduleInfo.meta.outsideModuleImports)) { + return; + } + const hookEventFactory: CompileEvent | undefined = getHookEventFactory(this.share, 'genAbc', 'moduleParsed'); + ModuleSourceFile.processSingleModuleSourceFile(this, moduleInfo.id, hookEventFactory); }, beforeBuildEnd: { // [pre] means this handler running in first at the stage of beforeBuildEnd. diff --git a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts index 2e6514a7e..fb70f5f06 100644 --- a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts +++ b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts @@ -202,7 +202,7 @@ mocha.describe('generate ohmUrl', function () { 'Failed to get a resolved OhmUrl for "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', - 'Check the corresponding file name is correct(including case-sensitivity).'] + 'Check if the corresponding file name "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" is correct(including case-sensitivity).'] ); const logger = CommonLogger.getInstance(this.rollup); const stub = sinon.stub(logger.getLoggerFromErrorCode(errInfo.code), 'printError'); @@ -224,7 +224,7 @@ mocha.describe('generate ohmUrl', function () { 'Failed to get a resolved OhmUrl for "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', - 'Check the corresponding file name is correct(including case-sensitivity).'] + 'Check if the corresponding file name "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" is correct(including case-sensitivity).'] ); CommonLogger.destroyInstance(); const getHvigorConsoleLogger = this.rollup.share.getHvigorConsoleLogger; @@ -252,7 +252,7 @@ mocha.describe('generate ohmUrl', function () { '"/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', - 'Check the corresponding file name is correct(including case-sensitivity).'] + 'Check if the corresponding file name "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" is correct(including case-sensitivity).'] ); const logger = CommonLogger.getInstance(this.rollup); const stub = sinon.stub(logger.getLoggerFromErrorCode(errInfo.code), 'printError'); @@ -276,7 +276,7 @@ mocha.describe('generate ohmUrl', function () { '"/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', - 'Check the corresponding file name is correct(including case-sensitivity).'] + 'Check if the corresponding file name "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" is correct(including case-sensitivity).'] ); CommonLogger.destroyInstance(); const getHvigorConsoleLogger = this.rollup.share.getHvigorConsoleLogger; @@ -983,7 +983,7 @@ mocha.describe('generate ohmUrl', function () { 'Failed to get a resolved OhmUrl for "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the "json5" module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', - 'Check the corresponding file name is correct(including case-sensitivity).'] + 'Check if the corresponding file name "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" is correct(including case-sensitivity).'] ); const logger = CommonLogger.getInstance(this.rollup); const stub = sinon.stub(logger.getLoggerFromErrorCode(errInfo.code), 'printError'); @@ -1015,7 +1015,7 @@ mocha.describe('generate ohmUrl', function () { 'Failed to get a resolved OhmUrl for "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" imported by "importTest.ts".', '', ['Check whether the "json5" module which /testProjectRootPath/entry/oh_modules/json5/dist/index.js belongs to is correctly configured.', - 'Check the corresponding file name is correct(including case-sensitivity).'] + 'Check if the corresponding file name "/testProjectRootPath/entry/oh_modules/json5/dist/index.js" is correct(including case-sensitivity).'] ); CommonLogger.destroyInstance(); const getHvigorConsoleLogger = this.rollup.share.getHvigorConsoleLogger; -- Gitee From 71e476a987078393203f7551d108a687ae1ce13f Mon Sep 17 00:00:00 2001 From: Yenan Date: Tue, 27 May 2025 16:58:13 +0800 Subject: [PATCH 081/140] =?UTF-8?q?extend=E5=87=BD=E6=95=B0=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E4=B8=8E=E7=BB=84=E4=BB=B6=E5=B1=9E=E6=80=A7=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=E6=B7=BB=E5=8A=A0warning=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/src/component_map.ts | 4 +- compiler/src/validate_ui_syntax.ts | 76 ++++++++++++++++++- .../animatableExtendAttributeDuplicate.ets | 46 +++++++++++ .../extendAttributeDuplicate.ets | 46 +++++++++++ .../extendAttributeDuplicate2.ets | 47 ++++++++++++ .../test/transform_ut/helpers/pathConfig.ts | 3 + compiler/test/transform_ut_error.json | 25 ++++++ 7 files changed, 244 insertions(+), 3 deletions(-) create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/animatableExtendAttributeDuplicate.ets create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/extendAttributeDuplicate.ets create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/extendAttributeDuplicate2.ets diff --git a/compiler/src/component_map.ts b/compiler/src/component_map.ts index df454e9f7..f99de2a42 100644 --- a/compiler/src/component_map.ts +++ b/compiler/src/component_map.ts @@ -83,7 +83,7 @@ function addExternalComponents(): void { }) } -const TRANSITION_COMMON_ATTRS: Set = new Set([ +export const TRANSITION_COMMON_ATTRS: Set = new Set([ 'slide', 'translate', 'scale', 'opacity' ]); export const GESTURE_ATTRS: Set = new Set([ @@ -101,7 +101,7 @@ export const forbiddenUseStateType: Set = new Set(['Scroller', 'SwiperSc 'ArcSwiperController' ]); -const FOREACH_ATTRIBUTE = ['onMove']; +export const FOREACH_ATTRIBUTE = ['onMove']; export const INNER_COMPONENT_NAMES: Set = new Set(); export const NO_DEBUG_LINE_COMPONENT: Set = new Set(); export const BUILDIN_CONTAINER_COMPONENT: Set = new Set(); diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 10bc7a70b..05b934ae0 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -82,7 +82,12 @@ import { GLOBAL_CUSTOM_BUILDER_METHOD, INNER_CUSTOM_BUILDER_METHOD, INNER_STYLE_FUNCTION, - INNER_CUSTOM_LOCALBUILDER_METHOD + INNER_CUSTOM_LOCALBUILDER_METHOD, + COMPONENT_MAP, + COMMON_ATTRS, + GESTURE_ATTRS, + TRANSITION_COMMON_ATTRS, + FOREACH_ATTRIBUTE } from './component_map'; import { LogType, @@ -665,6 +670,25 @@ export function methodDecoratorCollect(node: ts.MethodDeclaration | ts.FunctionD } } +/** + * Checker whether the function's name is the same with common attributes + * or the component's private attributes + * @param {string} componentName the component extended by the function + * @param {string} attributeName the name of the extend function + * @return {*} {boolean} whether the function's name is the same with common + * attributes or the component's private attributes + */ +function checkComponentAttrs(componentName: string, attributeName: string): boolean { + if (COMPONENT_MAP[componentName] && COMPONENT_MAP[componentName].attrs) { + // read the private attributes of the extend component + const compSet: Set = new Set(COMPONENT_MAP[componentName].attrs); + const checkSet: Set = new Set([...compSet, ...COMMON_ATTRS, + ...GESTURE_ATTRS, ...TRANSITION_COMMON_ATTRS, ...FOREACH_ATTRIBUTE]); + return checkSet.has(attributeName); + } + return false; +} + function collectStyles(node: ts.FunctionLikeDeclarationBase): void { if (ts.isBlock(node.body) && node.body.statements) { if (ts.isFunctionDeclaration(node)) { @@ -682,6 +706,7 @@ function validateFunction(node: ts.MethodDeclaration | ts.FunctionDeclaration, if (ts.isFunctionDeclaration(node)) { const decorators: readonly ts.Decorator[] = ts.getAllDecorators(node); const decoratorMap: Map = new Map(); + const extendResult: ExtendResult = { decoratorName: '', componentName: '' }; decorators.forEach((item: ts.Decorator) => { const decoratorName: string = item.getText().replace(/\([^\(\)]*\)/, '') .replace(/^@/, '').trim(); @@ -702,6 +727,16 @@ function validateFunction(node: ts.MethodDeclaration | ts.FunctionDeclaration, `'@AnimatableExtend', '@Builder', '@Extend', '@Styles', '@Concurrent' and '@Sendable'.`; addLog(LogType.ERROR, message, node.getStart(), log, sourceFileNode, { code: '10905117' }); } + if (isExtendFunction(node, extendResult) && + (extendResult.decoratorName === CHECK_COMPONENT_EXTEND_DECORATOR) && + checkComponentAttrs(extendResult.componentName, node.name.getText())) { + const message: string = `The '@Extend' function cannot have the same name as` + + ` the built-in style attribute '${node.name.getText()}'` + + ` of the component '${extendResult.componentName}'.`; + checkNameAttrCalled(node) ? + addLog(LogType.ERROR, message, node.getStart(), log, sourceFileNode, { code: '10905360' }) : + addLog(LogType.WARN, message, node.getStart(), log, sourceFileNode); + } } } @@ -715,6 +750,45 @@ function findDuplicateDecoratorFunction(mapKeys: string[], mapValues: number[]): return output; } + +/** + * check whether the extend decorated function is called by itself + * @param {ts.FunctionDeclaration} node + * @return {*} {boolean} if the extend decorated functio is called by itself + */ +function checkNameAttrCalled(node: ts.FunctionDeclaration): boolean { + const functionName: string = node.name.getText(); + if (!node.body.statements.length) { + return false; + } + const startExpression: ts.Node = node.body.statements[0]; + if (ts.isExpressionStatement(startExpression) && + ts.isCallExpression(startExpression.expression)) { + const attrsNames: Set = new Set(); + collectAttrsNames(startExpression.expression, attrsNames); + return attrsNames.has(functionName); + } + return false; +} + + +/** + * collect the attributes called in an extend decorated function + * @param {ts.CallExpression} node + * @param {Set} attrsNames a set used to collect attributes + * @return {*} {void} + */ +function collectAttrsNames(node: ts.CallExpression, attrsNames: Set): void { + if (!ts.isPropertyAccessExpression(node.expression)) { + return; + } + const newNode: ts.PropertyAccessExpression = node.expression; + attrsNames.add(newNode.name.getText()); + if (ts.isCallExpression(newNode.expression)) { + collectAttrsNames(newNode.expression, attrsNames); + } +} + function checkDecorator(sourceFileNode: ts.SourceFile, node: ts.Node, log: LogInfo[], structContext: boolean, classContext: boolean, isObservedClass: boolean, isComponentV2: boolean, isObservedV1Class: boolean, isSendableClass: boolean): void { diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/animatableExtendAttributeDuplicate.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/animatableExtendAttributeDuplicate.ets new file mode 100644 index 000000000..7e9be819b --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/animatableExtendAttributeDuplicate.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022-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. + */ + + /** + * check the situation when AnimatableExtend decorated function has the same name with + * common attributes or the component's private attributes but is not called by itself + */ + + const opacity = (target:Object) =>{ + + } + + @AnimatableExtend(Navigation) + function toolbarConfiguration(){ + .navBarWidth(100) + } + + @Styles + @Styles + function newStyle(){ + .width(100) + } + + @Entry + @Component + struct Index { + @State a:string = ''; + @State new_a:string = 'newaa'; + + build(){ + Row(){ + } + } + } \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/extendAttributeDuplicate.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/extendAttributeDuplicate.ets new file mode 100644 index 000000000..22e60df64 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/extendAttributeDuplicate.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022-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. + */ + + /** + * check the situation when extend decorated function has the same name with + * common attributes or the component's private attributes but is not called by itself + */ + + const opacity = (target:Object) =>{ + + } + + @Extend(Navigation) + function toolbarConfiguration(){ + .width(100) + } + + @Styles + @Styles + function newStyle(){ + .width(100) + } + + @Entry + @Component + struct Index { + @State a:string = ''; + @State new_a:string = 'newaa'; + + build(){ + Row(){ + } + } + } \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/extendAttributeDuplicate2.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/extendAttributeDuplicate2.ets new file mode 100644 index 000000000..6cbb0f472 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/vaildate_ui_syntax/extendAttributeDuplicate2.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022-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. + */ + + /** + * check the situation when extend decorated function has the same name with + * common attributes or the component's private attributes and is called by itself + */ + + const opacity = (target:Object) =>{ + + } + + @Extend(Navigation) + function toolbarConfiguration(){ + .width(100) + .toolbarConfiguration() + } + + @Styles + @Styles + function newStyle(){ + .width(100) + } + + @Entry + @Component + struct Index { + @State a:string = ''; + @State new_a:string = 'newaa'; + + build(){ + Row(){ + } + } + } \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/pathConfig.ts b/compiler/test/transform_ut/helpers/pathConfig.ts index 50a2b87f6..9ed688e8a 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -291,6 +291,9 @@ export const UT_VALIDATE_PAGES: string[] = [ 'Decorators/vaildate_ui_syntax/componentV2BothWithComponent', 'Decorators/vaildate_ui_syntax/ExceededEntry', 'Decorators/vaildate_ui_syntax/ExceededPreview', + 'Decorators/vaildate_ui_syntax/extendAttributeDuplicate', + 'Decorators/vaildate_ui_syntax/extendAttributeDuplicate2', + 'Decorators/vaildate_ui_syntax/animatableExtendAttributeDuplicate', 'Decorators/vaildate_ui_syntax/MethodNoExtend', 'Decorators/vaildate_ui_syntax/mutiDecoratorInComponentV2', 'Decorators/vaildate_ui_syntax/NoChild', diff --git a/compiler/test/transform_ut_error.json b/compiler/test/transform_ut_error.json index e7f94f2d7..a6a0320c0 100644 --- a/compiler/test/transform_ut_error.json +++ b/compiler/test/transform_ut_error.json @@ -354,6 +354,31 @@ "solutions": ["Please make sure that the splash page has one and only one '@Entry' decorator."] } ], + "extendAttributeDuplicate": [ + { + "message": "The '@Extend' function cannot have the same name as the built-in style attribute 'toolbarConfiguration' of the component 'Navigation'.", + "type": "WARN" + }, + { + "message": "Duplicate '@Styles' decorators for function are not allowed.", + "type": "WARN" + } + ], + "extendAttributeDuplicate2": [ + { + "message": "The '@Extend' function cannot have the same name as the built-in style attribute 'toolbarConfiguration' of the component 'Navigation'.", + "type": "ERROR", + "code": "10905360" + }, + { + "message": "Duplicate '@Styles' decorators for function are not allowed.", + "type": "WARN" + } + ], + "animatableExtendAttributeDuplicate": { + "message": "Duplicate '@Styles' decorators for function are not allowed.", + "type": "WARN" + }, "OneEntry": { "message": "A page configured in 'main_pages.json or build-profile.json5' must have one and only one '@Entry' decorator.", "type": "ERROR", -- Gitee From 5dbf940f4025a81ad7d7a3e130423fc839a25388 Mon Sep 17 00:00:00 2001 From: shitao Date: Tue, 3 Jun 2025 17:30:20 +0800 Subject: [PATCH 082/140] Error format where install after build Issue: ICC9BY Signed-off-by: shitao Change-Id: I2f887649150bdb1ad0169ea02ac25deb9bb1bb2d --- .../fast_build/ark_compiler/generate_sourcemap.ts | 12 +++++++++--- .../fast_build/ark_compiler/rollup-plugin-gen-abc.ts | 5 ----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index bedcb3db9..522df4094 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -109,7 +109,7 @@ export class SourceMapGenerator { if ((SourceMapGenerator.instance.projectConfig.hotReload && SourceMapGenerator.instance.projectConfig.watchMode !== 'true') || (SourceMapGenerator.instance.projectConfig.coldReload)) { - isShouldSourceMap = this.projectConfig.isFirstBuild; + isShouldSourceMap = SourceMapGenerator.instance.projectConfig.isFirstBuild; } SourceMapGenerator.instance.isCompileSingle = SourceMapGenerator.instance.isNewSourceMap && @@ -352,8 +352,14 @@ export class SourceMapGenerator { // skip unuse or uncompile in cache continue; } - this.writeOrigin(`,\n${this.formatOrigin(smObj.key, smObj.val)}`); - this.writeTemp(`\n${this.formatTemp(smObj.key, smObj.val)}`); + if (this.isFirstAppend) { + this.isFirstAppend = false; + this.writeOrigin(`{\n${this.formatOrigin(smObj.key, smObj.val)}`); + this.writeTemp(`${this.formatTemp(smObj.key, smObj.val)}`); + } else { + this.writeOrigin(`,\n${this.formatOrigin(smObj.key, smObj.val)}`); + this.writeTemp(`\n${this.formatTemp(smObj.key, smObj.val)}`); + } } if (!this.isFirstAppend) { this.writeOrigin('\n}'); diff --git a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts index fcda45826..f0f4b80e5 100644 --- a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts +++ b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts @@ -51,11 +51,6 @@ export function genAbc() { if (!this.share.projectConfig.singleFileEmit) { return; } - // Skip processing if a module outside the project is referenced but not configured in build_config.json; - // Hvigor will report the error at beforeBuildEnd. - if (moduleInfo?.meta?.outsideModuleImports && Array.isArray(moduleInfo.meta.outsideModuleImports)) { - return; - } const hookEventFactory: CompileEvent | undefined = getHookEventFactory(this.share, 'genAbc', 'moduleParsed'); ModuleSourceFile.processSingleModuleSourceFile(this, moduleInfo.id, hookEventFactory); }, -- Gitee From 2ee331f235df89d979573f173e8fe361a89ca5f6 Mon Sep 17 00:00:00 2001 From: wangcaoyu Date: Wed, 19 Feb 2025 14:18:20 +0800 Subject: [PATCH 083/140] =?UTF-8?q?=E4=BF=AE=E6=94=B9ohos=5Fdeclaration=5F?= =?UTF-8?q?ets=E4=BE=9D=E8=B5=96=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangcaoyu --- BUILD.gn | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 9dd538cb9..88a5392a1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -336,7 +336,8 @@ ohos_copy("ohos_declaration_ets_ark") { deps += [ "//interface/sdk-js:ohos_declaration_ets" ] } - sources = [ root_out_dir + "/ohos_declaration/ohos_declaration_ets" ] + sources = + [ root_out_dir + "/ohos_declaration/${sdk_type}/ohos_declaration_ets" ] outputs = [ target_out_dir + "/../api" ] } -- Gitee From b2f1eb6c2c9250c1b3cb0e7cce0f1ca095e970d1 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Tue, 1 Apr 2025 20:46:35 +0800 Subject: [PATCH 084/140] jiangbo91@huawei.com Signed-off-by: Bojiang Change-Id: I808be817858899aa17ce1c732c94e69a980a70d8 --- BUILD.gn | 15 ++++++++++++--- compiler/build_declarations_file.js | 4 ++-- compiler/build_kitConfigs_file.js | 8 ++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 88a5392a1..8bf020a7a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -14,6 +14,7 @@ import("//build/ohos.gni") import("//build/ohos/ace/ace.gni") import("//build/ohos_var.gni") +import("//build/templates/bpf/ohos_bpf_config.gni") import("//foundation/arkui/ace_engine/ace_config.gni") if (sdk_build_public) { import("//out/sdk-public/public_interface/sdk-js/interface_config.gni") @@ -46,6 +47,11 @@ action("build_ets_loader_library") { ":install_arkguard_tsc", ":server", ] + if (sdk_build_public) { + deps += [ "//out/sdk-public/public_interface/sdk-js:ets_component" ] + } else { + deps += [ "//interface/sdk-js:ets_component" ] + } script = "build_ets_loader_library.py" depfile = "$target_gen_dir/$target_name.d" outputs = [ @@ -63,14 +69,17 @@ action("build_ets_loader_library") { } else { _ace_config_dir = "//prebuilts/ace-toolkit/ets-loader/compiler" } - _declarations_file_dir = "//interface/sdk-js/api/@internal/component/ets" + input_project_dir = "//interface/sdk-js" + if (sdk_build_public || product_name == "ohos-sdk") { + input_project_dir = "//out/sdk-public/public_interface/sdk-js" + } + _declarations_file_dir = + input_project_dir + "/ets/${bpf_inc_out_dir}/ets_component" _kit_configs_file_dir = "//interface/sdk-js/kits" _kit_apis_file_dir = "//interface/sdk-js/api" _arkts_apis_file_dir = "//interface/sdk-js/arkts" isPublic = "false" if (sdk_build_public) { - _declarations_file_dir = - "//out/sdk-public/public_interface/sdk-js/api/@internal/component/ets" _kit_configs_file_dir = "//out/sdk-public/public_interface/sdk-js/kits" _kit_apis_file_dir = "//out/sdk-public/public_interface/sdk-js/api" _arkts_apis_file_dir = "//out/sdk-public/public_interface/sdk-js/arkts" diff --git a/compiler/build_declarations_file.js b/compiler/build_declarations_file.js index 695d29691..d3f4782eb 100644 --- a/compiler/build_declarations_file.js +++ b/compiler/build_declarations_file.js @@ -36,8 +36,8 @@ const addTSAttributeSet = ['AlphabetIndexer', 'Animator', 'Badge', 'Blank', 'But generateTargetFile(process.argv[2], process.argv[3]); function generateTargetFile(filePath, output) { const files = []; - const globalTsFile = path.resolve(filePath, '../../ets/global.d.ts'); - const featureAbilityPath = path.resolve(filePath, '../../../common/full/featureability.d.ts'); + const globalTsFile = path.resolve(filePath, '../ets_internal_api/global.d.ts'); + const featureAbilityPath = path.resolve(filePath, '../internal_full/featureability.d.ts'); const middleTsFile = path.resolve(filePath, 'middle_class.d.ts'); if (fs.existsSync(globalTsFile)) { files.push(globalTsFile); diff --git a/compiler/build_kitConfigs_file.js b/compiler/build_kitConfigs_file.js index cdbfce6a5..af72535e1 100644 --- a/compiler/build_kitConfigs_file.js +++ b/compiler/build_kitConfigs_file.js @@ -104,7 +104,7 @@ function readFile(dir, fileDir) { const status = fs.statSync(filePath); if (status.isDirectory()) { readFile(filePath, fileDir); - } else { + } else if (filePath.endsWith('.d.ts')) { fileDir.push(filePath); } }); @@ -115,12 +115,16 @@ function readSystemApis(dir, fileDir) { files.forEach(file => { const filePath = path.join(dir, file); const status = fs.statSync(filePath); - if (!status.isDirectory()) { + if (!status.isDirectory() && !hasSameApi(filePath)) { fileDir.push(file); } }); } +function hasSameApi(filePath) { + return filePath.endsWith('.d.ets') && fs.existsSync(filePath.replace('.d.ets', '.d.ts')); +} + function mkDir(filePath) { const parent = path.join(filePath, '..'); if (!(fs.existsSync(parent) && !fs.statSync(parent).isFile())) { -- Gitee From 1bec610d8320a9851ad2fc3be68014cf7c31e6b2 Mon Sep 17 00:00:00 2001 From: wangcaoyu Date: Wed, 9 Apr 2025 20:55:45 +0800 Subject: [PATCH 085/140] reset ets1.2 Signed-off-by: wangcaoyu --- BUILD.gn | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 8bf020a7a..5d9a75bfe 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,11 +16,7 @@ import("//build/ohos/ace/ace.gni") import("//build/ohos_var.gni") import("//build/templates/bpf/ohos_bpf_config.gni") import("//foundation/arkui/ace_engine/ace_config.gni") -if (sdk_build_public) { - import("//out/sdk-public/public_interface/sdk-js/interface_config.gni") -} else { - import("//interface/sdk-js/interface_config.gni") -} +import("//interface/sdk-js/interface_config.gni") ets_loader_lib_dir = get_label_info(":build_ets_loader_library", "target_out_dir") + "/lib" @@ -39,6 +35,8 @@ ets_sysResource = get_label_info(":build_ets_sysResource", "target_out_dir") + "/sysResource.js" ets_loader_kit_configs_dir = get_label_info(":build_ets_loader_library", "target_out_dir") + "/kit_configs" +ets_component_dep = "//interface/sdk-js:ets_component" +ets_component_out_dir = get_label_info(ets_component_dep, "target_out_dir") action("build_ets_loader_library") { deps = [ @@ -46,12 +44,11 @@ action("build_ets_loader_library") { ":form_components", ":install_arkguard_tsc", ":server", + "//interface/sdk-js:ets_component", + "//interface/sdk-js:bundle_kits", + "//interface/sdk-js:bundle_arkts", + "//interface/sdk-js:ets_internal_api", ] - if (sdk_build_public) { - deps += [ "//out/sdk-public/public_interface/sdk-js:ets_component" ] - } else { - deps += [ "//interface/sdk-js:ets_component" ] - } script = "build_ets_loader_library.py" depfile = "$target_gen_dir/$target_name.d" outputs = [ @@ -69,22 +66,10 @@ action("build_ets_loader_library") { } else { _ace_config_dir = "//prebuilts/ace-toolkit/ets-loader/compiler" } - input_project_dir = "//interface/sdk-js" - if (sdk_build_public || product_name == "ohos-sdk") { - input_project_dir = "//out/sdk-public/public_interface/sdk-js" - } - _declarations_file_dir = - input_project_dir + "/ets/${bpf_inc_out_dir}/ets_component" - _kit_configs_file_dir = "//interface/sdk-js/kits" - _kit_apis_file_dir = "//interface/sdk-js/api" - _arkts_apis_file_dir = "//interface/sdk-js/arkts" - isPublic = "false" - if (sdk_build_public) { - _kit_configs_file_dir = "//out/sdk-public/public_interface/sdk-js/kits" - _kit_apis_file_dir = "//out/sdk-public/public_interface/sdk-js/api" - _arkts_apis_file_dir = "//out/sdk-public/public_interface/sdk-js/arkts" - isPublic = "true" - } + _declarations_file_dir = ets_component_out_dir + "/${sdk_type}/ets_component" + _kit_configs_file_dir = ets_component_out_dir + "/${sdk_type}/bundle_kits" + _kit_apis_file_dir = root_out_dir + "/ohos_declaration/${sdk_type}/ohos_declaration_ets" + _arkts_apis_file_dir = ets_component_out_dir + "/${sdk_type}/bundle_arkts" _babel_js = _ace_config_dir + "/node_modules/@babel/cli/bin/babel.js" _babel_config_js = _ace_config_dir + "/babel.config.js" @@ -148,7 +133,7 @@ action("build_ets_loader_library") { "--arkts-apis-file-dir", rebase_path(_arkts_apis_file_dir, root_build_dir), "--build-public-sdk", - isPublic, + "${sdk_build_public}", ] } @@ -338,12 +323,7 @@ ohos_copy("ets_loader_ark_codegen") { } ohos_copy("ohos_declaration_ets_ark") { - deps = [] - if (sdk_build_public) { - deps += [ "//out/sdk-public/public_interface/sdk-js:ohos_declaration_ets" ] - } else { - deps += [ "//interface/sdk-js:ohos_declaration_ets" ] - } + deps = [ "//interface/sdk-js:ohos_declaration_ets" ] sources = [ root_out_dir + "/ohos_declaration/${sdk_type}/ohos_declaration_ets" ] -- Gitee From 7f86f0e00fb9a4fb4baf8bdc0e00abc6030a369f Mon Sep 17 00:00:00 2001 From: wangcaoyu Date: Sun, 27 Apr 2025 12:14:03 +0800 Subject: [PATCH 086/140] remove common_api Signed-off-by: wangcaoyu --- BUILD.gn | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 5d9a75bfe..26f24c05a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -331,8 +331,7 @@ ohos_copy("ohos_declaration_ets_ark") { outputs = [ target_out_dir + "/../api" ] } -ohos_copy("ets_loader_ark_hap") { - sources = common_api_src +group("ets_loader_ark_hap") { deps = [ ":ets_loader_ark", ":ets_loader_ark_codegen", @@ -343,8 +342,6 @@ ohos_copy("ets_loader_ark_hap") { ":ets_loader_ark_server", ":ohos_declaration_ets_ark", ] - outputs = [ target_out_dir + "/../../developtools/api/{{source_file_part}}" ] - module_install_name = "" } typescript_dir = get_label_info("//third_party/typescript:build_typescript", -- Gitee From 8e32504f8350dc3be2baa0ac9d4450283e84dc29 Mon Sep 17 00:00:00 2001 From: yangbo_404 Date: Thu, 5 Jun 2025 12:40:12 +0800 Subject: [PATCH 087/140] =?UTF-8?q?=E4=BF=AE=E5=A4=8DGN=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangbo_404 --- BUILD.gn | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 26f24c05a..9023cf7d3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -44,9 +44,9 @@ action("build_ets_loader_library") { ":form_components", ":install_arkguard_tsc", ":server", - "//interface/sdk-js:ets_component", - "//interface/sdk-js:bundle_kits", "//interface/sdk-js:bundle_arkts", + "//interface/sdk-js:bundle_kits", + "//interface/sdk-js:ets_component", "//interface/sdk-js:ets_internal_api", ] script = "build_ets_loader_library.py" @@ -68,7 +68,8 @@ action("build_ets_loader_library") { } _declarations_file_dir = ets_component_out_dir + "/${sdk_type}/ets_component" _kit_configs_file_dir = ets_component_out_dir + "/${sdk_type}/bundle_kits" - _kit_apis_file_dir = root_out_dir + "/ohos_declaration/${sdk_type}/ohos_declaration_ets" + _kit_apis_file_dir = + root_out_dir + "/ohos_declaration/${sdk_type}/ohos_declaration_ets" _arkts_apis_file_dir = ets_component_out_dir + "/${sdk_type}/bundle_arkts" _babel_js = _ace_config_dir + "/node_modules/@babel/cli/bin/babel.js" -- Gitee From 4532c153f7933590e87b4b2aa8ec179230f06606 Mon Sep 17 00:00:00 2001 From: wangcaoyu Date: Thu, 5 Jun 2025 20:39:40 +0800 Subject: [PATCH 088/140] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangcaoyu --- BUILD.gn | 1 - 1 file changed, 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 9023cf7d3..f97a5eb55 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -14,7 +14,6 @@ import("//build/ohos.gni") import("//build/ohos/ace/ace.gni") import("//build/ohos_var.gni") -import("//build/templates/bpf/ohos_bpf_config.gni") import("//foundation/arkui/ace_engine/ace_config.gni") import("//interface/sdk-js/interface_config.gni") -- Gitee From 75c1aa82eb4a47e3c52722e78294c22bdd6e3be7 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Thu, 29 May 2025 17:02:35 +0800 Subject: [PATCH 089/140] Fix atIntent not output to obfusion.txt Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IC66MT Signed-off-by: zhangzezhong --- .../fast_build/ark_compiler/common/ob_config_resolver.ts | 1 + .../fast_build/ark_compiler/common/process_ark_config.ts | 4 ---- .../test/ark_compiler_ut/common/ob_config_resolver.test.ts | 6 ++++++ .../test/ark_compiler_ut/common/process_ark_config.test.ts | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts b/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts index 8da204eff..c77ebcff3 100644 --- a/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts +++ b/compiler/src/fast_build/ark_compiler/common/ob_config_resolver.ts @@ -384,6 +384,7 @@ export function obfuscationPreprocess( ); updateIncrementalCaches(sourceProjectConfig.arkObfuscator); + sourceProjectConfig.arkObfuscator.obfConfigResolver?.emitConsumerConfigFiles(); if (BytecodeObfuscator.enable) { BytecodeObfuscator.getInstance().removeStructProp(); } diff --git a/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts b/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts index a77916061..933eaf2a9 100644 --- a/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts +++ b/compiler/src/fast_build/ark_compiler/common/process_ark_config.ts @@ -289,10 +289,6 @@ export function readProjectAndLibsSource( if (obfOptions.enableExportObfuscation) { arkObfuscator.addReservedSetForDefaultObf(projectAndLibs); } - if (obfOptions.enableAtKeep) { - // emit atKeep names and consumer configs - arkObfuscator.obfConfigResolver.emitConsumerConfigFiles(); - } } function processPlatformInfo(arkConfig: ArkConfig): void { diff --git a/compiler/test/ark_compiler_ut/common/ob_config_resolver.test.ts b/compiler/test/ark_compiler_ut/common/ob_config_resolver.test.ts index 19723ec8e..707734ebf 100644 --- a/compiler/test/ark_compiler_ut/common/ob_config_resolver.test.ts +++ b/compiler/test/ark_compiler_ut/common/ob_config_resolver.test.ts @@ -845,8 +845,12 @@ mocha.describe('test obfuscate config resolver api', function () { let filePathManagerStub; let fileContentManagerStub; let projectWhiteListManagerStub; + let obfConfigResolverStub; mocha.beforeEach(function () { + obfConfigResolverStub = { + emitConsumerConfigFiles: sinon.stub(), + }; filePathManagerStub = { getDeletedSourceFilePaths: sinon.stub(), createOrUpdateSourceFilePaths: sinon.stub(), @@ -868,6 +872,7 @@ mocha.describe('test obfuscate config resolver api', function () { fileContentManager: fileContentManagerStub, shouldReObfuscate: false, isIncremental: false, + obfConfigResolver: obfConfigResolverStub, }; ProjectCollections.initProjectWhiteListManager('', false, false); sinon.stub(ProjectCollections, 'projectWhiteListManager').value(projectWhiteListManagerStub); @@ -971,6 +976,7 @@ mocha.describe('test obfuscate config resolver api', function () { expect(filePathManagerStub.createOrUpdateSourceFilePaths.calledWith(allSourceFilePaths)).to.be.true; expect(projectWhiteListManagerStub.createOrUpdateWhiteListCaches.called).to.be.true; + expect(arkObfuscatorStub.obfConfigResolver.emitConsumerConfigFiles.called).to.be.true; expect(ProjectCollections.projectWhiteListManager).to.be.undefined; }); diff --git a/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts b/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts index 10b44a715..88be3b3a2 100644 --- a/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts +++ b/compiler/test/ark_compiler_ut/common/process_ark_config.test.ts @@ -535,6 +535,7 @@ mocha.describe('test process_ark_config file api', function () { arkObfuscator.obfConfigResolver = obConfigResolver; mergedObConfig.options.enableAtKeep = true; readProjectAndLibsSource(allFiles, mergedObConfig, arkObfuscator, false, keepFilesAndDependencies); + obConfigResolver.emitConsumerConfigFiles(); expect(AtKeepCollections.keepSymbol.globalNames.has('foo2')).to.be.true; expect(AtKeepCollections.keepSymbol.propertyNames.has('foo2')).to.be.true; expect(AtKeepCollections.keepSymbol.propertyNames.has('prop21')).to.be.true; -- Gitee From 2d07abbf62ef00d20b56aad299d7d7f7ec0d3cf8 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Fri, 6 Jun 2025 11:09:15 +0800 Subject: [PATCH 090/140] jiangbo91@huawei.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 静态检查修复 Signed-off-by: Bojiang Change-Id: I15c07f377b8c2fea01751febb39dc6d74c00d7ec --- compiler/src/component_map.ts | 4 ++-- compiler/src/external_component_map.ts | 2 +- compiler/src/performance.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/src/component_map.ts b/compiler/src/component_map.ts index f99de2a42..3527b3e6d 100644 --- a/compiler/src/component_map.ts +++ b/compiler/src/component_map.ts @@ -80,7 +80,7 @@ function addExternalComponents(): void { } else { COMPONENT_MAP[extCompName] = EXTERNAL_COMPONENT_MAP[extCompName]; } - }) + }); } export const TRANSITION_COMMON_ATTRS: Set = new Set([ @@ -153,7 +153,7 @@ export const CUSTOM_BUILDER_PROPERTIES: Set = new Set(['background', 'bi export const CUSTOM_BUILDER_PROPERTIES_WITHOUTKEY: Set = new Set(['showUnit', 'create']); export const CUSTOM_BUILDER_CONSTRUCTORS: Set = new Set(['MenuItem', 'MenuItemGroup', 'Refresh', 'WaterFlow', 'Radio', 'Checkbox']); -(function initComponent() { +(function initComponent(): void { Object.keys(COMPONENT_MAP).forEach((componentName) => { INNER_COMPONENT_NAMES.add(componentName); JS_BIND_COMPONENTS.add(componentName); diff --git a/compiler/src/external_component_map.ts b/compiler/src/external_component_map.ts index 89b4f0924..8e05675ed 100644 --- a/compiler/src/external_component_map.ts +++ b/compiler/src/external_component_map.ts @@ -31,7 +31,7 @@ export function readExternalComponents(): object { return EXT_COMPONENT_MAP; } for (const componentPath of componentPaths) { - if(!fs.existsSync(componentPath)){ + if (!fs.existsSync(componentPath)) { continue; } const files: string[] = fs.readdirSync(componentPath); diff --git a/compiler/src/performance.ts b/compiler/src/performance.ts index fea60b4ce..9b8e99707 100644 --- a/compiler/src/performance.ts +++ b/compiler/src/performance.ts @@ -105,7 +105,7 @@ export function processExternalEvents(projectConfig: Object, eventType: number, const isTsc: boolean = isTscEvents(eventType); const { parentEvent, filePath } = externalEventsInfo; let events: Event[] = isTsc ? ts.PerformanceDotting.getEventData() : - (fs.existsSync(filePath) ? JSON.parse(fs.readFileSync(filePath, 'utf-8')): []); + (fs.existsSync(filePath) ? JSON.parse(fs.readFileSync(filePath, 'utf-8')) : []); if (events && events.length) { events = events.sort((a, b) => a.startTime - b.startTime); asyncEvents.set(isTsc ? events[0].parentId : events[0].parentEvent, parentEvent); @@ -127,7 +127,7 @@ function setTotalTime(event: Event, isTsc: boolean): void { subEvent.start(); subEvent.stop(); subEvent.setTotalTime(event.duration); - asyncEvents.set(isTsc ? event.id : event.name, subEvent) + asyncEvents.set(isTsc ? event.id : event.name, subEvent); } } -- Gitee From c963cd06f76bf5a813864feedc274ee99c07304f Mon Sep 17 00:00:00 2001 From: seaside_wu Date: Thu, 5 Jun 2025 23:42:05 +0800 Subject: [PATCH 091/140] add uiplugin Signed-off-by: seaside_wu Change-Id: I0e17e6c1a05e7aeb7c0be2ea6199e49538ebd39d --- OAT.xml | 1 + arkui-plugins/.gitignore | 17 + arkui-plugins/.prettierrc | 8 + arkui-plugins/BUILD.gn | 43 + arkui-plugins/babel.config.js | 42 + arkui-plugins/build_ui_plugins.py | 80 + arkui-plugins/common/abstract-visitor.ts | 53 + arkui-plugins/common/arkts-utils.ts | 99 + arkui-plugins/common/debug.ts | 76 + arkui-plugins/common/etsglobal-remover.ts | 31 + arkui-plugins/common/gensym-generator.ts | 60 + arkui-plugins/common/plugin-context.ts | 109 + arkui-plugins/common/predefines.ts | 90 + arkui-plugins/common/print-visitor.ts | 34 + arkui-plugins/common/program-visitor.ts | 215 + arkui-plugins/custom-import-plugin.js | 48 + .../interop-plugins/decl_transformer.ts | 89 + .../interop-plugins/emit_transformer.ts | 60 + arkui-plugins/interop-plugins/index.ts | 20 + .../interop-plugins/interop_plugin.ts | 86 + arkui-plugins/interop-plugins/types.ts | 56 + arkui-plugins/jest-test.config.ts | 26 + .../memo-plugins/function-transformer.ts | 457 + .../memo-plugins/import-transformer.ts | 28 + arkui-plugins/memo-plugins/index.ts | 100 + arkui-plugins/memo-plugins/memo-factory.ts | 306 + .../memo-plugins/memo-transformer.ts | 50 + .../memo-plugins/parameter-transformer.ts | 130 + .../memo-plugins/return-transformer.ts | 65 + .../memo-plugins/signature-transformer.ts | 94 + arkui-plugins/memo-plugins/utils.ts | 274 + arkui-plugins/npm_preinstall.sh | 30 + arkui-plugins/package.json | 33 + arkui-plugins/path.ts | 61 + arkui-plugins/test/arktsconfig_gen.js | 57 + arkui-plugins/test/arktsconfig_template.json | 2797 ++++ .../demo/localtest/build_config_template.json | 24 + .../localtest/build_decl_config_template.json | 29 + .../test/demo/localtest/entry/index.ets | 47 + .../test/demo/localtest/entry/new.ets | 69 + .../builder-lambda/instantiate-content.ets | 27 + .../instantiate-multi-content.ets | 29 + .../demo/mock/builder-lambda/instantiate.ets | 24 + arkui-plugins/test/demo/mock/entry.ets | 16 + .../test/demo/mock/struct-to-class.ets | 22 + .../local/@ohos.arkui.component.column.d.ets | 41 + .../local/@ohos.arkui.component.common.d.ets | 55 + ...ohos.arkui.component.customComponent.d.ets | 57 + .../test/local/@ohos.arkui.component.d.ets | 22 + .../local/@ohos.arkui.component.enums.d.ets | 53 + .../@ohos.arkui.component.styledString.d.ets | 32 + .../local/@ohos.arkui.component.text.d.ets | 132 + .../local/@ohos.arkui.component.units.d.ets | 29 + .../local/@ohos.arkui.external.resource.d.ets | 16 + .../@ohos.arkui.stateManagement.common.d.ets | 61 + .../local/@ohos.arkui.stateManagement.d.ets | 18 + .../@ohos.arkui.stateManagement.runtime.d.ets | 62 + .../@ohos.arkui.stateManagement.storage.d.ets | 119 + arkui-plugins/test/localtest_config.js | 51 + arkui-plugins/test/localtest_decl_config.js | 51 + arkui-plugins/test/package.json | 17 + arkui-plugins/test/test.log | 372 + .../test/ut/common/annotation.test.ts | 50 + .../instantiate-content.test.ts | 133 + .../instantiate-multi-content.test.ts | 140 + .../builder-lambda/instantiate.test.ts | 120 + .../transform-struct-to-class.test.ts | 91 + arkui-plugins/test/utils/artkts-config.ts | 321 + arkui-plugins/test/utils/compile.ts | 63 + arkui-plugins/test/utils/global.ts | 90 + arkui-plugins/test/utils/parse-string.ts | 42 + arkui-plugins/test/utils/path-config.ts | 72 + arkui-plugins/test/utils/plugin-driver.ts | 107 + arkui-plugins/test/utils/plugin-tester.ts | 181 + arkui-plugins/test/utils/safe-types.ts | 20 + arkui-plugins/tsconfig.build.json | 28 + arkui-plugins/tsconfig.json | 33 + .../builder-lambda-transformer.ts | 274 + .../builder-lambda-translators/factory.ts | 162 + .../builder-lambda-translators/utils.ts | 309 + .../ui-plugins/checked-transformer.ts | 469 + .../ui-plugins/component-transformer.ts | 358 + .../entry-translators/entry-transformer.ts | 30 + .../ui-plugins/entry-translators/factory.ts | 291 + .../ui-plugins/entry-translators/utils.ts | 84 + arkui-plugins/ui-plugins/index.ts | 128 + arkui-plugins/ui-plugins/name-collector.ts | 87 + .../ui-plugins/preprocessor-transform.ts | 257 + .../ui-plugins/printer-transformer.ts | 27 + .../ui-plugins/property-translators/base.ts | 86 + .../property-translators/builderParam.ts | 115 + .../property-translators/consume.ts | 112 + .../property-translators/factory.ts | 236 + .../ui-plugins/property-translators/index.ts | 76 + .../ui-plugins/property-translators/link.ts | 119 + .../property-translators/localstoragelink.ts | 108 + .../property-translators/localstorageprop.ts | 177 + .../property-translators/objectlink.ts | 98 + .../ui-plugins/property-translators/prop.ts | 167 + .../property-translators/provide.ts | 128 + .../property-translators/regularProperty.ts | 67 + .../ui-plugins/property-translators/state.ts | 122 + .../property-translators/staticProperty.ts | 52 + .../property-translators/storageProp.ts | 161 + .../property-translators/storagelink.ts | 161 + .../ui-plugins/property-translators/types.ts | 34 + .../ui-plugins/property-translators/utils.ts | 324 + .../ui-plugins/struct-translators/factory.ts | 277 + .../struct-translators/struct-transformer.ts | 215 + .../ui-plugins/struct-translators/utils.ts | 79 + arkui-plugins/ui-plugins/ui-factory.ts | 229 + arkui-plugins/ui-plugins/utils.ts | 119 + koala-wrapper/.gitignore | 5 + koala-wrapper/.gitlab-ci.yml | 96 + koala-wrapper/.mocharc.json | 11 + koala-wrapper/BUILD.gn | 45 + koala-wrapper/arktsconfig-memo.json | 18 + koala-wrapper/arktsconfig-print-only.json | 21 + koala-wrapper/arktsconfig.json | 22 + koala-wrapper/babel.config.js | 37 + koala-wrapper/build_ts_wrapper.py | 95 + koala-wrapper/koalaui-transform.js | 46 + .../common/dist/bridges/ohos/chai/index.d.ts | 56 + .../common/dist/bridges/ohos/chai/index.js | 124 + .../common/dist/bridges/ohos/index.d.ts | 19 + .../koalaui/common/dist/bridges/ohos/index.js | 36 + .../common/dist/bridges/ohos/mocha/index.d.ts | 17 + .../common/dist/bridges/ohos/mocha/index.js | 47 + .../koalaui/common/dist/lib/src/Errors.d.ts | 18 + .../koalaui/common/dist/lib/src/Errors.js | 36 + .../common/dist/lib/src/Finalization.d.ts | 21 + .../common/dist/lib/src/Finalization.js | 39 + .../common/dist/lib/src/KoalaProfiler.d.ts | 73 + .../common/dist/lib/src/KoalaProfiler.js | 177 + .../common/dist/lib/src/LifecycleEvent.d.ts | 32 + .../common/dist/lib/src/LifecycleEvent.js | 37 + .../common/dist/lib/src/MarkableQueue.d.ts | 31 + .../common/dist/lib/src/MarkableQueue.js | 94 + .../koalaui/common/dist/lib/src/Matrix33.d.ts | 29 + .../koalaui/common/dist/lib/src/Matrix33.js | 83 + .../koalaui/common/dist/lib/src/Matrix44.d.ts | 80 + .../koalaui/common/dist/lib/src/Matrix44.js | 311 + .../common/dist/lib/src/PerfProbe.d.ts | 114 + .../koalaui/common/dist/lib/src/PerfProbe.js | 279 + .../koalaui/common/dist/lib/src/Point.d.ts | 31 + .../koalaui/common/dist/lib/src/Point.js | 65 + .../koalaui/common/dist/lib/src/Point3.d.ts | 26 + .../koalaui/common/dist/lib/src/Point3.js | 41 + .../koalaui/common/dist/lib/src/index.d.ts | 32 + .../koalaui/common/dist/lib/src/index.js | 79 + .../koalaui/common/dist/lib/src/koalaKey.d.ts | 24 + .../koalaui/common/dist/lib/src/koalaKey.js | 28 + .../koalaui/common/dist/lib/src/math.d.ts | 59 + .../koalaui/common/dist/lib/src/math.js | 100 + .../koalaui/common/dist/lib/src/sha1.d.ts | 39 + .../koalaui/common/dist/lib/src/sha1.js | 311 + .../common/dist/lib/src/stringUtils.d.ts | 21 + .../common/dist/lib/src/stringUtils.js | 30 + .../koalaui/common/dist/lib/src/uniqueId.d.ts | 28 + .../koalaui/common/dist/lib/src/uniqueId.js | 58 + koala-wrapper/koalaui/common/oh-package.json5 | 50 + koala-wrapper/koalaui/common/src/Errors.ts | 31 + .../koalaui/common/src/Finalization.ts | 40 + .../koalaui/common/src/KoalaProfiler.ts | 190 + .../koalaui/common/src/LifecycleEvent.ts | 34 + .../koalaui/common/src/MarkableQueue.ts | 112 + koala-wrapper/koalaui/common/src/Matrix33.ts | 86 + koala-wrapper/koalaui/common/src/Matrix44.ts | 381 + koala-wrapper/koalaui/common/src/PerfProbe.ts | 431 + koala-wrapper/koalaui/common/src/Point.ts | 76 + koala-wrapper/koalaui/common/src/Point3.ts | 53 + koala-wrapper/koalaui/common/src/index.ts | 56 + koala-wrapper/koalaui/common/src/koalaKey.ts | 30 + koala-wrapper/koalaui/common/src/math.ts | 97 + koala-wrapper/koalaui/common/src/sha1.ts | 353 + .../koalaui/common/src/stringUtils.ts | 29 + koala-wrapper/koalaui/common/src/uniqueId.ts | 62 + koala-wrapper/koalaui/compat/README.md | 4 + .../koalaui/compat/dist/src/index.d.ts | 16 + .../koalaui/compat/dist/src/index.js | 47 + .../compat/dist/src/typescript/array.d.ts | 22 + .../compat/dist/src/typescript/array.js | 38 + .../compat/dist/src/typescript/atomic.d.ts | 30 + .../compat/dist/src/typescript/atomic.js | 41 + .../compat/dist/src/typescript/double.d.ts | 21 + .../compat/dist/src/typescript/double.js | 35 + .../dist/src/typescript/finalization.d.ts | 21 + .../dist/src/typescript/finalization.js | 29 + .../compat/dist/src/typescript/index.d.ts | 28 + .../compat/dist/src/typescript/index.js | 43 + .../dist/src/typescript/observable.d.ts | 67 + .../compat/dist/src/typescript/observable.js | 406 + .../dist/src/typescript/performance.d.ts | 26 + .../compat/dist/src/typescript/performance.js | 34 + .../dist/src/typescript/prop-deep-copy.d.ts | 17 + .../dist/src/typescript/prop-deep-copy.js | 88 + .../dist/src/typescript/reflection.d.ts | 17 + .../compat/dist/src/typescript/reflection.js | 24 + .../compat/dist/src/typescript/strings.d.ts | 46 + .../compat/dist/src/typescript/strings.js | 189 + .../dist/src/typescript/ts-reflection.d.ts | 21 + .../dist/src/typescript/ts-reflection.js | 40 + .../compat/dist/src/typescript/types.d.ts | 26 + .../compat/dist/src/typescript/types.js | 18 + .../compat/dist/src/typescript/utils.d.ts | 17 + .../compat/dist/src/typescript/utils.js | 22 + .../koalaui/compat/src/arkts/array.ts | 58 + .../koalaui/compat/src/arkts/atomic.ts | 41 + .../koalaui/compat/src/arkts/double.ts | 33 + .../koalaui/compat/src/arkts/finalization.ts | 31 + .../koalaui/compat/src/arkts/index.ts | 27 + .../koalaui/compat/src/arkts/observable.ts | 311 + .../koalaui/compat/src/arkts/performance.ts | 30 + .../compat/src/arkts/prop-deep-copy.ts | 24 + .../koalaui/compat/src/arkts/reflection.ts | 22 + .../koalaui/compat/src/arkts/strings.ts | 214 + .../koalaui/compat/src/arkts/ts-reflection.ts | 38 + .../koalaui/compat/src/arkts/types.ts | 25 + .../koalaui/compat/src/arkts/utils.ts | 18 + koala-wrapper/koalaui/compat/src/index.ts | 56 + .../koalaui/compat/src/ohos/index.ts | 59 + .../koalaui/compat/src/ohos/performance.ts | 30 + .../koalaui/compat/src/typescript/Types.d.ts | 19 + .../koalaui/compat/src/typescript/array.ts | 36 + .../koalaui/compat/src/typescript/atomic.ts | 40 + .../koalaui/compat/src/typescript/double.ts | 32 + .../compat/src/typescript/finalization.ts | 43 + .../koalaui/compat/src/typescript/index.ts | 27 + .../compat/src/typescript/observable.ts | 404 + .../compat/src/typescript/performance.ts | 30 + .../compat/src/typescript/prop-deep-copy.ts | 95 + .../compat/src/typescript/reflection.ts | 20 + .../koalaui/compat/src/typescript/strings.ts | 205 + .../compat/src/typescript/ts-reflection.ts | 35 + .../koalaui/compat/src/typescript/types.ts | 25 + .../koalaui/compat/src/typescript/utils.ts | 18 + .../dist/lib/src/arkts/ResourceManager.d.ts | 29 + .../dist/lib/src/arkts/ResourceManager.js | 61 + .../lib/src/interop/DeserializerBase.d.ts | 55 + .../dist/lib/src/interop/DeserializerBase.js | 208 + .../dist/lib/src/interop/Finalizable.d.ts | 43 + .../dist/lib/src/interop/Finalizable.js | 100 + .../lib/src/interop/InteropNativeModule.d.ts | 53 + .../lib/src/interop/InteropNativeModule.js | 59 + .../dist/lib/src/interop/InteropOps.d.ts | 22 + .../dist/lib/src/interop/InteropOps.js | 75 + .../dist/lib/src/interop/InteropTypes.d.ts | 32 + .../dist/lib/src/interop/InteropTypes.js | 18 + .../lib/src/interop/MaterializedBase.d.ts | 20 + .../dist/lib/src/interop/MaterializedBase.js | 17 + .../dist/lib/src/interop/NativeBuffer.d.ts | 27 + .../dist/lib/src/interop/NativeBuffer.js | 38 + .../dist/lib/src/interop/NativeString.d.ts | 23 + .../dist/lib/src/interop/NativeString.js | 32 + .../dist/lib/src/interop/Platform.d.ts | 43 + .../interop/dist/lib/src/interop/Platform.js | 69 + .../dist/lib/src/interop/SerializerBase.d.ts | 96 + .../dist/lib/src/interop/SerializerBase.js | 298 + .../interop/dist/lib/src/interop/Wrapper.d.ts | 28 + .../interop/dist/lib/src/interop/Wrapper.js | 54 + .../interop/dist/lib/src/interop/arrays.d.ts | 28 + .../interop/dist/lib/src/interop/arrays.js | 32 + .../interop/dist/lib/src/interop/buffer.d.ts | 24 + .../interop/dist/lib/src/interop/buffer.js | 38 + .../interop/dist/lib/src/interop/index.d.ts | 40 + .../interop/dist/lib/src/interop/index.js | 96 + .../dist/lib/src/interop/loadLibraries.d.ts | 19 + .../dist/lib/src/interop/loadLibraries.js | 45 + .../dist/lib/src/interop/nullable.d.ts | 18 + .../interop/dist/lib/src/interop/nullable.js | 28 + .../dist/lib/src/napi/wrappers/Callback.d.ts | 20 + .../dist/lib/src/napi/wrappers/Callback.js | 27 + .../dist/lib/src/napi/wrappers/Wrapper.d.ts | 24 + .../dist/lib/src/napi/wrappers/Wrapper.js | 46 + .../dist/lib/src/napi/wrappers/arrays.d.ts | 35 + .../dist/lib/src/napi/wrappers/arrays.js | 116 + .../dist/lib/src/wasm/wrappers/Callback.d.ts | 20 + .../dist/lib/src/wasm/wrappers/Callback.js | 81 + .../dist/lib/src/wasm/wrappers/Wrapper.d.ts | 24 + .../dist/lib/src/wasm/wrappers/Wrapper.js | 44 + .../dist/lib/src/wasm/wrappers/arrays.d.ts | 35 + .../dist/lib/src/wasm/wrappers/arrays.js | 147 + .../koalaui/interop/oh-package.json5 | 62 + .../interop/src/arkts/DeserializerBase.sts | 245 + .../koalaui/interop/src/arkts/Finalizable.sts | 100 + .../interop/src/arkts/InteropNativeModule.sts | 58 + .../interop/src/arkts/InteropTypes.sts | 34 + .../interop/src/arkts/MaterializedBase.sts | 21 + .../interop/src/arkts/NativeBuffer.sts | 38 + .../interop/src/arkts/ResourceManager.ts | 69 + .../interop/src/arkts/SerializerBase.sts | 324 + .../koalaui/interop/src/arkts/buffer.sts | 42 + .../koalaui/interop/src/arkts/callback.sts | 92 + .../koalaui/interop/src/arkts/index.sts | 26 + .../interop/src/arkts/loadLibraries.sts | 28 + .../interop/src/cangjie/DeserializerBase.cj | 134 + .../interop/src/cangjie/Finalizable.cj | 33 + .../src/cangjie/InteropNativeModule.cj | 223 + .../interop/src/cangjie/InteropTypes.cj | 24 + .../interop/src/cangjie/ResourceManager.cj | 78 + .../interop/src/cangjie/SerializerBase.cj | 262 + .../koalaui/interop/src/cangjie/Tag.cj | 29 + .../koalaui/interop/src/cangjie/cjpm.toml | 12 + .../interop/src/cpp/DeserializerBase.h | 650 + .../koalaui/interop/src/cpp/SerializerBase.h | 264 + .../koalaui/interop/src/cpp/ani/ani.h | 9062 ++++++++++++ .../interop/src/cpp/ani/convertors-ani.cc | 154 + .../interop/src/cpp/ani/convertors-ani.h | 1378 ++ .../interop/src/cpp/callback-resource.cc | 95 + .../interop/src/cpp/callback-resource.h | 55 + .../interop/src/cpp/cangjie/convertors-cj.cc | 14 + .../interop/src/cpp/cangjie/convertors-cj.h | 875 ++ .../koalaui/interop/src/cpp/common-interop.cc | 469 + .../koalaui/interop/src/cpp/common-interop.h | 71 + .../koalaui/interop/src/cpp/crashdump.h | 43 + .../koalaui/interop/src/cpp/dynamic-loader.h | 110 + .../interop/src/cpp/ets/convertors-ets.cc | 149 + .../interop/src/cpp/ets/convertors-ets.h | 1349 ++ .../koalaui/interop/src/cpp/ets/etsapi.h | 1545 ++ .../interop/src/cpp/interop-logging.cc | 79 + .../koalaui/interop/src/cpp/interop-logging.h | 51 + .../koalaui/interop/src/cpp/interop-types.h | 145 + .../interop/src/cpp/jni/convertors-jni.cc | 107 + .../interop/src/cpp/jni/convertors-jni.h | 1465 ++ .../interop/src/cpp/jsc/convertors-jsc.cc | 285 + .../interop/src/cpp/jsc/convertors-jsc.h | 722 + .../interop/src/cpp/napi/convertors-napi.cc | 389 + .../interop/src/cpp/napi/convertors-napi.h | 1374 ++ .../interop/src/cpp/napi/win-dynamic-node.cc | 672 + .../koalaui/interop/src/cpp/ohos/hilog/log.h | 286 + .../koalaui/interop/src/cpp/ohos/oh_sk_log.cc | 67 + .../koalaui/interop/src/cpp/ohos/oh_sk_log.h | 57 + .../koalaui/interop/src/cpp/profiler.h | 98 + .../koalaui/interop/src/cpp/tracer.h | 45 + .../interop/src/cpp/types/koala-types.h | 225 + .../interop/src/cpp/types/signatures.cc | 157 + .../interop/src/cpp/types/signatures.h | 25 + .../koalaui/interop/src/cpp/vmloader.cc | 638 + .../interop/src/cpp/wasm/convertors-wasm.h | 778 + .../interop/src/interop/DeserializerBase.ts | 221 + .../interop/src/interop/Finalizable.ts | 109 + .../src/interop/InteropNativeModule.ts | 59 + .../koalaui/interop/src/interop/InteropOps.ts | 88 + .../interop/src/interop/InteropTypes.ts | 31 + .../interop/src/interop/MaterializedBase.ts | 20 + .../interop/src/interop/NativeBuffer.ts | 39 + .../interop/src/interop/NativeString.ts | 30 + .../koalaui/interop/src/interop/Platform.ts | 89 + .../interop/src/interop/SerializerBase.ts | 296 + .../koalaui/interop/src/interop/Wrapper.ts | 45 + .../koalaui/interop/src/interop/arrays.ts | 43 + .../koalaui/interop/src/interop/buffer.ts | 36 + .../koalaui/interop/src/interop/index.ts | 74 + .../src/interop/java/CallbackRecord.java | 25 + .../src/interop/java/CallbackRegistry.java | 69 + .../src/interop/java/CallbackTests.java | 181 + .../src/interop/java/CallbackType.java | 19 + .../interop/src/interop/loadLibraries.ts | 40 + .../koalaui/interop/src/interop/nullable.ts | 25 + .../interop/src/napi/wrappers/Callback.ts | 27 + .../interop/src/napi/wrappers/Wrapper.ts | 46 + .../interop/src/napi/wrappers/arrays.ts | 111 + .../interop/src/wasm/wrappers/Callback.ts | 99 + .../interop/src/wasm/wrappers/Wrapper.ts | 44 + .../interop/src/wasm/wrappers/arrays.ts | 171 + koala-wrapper/native/BUILD.gn | 162 + koala-wrapper/native/include/common.h | 39 + koala-wrapper/native/meson.build | 63 + koala-wrapper/native/meson_options.txt | 23 + koala-wrapper/native/src/bridges.cc | 373 + koala-wrapper/native/src/common.cc | 231 + koala-wrapper/native/src/generated/bridges.cc | 11764 ++++++++++++++++ koala-wrapper/package.json | 81 + koala-wrapper/src/Es2pandaEnums.ts | 184 + koala-wrapper/src/Es2pandaNativeModule.ts | 812 ++ koala-wrapper/src/InteropNativeModule.ts | 50 + koala-wrapper/src/arkts-api/class-by-peer.ts | 46 + .../src/arkts-api/factory/nodeFactory.ts | 441 + .../src/arkts-api/factory/nodeTests.ts | 89 + koala-wrapper/src/arkts-api/index.ts | 77 + .../node-utilities/AnnotationUsage.ts | 27 + .../node-utilities/ArrowFunctionExpression.ts | 35 + .../node-utilities/AssignmentExpression.ts | 38 + .../node-utilities/BinaryExpression.ts | 37 + .../node-utilities/BlockExpression.ts | 27 + .../node-utilities/BlockStatement.ts | 27 + .../node-utilities/CallExpression.ts | 45 + .../node-utilities/ChainExpression.ts | 27 + .../node-utilities/ClassDeclaration.ts | 27 + .../node-utilities/ClassDefinition.ts | 73 + .../arkts-api/node-utilities/ClassProperty.ts | 51 + .../node-utilities/ConditionalExpression.ts | 36 + .../node-utilities/ETSFunctionType.ts | 42 + .../node-utilities/ETSImportDeclaration.ts | 39 + .../ETSNewClassInstanceExpression.ts | 34 + .../node-utilities/ETSParameterExpression.ts | 43 + .../node-utilities/ETSPrimitiveType.ts | 28 + .../node-utilities/ETSTypeReference.ts | 27 + .../node-utilities/ETSTypeReferencePart.ts | 36 + .../node-utilities/ETSUndefinedType.ts | 24 + .../arkts-api/node-utilities/ETSUnionType.ts | 27 + .../node-utilities/ExpressionStatement.ts | 28 + .../node-utilities/FunctionDeclaration.ts | 37 + .../node-utilities/FunctionExpression.ts | 28 + .../arkts-api/node-utilities/Identifier.ts | 27 + .../arkts-api/node-utilities/IfStatement.ts | 37 + .../node-utilities/ImportSpecifier.ts | 31 + .../node-utilities/MemberExpression.ts | 42 + .../node-utilities/MethodDefinition.ts | 45 + .../arkts-api/node-utilities/NullLiteral.ts | 24 + .../arkts-api/node-utilities/NumberLiteral.ts | 30 + .../node-utilities/ReturnStatement.ts | 27 + .../node-utilities/ScriptFunction.ts | 46 + .../arkts-api/node-utilities/StringLiteral.ts | 27 + .../node-utilities/StructDeclaration.ts | 28 + .../node-utilities/SuperExpression.ts | 24 + .../node-utilities/TSAsExpression.ts | 36 + .../node-utilities/TSInterfaceBody.ts | 28 + .../node-utilities/TSInterfaceDeclaration.ts | 43 + .../node-utilities/TSNonNullExpression.ts | 27 + .../node-utilities/TSTypeAliasDeclaration.ts | 40 + .../node-utilities/TSTypeParameter.ts | 36 + .../TSTypeParameterDeclaration.ts | 31 + .../TSTypeParameterInstantiation.ts | 30 + .../node-utilities/ThisExpression.ts | 24 + .../node-utilities/UndefinedLiteral.ts | 24 + .../node-utilities/VariableDeclaration.ts | 38 + .../node-utilities/VariableDeclarator.ts | 39 + .../src/arkts-api/peers/ArktsObject.ts | 45 + koala-wrapper/src/arkts-api/peers/AstNode.ts | 129 + koala-wrapper/src/arkts-api/peers/Config.ts | 53 + koala-wrapper/src/arkts-api/peers/Context.ts | 56 + .../src/arkts-api/peers/ImportPathManager.ts | 36 + koala-wrapper/src/arkts-api/peers/Program.ts | 66 + .../src/arkts-api/peers/SourcePosition.ts | 38 + koala-wrapper/src/arkts-api/static/global.ts | 77 + .../src/arkts-api/static/globalUtils.ts | 27 + .../to-be-generated/MemberExpression.ts | 108 + koala-wrapper/src/arkts-api/types.ts | 903 ++ .../arkts-api/utilities/nativePtrDecoder.ts | 69 + .../src/arkts-api/utilities/performance.ts | 132 + .../src/arkts-api/utilities/private.ts | 201 + .../src/arkts-api/utilities/public.ts | 162 + koala-wrapper/src/arkts-api/visitor.ts | 346 + koala-wrapper/src/es2panda.ts | 24 + koala-wrapper/src/generated/Es2pandaEnums.ts | 1266 ++ .../src/generated/Es2pandaNativeModule.ts | 3715 +++++ koala-wrapper/src/generated/index.ts | 192 + koala-wrapper/src/generated/node-map.ts | 182 + .../src/generated/peers/AnnotatedAstNode.ts | 40 + .../generated/peers/AnnotatedExpression.ts | 50 + .../src/generated/peers/AnnotatedStatement.ts | 41 + .../generated/peers/AnnotationDeclaration.ts | 114 + .../src/generated/peers/AnnotationUsage.ts | 78 + .../src/generated/peers/ArrayExpression.ts | 80 + .../peers/ArrowFunctionExpression.ts | 71 + .../src/generated/peers/AssertStatement.ts | 58 + .../generated/peers/AssignmentExpression.ts | 80 + .../src/generated/peers/AstDumper.ts | 45 + .../src/generated/peers/AwaitExpression.ts | 54 + .../src/generated/peers/BigIntLiteral.ts | 54 + .../src/generated/peers/BinaryExpression.ts | 96 + .../src/generated/peers/BlockExpression.ts | 65 + .../src/generated/peers/BlockStatement.ts | 64 + .../src/generated/peers/BooleanLiteral.ts | 54 + .../src/generated/peers/BreakStatement.ts | 69 + .../src/generated/peers/CallExpression.ts | 98 + .../src/generated/peers/CatchClause.ts | 59 + .../src/generated/peers/ChainExpression.ts | 54 + .../src/generated/peers/CharLiteral.ts | 51 + .../src/generated/peers/ClassDeclaration.ts | 59 + .../src/generated/peers/ClassDefinition.ts | 222 + .../src/generated/peers/ClassElement.ts | 67 + .../src/generated/peers/ClassExpression.ts | 55 + .../src/generated/peers/ClassProperty.ts | 71 + .../src/generated/peers/ClassStaticBlock.ts | 53 + .../generated/peers/ConditionalExpression.ts | 75 + koala-wrapper/src/generated/peers/Context.ts | 37 + .../src/generated/peers/ContinueStatement.ts | 69 + .../src/generated/peers/DebuggerStatement.ts | 51 + .../src/generated/peers/Decorator.ts | 55 + .../generated/peers/DirectEvalExpression.ts | 53 + .../src/generated/peers/DoWhileStatement.ts | 59 + .../src/generated/peers/ETSClassLiteral.ts | 55 + .../generated/peers/ETSDynamicFunctionType.ts | 41 + .../src/generated/peers/ETSFunctionType.ts | 85 + .../generated/peers/ETSImportDeclaration.ts | 69 + .../generated/peers/ETSLaunchExpression.ts | 55 + .../src/generated/peers/ETSModule.ts | 72 + .../peers/ETSNewArrayInstanceExpression.ts | 63 + .../peers/ETSNewClassInstanceExpression.ts | 73 + .../ETSNewMultiDimArrayInstanceExpression.ts | 64 + .../src/generated/peers/ETSNullType.ts | 51 + .../generated/peers/ETSPackageDeclaration.ts | 52 + .../generated/peers/ETSParameterExpression.ts | 109 + .../src/generated/peers/ETSPrimitiveType.ts | 55 + .../generated/peers/ETSReExportDeclaration.ts | 52 + .../generated/peers/ETSStructDeclaration.ts | 52 + koala-wrapper/src/generated/peers/ETSTuple.ts | 82 + .../src/generated/peers/ETSTypeReference.ts | 56 + .../generated/peers/ETSTypeReferencePart.ts | 68 + .../src/generated/peers/ETSUndefinedType.ts | 51 + .../src/generated/peers/ETSUnionType.ts | 54 + .../src/generated/peers/ETSWildcardType.ts | 56 + .../src/generated/peers/EmptyStatement.ts | 51 + .../generated/peers/ExportAllDeclaration.ts | 59 + .../peers/ExportDefaultDeclaration.ts | 57 + .../generated/peers/ExportNamedDeclaration.ts | 74 + .../src/generated/peers/ExportSpecifier.ts | 58 + .../src/generated/peers/Expression.ts | 61 + .../generated/peers/ExpressionStatement.ts | 60 + .../src/generated/peers/ForInStatement.ts | 62 + .../src/generated/peers/ForOfStatement.ts | 65 + .../src/generated/peers/ForUpdateStatement.ts | 62 + .../src/generated/peers/FunctionDecl.ts | 41 + .../generated/peers/FunctionDeclaration.ts | 73 + .../src/generated/peers/FunctionExpression.ts | 68 + .../src/generated/peers/FunctionSignature.ts | 60 + .../src/generated/peers/Identifier.ts | 158 + .../src/generated/peers/IfStatement.ts | 61 + .../src/generated/peers/ImportDeclaration.ts | 62 + .../generated/peers/ImportDefaultSpecifier.ts | 55 + .../src/generated/peers/ImportExpression.ts | 54 + .../peers/ImportNamespaceSpecifier.ts | 55 + .../src/generated/peers/ImportSource.ts | 50 + .../src/generated/peers/ImportSpecifier.ts | 58 + .../src/generated/peers/InterfaceDecl.ts | 41 + .../src/generated/peers/LabelledStatement.ts | 58 + koala-wrapper/src/generated/peers/Literal.ts | 41 + .../src/generated/peers/LoopStatement.ts | 41 + .../peers/MaybeOptionalExpression.ts | 49 + .../src/generated/peers/MemberExpression.ts | 93 + .../src/generated/peers/MetaProperty.ts | 55 + .../src/generated/peers/MethodDefinition.ts | 98 + .../src/generated/peers/NamedType.ts | 77 + .../src/generated/peers/NewExpression.ts | 57 + .../src/generated/peers/NullLiteral.ts | 51 + .../src/generated/peers/NumberLiteral.ts | 48 + .../src/generated/peers/ObjectExpression.ts | 83 + .../src/generated/peers/OmittedExpression.ts | 51 + .../src/generated/peers/OpaqueTypeNode.ts | 51 + .../peers/PrefixAssertionExpression.ts | 58 + koala-wrapper/src/generated/peers/Property.ts | 80 + .../src/generated/peers/RegExpLiteral.ts | 58 + .../src/generated/peers/ReturnStatement.ts | 66 + .../src/generated/peers/ScriptFunction.ts | 199 + .../src/generated/peers/SequenceExpression.ts | 54 + .../src/generated/peers/SpreadElement.ts | 67 + .../src/generated/peers/SrcDumper.ts | 83 + .../src/generated/peers/Statement.ts | 40 + .../src/generated/peers/StringLiteral.ts | 59 + .../src/generated/peers/SuperExpression.ts | 51 + .../generated/peers/SwitchCaseStatement.ts | 58 + .../src/generated/peers/SwitchStatement.ts | 59 + .../src/generated/peers/TSAnyKeyword.ts | 51 + .../src/generated/peers/TSArrayType.ts | 54 + .../src/generated/peers/TSAsExpression.ts | 77 + .../src/generated/peers/TSBigintKeyword.ts | 51 + .../src/generated/peers/TSBooleanKeyword.ts | 51 + .../src/generated/peers/TSClassImplements.ts | 64 + .../src/generated/peers/TSConditionalType.ts | 64 + .../src/generated/peers/TSConstructorType.ts | 66 + .../src/generated/peers/TSEnumDeclaration.ts | 82 + .../src/generated/peers/TSEnumMember.ts | 67 + .../peers/TSExternalModuleReference.ts | 54 + .../src/generated/peers/TSFunctionType.ts | 68 + .../peers/TSImportEqualsDeclaration.ts | 62 + .../src/generated/peers/TSImportType.ts | 65 + .../src/generated/peers/TSIndexSignature.ts | 63 + .../generated/peers/TSIndexedAccessType.ts | 57 + .../src/generated/peers/TSInferType.ts | 55 + .../src/generated/peers/TSInterfaceBody.ts | 57 + .../generated/peers/TSInterfaceDeclaration.ts | 103 + .../generated/peers/TSInterfaceHeritage.ts | 55 + .../src/generated/peers/TSIntersectionType.ts | 55 + .../src/generated/peers/TSLiteralType.ts | 55 + .../src/generated/peers/TSMappedType.ts | 65 + .../src/generated/peers/TSMethodSignature.ts | 72 + .../src/generated/peers/TSModuleBlock.ts | 54 + .../generated/peers/TSModuleDeclaration.ts | 64 + .../src/generated/peers/TSNamedTupleMember.ts | 61 + .../src/generated/peers/TSNeverKeyword.ts | 51 + .../generated/peers/TSNonNullExpression.ts | 59 + .../src/generated/peers/TSNullKeyword.ts | 51 + .../src/generated/peers/TSNumberKeyword.ts | 51 + .../src/generated/peers/TSObjectKeyword.ts | 51 + .../generated/peers/TSParameterProperty.ts | 67 + .../generated/peers/TSParenthesizedType.ts | 55 + .../generated/peers/TSPropertySignature.ts | 73 + .../src/generated/peers/TSQualifiedName.ts | 58 + .../generated/peers/TSSignatureDeclaration.ts | 68 + .../src/generated/peers/TSStringKeyword.ts | 51 + .../src/generated/peers/TSThisType.ts | 51 + .../src/generated/peers/TSTupleType.ts | 54 + .../generated/peers/TSTypeAliasDeclaration.ts | 92 + .../src/generated/peers/TSTypeAssertion.ts | 64 + .../src/generated/peers/TSTypeLiteral.ts | 54 + .../src/generated/peers/TSTypeOperator.ts | 64 + .../src/generated/peers/TSTypeParameter.ts | 88 + .../peers/TSTypeParameterDeclaration.ts | 63 + .../peers/TSTypeParameterInstantiation.ts | 55 + .../src/generated/peers/TSTypePredicate.ts | 61 + .../src/generated/peers/TSTypeQuery.ts | 55 + .../src/generated/peers/TSTypeReference.ts | 60 + .../src/generated/peers/TSUndefinedKeyword.ts | 51 + .../src/generated/peers/TSUnionType.ts | 54 + .../src/generated/peers/TSUnknownKeyword.ts | 51 + .../src/generated/peers/TSVoidKeyword.ts | 51 + .../peers/TaggedTemplateExpression.ts | 62 + .../src/generated/peers/TemplateElement.ts | 63 + .../src/generated/peers/TemplateLiteral.ts | 58 + .../src/generated/peers/ThisExpression.ts | 51 + .../src/generated/peers/ThrowStatement.ts | 55 + .../src/generated/peers/TryStatement.ts | 67 + koala-wrapper/src/generated/peers/TypeNode.ts | 50 + .../src/generated/peers/TypedAstNode.ts | 40 + .../src/generated/peers/TypedStatement.ts | 41 + .../src/generated/peers/TypeofExpression.ts | 54 + .../src/generated/peers/UnaryExpression.ts | 58 + .../src/generated/peers/UndefinedLiteral.ts | 51 + .../src/generated/peers/UpdateExpression.ts | 61 + .../src/generated/peers/ValidationInfo.ts | 43 + .../generated/peers/VariableDeclaration.ts | 72 + .../src/generated/peers/VariableDeclarator.ts | 73 + .../src/generated/peers/WhileStatement.ts | 59 + .../src/generated/peers/YieldExpression.ts | 57 + koala-wrapper/src/reexport-for-generated.ts | 32 + koala-wrapper/src/utils.ts | 86 + koala-wrapper/tools/issue_gen.mjs | 66 + koala-wrapper/tsconfig.json | 38 + 630 files changed, 88913 insertions(+) create mode 100644 arkui-plugins/.gitignore create mode 100644 arkui-plugins/.prettierrc create mode 100755 arkui-plugins/BUILD.gn create mode 100644 arkui-plugins/babel.config.js create mode 100755 arkui-plugins/build_ui_plugins.py create mode 100644 arkui-plugins/common/abstract-visitor.ts create mode 100644 arkui-plugins/common/arkts-utils.ts create mode 100644 arkui-plugins/common/debug.ts create mode 100644 arkui-plugins/common/etsglobal-remover.ts create mode 100644 arkui-plugins/common/gensym-generator.ts create mode 100644 arkui-plugins/common/plugin-context.ts create mode 100644 arkui-plugins/common/predefines.ts create mode 100644 arkui-plugins/common/print-visitor.ts create mode 100644 arkui-plugins/common/program-visitor.ts create mode 100644 arkui-plugins/custom-import-plugin.js create mode 100644 arkui-plugins/interop-plugins/decl_transformer.ts create mode 100644 arkui-plugins/interop-plugins/emit_transformer.ts create mode 100644 arkui-plugins/interop-plugins/index.ts create mode 100644 arkui-plugins/interop-plugins/interop_plugin.ts create mode 100644 arkui-plugins/interop-plugins/types.ts create mode 100644 arkui-plugins/jest-test.config.ts create mode 100644 arkui-plugins/memo-plugins/function-transformer.ts create mode 100644 arkui-plugins/memo-plugins/import-transformer.ts create mode 100644 arkui-plugins/memo-plugins/index.ts create mode 100644 arkui-plugins/memo-plugins/memo-factory.ts create mode 100644 arkui-plugins/memo-plugins/memo-transformer.ts create mode 100644 arkui-plugins/memo-plugins/parameter-transformer.ts create mode 100644 arkui-plugins/memo-plugins/return-transformer.ts create mode 100644 arkui-plugins/memo-plugins/signature-transformer.ts create mode 100644 arkui-plugins/memo-plugins/utils.ts create mode 100755 arkui-plugins/npm_preinstall.sh create mode 100644 arkui-plugins/package.json create mode 100644 arkui-plugins/path.ts create mode 100644 arkui-plugins/test/arktsconfig_gen.js create mode 100644 arkui-plugins/test/arktsconfig_template.json create mode 100755 arkui-plugins/test/demo/localtest/build_config_template.json create mode 100644 arkui-plugins/test/demo/localtest/build_decl_config_template.json create mode 100644 arkui-plugins/test/demo/localtest/entry/index.ets create mode 100755 arkui-plugins/test/demo/localtest/entry/new.ets create mode 100644 arkui-plugins/test/demo/mock/builder-lambda/instantiate-content.ets create mode 100644 arkui-plugins/test/demo/mock/builder-lambda/instantiate-multi-content.ets create mode 100644 arkui-plugins/test/demo/mock/builder-lambda/instantiate.ets create mode 100644 arkui-plugins/test/demo/mock/entry.ets create mode 100644 arkui-plugins/test/demo/mock/struct-to-class.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.component.column.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.component.common.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.component.customComponent.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.component.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.component.enums.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.component.styledString.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.component.text.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.component.units.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.external.resource.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.stateManagement.common.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.stateManagement.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.stateManagement.runtime.d.ets create mode 100644 arkui-plugins/test/local/@ohos.arkui.stateManagement.storage.d.ets create mode 100644 arkui-plugins/test/localtest_config.js create mode 100644 arkui-plugins/test/localtest_decl_config.js create mode 100644 arkui-plugins/test/package.json create mode 100644 arkui-plugins/test/test.log create mode 100644 arkui-plugins/test/ut/common/annotation.test.ts create mode 100644 arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate-content.test.ts create mode 100644 arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate-multi-content.test.ts create mode 100644 arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate.test.ts create mode 100644 arkui-plugins/test/ut/ui-plugins/transform-struct-to-class.test.ts create mode 100644 arkui-plugins/test/utils/artkts-config.ts create mode 100644 arkui-plugins/test/utils/compile.ts create mode 100644 arkui-plugins/test/utils/global.ts create mode 100644 arkui-plugins/test/utils/parse-string.ts create mode 100644 arkui-plugins/test/utils/path-config.ts create mode 100644 arkui-plugins/test/utils/plugin-driver.ts create mode 100644 arkui-plugins/test/utils/plugin-tester.ts create mode 100644 arkui-plugins/test/utils/safe-types.ts create mode 100644 arkui-plugins/tsconfig.build.json create mode 100644 arkui-plugins/tsconfig.json create mode 100644 arkui-plugins/ui-plugins/builder-lambda-translators/builder-lambda-transformer.ts create mode 100644 arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts create mode 100644 arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts create mode 100644 arkui-plugins/ui-plugins/checked-transformer.ts create mode 100644 arkui-plugins/ui-plugins/component-transformer.ts create mode 100644 arkui-plugins/ui-plugins/entry-translators/entry-transformer.ts create mode 100644 arkui-plugins/ui-plugins/entry-translators/factory.ts create mode 100644 arkui-plugins/ui-plugins/entry-translators/utils.ts create mode 100644 arkui-plugins/ui-plugins/index.ts create mode 100644 arkui-plugins/ui-plugins/name-collector.ts create mode 100644 arkui-plugins/ui-plugins/preprocessor-transform.ts create mode 100644 arkui-plugins/ui-plugins/printer-transformer.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/base.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/builderParam.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/consume.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/factory.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/index.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/link.ts create mode 100755 arkui-plugins/ui-plugins/property-translators/localstoragelink.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/localstorageprop.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/objectlink.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/prop.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/provide.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/regularProperty.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/state.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/staticProperty.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/storageProp.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/storagelink.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/types.ts create mode 100644 arkui-plugins/ui-plugins/property-translators/utils.ts create mode 100644 arkui-plugins/ui-plugins/struct-translators/factory.ts create mode 100644 arkui-plugins/ui-plugins/struct-translators/struct-transformer.ts create mode 100644 arkui-plugins/ui-plugins/struct-translators/utils.ts create mode 100644 arkui-plugins/ui-plugins/ui-factory.ts create mode 100644 arkui-plugins/ui-plugins/utils.ts create mode 100644 koala-wrapper/.gitignore create mode 100644 koala-wrapper/.gitlab-ci.yml create mode 100644 koala-wrapper/.mocharc.json create mode 100644 koala-wrapper/BUILD.gn create mode 100644 koala-wrapper/arktsconfig-memo.json create mode 100644 koala-wrapper/arktsconfig-print-only.json create mode 100644 koala-wrapper/arktsconfig.json create mode 100644 koala-wrapper/babel.config.js create mode 100755 koala-wrapper/build_ts_wrapper.py create mode 100644 koala-wrapper/koalaui-transform.js create mode 100644 koala-wrapper/koalaui/common/dist/bridges/ohos/chai/index.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/bridges/ohos/chai/index.js create mode 100644 koala-wrapper/koalaui/common/dist/bridges/ohos/index.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/bridges/ohos/index.js create mode 100644 koala-wrapper/koalaui/common/dist/bridges/ohos/mocha/index.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/bridges/ohos/mocha/index.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Errors.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Errors.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Finalization.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Finalization.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/KoalaProfiler.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/KoalaProfiler.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/LifecycleEvent.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/LifecycleEvent.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/MarkableQueue.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/MarkableQueue.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Matrix33.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Matrix33.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Matrix44.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Matrix44.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/PerfProbe.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/PerfProbe.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Point.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Point.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Point3.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/Point3.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/index.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/index.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/koalaKey.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/koalaKey.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/math.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/math.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/sha1.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/sha1.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/stringUtils.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/stringUtils.js create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/uniqueId.d.ts create mode 100644 koala-wrapper/koalaui/common/dist/lib/src/uniqueId.js create mode 100644 koala-wrapper/koalaui/common/oh-package.json5 create mode 100644 koala-wrapper/koalaui/common/src/Errors.ts create mode 100644 koala-wrapper/koalaui/common/src/Finalization.ts create mode 100644 koala-wrapper/koalaui/common/src/KoalaProfiler.ts create mode 100644 koala-wrapper/koalaui/common/src/LifecycleEvent.ts create mode 100644 koala-wrapper/koalaui/common/src/MarkableQueue.ts create mode 100644 koala-wrapper/koalaui/common/src/Matrix33.ts create mode 100644 koala-wrapper/koalaui/common/src/Matrix44.ts create mode 100644 koala-wrapper/koalaui/common/src/PerfProbe.ts create mode 100644 koala-wrapper/koalaui/common/src/Point.ts create mode 100644 koala-wrapper/koalaui/common/src/Point3.ts create mode 100644 koala-wrapper/koalaui/common/src/index.ts create mode 100644 koala-wrapper/koalaui/common/src/koalaKey.ts create mode 100644 koala-wrapper/koalaui/common/src/math.ts create mode 100644 koala-wrapper/koalaui/common/src/sha1.ts create mode 100644 koala-wrapper/koalaui/common/src/stringUtils.ts create mode 100644 koala-wrapper/koalaui/common/src/uniqueId.ts create mode 100644 koala-wrapper/koalaui/compat/README.md create mode 100644 koala-wrapper/koalaui/compat/dist/src/index.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/index.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/array.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/array.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/atomic.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/atomic.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/double.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/double.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/finalization.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/finalization.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/index.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/index.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/observable.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/observable.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/performance.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/performance.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/prop-deep-copy.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/prop-deep-copy.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/reflection.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/reflection.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/strings.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/strings.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/ts-reflection.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/ts-reflection.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/types.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/types.js create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/utils.d.ts create mode 100644 koala-wrapper/koalaui/compat/dist/src/typescript/utils.js create mode 100644 koala-wrapper/koalaui/compat/src/arkts/array.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/atomic.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/double.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/finalization.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/index.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/observable.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/performance.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/prop-deep-copy.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/reflection.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/strings.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/ts-reflection.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/types.ts create mode 100644 koala-wrapper/koalaui/compat/src/arkts/utils.ts create mode 100644 koala-wrapper/koalaui/compat/src/index.ts create mode 100644 koala-wrapper/koalaui/compat/src/ohos/index.ts create mode 100644 koala-wrapper/koalaui/compat/src/ohos/performance.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/Types.d.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/array.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/atomic.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/double.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/finalization.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/index.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/observable.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/performance.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/prop-deep-copy.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/reflection.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/strings.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/ts-reflection.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/types.ts create mode 100644 koala-wrapper/koalaui/compat/src/typescript/utils.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/arkts/ResourceManager.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/arkts/ResourceManager.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/DeserializerBase.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/DeserializerBase.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/Finalizable.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/Finalizable.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropNativeModule.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropNativeModule.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropOps.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropOps.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropTypes.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropTypes.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/MaterializedBase.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/MaterializedBase.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeBuffer.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeBuffer.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeString.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeString.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/Platform.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/Platform.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/SerializerBase.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/SerializerBase.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/Wrapper.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/Wrapper.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/arrays.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/arrays.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/buffer.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/buffer.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/index.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/index.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/loadLibraries.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/loadLibraries.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/nullable.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/interop/nullable.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Callback.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Callback.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Wrapper.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Wrapper.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/arrays.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/arrays.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Callback.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Callback.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Wrapper.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Wrapper.js create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/arrays.d.ts create mode 100644 koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/arrays.js create mode 100644 koala-wrapper/koalaui/interop/oh-package.json5 create mode 100644 koala-wrapper/koalaui/interop/src/arkts/DeserializerBase.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/Finalizable.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/InteropNativeModule.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/InteropTypes.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/MaterializedBase.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/NativeBuffer.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/ResourceManager.ts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/SerializerBase.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/buffer.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/callback.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/index.sts create mode 100644 koala-wrapper/koalaui/interop/src/arkts/loadLibraries.sts create mode 100644 koala-wrapper/koalaui/interop/src/cangjie/DeserializerBase.cj create mode 100644 koala-wrapper/koalaui/interop/src/cangjie/Finalizable.cj create mode 100644 koala-wrapper/koalaui/interop/src/cangjie/InteropNativeModule.cj create mode 100644 koala-wrapper/koalaui/interop/src/cangjie/InteropTypes.cj create mode 100644 koala-wrapper/koalaui/interop/src/cangjie/ResourceManager.cj create mode 100644 koala-wrapper/koalaui/interop/src/cangjie/SerializerBase.cj create mode 100644 koala-wrapper/koalaui/interop/src/cangjie/Tag.cj create mode 100644 koala-wrapper/koalaui/interop/src/cangjie/cjpm.toml create mode 100644 koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/ani/ani.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/callback-resource.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/common-interop.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/common-interop.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/crashdump.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/dynamic-loader.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/ets/etsapi.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/interop-logging.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/interop-types.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/napi/win-dynamic-node.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/ohos/hilog/log.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/profiler.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/tracer.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/types/signatures.h create mode 100644 koala-wrapper/koalaui/interop/src/cpp/vmloader.cc create mode 100644 koala-wrapper/koalaui/interop/src/cpp/wasm/convertors-wasm.h create mode 100644 koala-wrapper/koalaui/interop/src/interop/DeserializerBase.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/Finalizable.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/InteropNativeModule.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/InteropOps.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/InteropTypes.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/MaterializedBase.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/NativeBuffer.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/NativeString.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/Platform.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/SerializerBase.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/Wrapper.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/arrays.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/buffer.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/index.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/java/CallbackRecord.java create mode 100644 koala-wrapper/koalaui/interop/src/interop/java/CallbackRegistry.java create mode 100644 koala-wrapper/koalaui/interop/src/interop/java/CallbackTests.java create mode 100644 koala-wrapper/koalaui/interop/src/interop/java/CallbackType.java create mode 100644 koala-wrapper/koalaui/interop/src/interop/loadLibraries.ts create mode 100644 koala-wrapper/koalaui/interop/src/interop/nullable.ts create mode 100644 koala-wrapper/koalaui/interop/src/napi/wrappers/Callback.ts create mode 100644 koala-wrapper/koalaui/interop/src/napi/wrappers/Wrapper.ts create mode 100644 koala-wrapper/koalaui/interop/src/napi/wrappers/arrays.ts create mode 100644 koala-wrapper/koalaui/interop/src/wasm/wrappers/Callback.ts create mode 100644 koala-wrapper/koalaui/interop/src/wasm/wrappers/Wrapper.ts create mode 100644 koala-wrapper/koalaui/interop/src/wasm/wrappers/arrays.ts create mode 100644 koala-wrapper/native/BUILD.gn create mode 100644 koala-wrapper/native/include/common.h create mode 100644 koala-wrapper/native/meson.build create mode 100644 koala-wrapper/native/meson_options.txt create mode 100644 koala-wrapper/native/src/bridges.cc create mode 100644 koala-wrapper/native/src/common.cc create mode 100644 koala-wrapper/native/src/generated/bridges.cc create mode 100644 koala-wrapper/package.json create mode 100644 koala-wrapper/src/Es2pandaEnums.ts create mode 100644 koala-wrapper/src/Es2pandaNativeModule.ts create mode 100644 koala-wrapper/src/InteropNativeModule.ts create mode 100644 koala-wrapper/src/arkts-api/class-by-peer.ts create mode 100644 koala-wrapper/src/arkts-api/factory/nodeFactory.ts create mode 100644 koala-wrapper/src/arkts-api/factory/nodeTests.ts create mode 100644 koala-wrapper/src/arkts-api/index.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/AnnotationUsage.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ArrowFunctionExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/AssignmentExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/BinaryExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/BlockExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/BlockStatement.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/CallExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ChainExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ClassDeclaration.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ClassDefinition.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ClassProperty.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ConditionalExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ETSFunctionType.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ETSImportDeclaration.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ETSNewClassInstanceExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ETSParameterExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ETSPrimitiveType.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ETSTypeReference.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ETSTypeReferencePart.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ETSUndefinedType.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ETSUnionType.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ExpressionStatement.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/FunctionDeclaration.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/FunctionExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/Identifier.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/IfStatement.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ImportSpecifier.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/MemberExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/MethodDefinition.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/NullLiteral.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/NumberLiteral.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ReturnStatement.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ScriptFunction.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/StringLiteral.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/StructDeclaration.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/SuperExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/TSAsExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/TSInterfaceBody.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/TSNonNullExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/TSTypeParameter.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/TSTypeParameterDeclaration.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/TSTypeParameterInstantiation.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/ThisExpression.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/UndefinedLiteral.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/VariableDeclaration.ts create mode 100644 koala-wrapper/src/arkts-api/node-utilities/VariableDeclarator.ts create mode 100644 koala-wrapper/src/arkts-api/peers/ArktsObject.ts create mode 100644 koala-wrapper/src/arkts-api/peers/AstNode.ts create mode 100644 koala-wrapper/src/arkts-api/peers/Config.ts create mode 100644 koala-wrapper/src/arkts-api/peers/Context.ts create mode 100644 koala-wrapper/src/arkts-api/peers/ImportPathManager.ts create mode 100644 koala-wrapper/src/arkts-api/peers/Program.ts create mode 100644 koala-wrapper/src/arkts-api/peers/SourcePosition.ts create mode 100644 koala-wrapper/src/arkts-api/static/global.ts create mode 100644 koala-wrapper/src/arkts-api/static/globalUtils.ts create mode 100644 koala-wrapper/src/arkts-api/to-be-generated/MemberExpression.ts create mode 100644 koala-wrapper/src/arkts-api/types.ts create mode 100644 koala-wrapper/src/arkts-api/utilities/nativePtrDecoder.ts create mode 100644 koala-wrapper/src/arkts-api/utilities/performance.ts create mode 100644 koala-wrapper/src/arkts-api/utilities/private.ts create mode 100644 koala-wrapper/src/arkts-api/utilities/public.ts create mode 100644 koala-wrapper/src/arkts-api/visitor.ts create mode 100644 koala-wrapper/src/es2panda.ts create mode 100644 koala-wrapper/src/generated/Es2pandaEnums.ts create mode 100644 koala-wrapper/src/generated/Es2pandaNativeModule.ts create mode 100644 koala-wrapper/src/generated/index.ts create mode 100644 koala-wrapper/src/generated/node-map.ts create mode 100644 koala-wrapper/src/generated/peers/AnnotatedAstNode.ts create mode 100644 koala-wrapper/src/generated/peers/AnnotatedExpression.ts create mode 100644 koala-wrapper/src/generated/peers/AnnotatedStatement.ts create mode 100644 koala-wrapper/src/generated/peers/AnnotationDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/AnnotationUsage.ts create mode 100644 koala-wrapper/src/generated/peers/ArrayExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ArrowFunctionExpression.ts create mode 100644 koala-wrapper/src/generated/peers/AssertStatement.ts create mode 100644 koala-wrapper/src/generated/peers/AssignmentExpression.ts create mode 100644 koala-wrapper/src/generated/peers/AstDumper.ts create mode 100644 koala-wrapper/src/generated/peers/AwaitExpression.ts create mode 100644 koala-wrapper/src/generated/peers/BigIntLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/BinaryExpression.ts create mode 100644 koala-wrapper/src/generated/peers/BlockExpression.ts create mode 100644 koala-wrapper/src/generated/peers/BlockStatement.ts create mode 100644 koala-wrapper/src/generated/peers/BooleanLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/BreakStatement.ts create mode 100644 koala-wrapper/src/generated/peers/CallExpression.ts create mode 100644 koala-wrapper/src/generated/peers/CatchClause.ts create mode 100644 koala-wrapper/src/generated/peers/ChainExpression.ts create mode 100644 koala-wrapper/src/generated/peers/CharLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/ClassDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/ClassDefinition.ts create mode 100644 koala-wrapper/src/generated/peers/ClassElement.ts create mode 100644 koala-wrapper/src/generated/peers/ClassExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ClassProperty.ts create mode 100644 koala-wrapper/src/generated/peers/ClassStaticBlock.ts create mode 100644 koala-wrapper/src/generated/peers/ConditionalExpression.ts create mode 100644 koala-wrapper/src/generated/peers/Context.ts create mode 100644 koala-wrapper/src/generated/peers/ContinueStatement.ts create mode 100644 koala-wrapper/src/generated/peers/DebuggerStatement.ts create mode 100644 koala-wrapper/src/generated/peers/Decorator.ts create mode 100644 koala-wrapper/src/generated/peers/DirectEvalExpression.ts create mode 100644 koala-wrapper/src/generated/peers/DoWhileStatement.ts create mode 100644 koala-wrapper/src/generated/peers/ETSClassLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/ETSDynamicFunctionType.ts create mode 100644 koala-wrapper/src/generated/peers/ETSFunctionType.ts create mode 100644 koala-wrapper/src/generated/peers/ETSImportDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/ETSLaunchExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ETSModule.ts create mode 100644 koala-wrapper/src/generated/peers/ETSNewArrayInstanceExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ETSNewClassInstanceExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ETSNullType.ts create mode 100644 koala-wrapper/src/generated/peers/ETSPackageDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/ETSParameterExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ETSPrimitiveType.ts create mode 100644 koala-wrapper/src/generated/peers/ETSReExportDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/ETSStructDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/ETSTuple.ts create mode 100644 koala-wrapper/src/generated/peers/ETSTypeReference.ts create mode 100644 koala-wrapper/src/generated/peers/ETSTypeReferencePart.ts create mode 100644 koala-wrapper/src/generated/peers/ETSUndefinedType.ts create mode 100644 koala-wrapper/src/generated/peers/ETSUnionType.ts create mode 100644 koala-wrapper/src/generated/peers/ETSWildcardType.ts create mode 100644 koala-wrapper/src/generated/peers/EmptyStatement.ts create mode 100644 koala-wrapper/src/generated/peers/ExportAllDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/ExportDefaultDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/ExportNamedDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/ExportSpecifier.ts create mode 100644 koala-wrapper/src/generated/peers/Expression.ts create mode 100644 koala-wrapper/src/generated/peers/ExpressionStatement.ts create mode 100644 koala-wrapper/src/generated/peers/ForInStatement.ts create mode 100644 koala-wrapper/src/generated/peers/ForOfStatement.ts create mode 100644 koala-wrapper/src/generated/peers/ForUpdateStatement.ts create mode 100644 koala-wrapper/src/generated/peers/FunctionDecl.ts create mode 100644 koala-wrapper/src/generated/peers/FunctionDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/FunctionExpression.ts create mode 100644 koala-wrapper/src/generated/peers/FunctionSignature.ts create mode 100644 koala-wrapper/src/generated/peers/Identifier.ts create mode 100644 koala-wrapper/src/generated/peers/IfStatement.ts create mode 100644 koala-wrapper/src/generated/peers/ImportDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/ImportDefaultSpecifier.ts create mode 100644 koala-wrapper/src/generated/peers/ImportExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ImportNamespaceSpecifier.ts create mode 100644 koala-wrapper/src/generated/peers/ImportSource.ts create mode 100644 koala-wrapper/src/generated/peers/ImportSpecifier.ts create mode 100644 koala-wrapper/src/generated/peers/InterfaceDecl.ts create mode 100644 koala-wrapper/src/generated/peers/LabelledStatement.ts create mode 100644 koala-wrapper/src/generated/peers/Literal.ts create mode 100644 koala-wrapper/src/generated/peers/LoopStatement.ts create mode 100644 koala-wrapper/src/generated/peers/MaybeOptionalExpression.ts create mode 100644 koala-wrapper/src/generated/peers/MemberExpression.ts create mode 100644 koala-wrapper/src/generated/peers/MetaProperty.ts create mode 100644 koala-wrapper/src/generated/peers/MethodDefinition.ts create mode 100644 koala-wrapper/src/generated/peers/NamedType.ts create mode 100644 koala-wrapper/src/generated/peers/NewExpression.ts create mode 100644 koala-wrapper/src/generated/peers/NullLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/NumberLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/ObjectExpression.ts create mode 100644 koala-wrapper/src/generated/peers/OmittedExpression.ts create mode 100644 koala-wrapper/src/generated/peers/OpaqueTypeNode.ts create mode 100644 koala-wrapper/src/generated/peers/PrefixAssertionExpression.ts create mode 100644 koala-wrapper/src/generated/peers/Property.ts create mode 100644 koala-wrapper/src/generated/peers/RegExpLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/ReturnStatement.ts create mode 100644 koala-wrapper/src/generated/peers/ScriptFunction.ts create mode 100644 koala-wrapper/src/generated/peers/SequenceExpression.ts create mode 100644 koala-wrapper/src/generated/peers/SpreadElement.ts create mode 100644 koala-wrapper/src/generated/peers/SrcDumper.ts create mode 100644 koala-wrapper/src/generated/peers/Statement.ts create mode 100644 koala-wrapper/src/generated/peers/StringLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/SuperExpression.ts create mode 100644 koala-wrapper/src/generated/peers/SwitchCaseStatement.ts create mode 100644 koala-wrapper/src/generated/peers/SwitchStatement.ts create mode 100644 koala-wrapper/src/generated/peers/TSAnyKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSArrayType.ts create mode 100644 koala-wrapper/src/generated/peers/TSAsExpression.ts create mode 100644 koala-wrapper/src/generated/peers/TSBigintKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSBooleanKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSClassImplements.ts create mode 100644 koala-wrapper/src/generated/peers/TSConditionalType.ts create mode 100644 koala-wrapper/src/generated/peers/TSConstructorType.ts create mode 100644 koala-wrapper/src/generated/peers/TSEnumDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/TSEnumMember.ts create mode 100644 koala-wrapper/src/generated/peers/TSExternalModuleReference.ts create mode 100644 koala-wrapper/src/generated/peers/TSFunctionType.ts create mode 100644 koala-wrapper/src/generated/peers/TSImportEqualsDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/TSImportType.ts create mode 100644 koala-wrapper/src/generated/peers/TSIndexSignature.ts create mode 100644 koala-wrapper/src/generated/peers/TSIndexedAccessType.ts create mode 100644 koala-wrapper/src/generated/peers/TSInferType.ts create mode 100644 koala-wrapper/src/generated/peers/TSInterfaceBody.ts create mode 100644 koala-wrapper/src/generated/peers/TSInterfaceDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/TSInterfaceHeritage.ts create mode 100644 koala-wrapper/src/generated/peers/TSIntersectionType.ts create mode 100644 koala-wrapper/src/generated/peers/TSLiteralType.ts create mode 100644 koala-wrapper/src/generated/peers/TSMappedType.ts create mode 100644 koala-wrapper/src/generated/peers/TSMethodSignature.ts create mode 100644 koala-wrapper/src/generated/peers/TSModuleBlock.ts create mode 100644 koala-wrapper/src/generated/peers/TSModuleDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/TSNamedTupleMember.ts create mode 100644 koala-wrapper/src/generated/peers/TSNeverKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSNonNullExpression.ts create mode 100644 koala-wrapper/src/generated/peers/TSNullKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSNumberKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSObjectKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSParameterProperty.ts create mode 100644 koala-wrapper/src/generated/peers/TSParenthesizedType.ts create mode 100644 koala-wrapper/src/generated/peers/TSPropertySignature.ts create mode 100644 koala-wrapper/src/generated/peers/TSQualifiedName.ts create mode 100644 koala-wrapper/src/generated/peers/TSSignatureDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/TSStringKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSThisType.ts create mode 100644 koala-wrapper/src/generated/peers/TSTupleType.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypeAliasDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypeAssertion.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypeLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypeOperator.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypeParameter.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypeParameterDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypeParameterInstantiation.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypePredicate.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypeQuery.ts create mode 100644 koala-wrapper/src/generated/peers/TSTypeReference.ts create mode 100644 koala-wrapper/src/generated/peers/TSUndefinedKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSUnionType.ts create mode 100644 koala-wrapper/src/generated/peers/TSUnknownKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TSVoidKeyword.ts create mode 100644 koala-wrapper/src/generated/peers/TaggedTemplateExpression.ts create mode 100644 koala-wrapper/src/generated/peers/TemplateElement.ts create mode 100644 koala-wrapper/src/generated/peers/TemplateLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/ThisExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ThrowStatement.ts create mode 100644 koala-wrapper/src/generated/peers/TryStatement.ts create mode 100644 koala-wrapper/src/generated/peers/TypeNode.ts create mode 100644 koala-wrapper/src/generated/peers/TypedAstNode.ts create mode 100644 koala-wrapper/src/generated/peers/TypedStatement.ts create mode 100644 koala-wrapper/src/generated/peers/TypeofExpression.ts create mode 100644 koala-wrapper/src/generated/peers/UnaryExpression.ts create mode 100644 koala-wrapper/src/generated/peers/UndefinedLiteral.ts create mode 100644 koala-wrapper/src/generated/peers/UpdateExpression.ts create mode 100644 koala-wrapper/src/generated/peers/ValidationInfo.ts create mode 100644 koala-wrapper/src/generated/peers/VariableDeclaration.ts create mode 100644 koala-wrapper/src/generated/peers/VariableDeclarator.ts create mode 100644 koala-wrapper/src/generated/peers/WhileStatement.ts create mode 100644 koala-wrapper/src/generated/peers/YieldExpression.ts create mode 100644 koala-wrapper/src/reexport-for-generated.ts create mode 100644 koala-wrapper/src/utils.ts create mode 100644 koala-wrapper/tools/issue_gen.mjs create mode 100644 koala-wrapper/tsconfig.json diff --git a/OAT.xml b/OAT.xml index 3aaf1c1b7..60823ce49 100644 --- a/OAT.xml +++ b/OAT.xml @@ -26,6 +26,7 @@ + diff --git a/arkui-plugins/.gitignore b/arkui-plugins/.gitignore new file mode 100644 index 000000000..7f8e5351e --- /dev/null +++ b/arkui-plugins/.gitignore @@ -0,0 +1,17 @@ +node_modules/ +**/*/node_modules/ + +**/*/dist/ +**/*/build/ +build/ +lib/ + +*.tgz + +package-lock.json +/**/*/package-lock.json + +coverage/ +**/*/generated + +test/demo/localtest/build_config.json diff --git a/arkui-plugins/.prettierrc b/arkui-plugins/.prettierrc new file mode 100644 index 000000000..e9e9c6fdb --- /dev/null +++ b/arkui-plugins/.prettierrc @@ -0,0 +1,8 @@ +{ + "semi": true, + "singleQuote": true, + "tabWidth": 4, + "trailingComma": "es5", + "bracketSpacing": true, + "printWidth": 120 +} \ No newline at end of file diff --git a/arkui-plugins/BUILD.gn b/arkui-plugins/BUILD.gn new file mode 100755 index 000000000..a262ea4c0 --- /dev/null +++ b/arkui-plugins/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2021-2022 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("//build/ohos.gni") + +npm_path = "//prebuilts/build-tools/common/nodejs/current/bin/npm" + +action("gen_ui_plugins") { + script = "build_ui_plugins.py" + args = [ + "--source_path", + rebase_path(get_path_info(".", "abspath")), + "--output_path", + rebase_path("$target_gen_dir"), + "--npm", + rebase_path(npm_path), + "--current_os", + "$current_os", + "--root_out_dir", + rebase_path(root_out_dir), + ] + outputs = [ "$target_gen_dir" ] +} + +ohos_copy("ui_plugin") { + deps = [ ":gen_ui_plugins" ] + sources = [ rebase_path("$target_gen_dir") ] + outputs = [ target_out_dir + "/$target_name" ] + module_source_dir = target_out_dir + "/$target_name" + module_install_name = "" + subsystem_name = "developtools" + part_name = "ace_ets2bundle" +} diff --git a/arkui-plugins/babel.config.js b/arkui-plugins/babel.config.js new file mode 100644 index 000000000..fe3d51b87 --- /dev/null +++ b/arkui-plugins/babel.config.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 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. + */ + +module.exports = function(api) { + api.cache(true); + + const presets = ['@babel/typescript']; + const plugins = [ + '@babel/plugin-transform-modules-commonjs', + '@babel/plugin-proposal-class-properties', + [ + '@babel/plugin-transform-arrow-functions', + { + spec: true + } + ], + './custom-import-plugin' + ]; + const ignore = [ + '**/test/**', + '**/node_modules/**', + 'jest-test.config.ts' + ]; + + return { + presets, + plugins, + ignore + }; +}; diff --git a/arkui-plugins/build_ui_plugins.py b/arkui-plugins/build_ui_plugins.py new file mode 100755 index 000000000..3fe73510c --- /dev/null +++ b/arkui-plugins/build_ui_plugins.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 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 argparse +import os +import shutil +import subprocess +import sys +import tarfile + + +def copy_files(source_path, dest_path, is_file=False): + try: + if is_file: + os.makedirs(os.path.dirname(dest_path), exist_ok=True) + shutil.copy(source_path, dest_path) + else: + shutil.copytree(source_path, dest_path, dirs_exist_ok=True, + symlinks=True) + except Exception as err: + raise Exception("Copy files failed. Error: " + str(err)) from err + + +def run_cmd(cmd, execution_path=None): + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stdin=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=execution_path) + stdout, stderr = proc.communicate(timeout=1000) + if proc.returncode != 0: + raise Exception(stderr.decode()) + + +def build(options): + build_cmd = [options.npm, 'run', 'compile:plugins'] + run_cmd(build_cmd, options.source_path) + + +def copy_output(options): + run_cmd(['rm', '-rf', options.output_path]) + copy_files(os.path.join(options.source_path, 'lib'), + os.path.join(options.output_path, 'lib')) + + copy_files(os.path.join(options.source_path, 'package.json'), + os.path.join(options.output_path, 'package.json'), True) + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--npm', help='path to a npm exetuable') + parser.add_argument('--source_path', help='path to build system source') + parser.add_argument('--output_path', help='path to output') + parser.add_argument('--root_out_dir', help='path to root out') + parser.add_argument('--current_os', help='current_os') + + options = parser.parse_args() + return options + + +def main(): + options = parse_args() + + build(options) + copy_output(options) + + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file diff --git a/arkui-plugins/common/abstract-visitor.ts b/arkui-plugins/common/abstract-visitor.ts new file mode 100644 index 000000000..2c7a307da --- /dev/null +++ b/arkui-plugins/common/abstract-visitor.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; + +export interface VisitorOptions { + isExternal?: boolean; + externalSourceName?: string; + program?: arkts.Program; +} + +export abstract class AbstractVisitor implements VisitorOptions { + public isExternal: boolean; + public externalSourceName?: string; + public program?: arkts.Program; + + constructor(options?: VisitorOptions) { + this.isExternal = options?.isExternal ?? false; + this.externalSourceName = options?.externalSourceName; + this.program = options?.program; + } + + indentation = 0; + + withIndentation(exec: () => T) { + this.indentation++; + const result = exec(); + this.indentation--; + return result; + } + + abstract visitor(node: arkts.AstNode): arkts.AstNode; + + reset(): void { + this.indentation = 0; + } + + visitEachChild(node: arkts.AstNode): arkts.AstNode { + return this.withIndentation(() => arkts.visitEachChild(node, (it) => this.visitor(it))); + } +} diff --git a/arkui-plugins/common/arkts-utils.ts b/arkui-plugins/common/arkts-utils.ts new file mode 100644 index 000000000..771442543 --- /dev/null +++ b/arkui-plugins/common/arkts-utils.ts @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +export function annotation(name: string): arkts.AnnotationUsage { + const ident: arkts.Identifier = arkts.factory.createIdentifier(name).setAnnotationUsage(); + const annotation: arkts.AnnotationUsage = arkts.factory.createAnnotationUsage(ident); + + annotation.modifiers = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_ANNOTATION_USAGE; + ident.parent = annotation; + + return annotation; +} + +export function isAnnotation(node: arkts.AnnotationUsage, annoName: string) { + return node.expr !== undefined && arkts.isIdentifier(node.expr) && node.expr.name === annoName; +} + +export function removeAnnotationByName( + annotations: readonly arkts.AnnotationUsage[], + annoName: string +): arkts.AnnotationUsage[] { + return annotations.filter((it) => !isAnnotation(it, annoName)); +} + +export function expectName(node: arkts.AstNode | undefined): string { + if (!node) { + throw new Error('Expected an identifier, got empty node'); + } + if (!arkts.isIdentifier(node)) { + throw new Error('Expected an identifier, got: ' + arkts.nodeType(node).toString()); + } + return node.name; +} + +export function mangle(value: string): string { + return `__${value}`; +} + +export function backingField(originalName: string): string { + return mangle(`backing_${originalName}`); +} + +export function filterDefined(value: (T | undefined)[]): T[] { + return value.filter((it: T | undefined): it is T => it != undefined); +} + +export function collect(...value: (ReadonlyArray | T | undefined)[]): T[] { + const empty: (T | undefined)[] = []; + return filterDefined(empty.concat(...value)); +} + +export function matchPrefix(prefixCollection: (string | RegExp)[], name: string): boolean { + for (const prefix of prefixCollection) { + let regex: RegExp; + + if (typeof prefix === 'string') { + regex = new RegExp('^' + prefix); + } else { + regex = new RegExp('^' + prefix.source); + } + + if (regex.test(name)) { + return true; + } + } + return false; +} + +export function updateStructMetadata( + structInfo: arkts.StructInfo, + propertyName: string, + properties: string[], + modifiers: arkts.Es2pandaModifierFlags, + hasStateManagementType?: boolean +): arkts.StructInfo { + const metadata: Record = structInfo.metadata ?? {}; + metadata[propertyName] = { + name: propertyName, + properties, + modifiers, + hasStateManagementType, + }; + structInfo.metadata = metadata; + return structInfo; +} diff --git a/arkui-plugins/common/debug.ts b/arkui-plugins/common/debug.ts new file mode 100644 index 000000000..f39940e8f --- /dev/null +++ b/arkui-plugins/common/debug.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 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 * as fs from 'fs'; +import * as path from 'path'; +import * as arkts from '@koalaui/libarkts'; + +const isDebugLog: boolean = false; +const isDebugDump: boolean = false; +const isPerformance: boolean = false; +arkts.Performance.getInstance().skip(!isPerformance); + +export function getEnumName(enumType: any, value: number): string | undefined { + return enumType[value]; +} + +function mkDir(filePath: string): void { + const parent = path.join(filePath, '..'); + if (!(fs.existsSync(parent) && !fs.statSync(parent).isFile())) { + mkDir(parent); + } + fs.mkdirSync(filePath); +} + +export function debugDump( + content: string, + fileName: string, + isInit: boolean, + cachePath: string | undefined, + programFileName: string +): void { + if (!isDebugDump) return; + const currentDirectory = process.cwd(); + const modifiedFileName = programFileName.replaceAll('.', '_'); + const outputDir: string = cachePath + ? path.resolve(currentDirectory, cachePath, modifiedFileName) + : path.resolve(currentDirectory, 'dist', 'cache', modifiedFileName); + const filePath: string = path.resolve(outputDir, fileName); + if (!fs.existsSync(outputDir)) { + mkDir(outputDir); + } + try { + if (!isInit && fs.existsSync(filePath)) { + const existingContent = fs.readFileSync(filePath, 'utf8'); + const newContent = + existingContent && !existingContent.endsWith('\n') + ? existingContent + '\n' + content + : existingContent + content; + fs.writeFileSync(filePath, newContent, 'utf8'); + } else { + fs.writeFileSync(filePath, content, 'utf8'); + } + } catch (error) { + console.error('文件操作失败:', error); + } +} + +export function debugLog(message?: any, ...optionalParams: any[]): void { + if (!isDebugLog) return; + console.log(message, ...optionalParams); +} + +export function getDumpFileName(state: number, prefix: string, index: number | undefined, suffix: string): string { + return `${state}_${prefix}_${index ?? ''}_${suffix}.sts`; +} diff --git a/arkui-plugins/common/etsglobal-remover.ts b/arkui-plugins/common/etsglobal-remover.ts new file mode 100644 index 000000000..3d9711799 --- /dev/null +++ b/arkui-plugins/common/etsglobal-remover.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { AbstractVisitor } from './abstract-visitor'; + +const ETSGLOBAL = 'ETSGLOBAL'; + +export class EtsglobalRemover extends AbstractVisitor { + visitor(node: arkts.AstNode): arkts.AstNode { + if (arkts.isEtsScript(node)) { + const keep = node.statements.filter((it) => { + return !(arkts.isClassDeclaration(it) && it.definition?.ident?.name == ETSGLOBAL); + }); + return arkts.factory.updateEtsScript(node, keep); + } + return node; + } +} diff --git a/arkui-plugins/common/gensym-generator.ts b/arkui-plugins/common/gensym-generator.ts new file mode 100644 index 000000000..6e05f109d --- /dev/null +++ b/arkui-plugins/common/gensym-generator.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 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 { getCommonPath } from '../path'; +const common = require(getCommonPath()); +const UniqueId = common.UniqueId; + +export class GenSymGenerator { + // Global for the whole program. + private static callCount: number = 0; + static instance: GenSymGenerator; + + // Set `stable` to true if you want to have more predictable values. + // For example for tests. + // Don't use it in production! + private constructor(public stableForTests: boolean = false) { + if (stableForTests) GenSymGenerator.callCount = 0; + } + + static getInstance(stableForTests: boolean = false): GenSymGenerator { + if (!this.instance) { + this.instance = new GenSymGenerator(stableForTests); + } + + return this.instance; + } + + sha1Id(callName: string): string { + const uniqId = new UniqueId(); + uniqId.addString('gensym uniqid'); + uniqId.addString(callName); + uniqId.addI32(GenSymGenerator.callCount++); + return uniqId.compute().substring(0, 7); + } + + stringId(callName: string): string { + return `${GenSymGenerator.callCount++}_${callName}_id`; + } + + id(callName: string = ''): string { + const positionId = this.stableForTests ? this.stringId(callName) : this.sha1Id(callName); + + const coreceToStr = parseInt(positionId, 16).toString(); + + // compiler use gensym%%_ but % is illegal before after-check phase + return `gensym___${coreceToStr}`; + } +} diff --git a/arkui-plugins/common/plugin-context.ts b/arkui-plugins/common/plugin-context.ts new file mode 100644 index 000000000..f0ad9ccb4 --- /dev/null +++ b/arkui-plugins/common/plugin-context.ts @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +// This is the same plugin-context in the build-system. +export class PluginContext { + private ast: arkts.EtsScript | undefined; + private program: arkts.Program | undefined; + private projectConfig: ProjectConfig | undefined; + private contextPtr: number | undefined; + + constructor() { + this.ast = undefined; + this.program = undefined; + this.projectConfig = undefined; + this.contextPtr = undefined; + } + + /** + * @deprecated + */ + public setArkTSAst(ast: arkts.EtsScript): void { + this.ast = ast; + } + + /** + * @deprecated + */ + public getArkTSAst(): arkts.EtsScript | undefined { + return this.ast; + } + + /** + * @deprecated + */ + public setArkTSProgram(program: arkts.Program): void { + this.program = program; + } + + /** + * @deprecated + */ + public getArkTSProgram(): arkts.Program | undefined { + return this.program; + } + + public setProjectConfig(projectConfig: ProjectConfig): void { + throw new Error('do not set projectConfig!'); + } + + public getProjectConfig(): ProjectConfig | undefined { + return this.projectConfig; + } + + public setContextPtr(ptr: number): void { + this.contextPtr = ptr; + } + + public getContextPtr(): number | undefined { + return this.contextPtr; + } +} + +export interface ProjectConfig { + bundleName: string; + moduleName: string; + cachePath: string; +} + +export type PluginHandlerFunction = () => void; + +export type PluginHandlerObject = { + order: 'pre' | 'post' | undefined; + handler: PluginHandlerFunction; +}; + +export type PluginHandler = PluginHandlerFunction | PluginHandlerObject; + +export interface Plugins { + name: string; + afterNew?: PluginHandler; + parsed?: PluginHandler; + scopeInited?: PluginHandler; + checked?: PluginHandler; + lowered?: PluginHandler; + asmGenerated?: PluginHandler; + binGenerated?: PluginHandler; + clean?: PluginHandler; +} + +export type PluginState = keyof Omit; + +export type PluginExecutor = { + name: string; + handler: PluginHandlerFunction; +}; diff --git a/arkui-plugins/common/predefines.ts b/arkui-plugins/common/predefines.ts new file mode 100644 index 000000000..08ce2babe --- /dev/null +++ b/arkui-plugins/common/predefines.ts @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2025 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 const EXTERNAL_SOURCE_PREFIX_NAMES: (string | RegExp)[] = [ + 'std', + 'escompat', + 'security', + 'application', + 'permissions', + 'bundleManager', + 'commonEvent', + /@arkts\..*/, + /@ohos\.(?!arkui).*/, + /@system\..*/, + /arkui\.(?![Uu]serView$)[A-Z]/, // temporary solution + /ability\..*/, +]; + +export const ARKUI_COMPONENT_IMPORT_NAME: string = '@ohos.arkui.component'; + +export const ARKUI_STATEMANAGEMENT_IMPORT_NAME: string = '@ohos.arkui.stateManagement'; + +export const EXTERNAL_SOURCE_ALLOWED_IMPORT_INSERT_NAMES: string[] = [ + ARKUI_COMPONENT_IMPORT_NAME, + ARKUI_STATEMANAGEMENT_IMPORT_NAME, +]; + +export const IMPORT_SOURCE_MAP: Map> = new Map>([ + ['@ohos.arkui.component', new Set(['$r', '$rawfile', '_r', '_rawfile'])], + [ + '@ohos.arkui.stateManagement', + new Set([ + 'State', + 'Prop', + 'Provide', + 'Consume', + 'StorageLink', + 'StorageProp', + 'LocalStorageLink', + 'LocalStorageProp', + 'Watch', + 'ObjectLink', + 'StateDecoratedVariable', + 'MutableState', + 'contextLocalStateOf', + 'contextLocal', + 'observableProxy', + 'SyncedProperty', + 'objectLinkState', + 'propState', + 'AppStorageLinkState', + 'StorageLinkState', + 'DecoratedV1VariableBase', + 'LinkDecoratedVariable', + 'PropDecoratedVariable', + 'StorageLinkDecoratedVariable', + 'StoragePropDecoratedVariable', + 'memo', + '__memo_context_type', + '__memo_id_type', + ]), + ], +]); + +export const OUTPUT_DEPENDENCY_MAP: Map = new Map([ + ['$r', ['_r']], + ['$rawfile', ['_rawfile']], + ['State', ['StateDecoratedVariable']], + ['Link', ['LinkDecoratedVariable', 'DecoratedV1VariableBase']], + ['Prop', ['PropDecoratedVariable']], + ['Provide', ['MutableState', 'contextLocalStateOf', 'observableProxy']], + ['Consume', ['MutableState', 'contextLocal', 'observableProxy']], + ['StorageProp', ['StoragePropDecoratedVariable']], + ['StorageLink', ['StorageLinkDecoratedVariable']], + ['LocalStorageLink', ['StorageLinkState', 'MutableState', 'observableProxy']], + ['LocalStorageProp', ['StorageLinkState', 'MutableState', 'observableProxy', 'propState']], + ['ObjectLink', ['objectLinkState', 'observableProxy', 'SyncedProperty']], +]); diff --git a/arkui-plugins/common/print-visitor.ts b/arkui-plugins/common/print-visitor.ts new file mode 100644 index 000000000..9f69e250d --- /dev/null +++ b/arkui-plugins/common/print-visitor.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { AbstractVisitor } from '../common/abstract-visitor'; + +export class PrintVisitor extends AbstractVisitor { + private result = ''; + + private printNode(node: arkts.AstNode) { + return `${' '.repeat(4 * this.indentation) + node.constructor.name} ${this.nameIfIdentifier(node)}`; + } + + private nameIfIdentifier(node: arkts.AstNode): string { + return arkts.isIdentifier(node) ? `'${node.name}'` : ''; + } + + visitor(node: arkts.AstNode): arkts.AstNode { + console.log(this.printNode(node)); + return this.visitEachChild(node); + } +} diff --git a/arkui-plugins/common/program-visitor.ts b/arkui-plugins/common/program-visitor.ts new file mode 100644 index 000000000..e50bcbe08 --- /dev/null +++ b/arkui-plugins/common/program-visitor.ts @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { AbstractVisitor, VisitorOptions } from './abstract-visitor'; +import { matchPrefix } from './arkts-utils'; +import { debugDump, getDumpFileName } from './debug'; +import { ARKUI_COMPONENT_IMPORT_NAME } from './predefines'; +import { PluginContext } from './plugin-context'; + +export interface ProgramVisitorOptions extends VisitorOptions { + pluginName: string; + state: arkts.Es2pandaContextState; + visitors: AbstractVisitor[]; + skipPrefixNames: (string | RegExp)[]; + hooks?: ProgramHooks; + pluginContext?: PluginContext; +} + +export interface ProgramHookConfig { + visitors: AbstractVisitor[]; + resetAfter?: arkts.Es2pandaContextState; +} + +export type ProgramHookLifeCycle = Partial>; + +export interface ProgramHooks { + external?: ProgramHookLifeCycle; + source?: ProgramHookLifeCycle; +} + +function flattenVisitorsInHooks( + programHooks?: ProgramHooks, + resetAfterValue?: arkts.Es2pandaContextState +): AbstractVisitor[] { + if (!programHooks) return []; + const flatMapInHook = (config: ProgramHookConfig): AbstractVisitor[] => { + if (!resetAfterValue) return []; + if (!config.resetAfter || resetAfterValue !== config.resetAfter) return []; + return config.visitors; + }; + return [ + ...Object.values(programHooks.external || {}).flatMap(flatMapInHook), + ...Object.values(programHooks.source || {}).flatMap(flatMapInHook), + ]; +} + +function sortExternalSources(externalSources: arkts.ExternalSource[]): arkts.ExternalSource[] { + return externalSources.sort((a, b) => { + const prefix = ARKUI_COMPONENT_IMPORT_NAME; + const hasPrefixA = a.getName().startsWith(prefix); + const hasPrefixB = b.getName().startsWith(prefix); + + // If both have the prefix, maintain their original order + if (hasPrefixA && hasPrefixB) { + return 0; + } + // If neither has the prefix, maintain their original order + if (!hasPrefixA && !hasPrefixB) { + return 0; + } + // If only one has the prefix, the one with the prefix comes first + return hasPrefixA ? -1 : 1; + }); +} + +export class ProgramVisitor extends AbstractVisitor { + private readonly pluginName: string; + private readonly state: arkts.Es2pandaContextState; + private readonly visitors: AbstractVisitor[]; + private readonly skipPrefixNames: (string | RegExp)[]; + private readonly hooks?: ProgramHooks; + private filenames: Map; + private pluginContext?: PluginContext; + + constructor(options: ProgramVisitorOptions) { + super(options); + this.pluginName = options.pluginName; + this.state = options.state; + this.visitors = options.visitors; + this.skipPrefixNames = options.skipPrefixNames ?? []; + this.hooks = options.hooks; + this.filenames = new Map(); + this.pluginContext = options.pluginContext; + } + + reset(): void { + super.reset(); + this.filenames = new Map(); + } + + programVisitor(program: arkts.Program): arkts.Program { + const skipPrefixes: (string | RegExp)[] = this.skipPrefixNames; + + const visited = new Set(); + const queue: arkts.Program[] = [program]; + + while (queue.length > 0) { + const currProgram = queue.shift()!; + if (visited.has(currProgram.peer)) { + continue; + } + + if (currProgram.peer !== program.peer) { + const name: string = this.filenames.get(currProgram.peer)!; + const cachePath: string | undefined = this.pluginContext?.getProjectConfig()?.cachePath; + debugDump( + currProgram.astNode.dumpSrc(), + getDumpFileName(this.state, 'ORI', undefined, name), + true, + cachePath, + program.programFileNameWithExtension + ); + const script = this.visitor(currProgram.astNode, currProgram, name); + if (script) { + debugDump( + script.dumpSrc(), + getDumpFileName(this.state, this.pluginName, undefined, name), + true, + cachePath, + program.programFileNameWithExtension + ); + } + } + + visited.add(currProgram.peer); + + for (const externalSource of sortExternalSources(currProgram.externalSources)) { + // TODO: this is very time-consuming... + if (matchPrefix(skipPrefixes, externalSource.getName())) { + continue; + } + + const nextProgramArr: arkts.Program[] = externalSource.programs ?? []; + for (const nextProgram of nextProgramArr) { + this.filenames.set(nextProgram.peer, externalSource.getName()); + if (!visited.has(nextProgram.peer)) { + queue.push(nextProgram); + } + } + } + } + + let programScript = program.astNode; + programScript = this.visitor(programScript, program, this.externalSourceName); + + const visitorsToReset = flattenVisitorsInHooks(this.hooks, this.state); + visitorsToReset.forEach((visitor) => visitor.reset()); + + return program; + } + + visitor(node: arkts.AstNode, program?: arkts.Program, externalSourceName?: string): arkts.EtsScript { + let hook: ProgramHookLifeCycle | undefined; + + let script: arkts.EtsScript = node as arkts.EtsScript; + let count: number = 0; + const isExternal: boolean = !!externalSourceName; + + // pre-run visitors + hook = isExternal ? this.hooks?.external : this.hooks?.source; + const preVisitors = hook?.pre?.visitors ?? []; + for (const transformer of preVisitors) { + transformer.isExternal = isExternal; + transformer.externalSourceName = externalSourceName; + transformer.program = program; + transformer.visitor(script); + if (!this.hooks?.external?.pre?.resetAfter) transformer.reset(); + } + + for (const transformer of this.visitors) { + transformer.isExternal = isExternal; + transformer.externalSourceName = externalSourceName; + transformer.program = program; + script = transformer.visitor(script) as arkts.EtsScript; + transformer.reset(); + arkts.setAllParents(script); + if (!transformer.isExternal) { + debugDump( + script.dumpSrc(), + getDumpFileName(this.state, this.pluginName, count, transformer.constructor.name), + true, + this.pluginContext?.getProjectConfig()?.cachePath, + program!.programFileNameWithExtension + ); + count += 1; + } + } + + // post-run visitors + hook = isExternal ? this.hooks?.external : this.hooks?.source; + const postVisitors = hook?.post?.visitors ?? []; + for (const transformer of postVisitors) { + transformer.isExternal = isExternal; + transformer.externalSourceName = externalSourceName; + transformer.program = program; + transformer.visitor(script); + if (!this.hooks?.external?.pre?.resetAfter) transformer.reset(); + } + + return script; + } +} diff --git a/arkui-plugins/custom-import-plugin.js b/arkui-plugins/custom-import-plugin.js new file mode 100644 index 000000000..84b8a6bd5 --- /dev/null +++ b/arkui-plugins/custom-import-plugin.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 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. + */ + + +const path = require('path'); + +module.exports = function (babel) { + const { types: t } = babel; + + return { + name: 'custom-import-plugin', + visitor: { + ImportDeclaration(pathNode) { + const sourceValue = pathNode.node.source.value; + if (sourceValue === '@koalaui/libarkts' && pathNode.node.specifiers.length === 1 && t.isImportNamespaceSpecifier(pathNode.node.specifiers[0])) { + const currentFileDir = path.dirname(pathNode.hub.file.opts.filename); + const configDir = process.cwd(); + const relativePath = path.relative(currentFileDir, configDir); + const importPath = relativePath ? path.join(relativePath, 'path') : './path'; + + const newImport = t.importDeclaration( + [t.importSpecifier(t.identifier('getArktsPath'), t.identifier('getArktsPath'))], + t.stringLiteral(importPath) + ); + + const requireCall = t.callExpression(t.identifier('require'), [t.callExpression(t.identifier('getArktsPath'), [])]); + const arkts = t.variableDeclaration('const', [ + t.variableDeclarator(t.identifier('arkts'), requireCall) + ]); + + pathNode.replaceWithMultiple([newImport, arkts]); + } + } + } + }; +}; \ No newline at end of file diff --git a/arkui-plugins/interop-plugins/decl_transformer.ts b/arkui-plugins/interop-plugins/decl_transformer.ts new file mode 100644 index 000000000..57cf9906d --- /dev/null +++ b/arkui-plugins/interop-plugins/decl_transformer.ts @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { AbstractVisitor } from '../common/abstract-visitor'; + +import { debugLog } from '../common/debug'; + +export class DeclTransformer extends AbstractVisitor { + constructor(private options?: interop.DeclTransformerOptions) { + super(); + } + + processComponent(node: arkts.StructDeclaration): arkts.ClassDeclaration { + const className = node.definition?.ident?.name; + if (!className) { + throw 'Non Empty className expected for Component'; + } + + let newDec: arkts.ClassDeclaration = arkts.factory.createClassDeclaration(node.definition); + + const newDefinition = arkts.factory.updateClassDefinition( + newDec.definition!, + newDec.definition?.ident, + undefined, + undefined, + newDec.definition?.implements!, + undefined, + undefined, + node.definition?.body, + newDec.definition?.modifiers!, + arkts.classDefinitionFlags(newDec.definition!) | arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + ); + + arkts.factory.updateClassDeclaration(newDec, newDefinition); + newDec.modifiers = node.modifiers; + return newDec; + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + let astNode: arkts.AstNode = beforeChildren; + if (arkts.isEtsScript(astNode)) { + astNode = this.transformImportDecl(astNode); + } + + const node = this.visitEachChild(astNode); + if (arkts.isStructDeclaration(node)) { + debugLog(`DeclTransformer:before:flag:${arkts.classDefinitionIsFromStructConst(node.definition!)}`); + arkts.classDefinitionSetFromStructModifier(node.definition!); + let newnode = this.processComponent(node); + debugLog(`DeclTransformer:after:flag:${arkts.classDefinitionIsFromStructConst(newnode.definition!)}`); + return newnode; + } + return node; + } + + transformImportDecl(estNode: arkts.AstNode): arkts.AstNode { + if (!arkts.isEtsScript(estNode)) { + return estNode; + } + + let statements = estNode.statements + .filter((node) => this.isImportDeclarationNeedFilter(node)) + .map((node) => this.updateImportDeclaration(node)); + + return arkts.factory.updateEtsScript(estNode, statements); + } + + isImportDeclarationNeedFilter(astNode: arkts.AstNode): boolean { + return !arkts.isETSImportDeclaration(astNode); + } + + updateImportDeclaration(astNode: arkts.AstNode): arkts.AstNode { + return astNode; + } +} diff --git a/arkui-plugins/interop-plugins/emit_transformer.ts b/arkui-plugins/interop-plugins/emit_transformer.ts new file mode 100644 index 000000000..d68dfbc2f --- /dev/null +++ b/arkui-plugins/interop-plugins/emit_transformer.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { AbstractVisitor } from '../common/abstract-visitor'; + +import { debugLog } from '../common/debug'; + +export class EmitTransformer extends AbstractVisitor { + constructor(private options?: interop.EmitTransformerOptions) { + super(); + } + + processComponent(node: arkts.ClassDeclaration): arkts.ClassDeclaration { + const className = node.definition?.ident?.name; + if (!className) { + throw 'Non Empty className expected for Component'; + } + + const newDefinition = arkts.factory.updateClassDefinition( + node.definition, + node.definition?.ident, + undefined, + undefined, + node.definition?.implements, + undefined, + undefined, + node.definition?.body, + node.definition?.modifiers, + arkts.classDefinitionFlags(node.definition) | arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + ); + + let newDec: arkts.ClassDeclaration = arkts.factory.updateClassDeclaration(node, newDefinition); + + debugLog(`DeclTransformer:checked:struct_ast:${newDefinition.dumpJson()}`); + newDec.modifiers = node.modifiers; + return newDec; + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + const node = this.visitEachChild(beforeChildren); + if (arkts.isClassDeclaration(node) && arkts.classDefinitionIsFromStructConst(node.definition!)) { + return this.processComponent(node); + } + return node; + } +} diff --git a/arkui-plugins/interop-plugins/index.ts b/arkui-plugins/interop-plugins/index.ts new file mode 100644 index 000000000..bac3e903b --- /dev/null +++ b/arkui-plugins/interop-plugins/index.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 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 { interopPlugin } from './interop_plugin'; + +export function interopTransform() { + return interopPlugin; +} diff --git a/arkui-plugins/interop-plugins/interop_plugin.ts b/arkui-plugins/interop-plugins/interop_plugin.ts new file mode 100644 index 000000000..e0ef5ddec --- /dev/null +++ b/arkui-plugins/interop-plugins/interop_plugin.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { DeclTransformer } from './decl_transformer'; +import { EmitTransformer } from './emit_transformer'; +import { ProgramVisitor } from '../common/program-visitor'; +import { EXTERNAL_SOURCE_PREFIX_NAMES } from '../common/predefines'; + +import { debugLog } from '../common/debug'; + +export const interopPlugin: interop.Plugin = { + name: 'interop-plugin', + parsed(this: interop.PluginContext) { + debugLog('interopTransform:parsed'); + let node = this.getArkTSAst(); + + if (node) { + debugLog('interopTransform:parsed:before:source: ', node.dumpSrc()); + debugLog('interopTransform:parsed:before:ast: ', node.dumpJson()); + + let script: arkts.EtsScript = node as arkts.EtsScript; + + const declTransformer = new DeclTransformer({ + arkui: '@koalaui.arkts-arkui.StructParse' as interop.TransfromerName, + }); + + const programVisitor = new ProgramVisitor({ + pluginName: 'decl', + state: arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, + visitors: [declTransformer], + skipPrefixNames: EXTERNAL_SOURCE_PREFIX_NAMES, + }); + + script = programVisitor.visitor(script); + + debugLog('interopTransform:parsed:after:source: ', script.dumpSrc()); + debugLog('interopTransform:parsed:after:ast: ', script.dumpJson()); + + this.setArkTSAst(script); + return script as interop.EtsScript; + } + }, + checked(this: interop.PluginContext) { + debugLog('interopTransform:checked'); + let node = this.getArkTSAst(); + if (node) { + debugLog('interopTransform:checked:before:source: ', node.dumpSrc()); + debugLog('interopTransform:parsed:before:ast: ', node.dumpJson()); + + let script: arkts.EtsScript = node as arkts.EtsScript; + + const emitTransformer = new EmitTransformer({ + arkui: '@koalaui.arkts-arkui.EmitBase' as interop.TransfromerName, + }); + + const programVisitor = new ProgramVisitor({ + pluginName: 'emit', + state: arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, + visitors: [emitTransformer], + skipPrefixNames: EXTERNAL_SOURCE_PREFIX_NAMES, + }); + + // script = programVisitor.visitor(script); + + debugLog('interopTransform:checked:after:source: ', script.dumpSrc()); + debugLog('interopTransform:checked:after:ast: ', script.dumpJson()); + + this.setArkTSAst(script); + return script as interop.EtsScript; + } + }, +}; diff --git a/arkui-plugins/interop-plugins/types.ts b/arkui-plugins/interop-plugins/types.ts new file mode 100644 index 000000000..49b257dc5 --- /dev/null +++ b/arkui-plugins/interop-plugins/types.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 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. + */ + +namespace interop { + export type NativePointer = number; + + export interface PluginContext { + setArkTSAst(ast: Node): void; + getArkTSAst(): Node | undefined; + setArkTSProgram(program: Node): void; + getArkTSProgram(): Node | undefined; + setProjectConfig(projectConfig: Node): void; + getProjectConfig(): Node | undefined; + } + + export interface ArktsObject { + readonly peer: NativePointer; + } + + export interface Node extends ArktsObject { + get originalPeer(): NativePointer; + set originalPeer(peer: NativePointer); + dumpJson(): string; + dumpSrc(): string; + } + + export interface EtsScript extends Node {} + + export interface Plugin { + name: string; + parsed?(context: PluginContext): EtsScript | undefined; + checked?(context: PluginContext): EtsScript | undefined; + } + + export type TransfromerName = string & { __TransfromerNameBrand: any }; + + export interface EmitTransformerOptions { + arkui: TransfromerName; + } + + export interface DeclTransformerOptions { + arkui: TransfromerName; + } +} diff --git a/arkui-plugins/jest-test.config.ts b/arkui-plugins/jest-test.config.ts new file mode 100644 index 000000000..8295964bc --- /dev/null +++ b/arkui-plugins/jest-test.config.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 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 default { + testEnvironment: 'node', + transform: { + '^.+\\.ts$': ['ts-jest', { isolatedModules: true }], + }, + testRegex: './test/ut/.+\\.test\\.ts$', + moduleFileExtensions: ['ts', 'js', 'json', 'node'], + coverageDirectory: './test/report', + collectCoverageFrom: ['common/**', 'memo-plugins/**', 'ui-plugins/**'], + verbose: true, +}; diff --git a/arkui-plugins/memo-plugins/function-transformer.ts b/arkui-plugins/memo-plugins/function-transformer.ts new file mode 100644 index 000000000..1d9b5a3cf --- /dev/null +++ b/arkui-plugins/memo-plugins/function-transformer.ts @@ -0,0 +1,457 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { factory } from './memo-factory'; +import { AbstractVisitor, VisitorOptions } from '../common/abstract-visitor'; +import { + PositionalIdTracker, + castArrowFunctionExpression, + castFunctionExpression, + castOverloadsToMethods, + castParameters, + findMemoFromTypeAnnotation, + hasMemoAnnotation, + hasMemoIntrinsicAnnotation, + hasMemoStableAnnotation, + isMemoArrowFunction, + isMemoClassProperty, + isMemoMethodDefinition, + isMemoTSTypeAliasDeclaration, + isStandaloneArrowFunction, + isVoidType, + removeMemoAnnotation, +} from './utils'; +import { ParameterTransformer } from './parameter-transformer'; +import { ReturnTransformer } from './return-transformer'; +import { SignatureTransformer } from './signature-transformer'; + +function mayAddLastReturn(node: arkts.BlockStatement): boolean { + return ( + node.statements.length > 0 && + !arkts.isReturnStatement(node.statements[node.statements.length - 1]) && + !arkts.isThrowStatement(node.statements[node.statements.length - 1]) + ); +} + +function updateFunctionBody( + node: arkts.BlockStatement, + parameters: arkts.ETSParameterExpression[], + returnTypeAnnotation: arkts.TypeNode | undefined, + stableThis: boolean, + hash: arkts.NumberLiteral | arkts.StringLiteral +): [ + arkts.BlockStatement, + arkts.VariableDeclaration | undefined, + arkts.ReturnStatement | arkts.BlockStatement | undefined +] { + let returnTypeAnno = + !returnTypeAnnotation || stableThis + ? arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID) + : returnTypeAnnotation; + const scopeDeclaration = factory.createScopeDeclaration(returnTypeAnno, hash, parameters.length); + const memoParameters = parameters.map((name, id) => { + return factory.createMemoParameterDeclarator(id, name.identifier.name); + }); + const memoParametersDeclaration = memoParameters.length + ? [ + arkts.factory.createVariableDeclaration( + 0, + arkts.Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_CONST, + memoParameters + ), + ] + : []; + const syntheticReturnStatement = factory.createSyntheticReturnStatement(stableThis); + const isVoidValue = isVoidType(returnTypeAnno); + const unchangedCheck = factory.createIfStatementWithSyntheticReturnStatement(syntheticReturnStatement, isVoidValue); + if (node) { + return [ + arkts.factory.updateBlock(node, [ + scopeDeclaration, + ...memoParametersDeclaration, + unchangedCheck, + ...node.statements, + ...(mayAddLastReturn(node) ? [arkts.factory.createReturnStatement()] : []), + ]), + memoParametersDeclaration.length ? memoParametersDeclaration[0] : undefined, + syntheticReturnStatement, + ]; + } else { + return [ + node, + memoParametersDeclaration.length ? memoParametersDeclaration[0] : undefined, + syntheticReturnStatement, + ]; + } +} + +function updateMemoTypeAnnotation(typeAnnotation: arkts.AstNode | undefined): arkts.TypeNode | undefined { + if (!typeAnnotation) return undefined; + if (!arkts.isTypeNode(typeAnnotation)) return undefined; + + if (typeAnnotation && arkts.isETSFunctionType(typeAnnotation)) { + return factory.updateFunctionTypeWithMemoParameters(typeAnnotation); + } else if (typeAnnotation && arkts.isETSUnionType(typeAnnotation)) { + return arkts.factory.updateUnionType( + typeAnnotation, + typeAnnotation.types.map((it) => { + if (arkts.isETSFunctionType(it)) { + return factory.updateFunctionTypeWithMemoParameters(it); + } + return it; + }) + ); + } + return typeAnnotation; +} + +type ScopeInfo = { + name?: string; + isMemo: boolean; +}; + +export interface FunctionTransformerOptions extends VisitorOptions { + positionalIdTracker: PositionalIdTracker; + parameterTransformer: ParameterTransformer; + returnTransformer: ReturnTransformer; + signatureTransformer: SignatureTransformer; +} + +export class FunctionTransformer extends AbstractVisitor { + private readonly positionalIdTracker: PositionalIdTracker; + private readonly parameterTransformer: ParameterTransformer; + private readonly returnTransformer: ReturnTransformer; + private readonly signatureTransformer: SignatureTransformer; + + constructor(options: FunctionTransformerOptions) { + super(options); + this.positionalIdTracker = options.positionalIdTracker; + this.parameterTransformer = options.parameterTransformer; + this.returnTransformer = options.returnTransformer; + this.signatureTransformer = options.signatureTransformer; + } + + private scopes: ScopeInfo[] = []; + private stable: number = 0; + + reset() { + super.reset(); + this.scopes = []; + this.stable = 0; + this.parameterTransformer.reset(); + this.returnTransformer.reset(); + this.signatureTransformer.reset(); + } + + enter(node: arkts.AstNode) { + if (arkts.isMethodDefinition(node)) { + const name = node.name.name; + const isMemo = isMemoMethodDefinition(node); + this.scopes.push({ name, isMemo }); + } + if (arkts.isClassProperty(node) && !!node.key && arkts.isIdentifier(node.key)) { + const name = node.key.name; + const isMemo = isMemoClassProperty(node); + this.scopes.push({ name, isMemo }); + } + if (isStandaloneArrowFunction(node)) { + const name = undefined; + const isMemo = isMemoArrowFunction(node); + this.scopes.push({ name, isMemo }); + } + if (arkts.isTSTypeAliasDeclaration(node) && !!node.id && !!node.typeAnnotation) { + const name = node.id.name; + const isMemo = isMemoTSTypeAliasDeclaration(node); + this.scopes.push({ name, isMemo }); + } + if (arkts.isClassDefinition(node)) { + if (hasMemoStableAnnotation(node)) { + this.stable++; + } + } + return this; + } + + exit(node: arkts.AstNode) { + if (arkts.isMethodDefinition(node)) { + this.scopes.pop(); + } + if (arkts.isClassDefinition(node)) { + if (hasMemoStableAnnotation(node)) { + this.stable--; + } + } + return this; + } + + enterAnonymousScope(node: arkts.ScriptFunction) { + const name = undefined; + const isMemo = hasMemoAnnotation(node) || hasMemoIntrinsicAnnotation(node); + this.scopes.push({ name, isMemo }); + return this; + } + + exitAnonymousScope() { + this.scopes.pop(); + return this; + } + + checkMemoCallInMethod(decl: arkts.MethodDefinition) { + if (this.scopes[this.scopes.length - 1].isMemo == false) { + if (this.scopes[this.scopes.length - 1].name) { + console.error( + `Attempt to call @memo-method ${decl.name.name} from non-@memo-method ${ + this.scopes[this.scopes.length - 1].name + }` + ); + throw 'Invalid @memo usage'; + } else { + console.error(`Attempt to call @memo-method ${decl.name.name} from anonymous non-@memo-method`); + throw 'Invalid @memo usage'; + } + } + return this; + } + + checkMemoCallInFunction() { + if (this.scopes[this.scopes.length - 1]?.isMemo == false) { + console.error(`Attempt to call @memo-function`); + throw 'Invalid @memo usage'; + } + return this; + } + + updateScriptFunction(scriptFunction: arkts.ScriptFunction, name: string = ''): arkts.ScriptFunction { + const isStableThis = + this.stable > 0 && + scriptFunction.returnTypeAnnotation !== undefined && + arkts.isTSThisType(scriptFunction.returnTypeAnnotation); + const [body, memoParametersDeclaration, syntheticReturnStatement] = updateFunctionBody( + scriptFunction.body as arkts.BlockStatement, + castParameters(scriptFunction.params), + scriptFunction.returnTypeAnnotation, + isStableThis, + this.positionalIdTracker.id(name) + ); + const afterParameterTransformer = this.parameterTransformer + .withParameters(scriptFunction.params as arkts.ETSParameterExpression[]) + .skip(memoParametersDeclaration) + .visitor(body); + const afterReturnTransformer = this.returnTransformer + .skip(syntheticReturnStatement) + .rewriteThis(this.stable > 0) + .visitor(afterParameterTransformer); + const updateScriptFunction = arkts.factory.updateScriptFunction( + scriptFunction, + afterReturnTransformer, + arkts.FunctionSignature.createFunctionSignature( + scriptFunction.typeParams, + [ + ...factory.createHiddenParameters(), + ...scriptFunction.params, // we handle function params with signature-transformer + ], + scriptFunction.returnTypeAnnotation, + scriptFunction.hasReceiver + ), + scriptFunction.flags, + scriptFunction.modifiers + ); + return updateScriptFunction; + } + + private updateMethodDefinition(node: arkts.MethodDefinition): arkts.MethodDefinition { + let updateMethod: arkts.MethodDefinition; + const that = this; + const updateOverloads = node.overloads?.map((overload) => that.visitor(overload)) ?? undefined; + if ( + node.scriptFunction.body && + (hasMemoAnnotation(node.scriptFunction) || hasMemoIntrinsicAnnotation(node.scriptFunction)) + ) { + updateMethod = arkts.factory.updateMethodDefinition( + node, + node.kind, + node.name, + arkts.factory.createFunctionExpression( + this.signatureTransformer.visitor( + removeMemoAnnotation(this.updateScriptFunction(node.scriptFunction, node.name.name)) + ) + ), + node.modifiers, + false + ); + } else { + updateMethod = arkts.factory.updateMethodDefinition( + node, + node.kind, + node.name, + arkts.factory.createFunctionExpression(this.signatureTransformer.visitor(node.scriptFunction)), + node.modifiers, + false + ); + } + if (!!updateOverloads) { + updateMethod.setOverloads(castOverloadsToMethods(updateOverloads)); + } + return updateMethod; + } + + private updateDeclaredMemoCall(node: arkts.CallExpression, decl: arkts.MethodDefinition): arkts.CallExpression { + this.checkMemoCallInMethod(decl); + const updatedArguments = node.arguments.map((it, index) => { + const type = (decl.scriptFunction.params[index] as arkts.ETSParameterExpression)?.type; + if (type && arkts.isETSFunctionType(type)) { + if ( + !hasMemoAnnotation(decl.scriptFunction.params[index] as arkts.ETSParameterExpression) && + !hasMemoIntrinsicAnnotation(decl.scriptFunction.params[index] as arkts.ETSParameterExpression) + ) { + return it; //factory.createComputeExpression(this.positionalIdTracker.id(decl.name.name), it) + } + if (arkts.isArrowFunctionExpression(it)) { + this.enterAnonymousScope(it.scriptFunction); + const res = this.updateScriptFunction(it.scriptFunction); + this.exitAnonymousScope(); + return arkts.factory.updateArrowFunction(it, res); + } + } + return it; + }); + return arkts.factory.updateCallExpression(node, node.expression, undefined, [ + ...factory.createHiddenArguments(this.positionalIdTracker.id(decl.name.name)), + ...updatedArguments, + ]); + } + + private udpateAnonymousMemoCall( + node: arkts.CallExpression, + expression: arkts.ArrowFunctionExpression + ): arkts.CallExpression { + const scope = this.scopes[this.scopes.length - 1]; + if (!scope || !scope.isMemo || scope.name !== expression.scriptFunction.id?.name) { + return node; + } + this.exitAnonymousScope(); + this.checkMemoCallInFunction(); + + this.enterAnonymousScope(expression.scriptFunction); + const res = this.updateScriptFunction(expression.scriptFunction, expression.scriptFunction.id?.name); + this.exitAnonymousScope(); + + return arkts.factory.updateCallExpression( + node, + arkts.factory.updateArrowFunction(expression, res), + node.typeArguments, + [...factory.createHiddenArguments(this.positionalIdTracker.id()), ...node.arguments] + ); + } + + private updateCallExpression(node: arkts.CallExpression): arkts.CallExpression { + const expr = node.expression; + const decl = arkts.getDecl(expr); + if ( + decl && + arkts.isMethodDefinition(decl) && + (hasMemoAnnotation(decl.scriptFunction) || hasMemoIntrinsicAnnotation(decl.scriptFunction)) + ) { + return this.updateDeclaredMemoCall(node, decl); + } + if (isStandaloneArrowFunction(node.expression)) { + return this.udpateAnonymousMemoCall(node, node.expression); + } + return node; + } + + private updateClassProperty(node: arkts.ClassProperty, key: arkts.Identifier): arkts.ClassProperty { + const scope = this.scopes[this.scopes.length - 1]; + if (!scope || !scope.isMemo || scope.name !== key.name) { + return node; + } + this.exitAnonymousScope(); + + let res: arkts.ScriptFunction | undefined; + if (!!node.value && arkts.isArrowFunctionExpression(node.value)) { + this.enterAnonymousScope(node.value.scriptFunction); + res = this.updateScriptFunction(node.value.scriptFunction, key.name); + this.exitAnonymousScope(); + } + + let typeAnnotation: arkts.TypeNode | undefined; + if (!!node.typeAnnotation && !(typeAnnotation = updateMemoTypeAnnotation(node.typeAnnotation))) { + console.error(`ETSFunctionType or ETSUnionType expected for @memo-property ${key.name}`); + throw 'Invalid @memo usage'; + } + + return arkts.factory.updateClassProperty( + node, + node.key, + res ? arkts.factory.updateArrowFunction(castArrowFunctionExpression(node.value), res) : undefined, + typeAnnotation, + node.modifiers, + node.isComputed + ); + } + + private updateTSTypeAliasDeclaration(node: arkts.TSTypeAliasDeclaration): arkts.TSTypeAliasDeclaration { + const scope = this.scopes[this.scopes.length - 1]; + if (!scope || !scope.isMemo || scope.name !== node.id?.name) { + return node; + } + this.exitAnonymousScope(); + + let typeAnnotation: arkts.TypeNode | undefined; + if (!(typeAnnotation = updateMemoTypeAnnotation(node.typeAnnotation))) { + console.error(`ETSFunctionType or ETSUnionType expected for @memo-type ${node.id!.name}`); + throw 'Invalid @memo usage'; + } + + return arkts.factory.updateTSTypeAliasDeclaration(node, node.id, node.typeParams, typeAnnotation); + } + + private updateStandaloneArrowFunction(node: arkts.ArrowFunctionExpression): arkts.ArrowFunctionExpression { + const scope = this.scopes[this.scopes.length - 1]; + if (!scope || !scope.isMemo || scope.name !== node.scriptFunction.id?.name) { + return node; + } + this.exitAnonymousScope(); + + this.enterAnonymousScope(node.scriptFunction); + const res = this.updateScriptFunction(node.scriptFunction, node.scriptFunction.id?.name); + this.exitAnonymousScope(); + + return arkts.factory.updateArrowFunction(node, res); + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + this.enter(beforeChildren); + const node = this.visitEachChild(beforeChildren); + this.exit(beforeChildren); + if (arkts.isMethodDefinition(node)) { + return this.updateMethodDefinition(node); + } + if (arkts.isCallExpression(node)) { + return this.updateCallExpression(node); + } + if (arkts.isClassProperty(node) && !!node.key && arkts.isIdentifier(node.key)) { + return this.updateClassProperty(node, node.key); + } + if (arkts.isTSTypeAliasDeclaration(node)) { + return this.updateTSTypeAliasDeclaration(node); + } + if (isStandaloneArrowFunction(node)) { + return this.updateStandaloneArrowFunction(node); + } + return node; + } +} diff --git a/arkui-plugins/memo-plugins/import-transformer.ts b/arkui-plugins/memo-plugins/import-transformer.ts new file mode 100644 index 000000000..ac8adfaf0 --- /dev/null +++ b/arkui-plugins/memo-plugins/import-transformer.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { AbstractVisitor } from '../common/abstract-visitor'; +import { factory } from './memo-factory'; + +export class ImportTransformer extends AbstractVisitor { + visitor(node: arkts.AstNode): arkts.AstNode { + if (node instanceof arkts.EtsScript) { + factory.createContextTypesImportDeclaration(arkts.arktsGlobal.compilerContext?.program); + return arkts.factory.updateEtsScript(node, node.statements); + } + return node; + } +} diff --git a/arkui-plugins/memo-plugins/index.ts b/arkui-plugins/memo-plugins/index.ts new file mode 100644 index 000000000..58f785dbd --- /dev/null +++ b/arkui-plugins/memo-plugins/index.ts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { Plugins, PluginContext } from '../common/plugin-context'; +import { FunctionTransformer } from './function-transformer'; +import { PositionalIdTracker } from './utils'; +import { ReturnTransformer } from './return-transformer'; +import { ParameterTransformer } from './parameter-transformer'; +import { ProgramVisitor } from '../common/program-visitor'; +import { EXTERNAL_SOURCE_PREFIX_NAMES } from '../common/predefines'; +import { debugDump, debugLog, getDumpFileName } from '../common/debug'; +import { SignatureTransformer } from './signature-transformer'; + +export function unmemoizeTransform(): Plugins { + return { + name: 'memo-plugin', + checked(this: PluginContext) { + console.log('[MEMO PLUGIN] AFTER CHECKED ENTER'); + const contextPtr = arkts.arktsGlobal.compilerContext?.peer ?? this.getContextPtr(); + if (!!contextPtr) { + let program = arkts.getOrUpdateGlobalContext(contextPtr).program; + let script = program.astNode; + + debugLog('[BEFORE MEMO SCRIPT] script: ', script.dumpSrc()); + const cachePath: string | undefined = this.getProjectConfig()?.cachePath; + debugDump( + script.dumpSrc(), + getDumpFileName(0, 'SRC', 5, 'MEMO_AfterCheck_Begin'), + true, + cachePath, + program.programFileNameWithExtension + ); + + arkts.Performance.getInstance().createEvent('memo-checked'); + + const positionalIdTracker = new PositionalIdTracker(arkts.getFileName(), false); + const parameterTransformer = new ParameterTransformer({ + positionalIdTracker, + }); + const returnTransformer = new ReturnTransformer(); + const signatureTransformer = new SignatureTransformer(); + const functionTransformer = new FunctionTransformer({ + positionalIdTracker, + parameterTransformer, + returnTransformer, + signatureTransformer, + }); + + const programVisitor = new ProgramVisitor({ + pluginName: unmemoizeTransform.name, + state: arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, + visitors: [functionTransformer], + skipPrefixNames: EXTERNAL_SOURCE_PREFIX_NAMES, + pluginContext: this, + }); + + program = programVisitor.programVisitor(program); + script = program.astNode; + + arkts.Performance.getInstance().stopEvent('memo-checked', true); + + debugLog('[AFTER MEMO SCRIPT] script: ', script.dumpSrc()); + debugDump( + script.dumpSrc(), + getDumpFileName(0, 'SRC', 6, 'MEMO_AfterCheck_End'), + true, + cachePath, + program.programFileNameWithExtension + ); + + arkts.Performance.getInstance().createEvent('memo-recheck'); + arkts.recheckSubtree(script); + arkts.Performance.getInstance().stopEvent('memo-recheck', true); + + arkts.Performance.getInstance().clearAllEvents(); + + this.setArkTSAst(script); + console.log('[MEMO PLUGIN] AFTER CHECKED EXIT'); + return script; + } + console.log('[MEMO PLUGIN] AFTER CHECKED EXIT WITH NO TRANSFORM'); + }, + clean() { + arkts.arktsGlobal.clearContext(); + }, + }; +} diff --git a/arkui-plugins/memo-plugins/memo-factory.ts b/arkui-plugins/memo-plugins/memo-factory.ts new file mode 100644 index 000000000..9cef81c70 --- /dev/null +++ b/arkui-plugins/memo-plugins/memo-factory.ts @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { RuntimeNames } from './utils'; + +export class factory { + // Importing + static createContextTypeImportSpecifier(): arkts.ImportSpecifier { + return arkts.factory.createImportSpecifier( + arkts.factory.createIdentifier(RuntimeNames.CONTEXT_TYPE), + arkts.factory.createIdentifier(RuntimeNames.CONTEXT_TYPE) + ); + } + static createIdTypeImportSpecifier(): arkts.ImportSpecifier { + return arkts.factory.createImportSpecifier( + arkts.factory.createIdentifier(RuntimeNames.ID_TYPE), + arkts.factory.createIdentifier(RuntimeNames.ID_TYPE) + ); + } + // TODO: Currently, import declaration can only be inserted at after-parsed stage. + static createContextTypesImportDeclaration(program?: arkts.Program): void { + const source: arkts.StringLiteral = arkts.factory.createStringLiteral(RuntimeNames.CONTEXT_TYPE_DEFAULT_IMPORT); + // const resolvedSource: arkts.StringLiteral = arkts.factory.create1StringLiteral( + // arkts.ImportPathManager.create().resolvePath('', source.str) + // ); + const importDecl: arkts.ETSImportDeclaration = arkts.factory.createImportDeclaration( + source, + [factory.createContextTypeImportSpecifier(), factory.createIdTypeImportSpecifier()], + arkts.Es2pandaImportKinds.IMPORT_KINDS_TYPE + ); + // Insert this import at the top of the script's statements. + if (!program) { + throw Error('Failed to insert import: Transformer has no program'); + } + arkts.importDeclarationInsert(importDecl, program); + return; + } + + // Parameters + static createContextParameter(): arkts.ETSParameterExpression { + return arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier( + RuntimeNames.CONTEXT, + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart(arkts.factory.createIdentifier(RuntimeNames.CONTEXT_TYPE)) + ) + ), + undefined + ); + } + static createIdParameter(): arkts.ETSParameterExpression { + return arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier( + RuntimeNames.ID, + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart(arkts.factory.createIdentifier(RuntimeNames.ID_TYPE)) + ) + ), + undefined + ); + } + static createHiddenParameters(): arkts.ETSParameterExpression[] { + return [factory.createContextParameter(), factory.createIdParameter()]; + } + static updateFunctionTypeWithMemoParameters(type: arkts.ETSFunctionType): arkts.ETSFunctionType { + return arkts.factory.updateFunctionType( + type, + arkts.factory.createFunctionSignature( + undefined, + [...factory.createHiddenParameters(), ...type.params], + type.returnType, + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW + ); + } + + // Arguments + static createContextArgument(): arkts.AstNode { + return arkts.factory.createIdentifier(RuntimeNames.CONTEXT); + } + static createIdArgument(hash: arkts.NumberLiteral | arkts.StringLiteral): arkts.AstNode { + return arkts.factory.createBinaryExpression( + arkts.factory.createIdentifier(RuntimeNames.ID), + hash, + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_PLUS + ); + } + static createHiddenArguments(hash: arkts.NumberLiteral | arkts.StringLiteral): arkts.AstNode[] { + return [factory.createContextArgument(), factory.createIdArgument(hash)]; + } + + // Memo parameters + static createMemoParameterIdentifier(name: string): arkts.Identifier { + return arkts.factory.createIdentifier(`${RuntimeNames.PARAMETER}_${name}`); + } + static createMemoParameterDeclarator(id: number, name: string): arkts.VariableDeclarator { + return arkts.factory.createVariableDeclarator( + arkts.Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_CONST, + factory.createMemoParameterIdentifier(name), + arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_PARAMETER_STATE), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + undefined, + [arkts.factory.createNumericLiteral(id), arkts.factory.createIdentifier(name)] + ) + ); + } + static createMemoParameterAccess(name: string): arkts.MemberExpression { + return arkts.factory.createMemberExpression( + factory.createMemoParameterIdentifier(name), + arkts.factory.createIdentifier(RuntimeNames.VALUE), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_GETTER, + false, + false + ); + } + static createMemoParameterAccessMemoWithScope( + name: string, + hash: arkts.NumberLiteral | arkts.StringLiteral, + passArgs?: arkts.AstNode[] + ): arkts.CallExpression { + const updatedArgs = passArgs ? passArgs : []; + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + factory.createMemoParameterIdentifier(name), + arkts.factory.createIdentifier(RuntimeNames.VALUE), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_GETTER, + false, + false + ), + undefined, + [...factory.createHiddenArguments(hash), ...updatedArgs] + ); + } + static createMemoParameterAccessMemoWithoutScope( + name: string, + hash: arkts.NumberLiteral | arkts.StringLiteral, + passArgs?: arkts.AstNode[] + ): arkts.CallExpression { + const updatedArgs = passArgs ? passArgs : []; + return arkts.factory.createCallExpression(arkts.factory.createIdentifier(name), undefined, [ + ...factory.createHiddenArguments(hash), + ...updatedArgs, + ]); + } + static createMemoParameterAccessCall( + name: string, + hash: arkts.NumberLiteral | arkts.StringLiteral, + passArgs?: arkts.AstNode[] + ): arkts.CallExpression { + const updatedArgs = passArgs ? passArgs : []; + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + factory.createMemoParameterIdentifier(name), + arkts.factory.createIdentifier(RuntimeNames.VALUE), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_GETTER, + false, + false + ), + undefined, + [...updatedArgs] + ); + } + + // Recache + static createScopeDeclaration( + returnTypeAnnotation: arkts.TypeNode | undefined, + hash: arkts.NumberLiteral | arkts.StringLiteral, + cnt: number + ): arkts.VariableDeclaration { + return arkts.factory.createVariableDeclaration( + 0, + arkts.Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_CONST, + [ + arkts.factory.createVariableDeclarator( + arkts.Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_CONST, + arkts.factory.createIdentifier(RuntimeNames.SCOPE), + arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.CONTEXT), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_SCOPE), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + returnTypeAnnotation + ? [returnTypeAnnotation] + : [arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID)], + [factory.createIdArgument(hash), arkts.factory.createNumericLiteral(cnt)] + ) + ), + ] + ); + } + static createRecacheCall(arg?: arkts.AstNode): arkts.CallExpression { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE_NEW), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + undefined, + arg ? [arg] : undefined + ); + } + static createReturnThis(): arkts.BlockStatement { + return arkts.factory.createBlock([ + arkts.factory.createExpressionStatement(factory.createRecacheCall()), + arkts.factory.createReturnStatement(arkts.factory.createThisExpression()), + ]); + } + static createSyntheticReturnStatement(stableThis: boolean): arkts.ReturnStatement | arkts.BlockStatement { + if (!stableThis) { + return arkts.factory.createReturnStatement( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_NONE, + false, + false + ) + ); + } + return arkts.factory.createBlock([ + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_NONE, + false, + false + ), + arkts.factory.createReturnStatement(arkts.factory.createThisExpression()), + ]); + } + static createIfStatementWithSyntheticReturnStatement( + syntheticReturnStatement: arkts.ReturnStatement | arkts.BlockStatement, + isVoidValue: boolean + ): arkts.IfStatement { + let returnStatement = syntheticReturnStatement; + if (isVoidValue && arkts.isReturnStatement(syntheticReturnStatement)) { + returnStatement = arkts.factory.createBlock([ + arkts.factory.createExpressionStatement(syntheticReturnStatement.argument!), + arkts.factory.createReturnStatement(), + ]); + } + return arkts.factory.createIfStatement( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.SCOPE), + arkts.factory.createIdentifier(RuntimeNames.INTERNAL_VALUE_OK), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_NONE, + false, + false + ), + returnStatement + ); + } + + // Compute + static createLambdaWrapper(node: arkts.Expression): arkts.ArrowFunctionExpression { + return arkts.factory.createArrowFunction( + arkts.factory.createScriptFunction( + arkts.factory.createBlock([arkts.factory.createReturnStatement(node)]), + arkts.factory.createFunctionSignature(undefined, [], undefined, false), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + ) + ); + } + static createComputeExpression( + hash: arkts.NumberLiteral | arkts.StringLiteral, + node: arkts.Expression + ): arkts.CallExpression { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(RuntimeNames.CONTEXT), + arkts.factory.createIdentifier(RuntimeNames.COMPUTE), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + undefined, + [factory.createIdArgument(hash), factory.createLambdaWrapper(node)] + ); + } +} diff --git a/arkui-plugins/memo-plugins/memo-transformer.ts b/arkui-plugins/memo-plugins/memo-transformer.ts new file mode 100644 index 000000000..430148fc2 --- /dev/null +++ b/arkui-plugins/memo-plugins/memo-transformer.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { FunctionTransformer } from './function-transformer'; +import { PositionalIdTracker } from './utils'; +import { factory } from './memo-factory'; +import { ReturnTransformer } from './return-transformer'; +import { ParameterTransformer } from './parameter-transformer'; +import { EtsglobalRemover } from '../common/etsglobal-remover'; +import { SignatureTransformer } from './signature-transformer'; + +export interface TransformerOptions { + trace?: boolean; + removeEtsglobal?: boolean; +} + +export default function memoTransformer(userPluginOptions?: TransformerOptions) { + return (node0: arkts.EtsScript) => { + const node = ( + userPluginOptions?.removeEtsglobal ? new EtsglobalRemover().visitor(node0) : node0 + ) as arkts.EtsScript; + const positionalIdTracker = new PositionalIdTracker(arkts.getFileName(), false); + const parameterTransformer = new ParameterTransformer({ + positionalIdTracker, + }); + const returnTransformer = new ReturnTransformer(); + const signatureTransformer = new SignatureTransformer(); + const functionTransformer = new FunctionTransformer({ + positionalIdTracker, + parameterTransformer, + returnTransformer, + signatureTransformer, + }); + factory.createContextTypesImportDeclaration(arkts.arktsGlobal.compilerContext?.program); + return functionTransformer.visitor(arkts.factory.updateEtsScript(node, node.statements)); + }; +} diff --git a/arkui-plugins/memo-plugins/parameter-transformer.ts b/arkui-plugins/memo-plugins/parameter-transformer.ts new file mode 100644 index 000000000..757e45f77 --- /dev/null +++ b/arkui-plugins/memo-plugins/parameter-transformer.ts @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; + +import { factory } from './memo-factory'; +import { AbstractVisitor, VisitorOptions } from '../common/abstract-visitor'; +import { + hasMemoAnnotation, + hasMemoIntrinsicAnnotation, + isMemoParametersDeclaration, + PositionalIdTracker, +} from './utils'; + +export interface ParameterTransformerOptions extends VisitorOptions { + positionalIdTracker: PositionalIdTracker; +} + +export class ParameterTransformer extends AbstractVisitor { + private rewriteIdentifiers?: Map arkts.MemberExpression | arkts.Identifier>; + private rewriteCalls?: Map arkts.CallExpression>; + private skipNode?: arkts.VariableDeclaration; + private readonly positionalIdTracker: PositionalIdTracker; + + constructor(options: ParameterTransformerOptions) { + super(options); + this.positionalIdTracker = options.positionalIdTracker; + } + + reset(): void { + super.reset(); + this.rewriteIdentifiers = undefined; + this.rewriteCalls = undefined; + this.skipNode = undefined; + } + + withParameters(parameters: arkts.ETSParameterExpression[]): ParameterTransformer { + this.rewriteCalls = new Map( + parameters + .filter((it) => it.type && (arkts.isETSFunctionType(it.type) || arkts.isETSUnionType(it.type))) + .map((it) => { + return [ + it.peer, + (passArgs: arkts.AstNode[]) => { + if (hasMemoAnnotation(it) || hasMemoIntrinsicAnnotation(it)) { + if (it.type && arkts.isETSFunctionType(it.type) && !it.optional) { + return factory.createMemoParameterAccessMemoWithScope( + it.identifier.name, + this.positionalIdTracker?.id(), + passArgs + ); + } else { + return factory.createMemoParameterAccessMemoWithoutScope( + it.identifier.name, + this.positionalIdTracker?.id(), + passArgs + ); + } + } + return factory.createMemoParameterAccessCall( + it.identifier.name, + this.positionalIdTracker?.id(), + passArgs + ); + }, + ]; + }) + ); + this.rewriteIdentifiers = new Map( + parameters.map((it) => { + return [ + it.peer, + () => { + if ((it.type && arkts.isETSFunctionType(it.type)) || it.optional) { + return arkts.factory.createIdentifier(it.identifier.name); + } + return factory.createMemoParameterAccess(it.identifier.name); + }, + ]; + }) + ); + return this; + } + + skip(memoParametersDeclaration?: arkts.VariableDeclaration): ParameterTransformer { + this.skipNode = memoParametersDeclaration; + return this; + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + // TODO: temporary checking skip nodes by comparison with expected skip nodes + // Should be fixed when update procedure implemented properly + if (!beforeChildren) { + return beforeChildren; + } + if (/* beforeChildren === this.skipNode */ isMemoParametersDeclaration(beforeChildren)) { + return beforeChildren; + } + if (arkts.isCallExpression(beforeChildren)) { + if (arkts.isIdentifier(beforeChildren.expression)) { + const decl = arkts.getDecl(beforeChildren.expression); + if (decl && arkts.isEtsParameterExpression(decl) && this.rewriteCalls?.has(decl.peer)) { + return this.rewriteCalls.get(decl.peer)!(beforeChildren.arguments.map((it) => this.visitor(it))); + } + } + } + const node = this.visitEachChild(beforeChildren); + if (arkts.isIdentifier(node)) { + const decl = arkts.getDecl(node); + if (decl && arkts.isEtsParameterExpression(decl) && this.rewriteIdentifiers?.has(decl.peer)) { + const res = this.rewriteIdentifiers.get(decl.peer)!(); + if (arkts.isMemberExpression(res)) { + return res; + } + } + } + return node; + } +} diff --git a/arkui-plugins/memo-plugins/return-transformer.ts b/arkui-plugins/memo-plugins/return-transformer.ts new file mode 100644 index 000000000..563d55621 --- /dev/null +++ b/arkui-plugins/memo-plugins/return-transformer.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { factory } from './memo-factory'; +import { AbstractVisitor } from '../common/abstract-visitor'; +import { isSyntheticReturnStatement } from './utils'; + +export class ReturnTransformer extends AbstractVisitor { + private skipNode?: arkts.ReturnStatement | arkts.BlockStatement; + private stableThis: boolean = false; + + reset() { + super.reset(); + this.skipNode = undefined; + this.stableThis = false; + } + + skip(syntheticReturnStatement?: arkts.ReturnStatement | arkts.BlockStatement): ReturnTransformer { + this.skipNode = syntheticReturnStatement; + return this; + } + + rewriteThis(stableThis: boolean): ReturnTransformer { + this.stableThis = stableThis; + return this; + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + // TODO: temporary checking skip nodes by comparison with expected skip nodes + // Should be fixed when update procedure implemented properly + if (/* beforeChildren === this.skipNode */ isSyntheticReturnStatement(beforeChildren)) { + return beforeChildren; + } + if (arkts.isScriptFunction(beforeChildren)) { + return beforeChildren; + } + const node = this.visitEachChild(beforeChildren); + if (arkts.isReturnStatement(node)) { + if (this.stableThis && node.argument && arkts.isThisExpression(node.argument)) { + return factory.createReturnThis(); + } + if (node.argument === undefined) { + return arkts.factory.createBlock([ + arkts.factory.createExpressionStatement(factory.createRecacheCall()), + node, + ]); + } + return arkts.factory.updateReturnStatement(node, factory.createRecacheCall(node.argument)); + } + return node; + } +} diff --git a/arkui-plugins/memo-plugins/signature-transformer.ts b/arkui-plugins/memo-plugins/signature-transformer.ts new file mode 100644 index 000000000..985d57d5c --- /dev/null +++ b/arkui-plugins/memo-plugins/signature-transformer.ts @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { factory } from './memo-factory'; +import { hasMemoAnnotation, hasMemoIntrinsicAnnotation } from './utils'; +import { AbstractVisitor } from '../common/abstract-visitor'; + +export class SignatureTransformer extends AbstractVisitor { + public modified = false; + + reset(): void { + super.reset(); + this.modified = false; + } + + visitor(node: T, applyMemo: boolean = false): T { + if (arkts.isScriptFunction(node)) { + const memo = hasMemoAnnotation(node) || hasMemoIntrinsicAnnotation(node) || applyMemo; + if (memo) { + this.modified = true; + } + return arkts.factory.updateScriptFunction( + node, + node.body, + arkts.factory.createFunctionSignature( + node.typeParams, + [...(memo ? factory.createHiddenParameters() : []), ...node.params.map((it) => this.visitor(it))], + node.returnTypeAnnotation + ? this.visitor(node.returnTypeAnnotation) + : memo + ? arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID) + : undefined, + node.hasReceiver + ), + node.flags, + node.modifiers + ) as any as T; + } + if (arkts.isEtsParameterExpression(node)) { + const memo = hasMemoAnnotation(node) || hasMemoIntrinsicAnnotation(node); + if (!node.type) { + if (memo) { + console.error(`@memo parameter ${node.identifier.name} without type annotatation`); + throw 'Invalid @memo usage'; + } + return node; + } + node.type = this.visitor(node.type, memo); + return node as any as T; + } + if (arkts.isETSFunctionType(node)) { + const memo = hasMemoAnnotation(node) || hasMemoIntrinsicAnnotation(node) || applyMemo; + if (memo) { + this.modified = true; + } + return arkts.factory.updateFunctionType( + node, + arkts.factory.createFunctionSignature( + undefined, + [...(memo ? factory.createHiddenParameters() : []), ...node.params.map((it) => this.visitor(it))], + this.visitor(node.returnType!), + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW + ) as any as T; + } + if (arkts.isETSUnionType(node)) { + return arkts.factory.updateUnionType( + node, + node.types.map((it) => this.visitor(it, applyMemo)) + ) as any as T; + } + if (arkts.isETSUndefinedType(node)) { + return node as any as T; + } + if (applyMemo) { + throw 'Invalid @memo usage'; + } + return node; + } +} diff --git a/arkui-plugins/memo-plugins/utils.ts b/arkui-plugins/memo-plugins/utils.ts new file mode 100644 index 000000000..cae4fa891 --- /dev/null +++ b/arkui-plugins/memo-plugins/utils.ts @@ -0,0 +1,274 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { getCommonPath } from '../path'; +const common = require(getCommonPath()); +const UniqueId = common.UniqueId; + +export enum RuntimeNames { + __CONTEXT = '__context', + __ID = '__id', + ANNOTATION = 'memo', + ANNOTATION_INTRINSIC = 'memo_intrinsic', + ANNOTATION_STABLE = 'memo_stable', + COMPUTE = 'compute', + CONTEXT = '__memo_context', + CONTEXT_TYPE = '__memo_context_type', + CONTEXT_TYPE_DEFAULT_IMPORT = '@ohos.arkui.StateManagement.runtime', + ID = '__memo_id', + ID_TYPE = '__memo_id_type', + INTERNAL_PARAMETER_STATE = 'param', + INTERNAL_SCOPE = 'scope', + INTERNAL_VALUE = 'cached', + INTERNAL_VALUE_NEW = 'recache', + INTERNAL_VALUE_OK = 'unchanged', + PARAMETER = '__memo_parameter', + SCOPE = '__memo_scope', + VALUE = 'value', +} + +function baseName(path: string): string { + return path.replace(/^.*\/(.*)$/, '$1'); +} + +export class PositionalIdTracker { + // Global for the whole program. + static callCount: number = 0; + + // Set `stable` to true if you want to have more predictable values. + // For example for tests. + // Don't use it in production! + constructor(public filename: string, public stableForTests: boolean = false) { + if (stableForTests) PositionalIdTracker.callCount = 0; + } + + sha1Id(callName: string, fileName: string): string { + const uniqId = new UniqueId(); + uniqId.addString('memo call uniqid'); + uniqId.addString(fileName); + uniqId.addString(callName); + uniqId.addI32(PositionalIdTracker.callCount++); + return uniqId.compute().substring(0, 7); + } + + stringId(callName: string, fileName: string): string { + return `${PositionalIdTracker.callCount++}_${callName}_id_DIRNAME/${fileName}`; + } + + id(callName: string = ''): arkts.NumberLiteral | arkts.StringLiteral { + const fileName = this.stableForTests ? baseName(this.filename) : this.filename; + + const positionId = this.stableForTests ? this.stringId(callName, fileName) : this.sha1Id(callName, fileName); + + return this.stableForTests + ? arkts.factory.createStringLiteral(positionId) + : arkts.factory.createNumericLiteral(parseInt(positionId, 16)); + } +} + +export function isMemoAnnotation(node: arkts.AnnotationUsage, memoName: RuntimeNames): boolean { + return node.expr !== undefined && arkts.isIdentifier(node.expr) && node.expr.name === memoName; +} + +export type MemoAstNode = + | arkts.ScriptFunction + | arkts.ETSParameterExpression + | arkts.ClassProperty + | arkts.TSTypeAliasDeclaration + | arkts.ETSFunctionType + | arkts.ArrowFunctionExpression; + +export function hasMemoAnnotation(node: T): boolean { + return node.annotations.some((it) => isMemoAnnotation(it, RuntimeNames.ANNOTATION)); +} + +export function hasMemoIntrinsicAnnotation(node: T): boolean { + return node.annotations.some((it) => isMemoAnnotation(it, RuntimeNames.ANNOTATION_INTRINSIC)); +} + +export function hasMemoStableAnnotation(node: arkts.ClassDefinition): boolean { + return node.annotations.some( + (it) => it.expr !== undefined && arkts.isIdentifier(it.expr) && it.expr.name === RuntimeNames.ANNOTATION_STABLE + ); +} + +export function removeMemoAnnotation(node: T): T { + const newAnnotations: arkts.AnnotationUsage[] = node.annotations.filter( + (it) => + !isMemoAnnotation(it, RuntimeNames.ANNOTATION) && + !isMemoAnnotation(it, RuntimeNames.ANNOTATION_INTRINSIC) && + !isMemoAnnotation(it, RuntimeNames.ANNOTATION_STABLE) + ); + if (arkts.isEtsParameterExpression(node)) { + node.annotations = newAnnotations; + return node; + } + return node.setAnnotations(newAnnotations) as T; +} + +/** + * TODO: + * @deprecated + */ +export function isSyntheticReturnStatement(node: arkts.AstNode): boolean { + return isIfStatementWithSyntheticReturn(node) || isSimpleSyntheticReturn(node) || isSyntheticReturnInBlock(node); +} + +function isIfStatementWithSyntheticReturn(node: arkts.AstNode): boolean { + return ( + arkts.isIfStatement(node) && + !!node.test && + arkts.isMemberExpression(node.test) && + arkts.isIdentifier(node.test.object) && + node.test.object.name === RuntimeNames.SCOPE && + arkts.isIdentifier(node.test.property) && + node.test.property.name === RuntimeNames.INTERNAL_VALUE_OK && + (arkts.isBlockStatement(node.consequent) || arkts.isReturnStatement(node.consequent)) + ); +} + +function isSimpleSyntheticReturn(node: arkts.AstNode): boolean { + return ( + arkts.isReturnStatement(node) && + !!node.argument && + arkts.isMemberExpression(node.argument) && + arkts.isIdentifier(node.argument.object) && + node.argument.object.name === RuntimeNames.SCOPE && + arkts.isIdentifier(node.argument.property) && + node.argument.property.name === RuntimeNames.INTERNAL_VALUE + ); +} + +function isSyntheticReturnInBlock(node: arkts.AstNode): boolean { + if (!arkts.isBlockStatement(node) || node.statements.length !== 2) { + return false; + } + if (!arkts.isReturnStatement(node.statements[1])) { + return false; + } + const isReturnThis: boolean = !!node.statements[1].argument && arkts.isThisExpression(node.statements[1].argument); + const isReturnVoid: boolean = node.statements[1].argument === undefined; + + return ( + arkts.isMemberExpression(node.statements[0]) && + arkts.isIdentifier(node.statements[0].object) && + node.statements[0].object.name === RuntimeNames.SCOPE && + arkts.isIdentifier(node.statements[0].property) && + node.statements[0].property.name === RuntimeNames.INTERNAL_VALUE && + (isReturnThis || isReturnVoid) + ); +} + +/** + * TODO: + * @deprecated + */ +export function isMemoParametersDeclaration(node: arkts.AstNode): boolean { + return ( + arkts.isVariableDeclaration(node) && + node.declarators.every((it) => it.name.name.startsWith(RuntimeNames.PARAMETER)) + ); +} + +/** + * TODO: change this to TypeNodeGetType to check void type + */ +export function isVoidType(typeNode: arkts.TypeNode | undefined): boolean { + return typeNode?.dumpSrc() === 'void'; +} + +/** + * es2panda API is weird here + * + * @deprecated + */ +export function castParameters(params: readonly arkts.Expression[]): arkts.ETSParameterExpression[] { + return params as arkts.ETSParameterExpression[]; +} + +/** + * es2panda API is weird here + * + * @deprecated + */ +export function castFunctionExpression(value: arkts.Expression | undefined): arkts.FunctionExpression { + return value as unknown as arkts.FunctionExpression; +} + +/** + * es2panda API is weird here + * + * @deprecated + */ +export function castArrowFunctionExpression(value: arkts.Expression | undefined): arkts.ArrowFunctionExpression { + return value as unknown as arkts.ArrowFunctionExpression; +} + +/** + * es2panda API is weird here + * + * @deprecated + */ +export function castOverloadsToMethods(overloads: arkts.AstNode[]): readonly arkts.MethodDefinition[] { + return overloads as unknown as readonly arkts.MethodDefinition[]; +} + +export function isStandaloneArrowFunction(node: arkts.AstNode): node is arkts.ArrowFunctionExpression { + if (!arkts.isArrowFunctionExpression(node)) return false; + + // handling anonymous arrow function call + if (arkts.isCallExpression(node.parent) && node.parent.expression.peer === node.peer) return true; + + return !arkts.isClassProperty(node.parent) && !(arkts.isCallExpression(node.parent) && node.parent.expression); +} + +export function isMemoClassProperty(node: arkts.ClassProperty): boolean { + let isMemo = findMemoFromTypeAnnotation(node.typeAnnotation); + if (node.value) { + isMemo ||= + arkts.isArrowFunctionExpression(node.value) && + (hasMemoAnnotation(node.value) || hasMemoIntrinsicAnnotation(node.value)); + } + isMemo ||= hasMemoAnnotation(node) || hasMemoIntrinsicAnnotation(node); + return isMemo; +} + +export function isMemoMethodDefinition(node: arkts.MethodDefinition): boolean { + return hasMemoAnnotation(node.scriptFunction) || hasMemoIntrinsicAnnotation(node.scriptFunction); +} + +export function isMemoArrowFunction(node: arkts.ArrowFunctionExpression): boolean { + return hasMemoAnnotation(node) || hasMemoIntrinsicAnnotation(node); +} + +export function isMemoTSTypeAliasDeclaration(node: arkts.TSTypeAliasDeclaration): boolean { + let isMemo = findMemoFromTypeAnnotation(node.typeAnnotation); + isMemo ||= hasMemoAnnotation(node) || hasMemoIntrinsicAnnotation(node); + return isMemo; +} + +export function findMemoFromTypeAnnotation(typeAnnotation: arkts.TypeNode | undefined): boolean { + if (!typeAnnotation) { + return false; + } + if (arkts.isETSFunctionType(typeAnnotation)) { + return hasMemoAnnotation(typeAnnotation) || hasMemoIntrinsicAnnotation(typeAnnotation); + } else if (arkts.isETSUnionType(typeAnnotation)) { + return typeAnnotation.types.some( + (type) => arkts.isETSFunctionType(type) && (hasMemoAnnotation(type) || hasMemoIntrinsicAnnotation(type)) + ); + } + return false; +} diff --git a/arkui-plugins/npm_preinstall.sh b/arkui-plugins/npm_preinstall.sh new file mode 100755 index 000000000..478471ab0 --- /dev/null +++ b/arkui-plugins/npm_preinstall.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# coding: utf-8 +# Copyright (c) 2025 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. + +if [ "$1" == "--init" ]; then + cd ../koala-wrapper + npm install + npm run compile + npm link + + cd ../ts_wrapper + npm install + npm run compile + npm link + + cd ../arkui-plugins + mkdir node_modules + npm link @koalaui/libarkts +fi \ No newline at end of file diff --git a/arkui-plugins/package.json b/arkui-plugins/package.json new file mode 100644 index 000000000..20078aeb0 --- /dev/null +++ b/arkui-plugins/package.json @@ -0,0 +1,33 @@ +{ + "name": "arkui-plugin", + "version": "1.0.0", + "description": "", + "private": true, + "workspaces": [ + "./test" + ], + "scripts": { + "local:install": "chmod 777 ./npm_preinstall.sh && ./npm_preinstall.sh --init", + "compile:plugins": "./node_modules/.bin/babel . --out-dir lib --extensions .ts", + "compile:clean": "rm -rf lib", + "test": "jest --config ./jest-test.config.ts", + "compile": "npm run compile:clean && npm run compile:plugins && cp -rf ./lib $INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ui-plugins/" + }, + "devDependencies": { + "@babel/cli": "7.20.7", + "@babel/core": "7.20.12", + "@babel/plugin-proposal-class-properties": "7.18.6", + "@babel/preset-env": "7.20.2", + "@babel/preset-typescript": "7.18.6", + "@babel/runtime": "7.20.13", + "@types/jest": "^29.5.14", + "@types/node": "^22.13.9", + "jest": "^29.7.0", + "ts-jest": "^29.2.0", + "ts-node": "^10.9.0", + "typescript": "^5.0.0" + }, + "dependencies": { + "@koalaui/libarkts": "../koala-wrapper" + } +} diff --git a/arkui-plugins/path.ts b/arkui-plugins/path.ts new file mode 100644 index 000000000..a8646fcbf --- /dev/null +++ b/arkui-plugins/path.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2022-2025 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 { error } from 'console'; +import * as path from 'path'; + +const UI_PLUGINS = 'ui-plugins'; +const ARKUI_PLUGINS = 'arkui-plugins'; + +function findMatchingFile(currentPath: string, targetFileName1: string, targetFileName2: string): string | null { + let current = currentPath; + while (true) { + // 获取当前路径的文件名 + const baseName = path.basename(current); + if (baseName === targetFileName1 || baseName === targetFileName2) { + return path.dirname(current); + } + + const parentPath = path.dirname(current); + if (parentPath === current) { + break; + } + current = parentPath; + } + throw new Error('ui-plugins not found.'); +} + +function findRootDir() { + const plugins = findMatchingFile(__dirname, UI_PLUGINS, ARKUI_PLUGINS); + if (plugins === null) { + throw 'error'; + } + return plugins; +} + +export function getArktsPath() { + return path.join(findRootDir(), 'koala-wrapper', './build/lib/arkts-api/index.js'); +} + +export function getInteropPath() { + return path.join(findRootDir(), 'koala-wrapper/koalaui/interop', './dist/lib/src/interop/index.js'); +} + +export function getCommonPath() { + return path.join(findRootDir(), 'koala-wrapper/koalaui/common', './dist/lib/src/index.js'); +} + +export function getCompatPath() { + return path.join(findRootDir(), 'koala-wrapper/koalaui/compat', './dist/src/index.js'); +} diff --git a/arkui-plugins/test/arktsconfig_gen.js b/arkui-plugins/test/arktsconfig_gen.js new file mode 100644 index 000000000..bd8b94608 --- /dev/null +++ b/arkui-plugins/test/arktsconfig_gen.js @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2025 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. + */ + +const fs = require('fs'); +const path = require('path'); + +// 获取当前目录 +const currentDirectory = process.cwd(); +let workSpace = currentDirectory; +for (let i = 0; i < 4; i++) { + workSpace = path.dirname(workSpace); +} +// JSON 文件路径 +const jsonFilePath = path.join(__dirname, 'arktsconfig_template.json'); +const outJsonFilePath = path.join(__dirname, 'dist/cache/arktsconfig.json'); + +try { + // 读取 JSON 文件内容 + const data = fs.readFileSync(jsonFilePath, 'utf8'); + const jsonData = JSON.parse(data); + + // 处理 baseUrl 字段 + if (jsonData.compilerOptions.baseUrl) { + jsonData.compilerOptions.baseUrl = jsonData.compilerOptions.baseUrl.replace(/workspace/g, workSpace); + } + + // 处理 Paths 字段 + if (jsonData.compilerOptions.paths) { + for (const key in jsonData.compilerOptions.paths) { + const values = jsonData.compilerOptions.paths[key]; + for (let i = 0; i < values.length; i++) { + if (key.startsWith('@ohos.arkui.')) { + values[i] = currentDirectory + "/dist/cache/" + key; + } else { + values[i] = values[i].replace(/workspace/g, workSpace); + } + } + } + } + + // 将修改后的内容写回 JSON 文件 + fs.writeFileSync(outJsonFilePath, JSON.stringify(jsonData, null, 2), 'utf8'); +} catch (error) { + console.error('处理 JSON 文件时出错:', error); +} \ No newline at end of file diff --git a/arkui-plugins/test/arktsconfig_template.json b/arkui-plugins/test/arktsconfig_template.json new file mode 100644 index 000000000..1353fee74 --- /dev/null +++ b/arkui-plugins/test/arktsconfig_template.json @@ -0,0 +1,2797 @@ +{ + "compilerOptions": { + "package": "entry", + "baseUrl": "workspace/developtools/ace_ets2bundle/arkui-plugins/test/dist/cache/", + "include": [ + "./0_SRC_Memo_2_FunctionTransformer.ets" + ], + "paths": { + "std": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ets2panda/lib/stdlib/std" + ], + "escompat": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ets2panda/lib/stdlib/escompat" + ], + "@ohos.InputMethodExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.InputMethodExtensionAbility" + ], + "@ohos.InputMethodExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.InputMethodExtensionContext" + ], + "@ohos.InputMethodSubtype": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.InputMethodSubtype" + ], + "@ohos.PiPWindow": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.PiPWindow" + ], + "@ohos.UiTest": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.UiTest" + ], + "@ohos.WallpaperExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.WallpaperExtensionAbility" + ], + "@ohos.WorkSchedulerExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.WorkSchedulerExtensionAbility" + ], + "@ohos.ability.ability": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.ability.ability" + ], + "@ohos.ability.dataUriUtils": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.ability.dataUriUtils" + ], + "@ohos.ability.errorCode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.ability.errorCode" + ], + "@ohos.ability.featureAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.ability.featureAbility" + ], + "@ohos.ability.particleAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.ability.particleAbility" + ], + "@ohos.ability.screenLockFileManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.ability.screenLockFileManager" + ], + "@ohos.ability.wantConstant": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.ability.wantConstant" + ], + "@ohos.abilityAccessCtrl": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.abilityAccessCtrl" + ], + "@ohos.accessibility.GesturePath": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.accessibility.GesturePath" + ], + "@ohos.accessibility.GesturePoint": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.accessibility.GesturePoint" + ], + "@ohos.accessibility.config": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.accessibility.config" + ], + "@ohos.accessibility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.accessibility" + ], + "@ohos.account.appAccount": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.account.appAccount" + ], + "@ohos.account.distributedAccount": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.account.distributedAccount" + ], + "@ohos.account.osAccount": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.account.osAccount" + ], + "@ohos.advertising.AdComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.advertising.AdComponent" + ], + "@ohos.advertising.AdsServiceExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.advertising.AdsServiceExtensionAbility" + ], + "@ohos.advertising.AutoAdComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.advertising.AutoAdComponent" + ], + "@ohos.advertising": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.advertising" + ], + "@ohos.ai.intelligentVoice": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.ai.intelligentVoice" + ], + "@ohos.ai.mindSporeLite": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.ai.mindSporeLite" + ], + "@ohos.animation.windowAnimationManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.animation.windowAnimationManager" + ], + "@ohos.animator": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.animator" + ], + "@ohos.app.ability.Ability": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.Ability" + ], + "@ohos.app.ability.AbilityConstant": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.AbilityConstant" + ], + "@ohos.app.ability.AbilityLifecycleCallback": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.AbilityLifecycleCallback" + ], + "@ohos.app.ability.AbilityStage": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.AbilityStage" + ], + "@ohos.app.ability.ActionExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.ActionExtensionAbility" + ], + "@ohos.app.ability.ApplicationStateChangeCallback": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.ApplicationStateChangeCallback" + ], + "@ohos.app.ability.AtomicServiceOptions": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.AtomicServiceOptions" + ], + "@ohos.app.ability.AutoFillExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.AutoFillExtensionAbility" + ], + "@ohos.app.ability.ChildProcess": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.ChildProcess" + ], + "@ohos.app.ability.ChildProcessArgs": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.ChildProcessArgs" + ], + "@ohos.app.ability.ChildProcessOptions": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.ChildProcessOptions" + ], + "@ohos.app.ability.Configuration": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.Configuration" + ], + "@ohos.app.ability.ConfigurationConstant": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.ConfigurationConstant" + ], + "@ohos.app.ability.DriverExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.DriverExtensionAbility" + ], + "@ohos.app.ability.EmbeddableUIAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.EmbeddableUIAbility" + ], + "@ohos.app.ability.EmbeddedUIExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.EmbeddedUIExtensionAbility" + ], + "@ohos.app.ability.EnvironmentCallback": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.EnvironmentCallback" + ], + "@ohos.app.ability.ExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.ExtensionAbility" + ], + "@ohos.app.ability.FenceExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.FenceExtensionAbility" + ], + "@ohos.app.ability.FenceExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.FenceExtensionContext" + ], + "@ohos.app.ability.InsightIntentContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.InsightIntentContext" + ], + "@ohos.app.ability.InsightIntentExecutor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.InsightIntentExecutor" + ], + "@ohos.app.ability.MediaControlExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.MediaControlExtensionAbility" + ], + "@ohos.app.ability.OpenLinkOptions": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.OpenLinkOptions" + ], + "@ohos.app.ability.PhotoEditorExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.PhotoEditorExtensionAbility" + ], + "@ohos.app.ability.PrintExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.PrintExtensionAbility" + ], + "@ohos.app.ability.ServiceExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.ServiceExtensionAbility" + ], + "@ohos.app.ability.ShareExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.ShareExtensionAbility" + ], + "@ohos.app.ability.StartOptions": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.StartOptions" + ], + "@ohos.app.ability.UIAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.UIAbility" + ], + "@ohos.app.ability.UIExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.UIExtensionAbility" + ], + "@ohos.app.ability.UIExtensionContentSession": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.UIExtensionContentSession" + ], + "@ohos.app.ability.UIServiceExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.UIServiceExtensionAbility" + ], + "@ohos.app.ability.UserAuthExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.UserAuthExtensionAbility" + ], + "@ohos.app.ability.VpnExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.VpnExtensionAbility" + ], + "@ohos.app.ability.Want": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.Want" + ], + "@ohos.app.ability.abilityDelegatorRegistry": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.abilityDelegatorRegistry" + ], + "@ohos.app.ability.abilityManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.abilityManager" + ], + "@ohos.app.ability.appManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.appManager" + ], + "@ohos.app.ability.appRecovery": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.appRecovery" + ], + "@ohos.app.ability.application": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.application" + ], + "@ohos.app.ability.autoFillManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.autoFillManager" + ], + "@ohos.app.ability.autoStartupManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.autoStartupManager" + ], + "@ohos.app.ability.childProcessManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.childProcessManager" + ], + "@ohos.app.ability.common": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.common" + ], + "@ohos.app.ability.contextConstant": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.contextConstant" + ], + "@ohos.app.ability.dataUriUtils": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.dataUriUtils" + ], + "@ohos.app.ability.dialogRequest": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.dialogRequest" + ], + "@ohos.app.ability.dialogSession": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.dialogSession" + ], + "@ohos.app.ability.errorManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.errorManager" + ], + "@ohos.app.ability.insightIntent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.insightIntent" + ], + "@ohos.app.ability.insightIntentDriver": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.insightIntentDriver" + ], + "@ohos.app.ability.missionManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.missionManager" + ], + "@ohos.app.ability.quickFixManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.quickFixManager" + ], + "@ohos.app.ability.sendableContextManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.sendableContextManager" + ], + "@ohos.app.ability.wantAgent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.wantAgent" + ], + "@ohos.app.ability.wantConstant": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.ability.wantConstant" + ], + "@ohos.app.appstartup.StartupConfig": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.appstartup.StartupConfig" + ], + "@ohos.app.appstartup.StartupConfigEntry": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.appstartup.StartupConfigEntry" + ], + "@ohos.app.appstartup.StartupListener": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.appstartup.StartupListener" + ], + "@ohos.app.appstartup.StartupTask": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.appstartup.StartupTask" + ], + "@ohos.app.appstartup.startupManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.appstartup.startupManager" + ], + "@ohos.app.businessAbilityRouter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.businessAbilityRouter" + ], + "@ohos.app.form.FormExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.form.FormExtensionAbility" + ], + "@ohos.app.form.formAgent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.form.formAgent" + ], + "@ohos.app.form.formBindingData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.form.formBindingData" + ], + "@ohos.app.form.formHost": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.form.formHost" + ], + "@ohos.app.form.formInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.form.formInfo" + ], + "@ohos.app.form.formObserver": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.form.formObserver" + ], + "@ohos.app.form.formProvider": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.app.form.formProvider" + ], + "@ohos.application.AccessibilityExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.AccessibilityExtensionAbility" + ], + "@ohos.application.BackupExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.BackupExtensionAbility" + ], + "@ohos.application.Configuration": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.Configuration" + ], + "@ohos.application.ConfigurationConstant": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.ConfigurationConstant" + ], + "@ohos.application.DataShareExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.DataShareExtensionAbility" + ], + "@ohos.application.StaticSubscriberExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.StaticSubscriberExtensionAbility" + ], + "@ohos.application.StaticSubscriberExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.StaticSubscriberExtensionContext" + ], + "@ohos.application.Want": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.Want" + ], + "@ohos.application.WindowExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.WindowExtensionAbility" + ], + "@ohos.application.abilityDelegatorRegistry": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.abilityDelegatorRegistry" + ], + "@ohos.application.abilityManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.abilityManager" + ], + "@ohos.application.appManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.appManager" + ], + "@ohos.application.formBindingData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.formBindingData" + ], + "@ohos.application.formError": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.formError" + ], + "@ohos.application.formHost": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.formHost" + ], + "@ohos.application.formInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.formInfo" + ], + "@ohos.application.formProvider": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.formProvider" + ], + "@ohos.application.missionManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.missionManager" + ], + "@ohos.application.testRunner": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.testRunner" + ], + "@ohos.application.uriPermissionManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.application.uriPermissionManager" + ], + "@ohos.arkui.Prefetcher": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.Prefetcher" + ], + "@ohos.arkui.StateManagement": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.StateManagement" + ], + "@ohos.arkui.StateManagement.runtime": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.StateManagement.runtime" + ], + "@ohos.arkui.UIContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.UIContext" + ], + "@ohos.arkui.advanced.Chip": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.Chip" + ], + "@ohos.arkui.advanced.ChipGroup": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.ChipGroup" + ], + "@ohos.arkui.advanced.ComposeListItem": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.ComposeListItem" + ], + "@ohos.arkui.advanced.ComposeTitleBar": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.ComposeTitleBar" + ], + "@ohos.arkui.advanced.Counter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.Counter" + ], + "@ohos.arkui.advanced.Dialog": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.Dialog" + ], + "@ohos.arkui.advanced.DownloadFileButton": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.DownloadFileButton" + ], + "@ohos.arkui.advanced.EditableTitleBar": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.EditableTitleBar" + ], + "@ohos.arkui.advanced.ExceptionPrompt": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.ExceptionPrompt" + ], + "@ohos.arkui.advanced.Filter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.Filter" + ], + "@ohos.arkui.advanced.FoldSplitContainer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.FoldSplitContainer" + ], + "@ohos.arkui.advanced.FormMenu": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.FormMenu" + ], + "@ohos.arkui.advanced.FullScreenLaunchComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.FullScreenLaunchComponent" + ], + "@ohos.arkui.advanced.GridObjectSortComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.GridObjectSortComponent" + ], + "@ohos.arkui.advanced.InnerFullScreenLaunchComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.InnerFullScreenLaunchComponent" + ], + "@ohos.arkui.advanced.Popup": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.Popup" + ], + "@ohos.arkui.advanced.ProgressButton": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.ProgressButton" + ], + "@ohos.arkui.advanced.SegmentButton": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.SegmentButton" + ], + "@ohos.arkui.advanced.SelectTitleBar": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.SelectTitleBar" + ], + "@ohos.arkui.advanced.SelectionMenu": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.SelectionMenu" + ], + "@ohos.arkui.advanced.SplitLayout": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.SplitLayout" + ], + "@ohos.arkui.advanced.SubHeader": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.SubHeader" + ], + "@ohos.arkui.advanced.SwipeRefresher": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.SwipeRefresher" + ], + "@ohos.arkui.advanced.TabTitleBar": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.TabTitleBar" + ], + "@ohos.arkui.advanced.ToolBar": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.ToolBar" + ], + "@ohos.arkui.advanced.TreeView": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.advanced.TreeView" + ], + "@ohos.arkui.component.AbilityComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.AbilityComponent" + ], + "@ohos.arkui.component.ActionSheet": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ActionSheet" + ], + "@ohos.arkui.component.AlertDialog": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.AlertDialog" + ], + "@ohos.arkui.component.AlphabetIndexer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.AlphabetIndexer" + ], + "@ohos.arkui.component.Animator": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Animator" + ], + "@ohos.arkui.component.Badge": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Badge" + ], + "@ohos.arkui.component.Blank": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Blank" + ], + "@ohos.arkui.component.Button": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Button" + ], + "@ohos.arkui.component.Calendar": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Calendar" + ], + "@ohos.arkui.component.CalendarPicker": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.CalendarPicker" + ], + "@ohos.arkui.component.Canvas": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Canvas" + ], + "@ohos.arkui.component.Checkbox": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Checkbox" + ], + "@ohos.arkui.component.CheckboxGroup": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.CheckboxGroup" + ], + "@ohos.arkui.component.Circle": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Circle" + ], + "@ohos.arkui.component.Column": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Column" + ], + "@ohos.arkui.component.ColumnSplit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ColumnSplit" + ], + "@ohos.arkui.component.Common": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Common" + ], + "@ohos.arkui.component.CommonTsEtsApi": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.CommonTsEtsApi" + ], + "@ohos.arkui.component.Component3d": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Component3d" + ], + "@ohos.arkui.component.ContainerSpan": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ContainerSpan" + ], + "@ohos.arkui.component.ContentSlot": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ContentSlot" + ], + "@ohos.arkui.component.ContextMenu": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ContextMenu" + ], + "@ohos.arkui.component.Counter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Counter" + ], + "@ohos.arkui.component.CustomDialogController": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.CustomDialogController" + ], + "@ohos.arkui.component.DataPanel": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.DataPanel" + ], + "@ohos.arkui.component.DatePicker": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.DatePicker" + ], + "@ohos.arkui.component.Divider": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Divider" + ], + "@ohos.arkui.component.EffectComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.EffectComponent" + ], + "@ohos.arkui.component.Ellipse": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Ellipse" + ], + "@ohos.arkui.component.EmbeddedComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.EmbeddedComponent" + ], + "@ohos.arkui.component.Enums": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Enums" + ], + "@ohos.arkui.component.Flex": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Flex" + ], + "@ohos.arkui.component.FlowItem": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.FlowItem" + ], + "@ohos.arkui.component.Focus": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Focus" + ], + "@ohos.arkui.component.FolderStack": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.FolderStack" + ], + "@ohos.arkui.component.ForEach": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ForEach" + ], + "@ohos.arkui.component.FormComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.FormComponent" + ], + "@ohos.arkui.component.FormLink": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.FormLink" + ], + "@ohos.arkui.component.Gauge": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Gauge" + ], + "@ohos.arkui.component.Gesture": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Gesture" + ], + "@ohos.arkui.component.Grid": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Grid" + ], + "@ohos.arkui.component.GridCol": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.GridCol" + ], + "@ohos.arkui.component.GridContainer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.GridContainer" + ], + "@ohos.arkui.component.GridItem": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.GridItem" + ], + "@ohos.arkui.component.GridRow": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.GridRow" + ], + "@ohos.arkui.component.Hyperlink": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Hyperlink" + ], + "@ohos.arkui.component.Image": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Image" + ], + "@ohos.arkui.component.ImageAnimator": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ImageAnimator" + ], + "@ohos.arkui.component.ImageCommon": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ImageCommon" + ], + "@ohos.arkui.component.ImageSpan": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ImageSpan" + ], + "@ohos.arkui.component.IndicatorComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.IndicatorComponent" + ], + "@ohos.arkui.component.Inspector": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Inspector" + ], + "@ohos.arkui.component.IsolatedComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.IsolatedComponent" + ], + "@ohos.arkui.component.LazyForEach": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.LazyForEach" + ], + "@ohos.arkui.component.Line": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Line" + ], + "@ohos.arkui.component.Linearindicator": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Linearindicator" + ], + "@ohos.arkui.component.List": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.List" + ], + "@ohos.arkui.component.ListItem": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ListItem" + ], + "@ohos.arkui.component.ListItemGroup": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ListItemGroup" + ], + "@ohos.arkui.component.LoadingProgress": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.LoadingProgress" + ], + "@ohos.arkui.component.Marquee": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Marquee" + ], + "@ohos.arkui.component.Matrix2d": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Matrix2d" + ], + "@ohos.arkui.component.MediaCachedImage": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.MediaCachedImage" + ], + "@ohos.arkui.component.Menu": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Menu" + ], + "@ohos.arkui.component.MenuItem": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.MenuItem" + ], + "@ohos.arkui.component.MenuItemGroup": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.MenuItemGroup" + ], + "@ohos.arkui.component.NavDestination": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.NavDestination" + ], + "@ohos.arkui.component.NavRouter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.NavRouter" + ], + "@ohos.arkui.component.Navigation": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Navigation" + ], + "@ohos.arkui.component.Navigator": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Navigator" + ], + "@ohos.arkui.component.NodeContainer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.NodeContainer" + ], + "@ohos.arkui.component.PageTransition": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.PageTransition" + ], + "@ohos.arkui.component.Panel": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Panel" + ], + "@ohos.arkui.component.Particle": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Particle" + ], + "@ohos.arkui.component.Path": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Path" + ], + "@ohos.arkui.component.PatternLock": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.PatternLock" + ], + "@ohos.arkui.component.Polygon": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Polygon" + ], + "@ohos.arkui.component.Polyline": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Polyline" + ], + "@ohos.arkui.component.Progress": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Progress" + ], + "@ohos.arkui.component.QRCode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.QRCode" + ], + "@ohos.arkui.component.Radio": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Radio" + ], + "@ohos.arkui.component.Rating": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Rating" + ], + "@ohos.arkui.component.Rect": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Rect" + ], + "@ohos.arkui.component.Refresh": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Refresh" + ], + "@ohos.arkui.component.RelativeContainer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.RelativeContainer" + ], + "@ohos.arkui.component.RichEditor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.RichEditor" + ], + "@ohos.arkui.component.RichText": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.RichText" + ], + "@ohos.arkui.component.Row": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Row" + ], + "@ohos.arkui.component.RowSplit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.RowSplit" + ], + "@ohos.arkui.component.Scroll": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Scroll" + ], + "@ohos.arkui.component.ScrollBar": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.ScrollBar" + ], + "@ohos.arkui.component.Search": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Search" + ], + "@ohos.arkui.component.Select": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Select" + ], + "@ohos.arkui.component.Shape": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Shape" + ], + "@ohos.arkui.component.Sidebar": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Sidebar" + ], + "@ohos.arkui.component.Slider": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Slider" + ], + "@ohos.arkui.component.Span": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Span" + ], + "@ohos.arkui.component.Stack": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Stack" + ], + "@ohos.arkui.component.StateManagement": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.StateManagement" + ], + "@ohos.arkui.component.StepperItem": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.StepperItem" + ], + "@ohos.arkui.component.StyledString": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.StyledString" + ], + "@ohos.arkui.component.Swiper": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Swiper" + ], + "@ohos.arkui.component.SymbolGlyph": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.SymbolGlyph" + ], + "@ohos.arkui.component.SymbolSpan": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.SymbolSpan" + ], + "@ohos.arkui.component.TabContent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.TabContent" + ], + "@ohos.arkui.component.Tabs": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Tabs" + ], + "@ohos.arkui.component.Text": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Text" + ], + "@ohos.arkui.component.TextArea": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.TextArea" + ], + "@ohos.arkui.component.TextClock": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.TextClock" + ], + "@ohos.arkui.component.TextCommon": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.TextCommon" + ], + "@ohos.arkui.component.TextInput": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.TextInput" + ], + "@ohos.arkui.component.TextPicker": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.TextPicker" + ], + "@ohos.arkui.component.TextTimer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.TextTimer" + ], + "@ohos.arkui.component.TimePicker": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.TimePicker" + ], + "@ohos.arkui.component.Toggle": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Toggle" + ], + "@ohos.arkui.component.Units": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Units" + ], + "@ohos.arkui.component.Video": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.Video" + ], + "@ohos.arkui.component.WaterFlow": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.WaterFlow" + ], + "@ohos.arkui.component.WithTheme": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.WithTheme" + ], + "@ohos.arkui.component.XComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component.XComponent" + ], + "@ohos.arkui.component": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.component" + ], + "@ohos.arkui.componentSnapshot": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.componentSnapshot" + ], + "@ohos.arkui.componentUtils": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.componentUtils" + ], + "@ohos.arkui.dragController": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.dragController" + ], + "@ohos.arkui.drawableDescriptor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.drawableDescriptor" + ], + "@ohos.arkui.inspector": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.inspector" + ], + "@ohos.arkui.modifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.modifier" + ], + "@ohos.arkui.node": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.node" + ], + "@ohos.arkui.observer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.observer" + ], + "@ohos.arkui.performanceMonitor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.performanceMonitor" + ], + "@ohos.arkui.shape": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.shape" + ], + "@ohos.arkui.stateManagement": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.stateManagement" + ], + "@ohos.arkui.theme": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.theme" + ], + "@ohos.arkui.uiExtension": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.arkui.uiExtension" + ], + "@ohos.atomicservice.AtomicServiceNavigation": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.atomicservice.AtomicServiceNavigation" + ], + "@ohos.atomicservice.AtomicServiceTabs": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.atomicservice.AtomicServiceTabs" + ], + "@ohos.atomicservice.AtomicServiceWeb": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.atomicservice.AtomicServiceWeb" + ], + "@ohos.atomicservice.InterstitialDialogAction": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.atomicservice.InterstitialDialogAction" + ], + "@ohos.atomicservice.NavPushPathHelper": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.atomicservice.NavPushPathHelper" + ], + "@ohos.backgroundTaskManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.backgroundTaskManager" + ], + "@ohos.base": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.base" + ], + "@ohos.batteryInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.batteryInfo" + ], + "@ohos.batteryStatistics": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.batteryStatistics" + ], + "@ohos.bluetooth.a2dp": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.a2dp" + ], + "@ohos.bluetooth.access": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.access" + ], + "@ohos.bluetooth.baseProfile": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.baseProfile" + ], + "@ohos.bluetooth.ble": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.ble" + ], + "@ohos.bluetooth.connection": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.connection" + ], + "@ohos.bluetooth.constant": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.constant" + ], + "@ohos.bluetooth": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth" + ], + "@ohos.bluetooth.hfp": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.hfp" + ], + "@ohos.bluetooth.hid": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.hid" + ], + "@ohos.bluetooth.map": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.map" + ], + "@ohos.bluetooth.pan": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.pan" + ], + "@ohos.bluetooth.pbap": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.pbap" + ], + "@ohos.bluetooth.socket": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.socket" + ], + "@ohos.bluetooth.wearDetection": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetooth.wearDetection" + ], + "@ohos.bluetoothManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bluetoothManager" + ], + "@ohos.brightness": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.brightness" + ], + "@ohos.buffer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.buffer" + ], + "@ohos.bundle.appControl": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.appControl" + ], + "@ohos.bundle.appDomainVerify": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.appDomainVerify" + ], + "@ohos.bundle.bundleManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.bundleManager" + ], + "@ohos.bundle.bundleMonitor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.bundleMonitor" + ], + "@ohos.bundle.bundleResourceManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.bundleResourceManager" + ], + "@ohos.bundle": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle" + ], + "@ohos.bundle.defaultAppManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.defaultAppManager" + ], + "@ohos.bundle.distributedBundleManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.distributedBundleManager" + ], + "@ohos.bundle.freeInstall": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.freeInstall" + ], + "@ohos.bundle.innerBundleManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.innerBundleManager" + ], + "@ohos.bundle.installer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.installer" + ], + "@ohos.bundle.launcherBundleManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.launcherBundleManager" + ], + "@ohos.bundle.overlay": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.overlay" + ], + "@ohos.bundle.shortcutManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundle.shortcutManager" + ], + "@ohos.bundleState": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bundleState" + ], + "@ohos.bytrace": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.bytrace" + ], + "@ohos.calendarManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.calendarManager" + ], + "@ohos.charger": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.charger" + ], + "@ohos.commonEvent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.commonEvent" + ], + "@ohos.commonEventManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.commonEventManager" + ], + "@ohos.configPolicy": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.configPolicy" + ], + "@ohos.connectedTag": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.connectedTag" + ], + "@ohos.contact": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.contact" + ], + "@ohos.continuation.continuationManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.continuation.continuationManager" + ], + "@ohos.cooperate": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.cooperate" + ], + "@ohos.curves": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.curves" + ], + "@ohos.customization.customConfig": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.customization.customConfig" + ], + "@ohos.data.DataShareResultSet": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.DataShareResultSet" + ], + "@ohos.data.ValuesBucket": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.ValuesBucket" + ], + "@ohos.data.cloudData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.cloudData" + ], + "@ohos.data.cloudExtension": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.cloudExtension" + ], + "@ohos.data.commonType": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.commonType" + ], + "@ohos.data.dataAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.dataAbility" + ], + "@ohos.data.dataShare": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.dataShare" + ], + "@ohos.data.dataSharePredicates": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.dataSharePredicates" + ], + "@ohos.data.distributedData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.distributedData" + ], + "@ohos.data.distributedDataObject": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.distributedDataObject" + ], + "@ohos.data.distributedKVStore": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.distributedKVStore" + ], + "@ohos.data.preferences": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.preferences" + ], + "@ohos.data.rdb": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.rdb" + ], + "@ohos.data.relationalStore": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.relationalStore" + ], + "@ohos.data.sendablePreferences": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.sendablePreferences" + ], + "@ohos.data.sendableRelationalStore": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.sendableRelationalStore" + ], + "@ohos.data.storage": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.storage" + ], + "@ohos.data.unifiedDataChannel": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.unifiedDataChannel" + ], + "@ohos.data.uniformDataStruct": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.uniformDataStruct" + ], + "@ohos.data.uniformTypeDescriptor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.data.uniformTypeDescriptor" + ], + "@ohos.deviceAttest": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.deviceAttest" + ], + "@ohos.deviceInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.deviceInfo" + ], + "@ohos.deviceStatus.dragInteraction": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.deviceStatus.dragInteraction" + ], + "@ohos.display": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.display" + ], + "@ohos.distributedBundle": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.distributedBundle" + ], + "@ohos.distributedDeviceManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.distributedDeviceManager" + ], + "@ohos.distributedHardware.deviceManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.distributedHardware.deviceManager" + ], + "@ohos.distributedHardware.hardwareManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.distributedHardware.hardwareManager" + ], + "@ohos.distributedMissionManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.distributedMissionManager" + ], + "@ohos.dlpPermission": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.dlpPermission" + ], + "@ohos.document": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.document" + ], + "@ohos.driver.deviceManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.driver.deviceManager" + ], + "@ohos.effectKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.effectKit" + ], + "@ohos.enterprise.EnterpriseAdminExtensionAbility": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.EnterpriseAdminExtensionAbility" + ], + "@ohos.enterprise.accountManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.accountManager" + ], + "@ohos.enterprise.adminManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.adminManager" + ], + "@ohos.enterprise.applicationManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.applicationManager" + ], + "@ohos.enterprise.bluetoothManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.bluetoothManager" + ], + "@ohos.enterprise.browser": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.browser" + ], + "@ohos.enterprise.bundleManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.bundleManager" + ], + "@ohos.enterprise.dateTimeManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.dateTimeManager" + ], + "@ohos.enterprise.deviceControl": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.deviceControl" + ], + "@ohos.enterprise.deviceInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.deviceInfo" + ], + "@ohos.enterprise.deviceSettings": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.deviceSettings" + ], + "@ohos.enterprise.locationManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.locationManager" + ], + "@ohos.enterprise.networkManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.networkManager" + ], + "@ohos.enterprise.restrictions": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.restrictions" + ], + "@ohos.enterprise.securityManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.securityManager" + ], + "@ohos.enterprise.systemManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.systemManager" + ], + "@ohos.enterprise.usbManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.usbManager" + ], + "@ohos.enterprise.wifiManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.enterprise.wifiManager" + ], + "@ohos.events.emitter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.events.emitter" + ], + "@ohos.faultLogger": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.faultLogger" + ], + "@ohos.file.AlbumPickerComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.AlbumPickerComponent" + ], + "@ohos.file.BackupExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.BackupExtensionContext" + ], + "@ohos.file.PhotoPickerComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.PhotoPickerComponent" + ], + "@ohos.file.RecentPhotoComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.RecentPhotoComponent" + ], + "@ohos.file.backup": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.backup" + ], + "@ohos.file.cloudSync": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.cloudSync" + ], + "@ohos.file.cloudSyncManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.cloudSyncManager" + ], + "@ohos.file.environment": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.environment" + ], + "@ohos.file.fileAccess": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.fileAccess" + ], + "@ohos.file.fileExtensionInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.fileExtensionInfo" + ], + "@ohos.file.fileuri": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.fileuri" + ], + "@ohos.file.fs": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.fs" + ], + "@ohos.file.hash": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.hash" + ], + "@ohos.file.photoAccessHelper": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.photoAccessHelper" + ], + "@ohos.file.picker": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.picker" + ], + "@ohos.file.recent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.recent" + ], + "@ohos.file.securityLabel": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.securityLabel" + ], + "@ohos.file.sendablePhotoAccessHelper": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.sendablePhotoAccessHelper" + ], + "@ohos.file.statvfs": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.statvfs" + ], + "@ohos.file.storageStatistics": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.storageStatistics" + ], + "@ohos.file.trash": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.trash" + ], + "@ohos.file.volumeManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.file.volumeManager" + ], + "@ohos.fileio": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.fileio" + ], + "@ohos.filemanagement.userFileManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.filemanagement.userFileManager" + ], + "@ohos.fileshare": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.fileshare" + ], + "@ohos.font": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.font" + ], + "@ohos.geoLocationManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.geoLocationManager" + ], + "@ohos.geolocation": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.geolocation" + ], + "@ohos.graphics.colorSpaceManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.graphics.colorSpaceManager" + ], + "@ohos.graphics.common2D": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.graphics.common2D" + ], + "@ohos.graphics.displaySync": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.graphics.displaySync" + ], + "@ohos.graphics.drawing": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.graphics.drawing" + ], + "@ohos.graphics.hdrCapability": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.graphics.hdrCapability" + ], + "@ohos.graphics.scene": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.graphics.scene" + ], + "@ohos.graphics.sendableColorSpaceManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.graphics.sendableColorSpaceManager" + ], + "@ohos.graphics.text": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.graphics.text" + ], + "@ohos.graphics.uiEffect": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.graphics.uiEffect" + ], + "@ohos.hiAppEvent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.hiAppEvent" + ], + "@ohos.hiSysEvent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.hiSysEvent" + ], + "@ohos.hiTraceChain": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.hiTraceChain" + ], + "@ohos.hiTraceMeter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.hiTraceMeter" + ], + "@ohos.hichecker": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.hichecker" + ], + "@ohos.hidebug": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.hidebug" + ], + "@ohos.hilog": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.hilog" + ], + "@ohos.hiviewdfx.hiAppEvent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.hiviewdfx.hiAppEvent" + ], + "@ohos.hiviewdfx.jsLeakWatcher": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.hiviewdfx.jsLeakWatcher" + ], + "@ohos.i18n": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.i18n" + ], + "@ohos.identifier.oaid": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.identifier.oaid" + ], + "@ohos.inputMethod.Panel": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.inputMethod.Panel" + ], + "@ohos.inputMethod": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.inputMethod" + ], + "@ohos.inputMethodEngine": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.inputMethodEngine" + ], + "@ohos.inputMethodList": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.inputMethodList" + ], + "@ohos.intl": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.intl" + ], + "@ohos.logLibrary": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.logLibrary" + ], + "@ohos.matrix4": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.matrix4" + ], + "@ohos.measure": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.measure" + ], + "@ohos.mediaquery": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.mediaquery" + ], + "@ohos.multimedia.audio": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.audio" + ], + "@ohos.multimedia.audioHaptic": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.audioHaptic" + ], + "@ohos.multimedia.avCastPicker": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.avCastPicker" + ], + "@ohos.multimedia.avCastPickerParam": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.avCastPickerParam" + ], + "@ohos.multimedia.avVolumePanel": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.avVolumePanel" + ], + "@ohos.multimedia.avsession": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.avsession" + ], + "@ohos.multimedia.camera": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.camera" + ], + "@ohos.multimedia.cameraPicker": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.cameraPicker" + ], + "@ohos.multimedia.drm": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.drm" + ], + "@ohos.multimedia.image": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.image" + ], + "@ohos.multimedia.media": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.media" + ], + "@ohos.multimedia.movingphotoview": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.movingphotoview" + ], + "@ohos.multimedia.sendableImage": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.sendableImage" + ], + "@ohos.multimedia.systemSoundManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimedia.systemSoundManager" + ], + "@ohos.multimodalInput.gestureEvent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.gestureEvent" + ], + "@ohos.multimodalInput.infraredEmitter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.infraredEmitter" + ], + "@ohos.multimodalInput.inputConsumer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.inputConsumer" + ], + "@ohos.multimodalInput.inputDevice": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.inputDevice" + ], + "@ohos.multimodalInput.inputDeviceCooperate": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.inputDeviceCooperate" + ], + "@ohos.multimodalInput.inputEvent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.inputEvent" + ], + "@ohos.multimodalInput.inputEventClient": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.inputEventClient" + ], + "@ohos.multimodalInput.inputMonitor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.inputMonitor" + ], + "@ohos.multimodalInput.intentionCode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.intentionCode" + ], + "@ohos.multimodalInput.keyCode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.keyCode" + ], + "@ohos.multimodalInput.keyEvent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.keyEvent" + ], + "@ohos.multimodalInput.mouseEvent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.mouseEvent" + ], + "@ohos.multimodalInput.pointer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.pointer" + ], + "@ohos.multimodalInput.shortKey": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.shortKey" + ], + "@ohos.multimodalInput.touchEvent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.multimodalInput.touchEvent" + ], + "@ohos.net.connection": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.connection" + ], + "@ohos.net.ethernet": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.ethernet" + ], + "@ohos.net.http": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.http" + ], + "@ohos.net.mdns": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.mdns" + ], + "@ohos.net.netFirewall": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.netFirewall" + ], + "@ohos.net.networkSecurity": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.networkSecurity" + ], + "@ohos.net.policy": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.policy" + ], + "@ohos.net.sharing": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.sharing" + ], + "@ohos.net.socket": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.socket" + ], + "@ohos.net.statistics": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.statistics" + ], + "@ohos.net.vpn": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.vpn" + ], + "@ohos.net.vpnExtension": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.vpnExtension" + ], + "@ohos.net.webSocket": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.net.webSocket" + ], + "@ohos.nfc.cardEmulation": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.nfc.cardEmulation" + ], + "@ohos.nfc.controller": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.nfc.controller" + ], + "@ohos.nfc.tag": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.nfc.tag" + ], + "@ohos.notification": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.notification" + ], + "@ohos.notificationManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.notificationManager" + ], + "@ohos.notificationSubscribe": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.notificationSubscribe" + ], + "@ohos.pasteboard": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.pasteboard" + ], + "@ohos.pluginComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.pluginComponent" + ], + "@ohos.power": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.power" + ], + "@ohos.print": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.print" + ], + "@ohos.privacyManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.privacyManager" + ], + "@ohos.prompt": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.prompt" + ], + "@ohos.promptAction": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.promptAction" + ], + "@ohos.reminderAgent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.reminderAgent" + ], + "@ohos.reminderAgentManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.reminderAgentManager" + ], + "@ohos.request": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.request" + ], + "@ohos.resourceManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.resourceManager" + ], + "@ohos.resourceschedule.backgroundTaskManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.resourceschedule.backgroundTaskManager" + ], + "@ohos.resourceschedule.deviceStandby": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.resourceschedule.deviceStandby" + ], + "@ohos.resourceschedule.systemload": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.resourceschedule.systemload" + ], + "@ohos.resourceschedule.usageStatistics": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.resourceschedule.usageStatistics" + ], + "@ohos.resourceschedule.workScheduler": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.resourceschedule.workScheduler" + ], + "@ohos.router": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.router" + ], + "@ohos.rpc": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.rpc" + ], + "@ohos.runningLock": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.runningLock" + ], + "@ohos.screen": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.screen" + ], + "@ohos.screenLock": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.screenLock" + ], + "@ohos.screenshot": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.screenshot" + ], + "@ohos.secureElement": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.secureElement" + ], + "@ohos.security.asset": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.security.asset" + ], + "@ohos.security.cert": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.security.cert" + ], + "@ohos.security.certManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.security.certManager" + ], + "@ohos.security.certManagerDialog": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.security.certManagerDialog" + ], + "@ohos.security.cryptoFramework": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.security.cryptoFramework" + ], + "@ohos.security.huks": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.security.huks" + ], + "@ohos.security.securityGuard": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.security.securityGuard" + ], + "@ohos.sendableResourceManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.sendableResourceManager" + ], + "@ohos.sensor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.sensor" + ], + "@ohos.settings": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.settings" + ], + "@ohos.statfs": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.statfs" + ], + "@ohos.stationary": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.stationary" + ], + "@ohos.systemCapability": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.systemCapability" + ], + "@ohos.systemDateTime": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.systemDateTime" + ], + "@ohos.systemParameterEnhance": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.systemParameterEnhance" + ], + "@ohos.systemTime": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.systemTime" + ], + "@ohos.systemTimer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.systemTimer" + ], + "@ohos.systemparameter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.systemparameter" + ], + "@ohos.telephony.call": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.telephony.call" + ], + "@ohos.telephony.data": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.telephony.data" + ], + "@ohos.telephony.observer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.telephony.observer" + ], + "@ohos.telephony.radio": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.telephony.radio" + ], + "@ohos.telephony.sim": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.telephony.sim" + ], + "@ohos.telephony.sms": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.telephony.sms" + ], + "@ohos.telephony.vcard": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.telephony.vcard" + ], + "@ohos.thermal": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.thermal" + ], + "@ohos.uiAppearance": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.uiAppearance" + ], + "@ohos.uiExtensionHost": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.uiExtensionHost" + ], + "@ohos.update": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.update" + ], + "@ohos.uri": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.uri" + ], + "@ohos.url": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.url" + ], + "@ohos.usb": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.usb" + ], + "@ohos.usbManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.usbManager" + ], + "@ohos.userIAM.faceAuth": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.userIAM.faceAuth" + ], + "@ohos.userIAM.userAuth": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.userIAM.userAuth" + ], + "@ohos.userIAM.userAuthIcon": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.userIAM.userAuthIcon" + ], + "@ohos.util.ArrayList": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.ArrayList" + ], + "@ohos.util.Deque": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.Deque" + ], + "@ohos.util.HashMap": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.HashMap" + ], + "@ohos.util.HashSet": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.HashSet" + ], + "@ohos.util.LightWeightMap": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.LightWeightMap" + ], + "@ohos.util.LightWeightSet": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.LightWeightSet" + ], + "@ohos.util.LinkedList": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.LinkedList" + ], + "@ohos.util.List": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.List" + ], + "@ohos.util.PlainArray": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.PlainArray" + ], + "@ohos.util.Queue": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.Queue" + ], + "@ohos.util.Stack": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.Stack" + ], + "@ohos.util.TreeMap": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.TreeMap" + ], + "@ohos.util.TreeSet": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.TreeSet" + ], + "@ohos.util": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util" + ], + "@ohos.util.json": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.json" + ], + "@ohos.util.stream": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.util.stream" + ], + "@ohos.vibrator": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.vibrator" + ], + "@ohos.wallpaper": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.wallpaper" + ], + "@ohos.wantAgent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.wantAgent" + ], + "@ohos.web.netErrorList": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.web.netErrorList" + ], + "@ohos.web.webview": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.web.webview" + ], + "@ohos.wifi": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.wifi" + ], + "@ohos.wifiManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.wifiManager" + ], + "@ohos.wifiManagerExt": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.wifiManagerExt" + ], + "@ohos.wifiext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.wifiext" + ], + "@ohos.window": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.window" + ], + "@ohos.worker": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.worker" + ], + "@ohos.zlib": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@ohos.zlib" + ], + "@ohos.@system.app": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.app" + ], + "@ohos.@system.battery": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.battery" + ], + "@ohos.@system.bluetooth": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.bluetooth" + ], + "@ohos.@system.brightness": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.brightness" + ], + "@ohos.@system.cipher": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.cipher" + ], + "@ohos.@system.configuration": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.configuration" + ], + "@ohos.@system.device": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.device" + ], + "@ohos.@system.fetch": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.fetch" + ], + "@ohos.@system.file": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.file" + ], + "@ohos.@system.geolocation": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.geolocation" + ], + "@ohos.@system.mediaquery": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.mediaquery" + ], + "@ohos.@system.network": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.network" + ], + "@ohos.@system.notification": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.notification" + ], + "@ohos.@system.package": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.package" + ], + "@ohos.@system.prompt": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.prompt" + ], + "@ohos.@system.request": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.request" + ], + "@ohos.@system.router": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.router" + ], + "@ohos.@system.sensor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.sensor" + ], + "@ohos.@system.storage": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.storage" + ], + "@ohos.@system.vibrator": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/@system.vibrator" + ], + "@ohos.ability.abilityResult": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/ability/abilityResult" + ], + "@ohos.ability.connectOptions": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/ability/connectOptions" + ], + "@ohos.ability.dataAbilityHelper": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/ability/dataAbilityHelper" + ], + "@ohos.ability.dataAbilityOperation": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/ability/dataAbilityOperation" + ], + "@ohos.ability.dataAbilityResult": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/ability/dataAbilityResult" + ], + "@ohos.ability.startAbilityParameter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/ability/startAbilityParameter" + ], + "@ohos.ability.want": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/ability/want" + ], + "@ohos.advertising.advertisement": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/advertising/advertisement" + ], + "@ohos.app.appVersionInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/app/appVersionInfo" + ], + "@ohos.app.context": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/app/context" + ], + "@ohos.app.processInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/app/processInfo" + ], + "@ohos.application.AbilityDelegator": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityDelegator" + ], + "@ohos.application.AbilityFirstFrameStateData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityFirstFrameStateData" + ], + "@ohos.application.AbilityFirstFrameStateObserver": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityFirstFrameStateObserver" + ], + "@ohos.application.AbilityForegroundStateObserver": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityForegroundStateObserver" + ], + "@ohos.application.AbilityMonitor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityMonitor" + ], + "@ohos.application.AbilityRunningInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityRunningInfo" + ], + "@ohos.application.AbilityStageContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityStageContext" + ], + "@ohos.application.AbilityStageMonitor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityStageMonitor" + ], + "@ohos.application.AbilityStartCallback": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityStartCallback" + ], + "@ohos.application.AbilityStateData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AbilityStateData" + ], + "@ohos.application.AccessibilityExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AccessibilityExtensionContext" + ], + "@ohos.application.AppForegroundStateObserver": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AppForegroundStateObserver" + ], + "@ohos.application.AppStateData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AppStateData" + ], + "@ohos.application.ApplicationContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ApplicationContext" + ], + "@ohos.application.ApplicationStateObserver": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ApplicationStateObserver" + ], + "@ohos.application.AutoFillExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AutoFillExtensionContext" + ], + "@ohos.application.AutoFillPopupConfig": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AutoFillPopupConfig" + ], + "@ohos.application.AutoFillRect": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AutoFillRect" + ], + "@ohos.application.AutoFillRequest": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AutoFillRequest" + ], + "@ohos.application.AutoFillType": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AutoFillType" + ], + "@ohos.application.AutoStartupCallback": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AutoStartupCallback" + ], + "@ohos.application.AutoStartupInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/AutoStartupInfo" + ], + "@ohos.application.BaseContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/BaseContext" + ], + "@ohos.application.BusinessAbilityInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/BusinessAbilityInfo" + ], + "@ohos.application.Context": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/Context" + ], + "@ohos.application.ContinuableInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ContinuableInfo" + ], + "@ohos.application.ContinueCallback": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ContinueCallback" + ], + "@ohos.application.ContinueDeviceInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ContinueDeviceInfo" + ], + "@ohos.application.ContinueMissionInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ContinueMissionInfo" + ], + "@ohos.application.CustomData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/CustomData" + ], + "@ohos.application.DriverExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/DriverExtensionContext" + ], + "@ohos.application.EmbeddableUIAbilityContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/EmbeddableUIAbilityContext" + ], + "@ohos.application.ErrorObserver": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ErrorObserver" + ], + "@ohos.application.EventHub": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/EventHub" + ], + "@ohos.application.ExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ExtensionContext" + ], + "@ohos.application.ExtensionRunningInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ExtensionRunningInfo" + ], + "@ohos.application.FormExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/FormExtensionContext" + ], + "@ohos.application.LoopObserver": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/LoopObserver" + ], + "@ohos.application.MediaControlExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/MediaControlExtensionContext" + ], + "@ohos.application.MissionCallbacks": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/MissionCallbacks" + ], + "@ohos.application.MissionDeviceInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/MissionDeviceInfo" + ], + "@ohos.application.MissionInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/MissionInfo" + ], + "@ohos.application.MissionListener": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/MissionListener" + ], + "@ohos.application.MissionParameter": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/MissionParameter" + ], + "@ohos.application.MissionSnapshot": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/MissionSnapshot" + ], + "@ohos.application.MultiAppMode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/MultiAppMode" + ], + "@ohos.application.PageNodeInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/PageNodeInfo" + ], + "@ohos.application.PhotoEditorExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/PhotoEditorExtensionContext" + ], + "@ohos.application.ProcessData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ProcessData" + ], + "@ohos.application.ProcessInformation": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ProcessInformation" + ], + "@ohos.application.ProcessRunningInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ProcessRunningInfo" + ], + "@ohos.application.RunningAppClone": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/RunningAppClone" + ], + "@ohos.application.RunningMultiAppInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/RunningMultiAppInfo" + ], + "@ohos.application.RunningMultiInstanceInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/RunningMultiInstanceInfo" + ], + "@ohos.application.SendableContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/SendableContext" + ], + "@ohos.application.ServiceExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ServiceExtensionContext" + ], + "@ohos.application.UIAbilityContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/UIAbilityContext" + ], + "@ohos.application.UIExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/UIExtensionContext" + ], + "@ohos.application.UIServiceExtensionConnectCallback": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/UIServiceExtensionConnectCallback" + ], + "@ohos.application.UIServiceExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/UIServiceExtensionContext" + ], + "@ohos.application.UIServiceHostProxy": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/UIServiceHostProxy" + ], + "@ohos.application.UIServiceProxy": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/UIServiceProxy" + ], + "@ohos.application.ViewData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/ViewData" + ], + "@ohos.application.VpnExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/VpnExtensionContext" + ], + "@ohos.application.WindowExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/WindowExtensionContext" + ], + "@ohos.application.WorkSchedulerExtensionContext": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/WorkSchedulerExtensionContext" + ], + "@ohos.application.abilityDelegatorArgs": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/abilityDelegatorArgs" + ], + "@ohos.application.shellCmdResult": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/application/shellCmdResult" + ], + "@ohos.arkui.AlphabetIndexerModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/AlphabetIndexerModifier" + ], + "@ohos.arkui.AttributeUpdater": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/AttributeUpdater" + ], + "@ohos.arkui.BlankModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/BlankModifier" + ], + "@ohos.arkui.BuilderNode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/BuilderNode" + ], + "@ohos.arkui.ButtonModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ButtonModifier" + ], + "@ohos.arkui.CalendarPickerModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/CalendarPickerModifier" + ], + "@ohos.arkui.CheckboxGroupModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/CheckboxGroupModifier" + ], + "@ohos.arkui.CheckboxModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/CheckboxModifier" + ], + "@ohos.arkui.ColumnModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ColumnModifier" + ], + "@ohos.arkui.ColumnSplitModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ColumnSplitModifier" + ], + "@ohos.arkui.CommonModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/CommonModifier" + ], + "@ohos.arkui.ComponentContent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ComponentContent" + ], + "@ohos.arkui.ContainerSpanModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ContainerSpanModifier" + ], + "@ohos.arkui.Content": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/Content" + ], + "@ohos.arkui.CounterModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/CounterModifier" + ], + "@ohos.arkui.DataPanelModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/DataPanelModifier" + ], + "@ohos.arkui.DatePickerModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/DatePickerModifier" + ], + "@ohos.arkui.DividerModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/DividerModifier" + ], + "@ohos.arkui.FormComponentModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/FormComponentModifier" + ], + "@ohos.arkui.FrameNode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/FrameNode" + ], + "@ohos.arkui.GaugeModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/GaugeModifier" + ], + "@ohos.arkui.Graphics": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/Graphics" + ], + "@ohos.arkui.GridColModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/GridColModifier" + ], + "@ohos.arkui.GridItemModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/GridItemModifier" + ], + "@ohos.arkui.GridModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/GridModifier" + ], + "@ohos.arkui.GridRowModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/GridRowModifier" + ], + "@ohos.arkui.HyperlinkModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/HyperlinkModifier" + ], + "@ohos.arkui.ImageAnimatorModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ImageAnimatorModifier" + ], + "@ohos.arkui.ImageModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ImageModifier" + ], + "@ohos.arkui.ImageSpanModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ImageSpanModifier" + ], + "@ohos.arkui.LineModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/LineModifier" + ], + "@ohos.arkui.ListItemGroupModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ListItemGroupModifier" + ], + "@ohos.arkui.ListItemModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ListItemModifier" + ], + "@ohos.arkui.ListModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ListModifier" + ], + "@ohos.arkui.LoadingProgressModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/LoadingProgressModifier" + ], + "@ohos.arkui.MarqueeModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/MarqueeModifier" + ], + "@ohos.arkui.MenuItemModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/MenuItemModifier" + ], + "@ohos.arkui.MenuModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/MenuModifier" + ], + "@ohos.arkui.NavDestinationModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/NavDestinationModifier" + ], + "@ohos.arkui.NavRouterModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/NavRouterModifier" + ], + "@ohos.arkui.NavigationModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/NavigationModifier" + ], + "@ohos.arkui.NavigatorModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/NavigatorModifier" + ], + "@ohos.arkui.NodeContent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/NodeContent" + ], + "@ohos.arkui.NodeController": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/NodeController" + ], + "@ohos.arkui.PanelModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/PanelModifier" + ], + "@ohos.arkui.ParticleModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ParticleModifier" + ], + "@ohos.arkui.PathModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/PathModifier" + ], + "@ohos.arkui.PatternLockModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/PatternLockModifier" + ], + "@ohos.arkui.PolygonModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/PolygonModifier" + ], + "@ohos.arkui.PolylineModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/PolylineModifier" + ], + "@ohos.arkui.ProgressModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ProgressModifier" + ], + "@ohos.arkui.QRCodeModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/QRCodeModifier" + ], + "@ohos.arkui.RadioModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/RadioModifier" + ], + "@ohos.arkui.RatingModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/RatingModifier" + ], + "@ohos.arkui.RectModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/RectModifier" + ], + "@ohos.arkui.RefreshModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/RefreshModifier" + ], + "@ohos.arkui.RenderNode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/RenderNode" + ], + "@ohos.arkui.RichEditorModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/RichEditorModifier" + ], + "@ohos.arkui.RowModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/RowModifier" + ], + "@ohos.arkui.RowSplitModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/RowSplitModifier" + ], + "@ohos.arkui.ScrollModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ScrollModifier" + ], + "@ohos.arkui.SearchModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/SearchModifier" + ], + "@ohos.arkui.SelectModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/SelectModifier" + ], + "@ohos.arkui.ShapeModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ShapeModifier" + ], + "@ohos.arkui.SideBarContainerModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/SideBarContainerModifier" + ], + "@ohos.arkui.SliderModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/SliderModifier" + ], + "@ohos.arkui.SpanModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/SpanModifier" + ], + "@ohos.arkui.StackModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/StackModifier" + ], + "@ohos.arkui.StepperItemModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/StepperItemModifier" + ], + "@ohos.arkui.SwiperModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/SwiperModifier" + ], + "@ohos.arkui.SymbolGlyphModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/SymbolGlyphModifier" + ], + "@ohos.arkui.SymbolSpanModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/SymbolSpanModifier" + ], + "@ohos.arkui.TabsModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/TabsModifier" + ], + "@ohos.arkui.TextAreaModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/TextAreaModifier" + ], + "@ohos.arkui.TextClockModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/TextClockModifier" + ], + "@ohos.arkui.TextInputModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/TextInputModifier" + ], + "@ohos.arkui.TextModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/TextModifier" + ], + "@ohos.arkui.TextPickerModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/TextPickerModifier" + ], + "@ohos.arkui.TextTimerModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/TextTimerModifier" + ], + "@ohos.arkui.TimePickerModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/TimePickerModifier" + ], + "@ohos.arkui.ToggleModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/ToggleModifier" + ], + "@ohos.arkui.VideoModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/VideoModifier" + ], + "@ohos.arkui.WaterFlowModifier": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/WaterFlowModifier" + ], + "@ohos.arkui.XComponentNode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/XComponentNode" + ], + "@ohos.arkui.component.column": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/component/column" + ], + "@ohos.arkui.component.common": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/component/common" + ], + "@ohos.arkui.component.customComponent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/component/customComponent" + ], + "@ohos.arkui.component.enums": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/component/enums" + ], + "@ohos.arkui.component.styledString": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/component/styledString" + ], + "@ohos.arkui.component.text": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/component/text" + ], + "@ohos.arkui.component.units": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/component/units" + ], + "@ohos.arkui.external.resource": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/external/resource" + ], + "@koalaui.arkts-arkui.Button": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.arkts-arkui.Button" + ], + "@koalaui.arkts-arkui.Column": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.arkts-arkui.Column" + ], + "@koalaui.arkts-arkui.Common": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.arkts-arkui.Common" + ], + "@koalaui.arkts-arkui.StructBase": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.arkts-arkui.StructBase" + ], + "@koalaui.arkts-arkui.Text": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.arkts-arkui.Text" + ], + "@koalaui.arkts-arkui.UserView": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.arkts-arkui.UserView" + ], + "@koalaui.runtime.annotations": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.annotations" + ], + "@koalaui.runtime.common": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.common" + ], + "@koalaui.runtime.internals": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.internals" + ], + "@koalaui.runtime.memo.bind": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.memo.bind" + ], + "@koalaui.runtime.memo.changeListener": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.memo.changeListener" + ], + "@koalaui.runtime.memo.contextLocal": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.memo.contextLocal" + ], + "@koalaui.runtime.memo.entry": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.memo.entry" + ], + "@koalaui.runtime.memo.node": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.memo.node" + ], + "@koalaui.runtime.memo.remember": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.memo.remember" + ], + "@koalaui.runtime.memo.repeat": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.memo.repeat" + ], + "@koalaui.runtime.memo.testing": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.memo.testing" + ], + "@koalaui.runtime.states.Disposable": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.states.Disposable" + ], + "@koalaui.runtime.states.GlobalStateManager": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.states.GlobalStateManager" + ], + "@koalaui.runtime.states.State": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.states.State" + ], + "@koalaui.runtime.tree.IncrementalNode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.tree.IncrementalNode" + ], + "@koalaui.runtime.tree.PrimeNumbers": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.tree.PrimeNumbers" + ], + "@koalaui.runtime.tree.ReadonlyTreeNode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.tree.ReadonlyTreeNode" + ], + "@koalaui.runtime.tree.TreeNode": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.tree.TreeNode" + ], + "@koalaui.runtime.tree.TreePath": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/runtime-api/@koalaui.runtime.tree.TreePath" + ], + "@ohos.arkui.stateManagement.common": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/stateManagement/common" + ], + "@ohos.arkui.stateManagement.runtime": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/stateManagement/runtime" + ], + "@ohos.arkui.stateManagement.storage": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/arkui/stateManagement/storage" + ], + "@ohos.bundle.PermissionDef": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/PermissionDef" + ], + "@ohos.bundle.abilityInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/abilityInfo" + ], + "@ohos.bundle.applicationInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/applicationInfo" + ], + "@ohos.bundle.bundleInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/bundleInfo" + ], + "@ohos.bundle.bundleInstaller": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/bundleInstaller" + ], + "@ohos.bundle.bundleStatusCallback": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/bundleStatusCallback" + ], + "@ohos.bundle.customizeData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/customizeData" + ], + "@ohos.bundle.elementName": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/elementName" + ], + "@ohos.bundle.hapModuleInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/hapModuleInfo" + ], + "@ohos.bundle.launcherAbilityInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/launcherAbilityInfo" + ], + "@ohos.bundle.moduleInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/moduleInfo" + ], + "@ohos.bundle.remoteAbilityInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/remoteAbilityInfo" + ], + "@ohos.bundle.shortcutInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundle/shortcutInfo" + ], + "@ohos.bundleManager.AbilityInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/AbilityInfo" + ], + "@ohos.bundleManager.AppProvisionInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/AppProvisionInfo" + ], + "@ohos.bundleManager.ApplicationInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/ApplicationInfo" + ], + "@ohos.bundleManager.BundleInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/BundleInfo" + ], + "@ohos.bundleManager.BundlePackInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/BundlePackInfo" + ], + "@ohos.bundleManager.BundleResourceInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/BundleResourceInfo" + ], + "@ohos.bundleManager.DispatchInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/DispatchInfo" + ], + "@ohos.bundleManager.ElementName": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/ElementName" + ], + "@ohos.bundleManager.ExtensionAbilityInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/ExtensionAbilityInfo" + ], + "@ohos.bundleManager.HapModuleInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/HapModuleInfo" + ], + "@ohos.bundleManager.LauncherAbilityInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/LauncherAbilityInfo" + ], + "@ohos.bundleManager.LauncherAbilityResourceInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/LauncherAbilityResourceInfo" + ], + "@ohos.bundleManager.Metadata": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/Metadata" + ], + "@ohos.bundleManager.OverlayModuleInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/OverlayModuleInfo" + ], + "@ohos.bundleManager.PermissionDef": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/PermissionDef" + ], + "@ohos.bundleManager.RecoverableApplicationInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/RecoverableApplicationInfo" + ], + "@ohos.bundleManager.RemoteAbilityInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/RemoteAbilityInfo" + ], + "@ohos.bundleManager.SharedBundleInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/SharedBundleInfo" + ], + "@ohos.bundleManager.ShortcutInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/ShortcutInfo" + ], + "@ohos.bundleManager.Skill": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/bundleManager/Skill" + ], + "@ohos.commonEvent.commonEventData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/commonEvent/commonEventData" + ], + "@ohos.commonEvent.commonEventPublishData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/commonEvent/commonEventPublishData" + ], + "@ohos.commonEvent.commonEventSubscribeInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/commonEvent/commonEventSubscribeInfo" + ], + "@ohos.commonEvent.commonEventSubscriber": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/commonEvent/commonEventSubscriber" + ], + "@ohos.continuation.continuationExtraParams": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/continuation/continuationExtraParams" + ], + "@ohos.continuation.continuationResult": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/continuation/continuationResult" + ], + "@ohos.data.rdb.resultSet": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/data/rdb/resultSet" + ], + "@ohos.device-define.default.json": [ + "" + ], + "@ohos.device-define.liteWearable.json": [ + "" + ], + "@ohos.device-define.tablet.json": [ + "" + ], + "@ohos.device-define.wearable.json": [ + "" + ], + "@ohos.global.rawFileDescriptor": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/global/rawFileDescriptor" + ], + "@ohos.global.resource": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/global/resource" + ], + "@ohos.global.sendableResource": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/global/sendableResource" + ], + "@ohos.graphics3d.Scene": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/graphics3d/Scene" + ], + "@ohos.graphics3d.SceneNodes": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/graphics3d/SceneNodes" + ], + "@ohos.graphics3d.ScenePostProcessSettings": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/graphics3d/ScenePostProcessSettings" + ], + "@ohos.graphics3d.SceneResources": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/graphics3d/SceneResources" + ], + "@ohos.graphics3d.SceneTypes": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/graphics3d/SceneTypes" + ], + "@ohos.multimedia.ringtonePlayer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/multimedia/ringtonePlayer" + ], + "@ohos.multimedia.soundPool": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/multimedia/soundPool" + ], + "@ohos.multimedia.systemTonePlayer": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/multimedia/systemTonePlayer" + ], + "@ohos.notification.NotificationCommonDef": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/NotificationCommonDef" + ], + "@ohos.notification.notificationActionButton": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationActionButton" + ], + "@ohos.notification.notificationContent": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationContent" + ], + "@ohos.notification.notificationFlags": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationFlags" + ], + "@ohos.notification.notificationRequest": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationRequest" + ], + "@ohos.notification.notificationSlot": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationSlot" + ], + "@ohos.notification.notificationSorting": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationSorting" + ], + "@ohos.notification.notificationSortingMap": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationSortingMap" + ], + "@ohos.notification.notificationSubscribeInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationSubscribeInfo" + ], + "@ohos.notification.notificationSubscriber": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationSubscriber" + ], + "@ohos.notification.notificationTemplate": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationTemplate" + ], + "@ohos.notification.notificationUserInput": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/notification/notificationUserInput" + ], + "@ohos.permissions": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/permissions" + ], + "@ohos.security.PermissionRequestResult": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/security/PermissionRequestResult" + ], + "@ohos.tag.nfctech": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/tag/nfctech" + ], + "@ohos.tag.tagSession": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/tag/tagSession" + ], + "@ohos.wantAgent.triggerInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/wantAgent/triggerInfo" + ], + "@ohos.wantAgent.wantAgentInfo": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/api/wantAgent/wantAgentInfo" + ], + "@ohos.@arkts.collections": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/arkts/@arkts.collections" + ], + "@ohos.@arkts.lang": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/arkts/@arkts.lang" + ], + "@ohos.@arkts.math.Decimal": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/arkts/@arkts.math.Decimal" + ], + "@ohos.@arkts.utils": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/arkts/@arkts.utils" + ], + "@ohos.@kit.AVSessionKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.AVSessionKit" + ], + "@ohos.@kit.AbilityKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.AbilityKit" + ], + "@ohos.@kit.AccessibilityKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.AccessibilityKit" + ], + "@ohos.@kit.AdsKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.AdsKit" + ], + "@ohos.@kit.ArkData": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.ArkData" + ], + "@ohos.@kit.ArkGraphics2D": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.ArkGraphics2D" + ], + "@ohos.@kit.ArkGraphics3D": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.ArkGraphics3D" + ], + "@ohos.@kit.ArkTS": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.ArkTS" + ], + "@ohos.@kit.ArkUI": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.ArkUI" + ], + "@ohos.@kit.ArkWeb": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.ArkWeb" + ], + "@ohos.@kit.AssetStoreKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.AssetStoreKit" + ], + "@ohos.@kit.AudioKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.AudioKit" + ], + "@ohos.@kit.BackgroundTasksKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.BackgroundTasksKit" + ], + "@ohos.@kit.BasicServicesKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.BasicServicesKit" + ], + "@ohos.@kit.CalendarKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.CalendarKit" + ], + "@ohos.@kit.CameraKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.CameraKit" + ], + "@ohos.@kit.ConnectivityKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.ConnectivityKit" + ], + "@ohos.@kit.ContactsKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.ContactsKit" + ], + "@ohos.@kit.CoreFileKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.CoreFileKit" + ], + "@ohos.@kit.CryptoArchitectureKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.CryptoArchitectureKit" + ], + "@ohos.@kit.DataLossPreventionKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.DataLossPreventionKit" + ], + "@ohos.@kit.DataProtectionKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.DataProtectionKit" + ], + "@ohos.@kit.DeviceCertificateKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.DeviceCertificateKit" + ], + "@ohos.@kit.DistributedServiceKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.DistributedServiceKit" + ], + "@ohos.@kit.DriverDevelopmentKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.DriverDevelopmentKit" + ], + "@ohos.@kit.DrmKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.DrmKit" + ], + "@ohos.@kit.FormKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.FormKit" + ], + "@ohos.@kit.IMEKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.IMEKit" + ], + "@ohos.@kit.IPCKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.IPCKit" + ], + "@ohos.@kit.ImageKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.ImageKit" + ], + "@ohos.@kit.InputKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.InputKit" + ], + "@ohos.@kit.LocalizationKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.LocalizationKit" + ], + "@ohos.@kit.LocationKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.LocationKit" + ], + "@ohos.@kit.MDMKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.MDMKit" + ], + "@ohos.@kit.MediaKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.MediaKit" + ], + "@ohos.@kit.MediaLibraryKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.MediaLibraryKit" + ], + "@ohos.@kit.MindSporeLiteKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.MindSporeLiteKit" + ], + "@ohos.@kit.MultimodalAwarenessKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.MultimodalAwarenessKit" + ], + "@ohos.@kit.NetworkKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.NetworkKit" + ], + "@ohos.@kit.NotificationKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.NotificationKit" + ], + "@ohos.@kit.PerformanceAnalysisKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.PerformanceAnalysisKit" + ], + "@ohos.@kit.SecurityGuardKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.SecurityGuardKit" + ], + "@ohos.@kit.SensorServiceKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.SensorServiceKit" + ], + "@ohos.@kit.TelephonyKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.TelephonyKit" + ], + "@ohos.@kit.TestKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.TestKit" + ], + "@ohos.@kit.UniversalKeystoreKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.UniversalKeystoreKit" + ], + "@ohos.@kit.UserAuthenticationKit": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.UserAuthenticationKit" + ], + "@ohos.@kit.network": [ + "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/kits/@kit.network" + ] + }, + "entry": "", + "dynamicPaths": {} + } +} \ No newline at end of file diff --git a/arkui-plugins/test/demo/localtest/build_config_template.json b/arkui-plugins/test/demo/localtest/build_config_template.json new file mode 100755 index 000000000..aa3de2c82 --- /dev/null +++ b/arkui-plugins/test/demo/localtest/build_config_template.json @@ -0,0 +1,24 @@ +{ + "plugins": { + "ui_plugin": "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ui-plugins/lib/ui-plugins/index", + "memo_plugin": "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ui-plugins/lib/memo-plugins/index" + }, + + "compileFiles": [ + "./demo/localtest/entry/new.ets" + ], + + "packageName" : "entry", + + "buildType": "build", + "buildMode": "Debug", + "moduleRootPath": "./demo/localtest/entry/", + "sourceRoots": ["./"], + + "loaderOutPath": "./dist", + "cachePath": "./dist/cache", + + "buildSdkPath": "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/", + + "dependentModuleList": [] +} \ No newline at end of file diff --git a/arkui-plugins/test/demo/localtest/build_decl_config_template.json b/arkui-plugins/test/demo/localtest/build_decl_config_template.json new file mode 100644 index 000000000..fc58a0e00 --- /dev/null +++ b/arkui-plugins/test/demo/localtest/build_decl_config_template.json @@ -0,0 +1,29 @@ +{ + "plugins": { + "interop_plugin": "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ui-plugins/lib/interop-plugins/index" + }, + + "compileFiles": [ + "./demo/localtest/entry/new.ets" + ], + + "packageName" : "entry", + + "buildType": "build", + "buildMode": "Debug", + "moduleRootPath": "./demo/localtest/entry/", + "sourceRoots": ["./"], + + "loaderOutPath": "./dist", + "cachePath": "./dist/cache", + + "buildSdkPath": "workspace/out/sdk/ohos-sdk/linux/ets/ets1.2/", + + "dependentModuleList": [], + + "isIDE": "false", + "enableDeclgenEts2Ts": true, + + "declgenV1OutPath": "workspace/developtools/ace_ets2bundle/arkui-plugins/test/demo/hello_world/declgenV1OutPath", + "declgenBridgeCodePath": "workspace/developtools/ace_ets2bundle/arkui-plugins/test/demo/hello_world/declgenBridgeCodePath" +} diff --git a/arkui-plugins/test/demo/localtest/entry/index.ets b/arkui-plugins/test/demo/localtest/entry/index.ets new file mode 100644 index 000000000..c54a0d153 --- /dev/null +++ b/arkui-plugins/test/demo/localtest/entry/index.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 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 { memo, __memo_context_type, __memo_id_type } from "@ohos.arkui.stateManagement"; +import { Text, Column, Component, Button, ClickEvent } from "@ohos.arkui.component"; + +import hilog from '@ohos.hilog'; + +@Component +export struct MyStateSample { + message: string = "Click"; + + build() { + Column(undefined) { + Text("Hello World") + .fontSize(20) + Button(this.message) + .backgroundColor("#FFFF00FF") + .onClick((e: ClickEvent) => { + hilog.info(0x0000, 'testTag', 'On Click'); + }) + Child() + } + } +} + +@Component +export struct Child { + stateVar: string = "Child"; + + build() { + Text(this.stateVar) + .fontSize(50) + } +} diff --git a/arkui-plugins/test/demo/localtest/entry/new.ets b/arkui-plugins/test/demo/localtest/entry/new.ets new file mode 100755 index 000000000..551759239 --- /dev/null +++ b/arkui-plugins/test/demo/localtest/entry/new.ets @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2025 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 { memo, __memo_context_type, __memo_id_type } from "@ohos.arkui.stateManagement" // should be insert by ui-plugins +import { Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView } from "@ohos.arkui.component" // TextAttribute should be insert by ui-plugins +import { State, Link, StateDecoratedVariable, LinkDecoratedVariable,MutableState, stateOf, observableProxy, DecoratedMutableVariable } from "@ohos.arkui.stateManagement" // should be insert by ui-plugins +import hilog from '@ohos.hilog' + +@Component +struct MyStateSample { + @State stateVar: string = "Parent"; + message: string = "var"; + changeValue() { + this.stateVar+="~"; + } + build() { + Column(undefined) { + Button("ParentChange").backgroundColor("#FFFF00FF") + .onClick((e: ClickEvent) => { + hilog.info(0x0000, 'testTag', 'On Click'); + this.changeValue(); + }) + Text(this.stateVar).fontSize(20) + ChildLink({stateVar: this.stateVar, stateVar1: this.stateVar, stateVar2: ""} as __Options_ChildLink) + } + } +} + + +@Component +struct ChildLink { + @Link stateVar: string = "Child"; + @State stateVar1: string = "Child"; + @Link stateVar2: string = "Child"; + changeValue() { + this.stateVar+="~"; + } + build() { + Button("ChildChange").backgroundColor("#FFFF00FF") + .onClick((e: ClickEvent) => { + hilog.info(0x0000, 'testTag', 'On Click'); + this.changeValue(); + }) + Text(this.stateVar).fontSize(50) + } +} + +export class ComExampleTrivialApplication extends UserView { + getBuilder() { + hilog.info(0x0000, 'testTag', 'getBuilder'); + let wrapper = @memo () => { + hilog.info(0x0000, 'testTag', 'MyStateSample'); + MyStateSample(undefined); + } + return wrapper; + } +} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/builder-lambda/instantiate-content.ets b/arkui-plugins/test/demo/mock/builder-lambda/instantiate-content.ets new file mode 100644 index 000000000..f63cefd67 --- /dev/null +++ b/arkui-plugins/test/demo/mock/builder-lambda/instantiate-content.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 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 { Component } from "@koalaui.arkts-arkui.Common" +import { Column } from "@koalaui.arkts-arkui.Column" +import { Text } from "@koalaui.arkts-arkui.Text" + +@Component +struct MyStateSample { + build() { + Column() { + Text("Hello!") + } + } +} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/builder-lambda/instantiate-multi-content.ets b/arkui-plugins/test/demo/mock/builder-lambda/instantiate-multi-content.ets new file mode 100644 index 000000000..c5712c859 --- /dev/null +++ b/arkui-plugins/test/demo/mock/builder-lambda/instantiate-multi-content.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 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 { Component } from "@koalaui.arkts-arkui.Common" +import { Column } from "@koalaui.arkts-arkui.Column" +import { Text } from "@koalaui.arkts-arkui.Text" +import { Button } from "@koalaui.arkts-arkui.Button" + +@Component +struct MyStateSample { + build() { + Column() { + Text("Hello!") + Button("click me") + } + } +} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/builder-lambda/instantiate.ets b/arkui-plugins/test/demo/mock/builder-lambda/instantiate.ets new file mode 100644 index 000000000..1b05c1e8a --- /dev/null +++ b/arkui-plugins/test/demo/mock/builder-lambda/instantiate.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 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 { Component } from "@koalaui.arkts-arkui.Common" +import { Column } from "@koalaui.arkts-arkui.Column" + +@Component +struct MyStateSample { + build() { + Column() {} + } +} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/entry.ets b/arkui-plugins/test/demo/mock/entry.ets new file mode 100644 index 000000000..1a0b18983 --- /dev/null +++ b/arkui-plugins/test/demo/mock/entry.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 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. + */ + +class A {} \ No newline at end of file diff --git a/arkui-plugins/test/demo/mock/struct-to-class.ets b/arkui-plugins/test/demo/mock/struct-to-class.ets new file mode 100644 index 000000000..85f67b07f --- /dev/null +++ b/arkui-plugins/test/demo/mock/struct-to-class.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 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 { Component } from "@koalaui.arkts-arkui.Common" + +@Component +struct MyStateSample { + build() {} +} \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.component.column.d.ets b/arkui-plugins/test/local/@ohos.arkui.component.column.d.ets new file mode 100644 index 000000000..915dc5ceb --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.component.column.d.ets @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2025 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 { memo } from '../stateManagement/runtime'; +import { ComponentBuilder, CommonMethod, PointLightStyle } from './common'; +import { HorizontalAlign, FlexAlign } from './enums'; + +export declare interface ColumnOptions { + space?: string | number; +} + +export declare interface ColumnAttribute extends CommonMethod { + @memo + alignItems(value: HorizontalAlign): this; + @memo + justifyContent(value: FlexAlign): this; + @memo + pointLight(value: PointLightStyle): this; + @memo + reverse(isReversed?: boolean): this; +} + +@memo +@ComponentBuilder +export declare function Column ( + options?: ColumnOptions, + @memo + content?: () => void +): ColumnAttribute; \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.component.common.d.ets b/arkui-plugins/test/local/@ohos.arkui.component.common.d.ets new file mode 100644 index 000000000..2ff6ea60a --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.component.common.d.ets @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2025 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 { Dimension, Length, ResourceColor } from "@ohos.arkui.component.units"; +import { IlluminatedType } from "@ohos.arkui.component.enums"; +import { memo } from '@ohos.arkui.stateManagement.runtime'; + +@Retention({policy: "SOURCE"}) +export @interface BuilderLambda { + value: string +} + +@Retention({policy: "SOURCE"}) +export declare @interface ComponentBuilder {}; + +@Retention({policy: "SOURCE"}) +export declare @interface BuilderParam {}; + +@Retention({policy: "SOURCE"}) +export declare @interface Builder {}; + +export declare interface LightSource { + positionX: Dimension; + positionY: Dimension; + positionZ: Dimension; + intensity: number; + color?: ResourceColor; +} + +export declare interface PointLightStyle { + lightSource?: LightSource; + illuminated?: IlluminatedType; + bloom?: number; +} + +export declare interface CommonMethod { + @memo + width(w: Length): this; + @memo + height(h: Length): this; + @memo + backgroundColor(color: ResourceColor): this; +} \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.component.customComponent.d.ets b/arkui-plugins/test/local/@ohos.arkui.component.customComponent.d.ets new file mode 100644 index 000000000..728c949e7 --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.component.customComponent.d.ets @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2025 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 { memo } from "@ohos.arkui.stateManagement.runtime"; +import { ComponentBuilder, CommonMethod } from "@ohos.arkui.component.common"; +import { Length, ResourceColor } from "@ohos.arkui.component.units"; + +@Retention({policy: "SOURCE"}) +export declare @interface Component {}; + +@Retention({policy: "SOURCE"}) +export declare @interface Entry { routeName: string }; + +@Retention({policy: "SOURCE"}) +export declare @interface Reusable {}; + +export declare abstract class CustomComponent, T_Options> implements + CommonMethod { + + @memo + @ComponentBuilder + static $_instantiate, S_Options>( + factory: () => S, + initializers?: S_Options, + @memo + content?: () => void + ): S; + + // Life cycle for custom component + aboutToAppear(): void; + aboutToDisappear(): void; + aboutToReuse(): void; + aboutToRecycle(): void; + + @memo + build(): void; + + // Implementation of common method + @memo + width(w: Length): this; + @memo + height(h: Length): this; + @memo + backgroundColor(color: ResourceColor): this; +} \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.component.d.ets b/arkui-plugins/test/local/@ohos.arkui.component.d.ets new file mode 100644 index 000000000..0f74a9db4 --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.component.d.ets @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2025 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 * from "@ohos.arkui.component.customComponent"; +export * from "@ohos.arkui.component.common"; +export * from "@ohos.arkui.component.column"; +export * from "@ohos.arkui.component.text"; +export * from "@ohos.arkui.component.styledString"; +export * from "@ohos.arkui.component.enums"; +export * from "@ohos.arkui.component.units"; \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.component.enums.d.ets b/arkui-plugins/test/local/@ohos.arkui.component.enums.d.ets new file mode 100644 index 000000000..e72c21ace --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.component.enums.d.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2025 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 declare enum FlexAlign { + Start = 0, + Center = 1, + End = 2, + SpaceBetween = 3, + SpaceAround = 4, + SpaceEvenly = 5 +} + +export declare enum HorizontalAlign { + Start = 0, + Center = 1, + End = 2 +} + +export declare enum IlluminatedType { + NONE = 0, + BORDER = 1, + CONTENT = 2, + BORDER_CONTENT = 3, + BLOOM_BORDER = 4, + BLOOM_BORDER_CONTENT = 5 +} + +export declare enum Color { + White = 0, + Black = 1, + Blue = 2, + Brown = 3, + Gray = 4, + Green = 5, + Grey = 6, + Orange = 7, + Pink = 8, + Red = 9, + Yellow = 10, + Transparent = 11 +} \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.component.styledString.d.ets b/arkui-plugins/test/local/@ohos.arkui.component.styledString.d.ets new file mode 100644 index 000000000..4a0e94d6f --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.component.styledString.d.ets @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2025 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 declare class StyledString { + constructor(value: string /*| ImageAttachment | CustomSpan, styles?: Array*/); + + readonly length: number; + + getString(): string; + // getStyles(start: number, length: number, styledKey?: StyledStringKey): Array; + equals(other: StyledString): boolean; + subStyledString(start: number, length?: number): StyledString; + + static fromHtml(html: string): Promise; + static toHtml(styledString: StyledString): string; + // static marshalling(styledString: StyledString, callback: StyledStringMarshallCallback): ArrayBuffer; + // static unmarshalling(buffer: ArrayBuffer, callback: StyledStringUnmarshallCallback): Promise; + // static marshalling(styledString: StyledString): ArrayBuffer; + // static unmarshalling(buffer: ArrayBuffer): Promise; +} \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.component.text.d.ets b/arkui-plugins/test/local/@ohos.arkui.component.text.d.ets new file mode 100644 index 000000000..5ba7ef754 --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.component.text.d.ets @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2025 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 { Resource } from "@ohos.arkui.external.resource"; +import { StyledString } from "@ohos.arkui.component.styledString"; +import { ComponentBuilder, CommonMethod } from "@ohos.arkui.component.common"; +import { ResourceColor, Length } from "@ohos.arkui.component.units"; +import { memo } from '@ohos.arkui.stateManagement.runtime'; + +export declare class TextController { + closeSelectionMenu(): void; + setStyledString(value: StyledString): void; + + // getLayoutManager(): LayoutManager; +} + +export declare interface TextOptions { + controller: TextController; +} + +export declare interface TextAttribute extends CommonMethod { + // @memo + // font(value: Font, options?: FontSettingOptions): this; + @memo + fontColor(value: ResourceColor): this; + @memo + fontSize(value: number | string | Resource): this; + @memo + minFontSize(value: number | string | Resource): this; + @memo + maxFontSize(value: number | string | Resource): this; + @memo + minFontScale(scale: number | Resource): this; + @memo + maxFontScale(scale: number | Resource): this; + // @memo + // fontStyle(value: FontStyle): this; + // @memo + // fontWeight(value: number | FontWeight | string): this; + // @memo + // fontWeight(weight: number | FontWeight | string, options?: FontSettingOptions): this; + // @memo + // lineSpacing(value: LengthMetrics): this; + // @memo + // textAlign(value: TextAlign): this; + @memo + lineHeight(value: number | string | Resource): this; + // @memo + // textOverflow(options: TextOverflowOptions): this; + @memo + fontFamily(value: string | Resource): this; + @memo + maxLines(value: number): this; + // @memo + // decoration(value: DecorationStyleInterface): this; + @memo + letterSpacing(value: number | string): this; + // @memo + // textCase(value: TextCase): this; + @memo + baselineOffset(value: number | string): this; + // @memo + // copyOption(value: CopyOptions): this; + @memo + draggable(value: boolean): this; + // @memo + // textShadow(value: ShadowOptions | Array): this; + // @memo + // heightAdaptivePolicy(value: TextHeightAdaptivePolicy): this; + @memo + textIndent(value: Length): this; + // @memo + // wordBreak(value: WordBreak): this; + // @memo + // lineBreakStrategy(strategy: LineBreakStrategy): this; + @memo + onCopy(callback: (value: string) => void): this; + @memo + selection(selectionStart: number, selectionEnd: number): this; + @memo + caretColor(color: ResourceColor): this; + @memo + selectedBackgroundColor(color: ResourceColor): this; + // @memo + // ellipsisMode(value: EllipsisMode): this; + @memo + enableDataDetector(enable: boolean): this; + // @memo + // dataDetectorConfig(config: TextDataDetectorConfig): this; + // @memo + // bindSelectionMenu(spanType: TextSpanType, content: CustomBuilder, responseType: TextResponseType, + // options?: SelectionMenuOptions): this; + @memo + onTextSelectionChange(callback: (selectionStart: number, selectionEnd: number) => void): this; + @memo + fontFeature(value: string): this; + // @memo + // marqueeOptions(options: Optional): this; + // @memo + // onMarqueeStateChange(callback: Callback): this; + @memo + privacySensitive(supported: boolean): this; + // @memo + // textSelectable(mode: TextSelectableMode): this; + // @memo + // editMenuOptions(editMenu: EditMenuOptions): this; + @memo + halfLeading(halfLeading: boolean): this; + @memo + enableHapticFeedback(isEnabled: boolean): this; +} + +@memo +@ComponentBuilder +export declare function Text ( + value?: string | Resource, + options?: TextOptions, + @memo + content?: () => void +): TextAttribute; diff --git a/arkui-plugins/test/local/@ohos.arkui.component.units.d.ets b/arkui-plugins/test/local/@ohos.arkui.component.units.d.ets new file mode 100644 index 000000000..c6a98e628 --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.component.units.d.ets @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2025 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 { Resource } from "@ohos.arkui.external.resource" +import { Color } from "@ohos.arkui.component.enums"; + +export type PX = string; +export type VP = string | number; +export type FP = string; +export type LPX = string; +export type Percentage = string; + +export type Dimension = PX | VP | FP | LPX | Percentage | Resource; + +export type Length = string | number | Resource; + +export type ResourceColor = Color | number | string | Resource; \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.external.resource.d.ets b/arkui-plugins/test/local/@ohos.arkui.external.resource.d.ets new file mode 100644 index 000000000..9cc3b09e0 --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.external.resource.d.ets @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2025 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 type Resource = boolean; \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.stateManagement.common.d.ets b/arkui-plugins/test/local/@ohos.arkui.stateManagement.common.d.ets new file mode 100644 index 000000000..274947957 --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.stateManagement.common.d.ets @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2025 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. + */ + +@Retention({policy: "SOURCE"}) +export declare @interface State {}; + +@Retention({policy: "SOURCE"}) +export declare @interface Prop {}; + +@Retention({policy: "SOURCE"}) +export declare @interface Link {}; + +@Retention({policy: "SOURCE"}) +export declare @interface Observed {}; + +@Retention({policy: "SOURCE"}) +export declare @interface Track {}; + +@Retention({policy: "SOURCE"}) +export declare @interface ObjectLink {}; + +@Retention({policy: "SOURCE"}) +export declare @interface StorageProp { value: string }; + +@Retention({policy: "SOURCE"}) +export declare @interface StorageLink { value: string }; + +@Retention({policy: "SOURCE"}) +export declare @interface LocalStorageProp { value: string }; + +@Retention({policy: "SOURCE"}) +export declare @interface LocalStorageLink { value: string }; + +@Retention({policy: "SOURCE"}) +export declare @interface Provide { value: string }; + +@Retention({policy: "SOURCE"}) +export declare @interface Consume { value: string }; + +@Retention({policy: "SOURCE"}) +export declare @interface Watch { value: string }; + +@Retention({policy: "SOURCE"}) +export declare @interface Require {}; + +export declare class UIUtils { + static getTarget(source: T): T; + static makeObserved(source: T): T; +} \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.stateManagement.d.ets b/arkui-plugins/test/local/@ohos.arkui.stateManagement.d.ets new file mode 100644 index 000000000..9cb01ec59 --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.stateManagement.d.ets @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2025 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 * from "@ohos.arkui.stateManagement.common"; +export * from "@ohos.arkui.stateManagement.runtime"; +export * from "@ohos.arkui.stateManagement.storage"; diff --git a/arkui-plugins/test/local/@ohos.arkui.stateManagement.runtime.d.ets b/arkui-plugins/test/local/@ohos.arkui.stateManagement.runtime.d.ets new file mode 100644 index 000000000..f70c0cb7f --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.stateManagement.runtime.d.ets @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2025 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 { LocalStorage } from "@ohos.arkui.stateManagement.storage" + +// From incremental engine +@Retention({policy: "SOURCE"}) +export declare @interface memo {}; + +export type __memo_context_type = StateContext; +export type __memo_id_type = MemoCallSiteKey; + +export type MemoCallSiteKey = int; + +export declare interface Disposable { + readonly disposed: boolean; + dispose(): void; +} + +export declare interface State { + readonly modified: boolean; + readonly value: T; +} + +export declare interface MutableState extends Disposable, State { + value: T; +} + +export type Equivalent = (oldV: T, newV: T) => boolean; + +export declare interface InternalScope { + readonly unchanged: boolean; + readonly cached: Value; + recache(newValue?: Value): Value; + param(index: int, value: T, equivalent?: Equivalent, name?: string, contextLocal?: boolean): State; +} + +export declare interface StateContext { + scope(id: MemoCallSiteKey, paramCount?: int): InternalScope; +} + +// From Arkoala +export declare function propState(value?: T): MutableState; +export declare function objectLinkState(value?: T): MutableState; +export declare function stateOf(value: T): MutableState; +export declare function contextLocalStateOf(value: T, key: () => T): MutableState; +export declare function contextLocal(value: T): MutableState; +export declare function observableProxy(value: T): T; +export declare function StorageLinkState(storage: LocalStorage, name: string, value: T): MutableState +export declare function AppStorageLinkState(name: string, value: T): MutableState; \ No newline at end of file diff --git a/arkui-plugins/test/local/@ohos.arkui.stateManagement.storage.d.ets b/arkui-plugins/test/local/@ohos.arkui.stateManagement.storage.d.ets new file mode 100644 index 000000000..a7257c839 --- /dev/null +++ b/arkui-plugins/test/local/@ohos.arkui.stateManagement.storage.d.ets @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2025 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 declare interface StorageProperty { + key: string; + defaultValue: number | string | boolean | Object; +} + +export type PersistPropsOptions = StorageProperty; + +export declare interface AbstractProperty { + info(): string; + get(): T; + set(newValue: T): void; +} + +export declare interface SubscribedAbstractProperty extends AbstractProperty { + aboutToBeDeleted(): void; +} + +export declare class LocalStorage { + static getShared(): LocalStorage | undefined; + + constructor(initializingProperties?: StorageProperty[]); + + has(propName: string): boolean; + + keys(): IterableIterator; + + size(): int; + + get(propName: string): T | undefined; + + set(propName: string, newValue: T): boolean; + + setOrCreate(propName: string, newValue?: T): boolean; + + ref(propName: string): AbstractProperty | undefined; + + setAndRef(propName: string, defaultValue: T): AbstractProperty; + + link(propName: string): SubscribedAbstractProperty | undefined; + + setAndLink(propName: string, defaultValue: T): SubscribedAbstractProperty; + + prop(propName: string): SubscribedAbstractProperty | undefined; + + setAndProp(propName: string, defaultValue: T): SubscribedAbstractProperty; + + delete(propName: string): boolean; + + clear(): boolean; +} + +export declare class AppStorage { + static has(propName: string): boolean; + + static keys(): IterableIterator; + + static size(): int; + + static get(propName: string): T | undefined; + + static set(propName: string, newValue: T): boolean; + + static setOrCreate(propName: string, newValue?: T): boolean; + + static ref(propName: string): AbstractProperty | undefined; + + static setAndRef(propName: string, defaultValue: T): AbstractProperty; + + static link(propName: string): SubscribedAbstractProperty | undefined; + + static setAndLink(propName: string, defaultValue: T): SubscribedAbstractProperty; + + static prop(propName: string): SubscribedAbstractProperty | undefined; + + static setAndProp(propName: string, defaultValue: T): SubscribedAbstractProperty; + + static delete(propName: string): boolean; + + static clear(): boolean; +} + +export declare class PersistentStorage { + + static persistProp(key: string, defaultValue: T): void; + + static deleteProp(key: string): void; + + static persistProps(props: PersistPropsOptions[]): void; + + static keys(): Array; +} + +export declare interface EnvPropsOptions { + key: string; + defaultValue: number | string | boolean; +} + +export declare class Environment { + static envProp(key: string, value: S): boolean; + + static envProps(props: EnvPropsOptions[]): void; + + static keys(): Array; +} \ No newline at end of file diff --git a/arkui-plugins/test/localtest_config.js b/arkui-plugins/test/localtest_config.js new file mode 100644 index 000000000..87fd2e7ee --- /dev/null +++ b/arkui-plugins/test/localtest_config.js @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2025 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. + */ + +const fs = require('fs'); +const path = require('path'); + +// 获取当前目录 +const currentDirectory = process.cwd(); +let workSpace = currentDirectory; +for (let i = 0; i < 4; i++) { + workSpace = path.dirname(workSpace); +} +// JSON 文件路径 +const jsonFilePath = path.join(__dirname, 'demo/localtest/build_config_template.json'); +const outJsonFilePath = path.join(__dirname, 'demo/localtest/build_config.json'); + +try { + // 读取 JSON 文件内容 + const data = fs.readFileSync(jsonFilePath, 'utf8'); + const jsonData = JSON.parse(data); + console.log(jsonData) + // 处理 baseUrl 字段 + if (jsonData.buildSdkPath) { + jsonData.buildSdkPath = jsonData.buildSdkPath.replace(/workspace/g, workSpace); + } + + // 处理 plugins 字段 + if (jsonData.plugins.ui_plugin) { + jsonData.plugins.ui_plugin = jsonData.plugins.ui_plugin.replace(/workspace/g, workSpace); + } + if (jsonData.plugins.memo_plugin) { + jsonData.plugins.memo_plugin = jsonData.plugins.memo_plugin.replace(/workspace/g, workSpace); + } + + // 将修改后的内容写回 JSON 文件 + fs.writeFileSync(outJsonFilePath, JSON.stringify(jsonData, null, 2), 'utf8'); +} catch (error) { + console.error('处理 JSON 文件时出错:', error); +} \ No newline at end of file diff --git a/arkui-plugins/test/localtest_decl_config.js b/arkui-plugins/test/localtest_decl_config.js new file mode 100644 index 000000000..999494cff --- /dev/null +++ b/arkui-plugins/test/localtest_decl_config.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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. + */ + +const fs = require('fs'); +const path = require('path'); + +const currentDirectory = process.cwd(); +let workSpace = currentDirectory; +for (let i = 0; i < 4; i++) { + workSpace = path.dirname(workSpace); +} + +const jsonFilePath = path.join(__dirname, 'demo/localtest/build_decl_config_template.json'); +const outJsonFilePath = path.join(__dirname, 'demo/localtest/build_decl_config.json'); + +try { + const data = fs.readFileSync(jsonFilePath, 'utf8'); + const jsonData = JSON.parse(data); + + if (jsonData.buildSdkPath) { + jsonData.buildSdkPath = jsonData.buildSdkPath.replace(/workspace/g, workSpace); + } + + if (jsonData.plugins.interop_plugin) { + jsonData.plugins.interop_plugin = jsonData.plugins.interop_plugin.replace(/workspace/g, workSpace); + } + + if (jsonData.declgenV1OutPath) { + jsonData.declgenV1OutPath = jsonData.declgenV1OutPath.replace(/workspace/g, workSpace); + } + + if (jsonData.declgenBridgeCodePath) { + jsonData.declgenBridgeCodePath = jsonData.declgenBridgeCodePath.replace(/workspace/g, workSpace); + } + + fs.writeFileSync(outJsonFilePath, JSON.stringify(jsonData, null, 2), 'utf8'); +} catch (error) { + console.error('writeFile error:', error); +} diff --git a/arkui-plugins/test/package.json b/arkui-plugins/test/package.json new file mode 100644 index 000000000..51154bd39 --- /dev/null +++ b/arkui-plugins/test/package.json @@ -0,0 +1,17 @@ +{ + "name": "arkui-plugins-test", + "version": "1.0.0", + "description": "", + "private": true, + "scripts": { + "compile:ohos": "node $INIT_CWD/../../../../arkcompiler/ets_frontend/ets2panda/driver/build-system/dist/entry.js ./demo/hello_world/build_config.json", + "compile:gdb": "gdb --args node $INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/driver/build-system/dist/entry.js ./demo/hello_world/build_config.json", + "compile:plugins": "npm run compile --prefix .. ", + "localtest": "rm -rf dist && node localtest_config.js && npm run compile:plugins && LD_LIBRARY_PATH=$INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ets2panda/lib node $INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/driver/build-system/dist/entry.js ./demo/localtest/build_config.json", + "localtest_gdb": "LD_LIBRARY_PATH=$INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ets2panda/lib gdb --args node $INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/driver/build-system/dist/entry.js ./demo/localtest/build_config.json", + "localtest_decl": "rm -rf dist && node localtest_decl_config.js && npm run compile:plugins && LD_LIBRARY_PATH=$INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ets2panda/lib node $INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/driver/build-system/dist/entry.js ./demo/localtest/build_decl_config.json", + "localtest_all": "npm run localtest_decl && npm run localtest", + "es2panda:compile": "node ./arktsconfig_gen.js && $INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ets2panda/bin/es2panda --arktsconfig=./dist/cache/arktsconfig.json", + "es2panda:test": "$INIT_CWD/../../../../out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ets2panda/bin/es2panda ./demo/localtest/entry/test.ets --output=test.abc" + } +} diff --git a/arkui-plugins/test/test.log b/arkui-plugins/test/test.log new file mode 100644 index 000000000..984a29adf --- /dev/null +++ b/arkui-plugins/test/test.log @@ -0,0 +1,372 @@ + +> build_system_test@1.0.0 compile:ohos_sdk +> node /home/wuhaibin/newcode/oh/out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/driver/build-system/dist/entry.js ./demo/hello_world/build_config.json + +[ + '/home/wuhaibin/.nvm/versions/node/v23.8.0/bin/node', + '/home/wuhaibin/newcode/oh/out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/driver/build-system/dist/entry.js', + './demo/hello_world/build_config.json' +] +Updated PATH: /home/wuhaibin/newcode/oh/developtools/ace_ets2bundle/arkui-plugins/test/node_modules/.bin:/home/wuhaibin/newcode/oh/developtools/ace_ets2bundle/arkui-plugins/node_modules/.bin:/home/wuhaibin/newcode/oh/developtools/ace_ets2bundle/node_modules/.bin:/home/wuhaibin/newcode/oh/developtools/node_modules/.bin:/home/wuhaibin/newcode/oh/node_modules/.bin:/home/wuhaibin/newcode/node_modules/.bin:/home/wuhaibin/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/home/wuhaibin/.nvm/versions/node/v23.8.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/home/wuhaibin/.local/bin:/home/wuhaibin/bin:/home/wuhaibin/.nvm/versions/node/v23.8.0/bin:/home/wuhaibin/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Users/wuhaibin/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/wuhaibin/AppData/Local/Programs/Microsoft VS Code/bin:/snap/bin:/home/wuhaibin/newcode/oh/out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ets2panda/lib +Loaded plugin: ui-plugin { uiTransform: [Function: uiTransform] } [Function: uiTransform] +Loaded plugin: memo-plugin { unmemoizeTransform: [Function: unmemoizeTransform] } [Function: unmemoizeTransform] +ets2pandaCmd: _ --extension ets --arktsconfig /home/wuhaibin/newcode/oh/developtools/ace_ets2bundle/arkui-plugins/test/dist/cache/entry/arktsconfig.json --output /home/wuhaibin/newcode/oh/developtools/ace_ets2bundle/arkui-plugins/test/dist/cache/entry/a.abc --debug-info ./demo/hello_world/entry/a.ets +[TS WRAPPER] CREATE CONFIG +InitModule: es2panda + +[TS WRAPPER] PROCEED TO STATE: 1 +es2panda proceedToState parsed +[TS WRAPPER] GET AST FROM CONTEXT +executing plugin: ui-plugin +[UI PLUGIN] AFTER PARSED ENTER +[AFTER PARSED SCRIPT]: +import { StructBase } from "@koalaui.arkts-arkui.StructBase"; + +import { Text as Text } from "@koalaui.arkts-arkui.Text"; + +import { Column as Column } from "@koalaui.arkts-arkui.Column"; + +import { Button as Button } from "@koalaui.arkts-arkui.Button"; + +import { Component as Component, StorageLink as StorageLink, State as State } from "@koalaui.arkts-arkui.Common"; + +import { UserView as UserView, UserViewBuilder as UserViewBuilder } from "@koalaui.arkts-arkui.UserView"; + +import { __memo_context_type as __memo_context_type, __memo_id_type as __memo_id_type } from "@ohos.arkui.StateManagement.runtime"; + +import { memo as memo } from "@ohos.arkui.StateManagement.runtime"; + +function isTrue(): string { + return "aa"; +} + +final class MyStateSample extends StructBase { + public aaa: string = isTrue(); + + public build() { + Column(){ + Text("Hello World!"); + Text((this).aaa); + Button("change"); + }; + } + + public constructor() {} + +} + +class ComExampleTrivialApplication extends UserView { + public getBuilder(): UserViewBuilder { + let wrapper = ((__memo_context: __memo_context_type, __memo_id: __memo_id_type) => { + MyStateSample.instantiateImpl(undefined, ((): MyStateSample => new MyStateSample()), ({} as __Options_MyStateSample), undefined); + }); + return wrapper; + } + + public constructor() {} + +} + +interface __Options_MyStateSample { + +} + + +[UI PLUGIN] AFTER PARSED EXIT +plugin parsed finished +[TS WRAPPER] GET AST FROM CONTEXT +[TS WRAPPER] DESTROY AND RECREATE +[TS WRAPPER] PROCEED TO STATE: 4 +es2panda proceedToState checked +[TS WRAPPER] GET AST FROM CONTEXT +executing plugin: ui-plugin +[UI PLUGIN] AFTER CHECKED ENTER +[AFTER STRUCT SCRIPT] script: +import { StructBase as StructBase } from "@koalaui.arkts-arkui.StructBase"; + +import { Text as Text } from "@koalaui.arkts-arkui.Text"; + +import { Column as Column } from "@koalaui.arkts-arkui.Column"; + +import { Button as Button } from "@koalaui.arkts-arkui.Button"; + +import { Component as Component, StorageLink as StorageLink, State as State } from "@koalaui.arkts-arkui.Common"; + +import { UserView as UserView, UserViewBuilder as UserViewBuilder } from "@koalaui.arkts-arkui.UserView"; + +import { __memo_context_type as __memo_context_type, __memo_id_type as __memo_id_type } from "@ohos.arkui.StateManagement.runtime"; + +import { memo as memo } from "@ohos.arkui.StateManagement.runtime"; + +abstract class ETSGLOBAL { + public static main() {} + + public static _$init$_() {} + + public static isTrue(): string { + return "aa"; + } + + +} + +class MyStateSample extends StructBase { + @memo()public __initializeStruct(initializers?: __Options_MyStateSample, @memo()content?: (()=> void)): void {} + + public __updateStruct(initializers: __Options_MyStateSample | undefined): void {} + + public aaa: string = ETSGLOBAL.isTrue(); + + @memo()protected _build(@memo()style: ((instance: MyStateSample)=> MyStateSample) | undefined, @memo()content: (()=> void) | undefined, initializers?: __Options_MyStateSample): void { + Column.instantiateImpl(((instance: Column): Column => { + return instance; + }), ((): Column => { + return new Column(); + }), (() => { + Text.instantiateImpl(((instance: Text): Text => { + return instance; + }), ((): Text => { + return new Text(); + }), "Hello World!") + Text.instantiateImpl(((instance: Text): Text => { + return instance; + }), ((): Text => { + return new Text(); + }), (this).aaa) + Button.instantiateImpl(((instance: Button): Button => { + return instance; + }), ((): Button => { + return new Button(); + }), "change") + })); + } + + public constructor() {} + +} + +class ComExampleTrivialApplication extends UserView { + public getBuilder(): UserViewBuilder { + let wrapper = ((__memo_context: __memo_context_type, __memo_id: __memo_id_type) => { + MyStateSample.instantiateImpl(undefined, ((): MyStateSample => { + return new MyStateSample(); + }), ({} as __Options_MyStateSample), undefined); + }); + return wrapper; + } + + public constructor() {} + +} + +interface __Options_MyStateSample { + +} + + +[UI PLUGIN] AFTER CHECKED EXIT +executing plugin: memo-plugin +[MEMO PLUGIN] AFTER CHECKED ENTER +[BEFORE MEMO SCRIPT] script: +import { StructBase as StructBase } from "@koalaui.arkts-arkui.StructBase"; + +import { Text as Text } from "@koalaui.arkts-arkui.Text"; + +import { Column as Column } from "@koalaui.arkts-arkui.Column"; + +import { Button as Button } from "@koalaui.arkts-arkui.Button"; + +import { Component as Component, StorageLink as StorageLink, State as State } from "@koalaui.arkts-arkui.Common"; + +import { UserView as UserView, UserViewBuilder as UserViewBuilder } from "@koalaui.arkts-arkui.UserView"; + +import { __memo_context_type as __memo_context_type, __memo_id_type as __memo_id_type } from "@ohos.arkui.StateManagement.runtime"; + +import { memo as memo } from "@ohos.arkui.StateManagement.runtime"; + +abstract class ETSGLOBAL { + public static main() {} + + public static _$init$_() {} + + public static isTrue(): string { + return "aa"; + } + + +} + +class MyStateSample extends StructBase { + @memo()public __initializeStruct(initializers?: __Options_MyStateSample, @memo()content?: (()=> void)): void {} + + public __updateStruct(initializers: __Options_MyStateSample | undefined): void {} + + public aaa: string = ETSGLOBAL.isTrue(); + + @memo()protected _build(@memo()style: ((instance: MyStateSample)=> MyStateSample) | undefined, @memo()content: (()=> void) | undefined, initializers?: __Options_MyStateSample): void { + Column.instantiateImpl(((instance: Column): Column => { + return instance; + }), ((): Column => { + return new Column(); + }), (() => { + Text.instantiateImpl(((instance: Text): Text => { + return instance; + }), ((): Text => { + return new Text(); + }), "Hello World!") + Text.instantiateImpl(((instance: Text): Text => { + return instance; + }), ((): Text => { + return new Text(); + }), (this).aaa) + Button.instantiateImpl(((instance: Button): Button => { + return instance; + }), ((): Button => { + return new Button(); + }), "change") + })); + } + + public constructor() {} + +} + +class ComExampleTrivialApplication extends UserView { + public getBuilder(): UserViewBuilder { + let wrapper = ((__memo_context: __memo_context_type, __memo_id: __memo_id_type) => { + MyStateSample.instantiateImpl(undefined, ((): MyStateSample => { + return new MyStateSample(); + }), ({} as __Options_MyStateSample), undefined); + }); + return wrapper; + } + + public constructor() {} + +} + +interface __Options_MyStateSample { + +} + + +[AFTER MEMO SCRIPT] script: +import { StructBase as StructBase } from "@koalaui.arkts-arkui.StructBase"; + +import { Text as Text } from "@koalaui.arkts-arkui.Text"; + +import { Column as Column } from "@koalaui.arkts-arkui.Column"; + +import { Button as Button } from "@koalaui.arkts-arkui.Button"; + +import { Component as Component, StorageLink as StorageLink, State as State } from "@koalaui.arkts-arkui.Common"; + +import { UserView as UserView, UserViewBuilder as UserViewBuilder } from "@koalaui.arkts-arkui.UserView"; + +import { __memo_context_type as __memo_context_type, __memo_id_type as __memo_id_type } from "@ohos.arkui.StateManagement.runtime"; + +import { memo as memo } from "@ohos.arkui.StateManagement.runtime"; + +abstract class ETSGLOBAL { + public static main() {} + + public static _$init$_() {} + + public static isTrue(): string { + return "aa"; + } + + +} + +class MyStateSample extends StructBase { + public __initializeStruct(__memo_context: __memo_context_type, __memo_id: __memo_id_type, initializers?: __Options_MyStateSample, content?: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void)): void { + const __memo_scope = __memo_context.scope(((__memo_id) + (168924120)), 2); + const __memo_parameter_initializers = __memo_scope.param(0, initializers), __memo_parameter_content = __memo_scope.param(1, content); + if (__memo_scope.unchanged) { + __memo_scope.recache(__memo_scope.cached) + return; + } + { + __memo_scope.recache() + return; + } + } + + public __updateStruct(initializers: __Options_MyStateSample | undefined): void {} + + public aaa: string = ETSGLOBAL.isTrue(); + + protected _build(__memo_context: __memo_context_type, __memo_id: __memo_id_type, style: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, instance: MyStateSample)=> MyStateSample) | undefined, content: ((__memo_context: __memo_context_type, __memo_id: __memo_id_type)=> void) | undefined, initializers?: __Options_MyStateSample): void { + const __memo_scope = __memo_context.scope(((__memo_id) + (168198604)), 3); + const __memo_parameter_style = __memo_scope.param(0, style), __memo_parameter_content = __memo_scope.param(1, content), __memo_parameter_initializers = __memo_scope.param(2, initializers); + if (__memo_scope.unchanged) { + __memo_scope.recache(__memo_scope.cached) + return; + } + Column.instantiateImpl(__memo_context, ((__memo_id) + (229216764)), ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, instance: Column): Column => { + return instance; + }), ((): Column => { + return new Column(); + }), ((__memo_context: __memo_context_type, __memo_id: __memo_id_type) => { + const __memo_scope = __memo_context.scope(((__memo_id) + (131080140)), 0); + if (__memo_scope.unchanged) { + __memo_scope.recache(__memo_scope.cached) + return; + } + Text.instantiateImpl(__memo_context, ((__memo_id) + (122349231)), ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, instance: Text): Text => { + return instance; + }), ((): Text => { + return new Text(); + }), "Hello World!") + Text.instantiateImpl(__memo_context, ((__memo_id) + (259830593)), ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, instance: Text): Text => { + return instance; + }), ((): Text => { + return new Text(); + }), (this).aaa) + Button.instantiateImpl(__memo_context, ((__memo_id) + (23671947)), ((__memo_context: __memo_context_type, __memo_id: __memo_id_type, instance: Button): Button => { + return instance; + }), ((): Button => { + return new Button(); + }), "change") + { + __memo_scope.recache() + return; + } + })); + { + __memo_scope.recache() + return; + } + } + + public constructor() {} + +} + +class ComExampleTrivialApplication extends UserView { + public getBuilder(): UserViewBuilder { + let wrapper = ((__memo_context: __memo_context_type, __memo_id: __memo_id_type) => { + MyStateSample.instantiateImpl(__memo_context, ((__memo_id) + (44218244)), undefined, ((): MyStateSample => { + return new MyStateSample(); + }), ({} as __Options_MyStateSample), undefined); + }); + return wrapper; + } + + public constructor() {} + +} + +interface __Options_MyStateSample { + +} + + +[MEMO PLUGIN] AFTER CHECKED EXIT +plugin checked finished +[TS WRAPPER] GET AST FROM CONTEXT +[TS WRAPPER] DESTROY AND RECREATE +[TS WRAPPER] PROCEED TO STATE: 7 +es2panda bin generated +"/home/wuhaibin/newcode/oh/out/sdk/ohos-sdk/linux/ets/ets1.2/build-tools/ets2panda/bin/ark_link" --output "/home/wuhaibin/newcode/oh/developtools/ace_ets2bundle/arkui-plugins/test/dist/modules_static.abc" -- @"dist/cache/fileInfo.txt" diff --git a/arkui-plugins/test/ut/common/annotation.test.ts b/arkui-plugins/test/ut/common/annotation.test.ts new file mode 100644 index 000000000..7091e7d52 --- /dev/null +++ b/arkui-plugins/test/ut/common/annotation.test.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { PluginTestContext, PluginTester } from '../../utils/plugin-tester'; +import { annotation } from '../../../common/arkts-utils'; + +const pluginTester = new PluginTester('test arkts-utils'); + +function testAnnotation(this: PluginTestContext): void { + const anno: arkts.AnnotationUsage = annotation('State'); + expect(arkts.isAnnotationUsage(anno)).toBeTruthy(); + expect(anno.dumpSrc()).toBe('@State()'); +} + +pluginTester.run( + 'annotation', + [], + { + parsed: [testAnnotation], + checked: [testAnnotation], + }, + { + stopAfter: 'checked', + }, + { + beforeEach: [ + () => { + jest.spyOn(console, 'warn').mockImplementation(() => {}); + }, + ], + afterEach: [ + () => { + jest.spyOn(console, 'warn').mockRestore(); + }, + ], + } +); diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate-content.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate-content.test.ts new file mode 100644 index 000000000..0b4e71c2d --- /dev/null +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate-content.test.ts @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2025 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 * as path from 'path'; +import * as arkts from '@koalaui/libarkts'; +import { PluginTestContext, PluginTester } from '../../../utils/plugin-tester'; +import { mockBuildConfig } from '../../../utils/artkts-config'; +import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../../utils/path-config'; +import { parseDumpSrc } from '../../../utils/parse-string'; +import { PluginContext, Plugins } from '../../../../common/plugin-context'; +import { ComponentTransformer } from '../../../../ui-plugins/component-transformer'; +import { BuilderLambdaTransformer } from '../../../../ui-plugins/builder-lambda-translators/builder-lambda-transformer'; + +const moduleRootPath: string = path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, 'builder-lambda'); + +const instantiateTransform: Plugins = { + name: 'instantiate', + parsed(this: PluginContext) { + let program = this.getArkTSProgram(); + if (program) { + let script: arkts.EtsScript = program.astNode; + + const componentTransformer = new ComponentTransformer({ + arkui: '@koalaui.arkts-arkui.StructBase', + }); + script = componentTransformer.visitor(script) as arkts.EtsScript; + arkts.setAllParents(script); + return script; + } + }, + checked(this: PluginContext) { + let program = this.getArkTSProgram(); + if (program) { + let script: arkts.EtsScript = program.astNode; + + const builderLambdaTransformer = new BuilderLambdaTransformer(); + script = builderLambdaTransformer.visitor(script) as arkts.EtsScript; + arkts.setAllParents(script); + return script; + } + }, +}; + +const pluginTester = new PluginTester('test build-lambda transformer'); + +// Test single-content instantiateImpl transformation +function testSingleContent(this: PluginTestContext): void { + const script: arkts.EtsScript = this.script as arkts.EtsScript; + const expectedScript: string = ` +import { StructBase as StructBase } from "@koalaui.arkts-arkui.StructBase"; + +import { Component as Component } from "@koalaui.arkts-arkui.Common"; + +import { Column as Column } from "@koalaui.arkts-arkui.Column"; + +import { Text as Text } from "@koalaui.arkts-arkui.Text"; + +abstract class ETSGLOBAL { + public static main() {} + + public static _$init$_() {} + + +} + +final class MyStateSample extends StructBase { + public build() { + Column.instantiateImpl(((instance: Column): Column => { + return instance; + }), ((): Column => { + return new Column(); + }), (() => { + Text.instantiateImpl(((instance: Text): Text => { + return instance; + }), ((): Text => { + return new Text(); + }), "Hello!"); + })); + } + + public constructor() {} + +} + +interface __Options_MyStateSample { + +} + +`; + expect(parseDumpSrc(script.dumpSrc())).toBe(parseDumpSrc(expectedScript)); +} + +pluginTester.run( + 'transform $_instantiate for single component content', + [instantiateTransform], + { + 'checked:instantiate': [testSingleContent], + }, + { + stopAfter: 'checked', + buildConfig: { + ...mockBuildConfig(), + compileFiles: [ + path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, 'builder-lambda', 'instantiate-content.ets'), + ], + moduleRootPath, + }, + }, + { + beforeEach: [ + () => { + jest.spyOn(console, 'warn').mockImplementation(() => {}); + }, + ], + afterEach: [ + () => { + jest.spyOn(console, 'warn').mockRestore(); + }, + ], + } +); diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate-multi-content.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate-multi-content.test.ts new file mode 100644 index 000000000..34c169437 --- /dev/null +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate-multi-content.test.ts @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2025 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 * as path from 'path'; +import * as arkts from '@koalaui/libarkts'; +import { PluginTestContext, PluginTester } from '../../../utils/plugin-tester'; +import { mockBuildConfig } from '../../../utils/artkts-config'; +import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../../utils/path-config'; +import { parseDumpSrc } from '../../../utils/parse-string'; +import { PluginContext, Plugins } from '../../../../common/plugin-context'; +import { ComponentTransformer } from '../../../../ui-plugins/component-transformer'; +import { BuilderLambdaTransformer } from '../../../../ui-plugins/builder-lambda-translators/builder-lambda-transformer'; + +const moduleRootPath: string = path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, 'builder-lambda'); + +const instantiateTransform: Plugins = { + name: 'instantiate', + parsed(this: PluginContext) { + let program = this.getArkTSProgram(); + if (program) { + let script: arkts.EtsScript = program.astNode; + + const componentTransformer = new ComponentTransformer({ + arkui: '@koalaui.arkts-arkui.StructBase', + }); + script = componentTransformer.visitor(script) as arkts.EtsScript; + arkts.setAllParents(script); + return script; + } + }, + checked(this: PluginContext) { + let program = this.getArkTSProgram(); + if (program) { + let script: arkts.EtsScript = program.astNode; + + const builderLambdaTransformer = new BuilderLambdaTransformer(); + script = builderLambdaTransformer.visitor(script) as arkts.EtsScript; + arkts.setAllParents(script); + return script; + } + }, +}; + +const pluginTester = new PluginTester('test build-lambda transformer'); + +// Test multi-content instantiateImpl transformation +function testMultiContent(this: PluginTestContext): void { + const script: arkts.EtsScript = this.script as arkts.EtsScript; + const expectedScript: string = ` +import { StructBase as StructBase } from "@koalaui.arkts-arkui.StructBase"; + +import { Component as Component } from "@koalaui.arkts-arkui.Common"; + +import { Column as Column } from "@koalaui.arkts-arkui.Column"; + +import { Text as Text } from "@koalaui.arkts-arkui.Text"; + +import { Button as Button } from "@koalaui.arkts-arkui.Button"; + +abstract class ETSGLOBAL { + public static main() {} + + public static _$init$_() {} + + +} + +final class MyStateSample extends StructBase { + public build() { + Column.instantiateImpl(((instance: Column): Column => { + return instance; + }), ((): Column => { + return new Column(); + }), (() => { + Text.instantiateImpl(((instance: Text): Text => { + return instance; + }), ((): Text => { + return new Text(); + }), "Hello!"); + Button.instantiateImpl(((instance: Button): Button => { + return instance; + }), ((): Button => { + return new Button(); + }), "click me"); + })); + } + + public constructor() {} + +} + +interface __Options_MyStateSample { + +} + +`; + expect(parseDumpSrc(script.dumpSrc())).toBe(parseDumpSrc(expectedScript)); +} + +pluginTester.run( + 'transform $_instantiate for multiple component contents', + [instantiateTransform], + { + 'checked:instantiate': [testMultiContent], + }, + { + stopAfter: 'checked', + buildConfig: { + ...mockBuildConfig(), + compileFiles: [ + path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, 'builder-lambda', 'instantiate-multi-content.ets'), + ], + moduleRootPath, + }, + }, + { + beforeEach: [ + () => { + jest.spyOn(console, 'warn').mockImplementation(() => {}); + }, + ], + afterEach: [ + () => { + jest.spyOn(console, 'warn').mockRestore(); + }, + ], + } +); diff --git a/arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate.test.ts b/arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate.test.ts new file mode 100644 index 000000000..3a54f332b --- /dev/null +++ b/arkui-plugins/test/ut/ui-plugins/builder-lambda/instantiate.test.ts @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2025 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 * as path from 'path'; +import * as arkts from '@koalaui/libarkts'; +import { PluginTestContext, PluginTester } from '../../../utils/plugin-tester'; +import { BuildConfig, mockBuildConfig } from '../../../utils/artkts-config'; +import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../../utils/path-config'; +import { parseDumpSrc } from '../../../utils/parse-string'; +import { PluginContext, Plugins } from '../../../../common/plugin-context'; +import { ComponentTransformer } from '../../../../ui-plugins/component-transformer'; +import { BuilderLambdaTransformer } from '../../../../ui-plugins/builder-lambda-translators/builder-lambda-transformer'; + +const buildConfig: BuildConfig = mockBuildConfig(); +buildConfig.compileFiles = [path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, 'builder-lambda', 'instantiate.ets')]; +buildConfig.moduleRootPath = path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, 'builder-lambda'); + +const instantiateTransform: Plugins = { + name: 'instantiate', + parsed(this: PluginContext) { + let program = this.getArkTSProgram(); + if (program) { + let script: arkts.EtsScript = program.astNode; + + const componentTransformer = new ComponentTransformer({ + arkui: '@koalaui.arkts-arkui.StructBase', + }); + script = componentTransformer.visitor(script) as arkts.EtsScript; + arkts.setAllParents(script); + return script; + } + }, + checked(this: PluginContext) { + let program = this.getArkTSProgram(); + if (program) { + let script: arkts.EtsScript = program.astNode; + + const builderLambdaTransformer = new BuilderLambdaTransformer(); + script = builderLambdaTransformer.visitor(script) as arkts.EtsScript; + + arkts.setAllParents(script); + return script; + } + }, +}; + +const pluginTester = new PluginTester('test build-lambda transformer', buildConfig); + +function testInstantiateImpl(this: PluginTestContext): void { + const script: arkts.EtsScript = this.script as arkts.EtsScript; + const expectedScript: string = ` +import { StructBase as StructBase } from "@koalaui.arkts-arkui.StructBase"; + +import { Component as Component } from "@koalaui.arkts-arkui.Common"; + +import { Column as Column } from "@koalaui.arkts-arkui.Column"; + +abstract class ETSGLOBAL { + public static main() {} + + public static _$init$_() {} + + +} + +final class MyStateSample extends StructBase { + public build() { + Column.instantiateImpl(((instance: Column): Column => { + return instance; + }), ((): Column => { + return new Column(); + }), (() => {})); + } + + public constructor() {} + +} + +interface __Options_MyStateSample { + +} + +`; + expect(parseDumpSrc(script.dumpSrc())).toBe(parseDumpSrc(expectedScript)); +} + +pluginTester.run( + 'transform $_instantiate for a single component', + [instantiateTransform], + { + 'checked:instantiate': [testInstantiateImpl], + }, + { + stopAfter: 'checked', + }, + { + beforeEach: [ + () => { + jest.spyOn(console, 'warn').mockImplementation(() => {}); + }, + ], + afterEach: [ + () => { + jest.spyOn(console, 'warn').mockRestore(); + }, + ], + } +); diff --git a/arkui-plugins/test/ut/ui-plugins/transform-struct-to-class.test.ts b/arkui-plugins/test/ut/ui-plugins/transform-struct-to-class.test.ts new file mode 100644 index 000000000..8cac48c6f --- /dev/null +++ b/arkui-plugins/test/ut/ui-plugins/transform-struct-to-class.test.ts @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2025 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 * as path from 'path'; +import * as arkts from '@koalaui/libarkts'; +import { PluginTestContext, PluginTester } from '../../utils/plugin-tester'; +import { BuildConfig, mockBuildConfig } from '../../utils/artkts-config'; +import { getRootPath, MOCK_ENTRY_DIR_PATH } from '../../utils/path-config'; +import { parseDumpSrc } from '../../utils/parse-string'; +import { PluginContext, Plugins } from '../../../common/plugin-context'; +import { ComponentTransformer } from '../../../ui-plugins/component-transformer'; + +const buildConfig: BuildConfig = mockBuildConfig(); +buildConfig.compileFiles = [path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, 'struct-to-class.ets')]; + +const componentTransform: Plugins = { + name: 'component', + parsed(this: PluginContext) { + let program = this.getArkTSProgram(); + if (program) { + let script: arkts.EtsScript = program.astNode; + + const componentTransformer = new ComponentTransformer({ + arkui: '@koalaui.arkts-arkui.StructBase', + }); + script = componentTransformer.visitor(script) as arkts.EtsScript; + arkts.setAllParents(script); + return script; + } + }, +}; + +const pluginTester = new PluginTester('test component transformer', buildConfig); + +function testComponentTransformer(this: PluginTestContext): void { + const script: arkts.EtsScript = this.script as arkts.EtsScript; + const expectedScript: string = ` +import { StructBase } from \"@koalaui.arkts-arkui.StructBase\"; + +import { Component as Component } from \"@koalaui.arkts-arkui.Common\"; + +final class MyStateSample extends StructBase { + + public build() {} + + public constructor() {} + +} + +interface __Options_MyStateSample { + +} + +`; + expect(parseDumpSrc(script.dumpSrc())).toBe(parseDumpSrc(expectedScript)); +} + +pluginTester.run( + 'transform struct to class', + [componentTransform], + { + 'parsed:component': [testComponentTransformer], + }, + { + stopAfter: 'parsed', + }, + { + beforeEach: [ + () => { + jest.spyOn(console, 'warn').mockImplementation(() => {}); + }, + ], + afterEach: [ + () => { + jest.spyOn(console, 'warn').mockRestore(); + }, + ], + } +); diff --git a/arkui-plugins/test/utils/artkts-config.ts b/arkui-plugins/test/utils/artkts-config.ts new file mode 100644 index 000000000..db63f0e4b --- /dev/null +++ b/arkui-plugins/test/utils/artkts-config.ts @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2025 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 * as fs from 'fs'; +import * as path from 'path'; +import { + ABC_SUFFIX, + ARKTS_CONFIG_FILE_PATH, + changeFileExtension, + ensurePathExists, + getFileName, + getPandaSDKPath, + getRootPath, + MOCK_ENTRY_DIR_PATH, + MOCK_ENTRY_FILE_NAME, + MOCK_LOCAL_SDK_DIR_PATH, + MOCK_OUTPUT_CACHE_PATH, + MOCK_OUTPUT_DIR_PATH, + MOCK_OUTPUT_FILE_NAME, + PANDA_SDK_STDLIB_PATH, + RUNTIME_API_PATH, + STDLIB_ESCOMPAT_PATH, + STDLIB_PATH, + STDLIB_STD_PATH, +} from './path-config'; + +export interface ArkTSConfigObject { + compilerOptions: { + package: string; + baseUrl: string; + paths: Record; + dependencies: string[] | undefined; + entry: string; + }; +} + +export interface CompileFileInfo { + fileName: string; + filePath: string; + dependentFiles: string[]; + abcFilePath: string; + arktsConfigFile: string; + stdLibPath: string; +} + +export interface ModuleInfo { + isMainModule: boolean; + packageName: string; + moduleRootPath: string; + sourceRoots: string[]; + entryFile: string; + arktsConfigFile: string; + compileFileInfos: CompileFileInfo[]; + dependencies?: string[]; +} + +export interface DependentModule { + packageName: string; + moduleName: string; + moduleType: string; + modulePath: string; + sourceRoots: string[]; + entryFile: string; +} + +export type ModuleType = 'har' | string; // TODO: module type unclear + +export interface DependentModule { + packageName: string; + moduleName: string; + moduleType: ModuleType; + modulePath: string; + sourceRoots: string[]; + entryFile: string; +} + +export interface BuildConfig { + packageName: string; + compileFiles: string[]; + loaderOutPath: string; + cachePath: string; + pandaSdkPath: string; + buildSdkPath: string; + sourceRoots: string[]; + moduleRootPath: string; + dependentModuleList: DependentModule[]; +} + +export interface ArktsConfigBuilder { + buildConfig: BuildConfig; + entryFiles: Set; + outputDir: string; + cacheDir: string; + pandaSdkPath: string; + buildSdkPath: string; + packageName: string; + sourceRoots: string[]; + moduleRootPath: string; + dependentModuleList: DependentModule[]; + moduleInfos: Map; + mergedAbcFile: string; + // logger: Logger; // TODO + isDebug: boolean; +} + +function writeArkTSConfigFile( + moduleInfo: ModuleInfo, + pathSection: Record, + dependenciesSection: string[] +): void { + if (!moduleInfo.sourceRoots || moduleInfo.sourceRoots.length == 0) { + throw new Error('Write Arkts config: does not have sourceRoots.'); + } + + const baseUrl: string = path.resolve(moduleInfo.moduleRootPath, moduleInfo.sourceRoots[0]); + pathSection[moduleInfo.packageName] = [baseUrl]; + const arktsConfig: ArkTSConfigObject = { + compilerOptions: { + package: moduleInfo.packageName, + baseUrl: baseUrl, + paths: pathSection, + dependencies: dependenciesSection.length === 0 ? undefined : dependenciesSection, + entry: moduleInfo.entryFile, + }, + }; + + ensurePathExists(moduleInfo.arktsConfigFile); + fs.writeFileSync(moduleInfo.arktsConfigFile, JSON.stringify(arktsConfig, null, 2), 'utf-8'); +} + +function getDependentModules(moduleInfo: ModuleInfo, moduleInfoMap: Map): Map { + if (moduleInfo.isMainModule) { + return moduleInfoMap; + } + + const depModules: Map = new Map(); + if (moduleInfo.dependencies) { + moduleInfo.dependencies.forEach((packageName: string) => { + const depModuleInfo: ModuleInfo | undefined = moduleInfoMap.get(packageName); + if (!depModuleInfo) { + throw new Error(`Dependent Module: Module ${packageName} not found in moduleInfos`); + } else { + depModules.set(packageName, depModuleInfo); + } + }); + } + return depModules; +} + +function traverse(currentDir: string, pathSection: Record) { + const items = fs.readdirSync(currentDir); + for (const item of items) { + const itemPath = path.join(currentDir, item); + const stat = fs.statSync(itemPath); + + if (stat.isFile()) { + const basename = path.basename(item, '.d.ets'); + pathSection[basename] = [changeFileExtension(itemPath, '', '.d.ets')]; + } else if (stat.isDirectory()) { + traverse(itemPath, pathSection); + } + } +} + +function mockBuildConfig(): BuildConfig { + return { + packageName: 'mock', + compileFiles: [path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH, MOCK_ENTRY_FILE_NAME)], + loaderOutPath: path.resolve(getRootPath(), MOCK_OUTPUT_DIR_PATH), + cachePath: path.resolve(getRootPath(), MOCK_OUTPUT_CACHE_PATH), + pandaSdkPath: getPandaSDKPath(), + buildSdkPath: path.resolve(getRootPath(), MOCK_LOCAL_SDK_DIR_PATH), + sourceRoots: [getRootPath()], + moduleRootPath: path.resolve(getRootPath(), MOCK_ENTRY_DIR_PATH), + dependentModuleList: [ + { + packageName: '@koalaui/runtime', + moduleName: '@koalaui/runtime', + moduleType: 'har', + modulePath: path.resolve(getRootPath(), RUNTIME_API_PATH), + sourceRoots: ['./'], + entryFile: 'index.sts', + }, + ], + }; +} + +class MockArktsConfigBuilder implements ArktsConfigBuilder { + buildConfig: BuildConfig; + entryFiles: Set; + outputDir: string; + cacheDir: string; + pandaSdkPath: string; + buildSdkPath: string; + packageName: string; + sourceRoots: string[]; + moduleRootPath: string; + dependentModuleList: DependentModule[]; + moduleInfos: Map; + mergedAbcFile: string; + isDebug: boolean; + + constructor(buildConfig?: BuildConfig) { + const _buildConfig: BuildConfig = buildConfig ?? mockBuildConfig(); + this.buildConfig = _buildConfig; + this.entryFiles = new Set(_buildConfig.compileFiles as string[]); + this.outputDir = _buildConfig.loaderOutPath as string; + this.cacheDir = _buildConfig.cachePath as string; + this.pandaSdkPath = path.resolve(_buildConfig.pandaSdkPath as string); + this.buildSdkPath = path.resolve(_buildConfig.buildSdkPath as string); + this.packageName = _buildConfig.packageName as string; + this.sourceRoots = _buildConfig.sourceRoots as string[]; + this.moduleRootPath = path.resolve(_buildConfig.moduleRootPath as string); + this.dependentModuleList = _buildConfig.dependentModuleList as DependentModule[]; + this.isDebug = true; + + this.moduleInfos = new Map(); + this.mergedAbcFile = path.resolve(this.outputDir, MOCK_OUTPUT_FILE_NAME); + + this.generateModuleInfos(); + this.generateArkTSConfigForModules(); + } + + private generateModuleInfos(): void { + if (!this.packageName || !this.moduleRootPath || !this.sourceRoots) { + throw new Error('Main module: packageName, moduleRootPath, and sourceRoots are required'); + } + const mainModuleInfo: ModuleInfo = { + isMainModule: true, + packageName: this.packageName, + moduleRootPath: this.moduleRootPath, + sourceRoots: this.sourceRoots, + entryFile: '', + arktsConfigFile: path.resolve(this.cacheDir, this.packageName, ARKTS_CONFIG_FILE_PATH), + compileFileInfos: [], + }; + this.moduleInfos.set(this.moduleRootPath, mainModuleInfo); + this.dependentModuleList.forEach((module: DependentModule) => { + if (!module.packageName || !module.modulePath || !module.sourceRoots || !module.entryFile) { + throw new Error('Dependent module: packageName, modulePath, sourceRoots, and entryFile are required'); + } + const moduleInfo: ModuleInfo = { + isMainModule: false, + packageName: module.packageName, + moduleRootPath: module.modulePath, + sourceRoots: module.sourceRoots, + entryFile: module.entryFile, + arktsConfigFile: path.resolve(this.cacheDir, module.packageName, ARKTS_CONFIG_FILE_PATH), + compileFileInfos: [], + }; + this.moduleInfos.set(module.modulePath, moduleInfo); + }); + this.entryFiles.forEach((file: string) => { + const _file = path.resolve(file); + for (const [modulePath, moduleInfo] of this.moduleInfos) { + if (_file.startsWith(modulePath)) { + const filePathFromModuleRoot: string = path.relative(modulePath, _file); + const filePathInCache: string = path.join( + this.cacheDir, + moduleInfo.packageName, + filePathFromModuleRoot + ); + const abcFilePath: string = path.resolve(changeFileExtension(filePathInCache, ABC_SUFFIX)); + + const fileInfo: CompileFileInfo = { + fileName: getFileName(_file), + filePath: _file, + dependentFiles: [], + abcFilePath: abcFilePath, + arktsConfigFile: moduleInfo.arktsConfigFile, + stdLibPath: path.resolve(this.pandaSdkPath, PANDA_SDK_STDLIB_PATH, STDLIB_PATH), + }; + moduleInfo.compileFileInfos.push(fileInfo); + return; + } + } + throw new Error('Entry File does not belong to any module in moduleInfos.'); + }); + } + + private generateArkTSConfigForModules(): void { + const pathSection: Record = {}; + pathSection['std'] = [path.resolve(this.pandaSdkPath, PANDA_SDK_STDLIB_PATH, STDLIB_STD_PATH)]; + pathSection['escompat'] = [path.resolve(this.pandaSdkPath, PANDA_SDK_STDLIB_PATH, STDLIB_ESCOMPAT_PATH)]; + traverse(this.buildSdkPath, pathSection); + + this.moduleInfos.forEach((moduleInfo: ModuleInfo, moduleRootPath: string) => { + pathSection[moduleInfo.packageName] = [path.resolve(moduleRootPath, moduleInfo.sourceRoots[0])]; + }); + + this.moduleInfos.forEach((moduleInfo: ModuleInfo, moduleRootPath: string) => { + const dependenciesSection: string[] = []; + this.generateDependenciesSection(moduleInfo, dependenciesSection); + writeArkTSConfigFile(moduleInfo, pathSection, dependenciesSection); + }); + } + + private generateDependenciesSection(moduleInfo: ModuleInfo, dependenciesSection: string[]): void { + const depModules: Map = getDependentModules(moduleInfo, this.moduleInfos); + depModules.forEach((depModuleInfo: ModuleInfo) => { + if (depModuleInfo.isMainModule) { + return; + } + dependenciesSection.push(depModuleInfo.arktsConfigFile); + }); + } +} + +export { mockBuildConfig, MockArktsConfigBuilder }; diff --git a/arkui-plugins/test/utils/compile.ts b/arkui-plugins/test/utils/compile.ts new file mode 100644 index 000000000..7694eac9f --- /dev/null +++ b/arkui-plugins/test/utils/compile.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { arktsGlobal } from '@koalaui/libarkts/build/lib/es2panda'; +import { PluginDriver } from './plugin-driver'; +import { PluginContext, PluginExecutor } from '../../common/plugin-context'; +import { EtsglobalRemover } from '../../common/etsglobal-remover'; + +function restartCompilerUptoState(state: arkts.Es2pandaContextState, restart: boolean): boolean { + try { + const ast: arkts.EtsScript | undefined = arkts.EtsScript.fromContext(); + if (!ast) { + return false; + } + + if (restart) { + const srcText = new EtsglobalRemover().visitor(ast).dumpSrc(); + arktsGlobal.es2panda._DestroyContext(arktsGlobal.context); + arktsGlobal.compilerContext = arkts.Context.createFromString(srcText); + } + + arkts.proceedToState(state); + return true; + } catch (e) { + return false; + } +} + +function insertPlugin( + driver: PluginDriver, + plugin: PluginExecutor | undefined, + state: arkts.Es2pandaContextState +): boolean { + arkts.proceedToState(state); + const pluginContext: PluginContext = driver.getPluginContext(); + const ast: arkts.EtsScript | undefined = arkts.EtsScript.fromContext(); + + if (!ast) { + return false; + } + + if (plugin) { + pluginContext.setArkTSAst(ast); + pluginContext.setArkTSProgram(arktsGlobal.compilerContext.program); + plugin.handler.apply(pluginContext); + } + return true; +} + +export { restartCompilerUptoState, insertPlugin }; diff --git a/arkui-plugins/test/utils/global.ts b/arkui-plugins/test/utils/global.ts new file mode 100644 index 000000000..4dc3d8511 --- /dev/null +++ b/arkui-plugins/test/utils/global.ts @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2025 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 * as fs from 'fs'; +import * as arkts from '@koalaui/libarkts'; +import { arktsGlobal } from '@koalaui/libarkts/build/lib/es2panda'; +import { CompileFileInfo } from './artkts-config'; + +function initGlobal(fileInfo: CompileFileInfo, isDebug: boolean = true): void { + const config = [ + '_', + '--extension', + 'sts', + '--arktsconfig', + fileInfo.arktsConfigFile, + '--output', + fileInfo.abcFilePath, + ]; + + if (isDebug) { + config.push('--debug-info'); + } + config.push(fileInfo.filePath); + + arktsGlobal.filePath = fileInfo.filePath; + resetConfig(config); + + const source: string = fs.readFileSync(fileInfo.filePath).toString(); + resetContext(source); +} + +function resetContext(source: string): void { + try { + arktsGlobal.context; + } catch (e) { + // Do nothing + } finally { + const context: arkts.Context = arkts.Context.createFromString(source); + arktsGlobal.compilerContext = context; + } +} + +function resetConfig(cmd: string[]): void { + try { + arktsGlobal.config; + destroyConfig(); + } catch (e) { + // Do nothing + } finally { + const arkTSConfig: arkts.Config = arkts.Config.create(cmd); + arktsGlobal.config = arkTSConfig.peer; + } +} + +function destroyContext(): void { + arktsGlobal.es2panda._DestroyContext(arktsGlobal.context); +} + +function destroyConfig(): void { + arkts.destroyConfig(arktsGlobal.config); +} + +function canProceedToState(state: arkts.Es2pandaContextState): boolean { + const stateToSkip: arkts.Es2pandaContextState[] = [ + arkts.Es2pandaContextState.ES2PANDA_STATE_SCOPE_INITED, + arkts.Es2pandaContextState.ES2PANDA_STATE_ASM_GENERATED, + arkts.Es2pandaContextState.ES2PANDA_STATE_ERROR, + ]; + + if (state in stateToSkip) { + return false; + } + + const currState = arktsGlobal.es2panda._ContextState(arktsGlobal.context); + return currState < state; +} + +export { initGlobal, resetContext, resetConfig, canProceedToState }; diff --git a/arkui-plugins/test/utils/parse-string.ts b/arkui-plugins/test/utils/parse-string.ts new file mode 100644 index 000000000..58430ca1d --- /dev/null +++ b/arkui-plugins/test/utils/parse-string.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 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. + */ + +function parseDumpSrc(str: string): string { + let _str: string = filterSource(str); + _str = cleanCopyRight(_str); + _str = removeSpaceAndReturn(_str); + + return _str; +} + +function filterSource(text: string): string { + const filtered: string = text.replaceAll(/%/g, '_').replaceAll(/#/g, '_').replaceAll('', '_cctor_'); + + return filtered; +} + +function cleanCopyRight(str: string): string { + const copyrightBlockRegex = /(?:\/\*.*Copyright \(c\) [- \d]+ Huawei Device Co\., Ltd\..*\*\/)/gs; + + return str.replace(copyrightBlockRegex, ''); +} + +function removeSpaceAndReturn(str: string): string { + const spaceAndReturnRegex = /^[\s\r]+/gm; + + return str.replace(spaceAndReturnRegex, ''); +} + +export { parseDumpSrc, filterSource, cleanCopyRight, removeSpaceAndReturn }; diff --git a/arkui-plugins/test/utils/path-config.ts b/arkui-plugins/test/utils/path-config.ts new file mode 100644 index 000000000..e322f28c8 --- /dev/null +++ b/arkui-plugins/test/utils/path-config.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 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 * as fs from 'fs'; +import * as path from 'path'; + +export const ARKTS_CONFIG_FILE_PATH: string = 'arktsconfig.json'; +export const PANDA_SDK_PATH: string = 'node_modules/@panda/sdk'; +export const PANDA_SDK_STDLIB_PATH: string = 'lib'; +export const STDLIB_PATH: string = 'stdlib'; +export const STDLIB_STD_PATH: string = 'stdlib/std'; +export const STDLIB_ESCOMPAT_PATH: string = 'stdlib/escompat'; +export const RUNTIME_API_PATH: string = 'demo/runtime-api'; +export const MOCK_ENTRY_DIR_PATH: string = 'demo/mock'; +export const MOCK_ENTRY_FILE_NAME: string = 'entry.ets'; +export const MOCK_OUTPUT_CACHE_PATH: string = 'generated/cache'; +export const MOCK_OUTPUT_DIR_PATH: string = 'generated/abc'; +export const MOCK_OUTPUT_FILE_NAME: string = 'entry.abc'; +export const MOCK_LOCAL_SDK_DIR_PATH: string = 'local'; +export const ETS_SUFFIX: string = '.ets'; +export const ABC_SUFFIX: string = '.abc'; + +function getRootPath(): string { + return path.resolve(__dirname, '..'); +} + +function getPandaSDKPath(): string { + if (!process.env.ETS2PANDA_PATH) { + throw new Error('Environment Error: ets2panda path is not defined'); + } + + return path.resolve(process.env.ETS2PANDA_PATH); +} + +function changeFileExtension(file: string, targetExt: string, originExt = ''): string { + const currentExt: string = originExt.length === 0 ? path.extname(file) : originExt; + const fileWithoutExt: string = file.substring(0, file.lastIndexOf(currentExt)); + return fileWithoutExt + targetExt; +} + +function getFileName(file: string): string { + const fileWithExt: string = path.basename(file); + const currentExt: string = path.extname(file); + return fileWithExt.substring(0, fileWithExt.lastIndexOf(currentExt)); +} + +function ensurePathExists(filePath: string): void { + try { + const dirPath: string = path.dirname(filePath); + if (!fs.existsSync(dirPath)) { + fs.mkdirSync(dirPath, { recursive: true }); + } + } catch (error) { + if (error instanceof Error) { + console.error(`Error: ${error.message}`); + } + } +} + +export { getRootPath, getPandaSDKPath, changeFileExtension, getFileName, ensurePathExists }; diff --git a/arkui-plugins/test/utils/plugin-driver.ts b/arkui-plugins/test/utils/plugin-driver.ts new file mode 100644 index 000000000..74e60a414 --- /dev/null +++ b/arkui-plugins/test/utils/plugin-driver.ts @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { isNumber } from './safe-types'; +import { Plugins, PluginContext, PluginHandler, PluginState, PluginExecutor } from '../../common/plugin-context'; + +export interface PluginDriver { + initPlugins(plugins: Plugins[]): void; + getSortedPlugins(state: arkts.Es2pandaContextState): PluginExecutor[] | undefined; + getPluginContext(): PluginContext; +} + +function toCamelCase(str: string): string { + return str + .split('_') + .map((word, index) => { + if (index === 0) { + return word; + } + return word.charAt(0).toUpperCase() + word.slice(1); + }) + .join(''); +} + +function stateName(value: arkts.Es2pandaContextState): PluginState { + return toCamelCase( + arkts.Es2pandaContextState[value].substring('ES2PANDA_STATE_'.length).toLowerCase() + ) as PluginState; +} + +function selectPlugins(plugins: Plugins[], stage: PluginState): PluginExecutor[] { + const pre: PluginExecutor[] = []; + const normal: PluginExecutor[] = []; + const post: PluginExecutor[] = []; + + plugins + .filter((it) => stage in it) + .forEach((it) => { + const pluginName: string = it.name; + const handler: PluginHandler = it[stage]!; + const order: string | undefined = typeof handler === 'object' ? handler.order : undefined; + const rawPluginHook: PluginExecutor = { + name: pluginName, + handler: typeof handler === 'object' ? handler.handler : handler, + }; + + if (order === 'pre') { + pre.push(rawPluginHook); + } else if (order === 'post') { + post.push(rawPluginHook); + } else { + normal.push(rawPluginHook); + } + }); + + return [...pre, ...normal, ...post]; +} + +class MockPluginDriver implements PluginDriver { + private sortedPlugins: Map; + private context: PluginContext; + + constructor() { + this.sortedPlugins = new Map(); + this.context = new PluginContext(); + } + + public initPlugins(plugins: Plugins[]): void { + const pluginsByState = new Map(); + + Object.values(arkts.Es2pandaContextState) + .filter(isNumber) + .forEach((it) => { + const selected = selectPlugins(plugins, stateName(it)); + if (selected.length > 0) { + pluginsByState.set(it, selected); + } else { + pluginsByState.set(it, undefined); + } + }); + + this.sortedPlugins = pluginsByState; + } + + public getSortedPlugins(state: arkts.Es2pandaContextState): PluginExecutor[] | undefined { + return this.sortedPlugins.get(state); + } + + public getPluginContext(): PluginContext { + return this.context; + } +} + +export { stateName, MockPluginDriver }; diff --git a/arkui-plugins/test/utils/plugin-tester.ts b/arkui-plugins/test/utils/plugin-tester.ts new file mode 100644 index 000000000..c6b36d33d --- /dev/null +++ b/arkui-plugins/test/utils/plugin-tester.ts @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { ArktsConfigBuilder, BuildConfig, CompileFileInfo, MockArktsConfigBuilder, ModuleInfo } from './artkts-config'; +import { MockPluginDriver, PluginDriver, stateName } from './plugin-driver'; +import { isNumber } from './safe-types'; +import { canProceedToState, initGlobal } from './global'; +import { insertPlugin, restartCompilerUptoState } from './compile'; +import { PluginExecutor, Plugins, PluginState } from '../../common/plugin-context'; + +type TestParams = Parameters; + +type SkipFirstParam = T extends [unknown, ...infer Rest] ? Rest : never; + +type PluginTestHooks = { + [K in PluginState | `${PluginState}:${string}`]?: SkipFirstParam; +}; + +type TestHooks = { + beforeAll?: Parameters; + afterAll?: Parameters; + beforeEach?: Parameters; + afterEach?: Parameters; +}; + +export interface PluginTestContext { + script?: arkts.AstNode; + errors?: string[]; + warnings?: string[]; +} + +export interface PluginTesterOptions { + stopAfter: PluginState; + buildConfig?: BuildConfig; +} + +class PluginTester { + private configBuilder: ArktsConfigBuilder; + private pluginDriver: PluginDriver; + private describe: string; + private cache?: PluginTestContext; + + constructor(describe: string, buildConfig?: BuildConfig) { + this.describe = describe; + this.configBuilder = new MockArktsConfigBuilder(buildConfig); + this.pluginDriver = new MockPluginDriver(); + } + + private loadPluginDriver(plugins: Plugins[]): void { + this.pluginDriver.initPlugins(plugins); + } + + private test( + key: PluginState | `${PluginState}:${string}`, + index: arkts.Es2pandaContextState, + testName: string, + pluginHooks: PluginTestHooks, + plugin?: PluginExecutor + ): void { + if (!this.cache) { + this.cache = {}; + } + if (index > arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED) { + return; + } + if (canProceedToState(index)) { + // TODO: this is a bug from compiler. + if (index > arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED) { + restartCompilerUptoState(index, true); + } + arkts.proceedToState(index); + } + if (plugin) { + insertPlugin(this.pluginDriver, plugin, index); + // TODO: add error/warning handling after plugin + this.cache.script = arkts.EtsScript.fromContext(); + } + const hook: SkipFirstParam | undefined = pluginHooks[key]; + if (!!hook) { + test(testName, hook[0]?.bind(this.cache), hook[1]); + } + } + + private proceedToState( + state: PluginState, + index: arkts.Es2pandaContextState, + testName: string, + pluginHooks: PluginTestHooks, + plugins?: PluginExecutor[] + ): void { + if (plugins && plugins.length > 0) { + plugins.forEach((plugin) => { + const pluginName: string = plugin.name; + const key: `${PluginState}:${string}` = `${state}:${pluginName}`; + this.test(key, index, `[${key}] ${testName}`, pluginHooks, plugin); + }); + } + this.test(state, index, `[${state}] ${testName}`, pluginHooks); + } + + private singleFileCompile( + fileInfo: CompileFileInfo, + moduleInfo: ModuleInfo, + testName: string, + pluginHooks: PluginTestHooks, + stopAfter: PluginState + ): void { + let shouldStop: boolean = false; + + initGlobal(fileInfo, this.configBuilder.isDebug); + + Object.values(arkts.Es2pandaContextState) + .filter(isNumber) + .forEach((it) => { + if (shouldStop) return; + const state: PluginState = stateName(it); + const plugins: PluginExecutor[] | undefined = this.pluginDriver.getSortedPlugins(it); + this.proceedToState( + state, + it, + `${moduleInfo.packageName} - ${fileInfo.fileName}: ${testName}`, + pluginHooks, + plugins + ); + shouldStop = state === stopAfter; + }); + } + + private traverseFile(testName: string, pluginHooks: PluginTestHooks, stopAfter: PluginState): void { + this.configBuilder.moduleInfos.forEach((moduleInfo) => { + moduleInfo.compileFileInfos.forEach((fileInfo) => { + this.singleFileCompile(fileInfo, moduleInfo, testName, pluginHooks, stopAfter); + }); + }); + } + + run( + testName: string, + plugins: Plugins[], + pluginHooks: PluginTestHooks, + options: PluginTesterOptions, + testHooks?: TestHooks + ): void { + if (!!options.buildConfig) { + this.configBuilder = new MockArktsConfigBuilder(options.buildConfig); + } + + this.loadPluginDriver(plugins); + + describe(this.describe, () => { + if (testHooks?.beforeAll) { + beforeAll(...testHooks.beforeAll); + } + if (testHooks?.afterAll) { + afterAll(...testHooks.afterAll); + } + if (testHooks?.beforeEach) { + beforeEach(...testHooks.beforeEach); + } + if (testHooks?.afterEach) { + afterEach(...testHooks.afterEach); + } + this.traverseFile(testName, pluginHooks, options.stopAfter); + }); + } +} + +export { PluginTester }; diff --git a/arkui-plugins/test/utils/safe-types.ts b/arkui-plugins/test/utils/safe-types.ts new file mode 100644 index 000000000..728c06501 --- /dev/null +++ b/arkui-plugins/test/utils/safe-types.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 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. + */ + +function isNumber(value: any): value is number { + return typeof value === `number`; +} + +export { isNumber }; diff --git a/arkui-plugins/tsconfig.build.json b/arkui-plugins/tsconfig.build.json new file mode 100644 index 000000000..7efa8486d --- /dev/null +++ b/arkui-plugins/tsconfig.build.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "target": "es2018", + "lib": ["ESNext", "ESNext.WeakRef", "DOM"], + "module": "CommonJS", + "rootDir": ".", + "baseUrl": ".", + "outDir": "./lib", + "moduleResolution": "node", + "incremental": false, + "declarationMap": false, + "sourceMap": false, + "declaration": false, + "noEmitOnError": true, + "strict": true, + "skipLibCheck": true, + "removeComments": false + }, + "include": [ + "./common/**/*.ts", + "./memo-plugins/**/*.ts", + "./ui-plugins/**/*.ts", + "./interop-plugins/**/*.ts", + ], + "exclude": [ + "./test/**" + ] +} diff --git a/arkui-plugins/tsconfig.json b/arkui-plugins/tsconfig.json new file mode 100644 index 000000000..eab872848 --- /dev/null +++ b/arkui-plugins/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "target": "es2018", + "lib": ["ESNext", "ESNext.WeakRef", "DOM"], + "module": "CommonJS", + "rootDir": ".", + "baseUrl": ".", + "outDir": "./lib", + "moduleResolution": "node", + "composite": true, + "incremental": true, + "declarationMap": true, + "sourceMap": true, + "declaration": true, + "noEmitOnError": true, + "strict": true, + "skipLibCheck": true, + "removeComments": false + }, + "include": [ + "./common/**/*.ts", + "./memo-plugins/**/*.ts", + "./ui-plugins/**/*.ts", + "./interop-plugins/**/*.ts", + "./path.ts", + "./test/ut/**/*.ts", + "./test/utils/**/*.ts" + ], + "exclude": [ + "./test/demo/", + "./test/local/" + ] +} diff --git a/arkui-plugins/ui-plugins/builder-lambda-translators/builder-lambda-transformer.ts b/arkui-plugins/ui-plugins/builder-lambda-translators/builder-lambda-transformer.ts new file mode 100644 index 000000000..a0d1134c5 --- /dev/null +++ b/arkui-plugins/ui-plugins/builder-lambda-translators/builder-lambda-transformer.ts @@ -0,0 +1,274 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { AbstractVisitor } from '../../common/abstract-visitor'; +import { BuilderLambdaNames } from '../utils'; +import { filterDefined, removeAnnotationByName, backingField } from '../../common/arkts-utils'; +import { DecoratorNames } from '../property-translators/utils'; +import { + BuilderLambdaDeclInfo, + isBuilderLambda, + builderLambdaFunctionName, + findBuilderLambdaDeclInfo, + isBuilderLambdaMethodDecl, + replaceBuilderLambdaDeclMethodName, + isBuilderLambdaFunctionCall, + callIsGoodForBuilderLambda, + builderLambdaTypeName, + builderLambdaMethodDeclType, + builderLambdaType, +} from './utils'; +import { factory } from './factory'; + +// TODO: very time-consuming... +function updateIfElseContentBodyInBuilderLambda(statement: arkts.AstNode, isExternal?: boolean): arkts.AstNode { + if (arkts.isIfStatement(statement)) { + const alternate = !!statement.alternate + ? updateIfElseContentBodyInBuilderLambda(statement.alternate, isExternal) + : statement.alternate; + const consequence = updateIfElseContentBodyInBuilderLambda(statement.consequent, isExternal); + return arkts.factory.updateIfStatement(statement, statement.test, consequence!, alternate); + } + if (arkts.isBlockStatement(statement)) { + return arkts.factory.updateBlock( + statement, + statement.statements.map((st) => updateContentBodyInBuilderLambda(st, isExternal)) + ); + } + return statement; +} + +function updateContentBodyInBuilderLambda(statement: arkts.Statement, isExternal?: boolean): arkts.Statement { + if ( + arkts.isExpressionStatement(statement) && + arkts.isCallExpression(statement.expression) && + isBuilderLambda(statement.expression, isExternal) + ) { + return arkts.factory.updateExpressionStatement(statement, transformBuilderLambda(statement.expression)); + } + // TODO: very time-consuming... + if (arkts.isIfStatement(statement)) { + return updateIfElseContentBodyInBuilderLambda(statement, isExternal); + } + + return statement; +} + +function builderLambdaReplace(leaf: arkts.CallExpression): arkts.Identifier | arkts.MemberExpression | undefined { + if (!callIsGoodForBuilderLambda(leaf)) { + return undefined; + } + const node = leaf.expression; + const funcName = builderLambdaFunctionName(leaf); + if (!funcName) { + return undefined; + } + if (arkts.isIdentifier(node)) { + return arkts.factory.createIdentifier(funcName); + } + if (arkts.isMemberExpression(node)) { + return arkts.factory.createMemberExpression( + node.object, + arkts.factory.createIdentifier(funcName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + node.computed, + node.optional + ); + } + return undefined; +} + +function createOrUpdateArgInBuilderLambda( + arg: arkts.Expression | undefined, + isExternal?: boolean, + typeName?: string, + fallback?: arkts.AstNode +): arkts.AstNode { + if (!arg) { + return fallback ?? arkts.factory.createUndefinedLiteral(); + } + if (arkts.isArrowFunctionExpression(arg)) { + return processArgArrowFunction(arg, isExternal); + } + if (arkts.isTSAsExpression(arg)) { + return processArgTSAsExpression(arg, typeName!); + } + return arg; +} + +function processArgArrowFunction( + arg: arkts.ArrowFunctionExpression, + isExternal?: boolean +): arkts.ArrowFunctionExpression { + const func: arkts.ScriptFunction = arg.scriptFunction; + const updateFunc = arkts.factory.updateScriptFunction( + func, + !!func.body && arkts.isBlockStatement(func.body) + ? arkts.factory.updateBlock( + func.body, + func.body.statements.map((st) => updateContentBodyInBuilderLambda(st, isExternal)) + ) + : undefined, + arkts.FunctionSignature.createFunctionSignature(func.typeParams, func.params, func.returnTypeAnnotation, false), + func.flags, + func.modifiers + ); + return arkts.factory.updateArrowFunction(arg, updateFunc); +} + +function updateParameterPassing( + prop: arkts.Property, + index: number, + currentStructInfo: arkts.StructInfo, + properties: arkts.Property[] +): void { + if ( + prop.key && + prop.value && + arkts.isIdentifier(prop.key) && + arkts.isMemberExpression(prop.value) && + arkts.isThisExpression(prop.value.object) && + arkts.isIdentifier(prop.value.property) + ) { + const structVariableMetadata = currentStructInfo.metadata[prop.key.name]; + if (structVariableMetadata.properties.includes(DecoratorNames.LINK)) { + properties[index] = arkts.Property.updateProperty( + prop, + arkts.factory.createIdentifier(backingField(prop.key.name)), + factory.updateBackingMember(prop.value, prop.value.property.name) + ); + } + } +} + +function processArgTSAsExpression(arg: arkts.TSAsExpression, typeName: string): arkts.TSAsExpression { + if (!arg.expr || !arkts.isObjectExpression(arg.expr)) { + return arg; + } + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(typeName!); + const properties = arg.expr.properties as arkts.Property[]; + properties.forEach((prop, index) => { + updateParameterPassing(prop, index, currentStructInfo, properties); + }); + const updatedExpr: arkts.ObjectExpression = arkts.ObjectExpression.updateObjectExpression( + arg.expr, + arkts.Es2pandaAstNodeType.AST_NODE_TYPE_OBJECT_EXPRESSION, + properties, + false + ); + return arkts.TSAsExpression.updateTSAsExpression(arg, updatedExpr, arg.typeAnnotation, arg.isConst); +} + +function generateArgsInBuilderLambda( + leaf: arkts.CallExpression, + lambdaBody: arkts.Identifier | arkts.CallExpression, + declInfo: BuilderLambdaDeclInfo, + isExternal?: boolean +): (arkts.AstNode | undefined)[] { + const { params } = declInfo; + const typeNode: arkts.TypeNode | undefined = builderLambdaType(leaf); + const typeName: string | undefined = builderLambdaTypeName(leaf); + const args: (arkts.AstNode | undefined)[] = [factory.createStyleArgInBuilderLambda(lambdaBody, typeNode)]; + let index = 0; + while (index < params.length) { + const isReusable: boolean = typeName + ? arkts.GlobalInfo.getInfoInstance().getStructInfo(typeName).isReusable + : false; + if (isReusable && index === params.length - 1) { + const reuseId = arkts.factory.createStringLiteral(typeName!); + args.push(createOrUpdateArgInBuilderLambda(leaf.arguments.at(index), isExternal, typeName, reuseId)); + } else { + args.push(createOrUpdateArgInBuilderLambda(leaf.arguments.at(index), isExternal, typeName)); + } + index++; + } + return args; +} + +function transformBuilderLambda(node: arkts.CallExpression, isExternal?: boolean): arkts.AstNode { + let instanceCalls: arkts.CallExpression[] = []; + let leaf: arkts.CallExpression = node; + + while ( + true && + arkts.isMemberExpression(leaf.expression) && + arkts.isIdentifier(leaf.expression.property) && + arkts.isCallExpression(leaf.expression.object) + ) { + instanceCalls.push(arkts.factory.createCallExpression(leaf.expression.property, undefined, leaf.arguments)); + leaf = leaf.expression.object; + } + + const replace: arkts.Identifier | arkts.MemberExpression | undefined = builderLambdaReplace(leaf); + const declInfo: BuilderLambdaDeclInfo | undefined = findBuilderLambdaDeclInfo(leaf); + if (!replace || !declInfo) { + return node; + } + let lambdaBody: arkts.Identifier | arkts.CallExpression | undefined; + if (instanceCalls.length > 0) { + instanceCalls = instanceCalls.reverse(); + lambdaBody = arkts.factory.createIdentifier(BuilderLambdaNames.STYLE_ARROW_PARAM_NAME); + instanceCalls.forEach((call) => { + if (!arkts.isIdentifier(call.expression)) { + throw new Error('call expression should be identifier'); + } + lambdaBody = factory.createStyleLambdaBody(lambdaBody!, call); + }); + } + const args: (arkts.AstNode | undefined)[] = generateArgsInBuilderLambda(leaf, lambdaBody!, declInfo, isExternal); + return arkts.factory.updateCallExpression(node, replace, undefined, filterDefined(args)); +} + +function transformBuilderLambdaMethodDecl(node: arkts.MethodDefinition): arkts.AstNode { + const func: arkts.ScriptFunction = node.scriptFunction; + const isFunctionCall: boolean = isBuilderLambdaFunctionCall(node); + const typeNode: arkts.TypeNode | undefined = builderLambdaMethodDeclType(node); + const styleArg: arkts.ETSParameterExpression = factory.createStyleArgInBuilderLambdaDecl(typeNode, isFunctionCall); + return factory.updateBuilderLambdaMethodDecl( + node, + styleArg, + removeAnnotationByName(func.annotations, BuilderLambdaNames.ANNOTATION_NAME), + replaceBuilderLambdaDeclMethodName(node.name.name) + ); +} + +export class BuilderLambdaTransformer extends AbstractVisitor { + visitEachChild(node: arkts.AstNode): arkts.AstNode { + if (arkts.isCallExpression(node) && isBuilderLambda(node, this.isExternal)) { + return node; + } + if (arkts.isMethodDefinition(node) && isBuilderLambdaMethodDecl(node, this.isExternal)) { + return node; + } + + return super.visitEachChild(node); + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + const node = this.visitEachChild(beforeChildren); + + if (arkts.isCallExpression(node) && isBuilderLambda(node, this.isExternal)) { + const lambda = transformBuilderLambda(node, this.isExternal); + return lambda; + } + if (arkts.isMethodDefinition(node) && isBuilderLambdaMethodDecl(node, this.isExternal)) { + const lambda = transformBuilderLambdaMethodDecl(node); + return lambda; + } + + return node; + } +} diff --git a/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts b/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts new file mode 100644 index 000000000..5cf2d1240 --- /dev/null +++ b/arkui-plugins/ui-plugins/builder-lambda-translators/factory.ts @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2025 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 * as arkts from '@koalaui/libarkts'; +import { BuilderLambdaNames } from '../utils'; +import { annotation, backingField } from '../../common/arkts-utils'; + +export class factory { + /* + * update @ComponentBuilder decorated method. + */ + static updateBuilderLambdaMethodDecl( + node: arkts.MethodDefinition, + styleArg: arkts.ETSParameterExpression, + newAnno: arkts.AnnotationUsage[], + newName: string | undefined + ): arkts.AstNode { + const func: arkts.ScriptFunction = node.scriptFunction; + const updateFunc = arkts.factory + .updateScriptFunction( + func, + func.body, + arkts.FunctionSignature.createFunctionSignature( + func.typeParams, + [styleArg, ...func.params], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + func.flags, + func.modifiers + ) + .setAnnotations(newAnno); + + return arkts.factory.updateMethodDefinition( + node, + node.kind, + arkts.factory.updateIdentifier(node.name, newName ?? node.name.name), + arkts.factory.createFunctionExpression(updateFunc), + node.modifiers, + false // TODO: how do I get it? + ); + } + + /* + * create style instance call, e.g. `instance.margin(10)`. + */ + static createStyleLambdaBody(lambdaBody: arkts.AstNode, call: arkts.CallExpression): arkts.CallExpression { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + lambdaBody, + call.expression, + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + undefined, + call.arguments + ); + } + + /* + * update parameter passing, e.g. `: __backing_`. + */ + static updateBackingMember(val: arkts.MemberExpression, originName: string): arkts.MemberExpression { + return arkts.factory.updateMemberExpression( + val, + val.object, + arkts.factory.createIdentifier(backingField(originName)), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); + } + + /* + * create style arguments in builder lambda. + */ + static createStyleArgInBuilderLambda( + lambdaBody: arkts.Expression | undefined, + typeNode: arkts.TypeNode | undefined + ): arkts.UndefinedLiteral | arkts.ArrowFunctionExpression { + if (!lambdaBody) { + return arkts.factory.createUndefinedLiteral(); + } + + const styleLambdaParam: arkts.ETSParameterExpression = arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier(BuilderLambdaNames.STYLE_ARROW_PARAM_NAME, typeNode), + undefined + ); + + const body: arkts.BlockStatement = arkts.factory.createBlock([ + arkts.factory.createExpressionStatement(lambdaBody), + arkts.factory.createReturnStatement(), + ]); + + const func = arkts.factory.createScriptFunction( + body, + arkts.FunctionSignature.createFunctionSignature( + undefined, + [styleLambdaParam], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ); + + return arkts.factory.createArrowFunction(func); + } + + /* + * create style arguments in builder lambda declaration. + */ + static createStyleArgInBuilderLambdaDecl( + typeNode: arkts.TypeNode | undefined, + isFunctionCall: boolean + ): arkts.ETSParameterExpression { + const styleLambdaParam: arkts.ETSParameterExpression = arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier(BuilderLambdaNames.STYLE_ARROW_PARAM_NAME, typeNode), + undefined + ); + const funcType = arkts.factory.createFunctionType( + arkts.FunctionSignature.createFunctionSignature( + undefined, + [styleLambdaParam], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW + ); + + let parameter: arkts.ETSParameterExpression; + if (isFunctionCall) { + parameter = arkts.factory + .createParameterDeclaration( + arkts.factory.createIdentifier(BuilderLambdaNames.STYLE_PARAM_NAME, funcType), + undefined + ) + .setOptional(true); + } else { + const optionalFuncType = arkts.factory.createUnionType([funcType, arkts.factory.createETSUndefinedType()]); + parameter = arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier(BuilderLambdaNames.STYLE_PARAM_NAME, optionalFuncType), + undefined + ); + } + parameter.annotations = [annotation('memo')]; + return parameter; + } +} diff --git a/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts b/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts new file mode 100644 index 000000000..b31f6e284 --- /dev/null +++ b/arkui-plugins/ui-plugins/builder-lambda-translators/utils.ts @@ -0,0 +1,309 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { isAnnotation } from '../../common/arkts-utils'; +import { BuilderLambdaNames } from '../utils'; + +export type BuilderLambdaDeclInfo = { + isFunctionCall: boolean; // isFunctionCall means it is from $_instantiate. + params: readonly arkts.Expression[]; +}; + +export type BuilderLambdaAstNode = arkts.ScriptFunction | arkts.ETSParameterExpression | arkts.FunctionDeclaration; + +/** + * Used in finding "XXX" in BuilderLambda("XXX") + * @deprecated + */ +export function builderLambdaArgumentName(annotation: arkts.AnnotationUsage): string | undefined { + if (!isBuilderLambdaAnnotation(annotation)) { + return undefined; + } + + const property = annotation.properties.at(0); + if (!property || !arkts.isClassProperty(property)) { + return undefined; + } + if (!property.value || !arkts.isStringLiteral(property.value)) { + return undefined; + } + + return property.value.str; +} + +/** + * Determine whether it is a custom component. + * + * @param node class declaration node + */ +export function isBuilderLambda(node: arkts.AstNode, isExternal?: boolean): boolean { + const builderLambdaCall: arkts.AstNode | undefined = getDeclForBuilderLambda(node); + return !!builderLambdaCall; +} + +/** + * replace $_instantiate with _instantiateImpl. + * + * @param name origin name + */ +export function replaceBuilderLambdaDeclMethodName(name: string | undefined): string | undefined { + if (!!name && name === BuilderLambdaNames.ORIGIN_METHOD_NAME) { + return BuilderLambdaNames.TRANSFORM_METHOD_NAME; + } + return undefined; +} + +export function isBuilderLambdaMethodDecl(node: arkts.AstNode, isExternal?: boolean): boolean { + const builderLambdaMethodDecl: arkts.AstNode | undefined = getDeclForBuilderLambdaMethodDecl(node); + return !!builderLambdaMethodDecl; +} + +export function getDeclForBuilderLambdaMethodDecl( + node: arkts.AstNode, + isExternal?: boolean +): arkts.AstNode | undefined { + if (!node || !arkts.isMethodDefinition(node)) { + return undefined; + } + + const isBuilderLambda: boolean = !!node.name && isBuilderLambdaCall(node.name); + const isMethodDecl: boolean = + !!node.scriptFunction && + arkts.hasModifierFlag(node.scriptFunction, arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE); + if (isBuilderLambda && isMethodDecl) { + return node; + } + return undefined; +} + +export function getDeclForBuilderLambda(node: arkts.AstNode, isExternal?: boolean): arkts.AstNode | undefined { + if (!node || !arkts.isCallExpression(node)) { + return undefined; + } + + let currNode: arkts.AstNode = node; + while ( + !!currNode && + arkts.isCallExpression(currNode) && + !!currNode.expression && + arkts.isMemberExpression(currNode.expression) + ) { + const _node: arkts.MemberExpression = currNode.expression; + + if (!!_node.property && arkts.isIdentifier(_node.property) && isBuilderLambdaCall(_node.property)) { + return node; + } + + if (!!_node.object && arkts.isCallExpression(_node.object) && isBuilderLambdaCall(_node.object)) { + return node; + } + + currNode = _node.object; + } + + if (isBuilderLambdaCall(node)) { + return node; + } + return undefined; +} + +export function isBuilderLambdaCall(node: arkts.CallExpression | arkts.Identifier): boolean { + const expr = arkts.isIdentifier(node) ? node : node.expression; + const decl = arkts.getDecl(expr); + + if (!decl) { + return false; + } + + if (arkts.isMethodDefinition(decl)) { + return isBuilderLambdaMethod(decl); + } + if (arkts.isFunctionExpression(decl)) { + return hasBuilderLambdaAnnotation(decl.scriptFunction); + } + return false; +} + +export function isBuilderLambdaMethod(node: arkts.MethodDefinition): boolean { + if (!node || !arkts.isMethodDefinition(node)) { + return false; + } + + const result = hasBuilderLambdaAnnotation(node.scriptFunction); + if (result) { + return true; + } + if (node.overloads.length > 0) { + return node.overloads.some(isBuilderLambdaMethod); + } + return false; +} + +export function hasBuilderLambdaAnnotation(node: BuilderLambdaAstNode): boolean { + return node.annotations.some(isBuilderLambdaAnnotation); +} + +export function isBuilderLambdaAnnotation(node: arkts.AnnotationUsage): boolean { + return isAnnotation(node, BuilderLambdaNames.ANNOTATION_NAME); +} + +export function findBuilderLambdaAnnotation( + node: arkts.ScriptFunction | arkts.ETSParameterExpression +): arkts.AnnotationUsage | undefined { + return node.annotations.find(isBuilderLambdaAnnotation); +} + +export function findBuilderLambdaInMethod(node: arkts.MethodDefinition): arkts.AnnotationUsage | undefined { + if (!node || !arkts.isMethodDefinition(node)) { + return undefined; + } + const result = findBuilderLambdaAnnotation(node.scriptFunction); + if (!!result) { + return result; + } + node.overloads.forEach((overload) => { + const anno: arkts.AnnotationUsage | undefined = findBuilderLambdaInMethod(overload); + if (!!anno) { + return anno; + } + }); + return undefined; +} + +export function findBuilderLambdaInCall( + node: arkts.CallExpression | arkts.Identifier +): arkts.AnnotationUsage | undefined { + const decl = findBuilderLambdaDecl(node); + if (!decl) { + return undefined; + } + + if (arkts.isMethodDefinition(decl)) { + return findBuilderLambdaInMethod(decl); + } + if (arkts.isFunctionExpression(decl)) { + return findBuilderLambdaAnnotation(decl.scriptFunction); + } + return undefined; +} + +export function findBuilderLambdaDecl(node: arkts.CallExpression | arkts.Identifier): arkts.AstNode | undefined { + const expr = arkts.isIdentifier(node) ? node : node.expression; + const decl = arkts.getDecl(expr); + if (!decl) { + return undefined; + } + return decl; +} + +/** + * check whether `` is the passing parameter. + * + * @param name origin name + */ +export function isParameterPassing(prop: arkts.Property): boolean | undefined { + return ( + prop.key && + prop.value && + arkts.isIdentifier(prop.key) && + arkts.isMemberExpression(prop.value) && + arkts.isThisExpression(prop.value.object) && + arkts.isIdentifier(prop.value.property) + ); +} + +export function findBuilderLambdaDeclInfo(node: arkts.CallExpression): BuilderLambdaDeclInfo | undefined { + const decl = findBuilderLambdaDecl(node); + if (!decl) { + return undefined; + } + if (arkts.isMethodDefinition(decl)) { + const params = decl.scriptFunction.params.map((p) => p.clone()); + const isFunctionCall = isBuilderLambdaFunctionCall(decl); + return { isFunctionCall, params }; + } + + return undefined; +} + +export function isBuilderLambdaFunctionCall(decl: arkts.AstNode | undefined): boolean { + if (!decl) { + return false; + } + if (arkts.isMethodDefinition(decl)) { + return ( + decl.name.name !== BuilderLambdaNames.ORIGIN_METHOD_NAME && + decl.name.name !== BuilderLambdaNames.TRANSFORM_METHOD_NAME + ); + } + return false; +} + +export function callIsGoodForBuilderLambda(leaf: arkts.CallExpression): boolean { + const node = leaf.expression; + return arkts.isIdentifier(node) || arkts.isMemberExpression(node); +} + +export function builderLambdaType(leaf: arkts.CallExpression): arkts.TypeNode | undefined { + const name: string | undefined = builderLambdaTypeName(leaf); + if (!name) { + return undefined; + } + // TODO: it should be the return type of the function annotated with the @BuilderLambda + return arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart(arkts.factory.createIdentifier(`${name}Attribute`)) + ); +} + +export function builderLambdaMethodDeclType(method: arkts.MethodDefinition): arkts.TypeNode | undefined { + if (!method || !method.scriptFunction) { + return undefined; + } + return method.scriptFunction.returnTypeAnnotation; +} + +export function builderLambdaTypeName(leaf: arkts.CallExpression): string | undefined { + if (!callIsGoodForBuilderLambda(leaf)) { + return undefined; + } + const node = leaf.expression; + let name: string | undefined; + if (arkts.isIdentifier(node)) { + name = node.name; + } + if (arkts.isMemberExpression(node) && arkts.isIdentifier(node.object)) { + name = node.object.name; + } + return name; +} + +export function builderLambdaFunctionName(node: arkts.CallExpression): string | undefined { + const annotation = findBuilderLambdaInCall(node); + if (!annotation) { + return undefined; + } + if (arkts.isIdentifier(node.expression)) { + return node.expression.name; + } + if ( + arkts.isMemberExpression(node.expression) && + arkts.isIdentifier(node.expression.property) && + node.expression.property.name === BuilderLambdaNames.ORIGIN_METHOD_NAME + ) { + return BuilderLambdaNames.TRANSFORM_METHOD_NAME; + } + return undefined; +} diff --git a/arkui-plugins/ui-plugins/checked-transformer.ts b/arkui-plugins/ui-plugins/checked-transformer.ts new file mode 100644 index 000000000..e544623b2 --- /dev/null +++ b/arkui-plugins/ui-plugins/checked-transformer.ts @@ -0,0 +1,469 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { ProjectConfig } from '../common/plugin-context'; +import { factory as structFactory } from './struct-translators/factory'; +import { factory as builderLambdaFactory } from './builder-lambda-translators/factory'; +import { factory as uiFactory } from './ui-factory'; +import { factory as entryFactory } from './entry-translators/factory'; +import { AbstractVisitor } from '../common/abstract-visitor'; +import { annotation, collect, filterDefined, removeAnnotationByName, backingField } from '../common/arkts-utils'; +import { + CustomComponentNames, + getCustomComponentOptionsName, + getTypeNameFromTypeParameter, + getTypeParamsFromClassDecl, + BuilderLambdaNames, +} from './utils'; +import { hasDecorator, DecoratorNames } from './property-translators/utils'; +import { + ScopeInfo, + isCustomComponentClass, + isKnownMethodDefinition, + isEtsGlobalClass, + isReourceNode, +} from './struct-translators/utils'; +import { + isBuilderLambda, + isBuilderLambdaMethodDecl, + isBuilderLambdaFunctionCall, + builderLambdaMethodDeclType, + replaceBuilderLambdaDeclMethodName, + findBuilderLambdaDeclInfo, + callIsGoodForBuilderLambda, + builderLambdaFunctionName, + BuilderLambdaDeclInfo, + builderLambdaType, + builderLambdaTypeName, +} from './builder-lambda-translators/utils'; +import { isEntryWrapperClass } from './entry-translators/utils'; +import { classifyProperty, PropertyTranslator } from './property-translators'; + +export class CheckedTransformer extends AbstractVisitor { + private scopeInfos: ScopeInfo[] = []; + projectConfig: ProjectConfig | undefined; + + constructor(projectConfig: ProjectConfig | undefined) { + super(); + this.projectConfig = projectConfig; + } + + reset(): void { + super.reset(); + this.scopeInfos = []; + } + + enter(node: arkts.AstNode): void { + if (arkts.isClassDeclaration(node) && isCustomComponentClass(node)) { + this.scopeInfos.push({ name: node.definition!.ident!.name }); + } + if (arkts.isMethodDefinition(node) && this.scopeInfos.length > 0) { + const name = node.name.name; + const scopeInfo = this.scopeInfos.pop()!; + scopeInfo.hasInitializeStruct ||= name === CustomComponentNames.COMPONENT_INITIALIZE_STRUCT; + scopeInfo.hasUpdateStruct ||= name === CustomComponentNames.COMPONENT_UPDATE_STRUCT; + scopeInfo.hasReusableRebind ||= name === CustomComponentNames.REUSABLE_COMPONENT_REBIND_STATE; + this.scopeInfos.push(scopeInfo); + } + } + + exit(node: arkts.AstNode): void { + if (arkts.isClassDeclaration(node) && isCustomComponentClass(node)) { + this.scopeInfos.pop(); + } + } + + visitEachChild(node: arkts.AstNode): arkts.AstNode { + if (arkts.isCallExpression(node) && isBuilderLambda(node, this.isExternal)) { + return node; + } + if (arkts.isMethodDefinition(node) && isBuilderLambdaMethodDecl(node, this.isExternal)) { + return node; + } + + return super.visitEachChild(node); + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + this.enter(beforeChildren); + const node = this.visitEachChild(beforeChildren); + if (arkts.isClassDeclaration(node) && isCustomComponentClass(node)) { + let scope: ScopeInfo | undefined; + if (this.scopeInfos.length > 0) { + scope = this.scopeInfos[this.scopeInfos.length - 1]; + } + const newClass: arkts.ClassDeclaration = tranformClassMembers( + node, + arkts.hasModifierFlag(node, arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE), + scope + ); + this.exit(beforeChildren); + return newClass; + } else if (isEntryWrapperClass(node)) { + entryFactory.addMemoToEntryWrapperClassMethods(node); + return node; + } else if (arkts.isClassDeclaration(node) && isEtsGlobalClass(node)) { + return transformEtsGlobalClassMembers(node); + } else if (arkts.isCallExpression(node) && isReourceNode(node)) { + return transformResource(node, this.projectConfig); + } else if (arkts.isCallExpression(node) && isBuilderLambda(node, this.isExternal)) { + const lambda = transformBuilderLambda(node, this.isExternal); + return lambda; + } else if (arkts.isMethodDefinition(node) && isBuilderLambdaMethodDecl(node, this.isExternal)) { + const lambda = transformBuilderLambdaMethodDecl(node); + return lambda; + } + return node; + } +} + +function tranformClassMembers( + node: arkts.ClassDeclaration, + isDecl?: boolean, + scope?: ScopeInfo +): arkts.ClassDeclaration { + if (!node.definition) { + return node; + } + + let classTypeName: string | undefined; + let classOptionsName: string | undefined; + if (isDecl) { + const [classType, classOptions] = getTypeParamsFromClassDecl(node); + classTypeName = getTypeNameFromTypeParameter(classType); + classOptionsName = getTypeNameFromTypeParameter(classOptions); + } + const definition: arkts.ClassDefinition = node.definition; + const className: string | undefined = node.definition.ident?.name; + if (!className) { + throw new Error('Non Empty className expected for Component'); + } + + const propertyTranslators: PropertyTranslator[] = filterDefined( + definition.body.map((it) => classifyProperty(it, className)) + ); + const translatedMembers: arkts.AstNode[] = tranformPropertyMembers( + className, + propertyTranslators, + classOptionsName ?? getCustomComponentOptionsName(className), + isDecl, + scope + ); + const updateMembers: arkts.AstNode[] = definition.body + .filter((member) => !arkts.isClassProperty(member)) + .map((member: arkts.AstNode) => + transformOtherMembersInClass(member, classTypeName, classOptionsName, className, isDecl) + ); + + const updateClassDef: arkts.ClassDefinition = structFactory.updateCustomComponentClass(definition, [ + ...translatedMembers, + ...updateMembers, + ]); + return arkts.factory.updateClassDeclaration(node, updateClassDef); +} + +function transformOtherMembersInClass( + member: arkts.AstNode, + classTypeName: string | undefined, + classOptionsName: string | undefined, + className: string, + isDecl?: boolean +): arkts.AstNode { + if (arkts.isMethodDefinition(member) && hasDecorator(member, DecoratorNames.BUILDER)) { + member.scriptFunction.setAnnotations([annotation('memo')]); + return member; + } + if ( + arkts.isMethodDefinition(member) && + isKnownMethodDefinition(member, CustomComponentNames.COMPONENT_CONSTRUCTOR_ORI) && + !isDecl + ) { + return uiFactory.createConstructorMethod(member); + } + if (arkts.isMethodDefinition(member) && isKnownMethodDefinition(member, CustomComponentNames.COMPONENT_BUILD_ORI)) { + return structFactory.transformBuildMethodWithOriginBuild( + member, + classTypeName ?? className, + classOptionsName ?? getCustomComponentOptionsName(className), + isDecl + ); + } + return member; +} + +function tranformPropertyMembers( + className: string, + propertyTranslators: PropertyTranslator[], + optionsTypeName: string, + isDecl?: boolean, + scope?: ScopeInfo +): arkts.AstNode[] { + const propertyMembers = propertyTranslators.map((translator) => translator.translateMember()); + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(className); + const collections = []; + if (!scope?.hasInitializeStruct) { + collections.push(structFactory.createInitializeStruct(currentStructInfo, optionsTypeName, isDecl)); + } + if (!scope?.hasUpdateStruct) { + collections.push(structFactory.createUpdateStruct(currentStructInfo, optionsTypeName, isDecl)); + } + if (currentStructInfo.isReusable) { + collections.push(structFactory.toRecord(optionsTypeName, currentStructInfo.toRecordBody)); + } + return collect(...collections, ...propertyMembers); +} + +function transformBuilderLambdaMethodDecl(node: arkts.MethodDefinition): arkts.AstNode { + const func: arkts.ScriptFunction = node.scriptFunction; + const isFunctionCall: boolean = isBuilderLambdaFunctionCall(node); + const typeNode: arkts.TypeNode | undefined = builderLambdaMethodDeclType(node); + const styleArg: arkts.ETSParameterExpression = builderLambdaFactory.createStyleArgInBuilderLambdaDecl( + typeNode, + isFunctionCall + ); + return builderLambdaFactory.updateBuilderLambdaMethodDecl( + node, + styleArg, + removeAnnotationByName(func.annotations, BuilderLambdaNames.ANNOTATION_NAME), + replaceBuilderLambdaDeclMethodName(node.name.name) + ); +} + +function transformEtsGlobalClassMembers(node: arkts.ClassDeclaration): arkts.ClassDeclaration { + if (!node.definition) { + return node; + } + node.definition.body.map((member: arkts.AstNode) => { + if (arkts.isMethodDefinition(member) && hasDecorator(member, DecoratorNames.BUILDER)) { + member.scriptFunction.setAnnotations([annotation('memo')]); + } + return member; + }); + return node; +} + +function transformResource( + resourceNode: arkts.CallExpression, + projectConfig: ProjectConfig | undefined +): arkts.CallExpression { + const newArgs: arkts.AstNode[] = [ + arkts.factory.create1StringLiteral(projectConfig?.bundleName ? projectConfig.bundleName : ''), + arkts.factory.create1StringLiteral(projectConfig?.moduleName ? projectConfig.moduleName : ''), + ...resourceNode.arguments, + ]; + return structFactory.generateTransformedResource(resourceNode, newArgs); +} + +function transformBuilderLambda(node: arkts.CallExpression, isExternal?: boolean): arkts.AstNode { + let instanceCalls: arkts.CallExpression[] = []; + let leaf: arkts.CallExpression = node; + + while ( + true && + arkts.isMemberExpression(leaf.expression) && + arkts.isIdentifier(leaf.expression.property) && + arkts.isCallExpression(leaf.expression.object) + ) { + instanceCalls.push(arkts.factory.createCallExpression(leaf.expression.property, undefined, leaf.arguments)); + leaf = leaf.expression.object; + } + + const replace: arkts.Identifier | arkts.MemberExpression | undefined = builderLambdaReplace(leaf); + const declInfo: BuilderLambdaDeclInfo | undefined = findBuilderLambdaDeclInfo(leaf); + if (!replace || !declInfo) { + return node; + } + let lambdaBody: arkts.Identifier | arkts.CallExpression | undefined; + if (instanceCalls.length > 0) { + instanceCalls = instanceCalls.reverse(); + lambdaBody = arkts.factory.createIdentifier(BuilderLambdaNames.STYLE_ARROW_PARAM_NAME); + instanceCalls.forEach((call) => { + if (!arkts.isIdentifier(call.expression)) { + throw new Error('call expression should be identifier'); + } + lambdaBody = builderLambdaFactory.createStyleLambdaBody(lambdaBody!, call); + }); + } + const args: (arkts.AstNode | undefined)[] = generateArgsInBuilderLambda(leaf, lambdaBody!, declInfo, isExternal); + return arkts.factory.updateCallExpression(node, replace, undefined, filterDefined(args)); +} + +function builderLambdaReplace(leaf: arkts.CallExpression): arkts.Identifier | arkts.MemberExpression | undefined { + if (!callIsGoodForBuilderLambda(leaf)) { + return undefined; + } + const node = leaf.expression; + const funcName = builderLambdaFunctionName(leaf); + if (!funcName) { + return undefined; + } + if (arkts.isIdentifier(node)) { + return arkts.factory.createIdentifier(funcName); + } + if (arkts.isMemberExpression(node)) { + return arkts.factory.createMemberExpression( + node.object, + arkts.factory.createIdentifier(funcName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + node.computed, + node.optional + ); + } + return undefined; +} + +function generateArgsInBuilderLambda( + leaf: arkts.CallExpression, + lambdaBody: arkts.Identifier | arkts.CallExpression, + declInfo: BuilderLambdaDeclInfo, + isExternal?: boolean +): (arkts.AstNode | undefined)[] { + const { params } = declInfo; + const typeNode: arkts.TypeNode | undefined = builderLambdaType(leaf); + const typeName: string | undefined = builderLambdaTypeName(leaf); + const args: (arkts.AstNode | undefined)[] = [ + builderLambdaFactory.createStyleArgInBuilderLambda(lambdaBody, typeNode), + ]; + let index = 0; + while (index < params.length) { + const isReusable: boolean = typeName + ? arkts.GlobalInfo.getInfoInstance().getStructInfo(typeName).isReusable + : false; + if (isReusable && index === params.length - 1) { + const reuseId = arkts.factory.createStringLiteral(typeName!); + args.push(createOrUpdateArgInBuilderLambda(leaf.arguments.at(index), isExternal, typeName, reuseId)); + } else { + args.push(createOrUpdateArgInBuilderLambda(leaf.arguments.at(index), isExternal, typeName)); + } + index++; + } + return args; +} + +function createOrUpdateArgInBuilderLambda( + arg: arkts.Expression | undefined, + isExternal?: boolean, + typeName?: string, + fallback?: arkts.AstNode +): arkts.AstNode { + if (!arg) { + return fallback ?? arkts.factory.createUndefinedLiteral(); + } + if (arkts.isArrowFunctionExpression(arg)) { + return processArgArrowFunction(arg, isExternal); + } + if (arkts.isTSAsExpression(arg)) { + return processArgTSAsExpression(arg, typeName!); + } + return arg; +} + +function processArgArrowFunction( + arg: arkts.ArrowFunctionExpression, + isExternal?: boolean +): arkts.ArrowFunctionExpression { + const func: arkts.ScriptFunction = arg.scriptFunction; + const updateFunc = arkts.factory.updateScriptFunction( + func, + !!func.body && arkts.isBlockStatement(func.body) + ? arkts.factory.updateBlock( + func.body, + func.body.statements.map((st) => updateContentBodyInBuilderLambda(st, isExternal)) + ) + : undefined, + arkts.FunctionSignature.createFunctionSignature(func.typeParams, func.params, func.returnTypeAnnotation, false), + func.flags, + func.modifiers + ); + return arkts.factory.updateArrowFunction(arg, updateFunc); +} + +function processArgTSAsExpression(arg: arkts.TSAsExpression, typeName: string): arkts.TSAsExpression { + if (!arg.expr || !arkts.isObjectExpression(arg.expr)) { + return arg; + } + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(typeName!); + const properties = arg.expr.properties as arkts.Property[]; + properties.forEach((prop, index) => { + updateParameterPassing(prop, index, currentStructInfo, properties); + }); + const updatedExpr: arkts.ObjectExpression = arkts.ObjectExpression.updateObjectExpression( + arg.expr, + arkts.Es2pandaAstNodeType.AST_NODE_TYPE_OBJECT_EXPRESSION, + properties, + false + ); + return arkts.TSAsExpression.updateTSAsExpression(arg, updatedExpr, arg.typeAnnotation, arg.isConst); +} + +function updateContentBodyInBuilderLambda(statement: arkts.Statement, isExternal?: boolean): arkts.Statement { + if ( + arkts.isExpressionStatement(statement) && + arkts.isCallExpression(statement.expression) && + isBuilderLambda(statement.expression, isExternal) + ) { + return arkts.factory.updateExpressionStatement(statement, transformBuilderLambda(statement.expression)); + } + // TODO: very time-consuming... + if (arkts.isIfStatement(statement)) { + return updateIfElseContentBodyInBuilderLambda(statement, isExternal); + } + + return statement; +} + +function updateParameterPassing( + prop: arkts.Property, + index: number, + currentStructInfo: arkts.StructInfo, + properties: arkts.Property[] +): void { + if ( + prop.key && + prop.value && + arkts.isIdentifier(prop.key) && + arkts.isMemberExpression(prop.value) && + arkts.isThisExpression(prop.value.object) && + arkts.isIdentifier(prop.value.property) + ) { + const structVariableMetadata = currentStructInfo.metadata[prop.key.name]; + if (structVariableMetadata.properties.includes(DecoratorNames.LINK)) { + properties[index] = arkts.Property.updateProperty( + prop, + arkts.factory.createIdentifier(backingField(prop.key.name)), + builderLambdaFactory.updateBackingMember(prop.value, prop.value.property.name) + ); + } + } +} + +// TODO: very time-consuming... +function updateIfElseContentBodyInBuilderLambda(statement: arkts.AstNode, isExternal?: boolean): arkts.AstNode { + if (arkts.isIfStatement(statement)) { + const alternate = !!statement.alternate + ? updateIfElseContentBodyInBuilderLambda(statement.alternate, isExternal) + : statement.alternate; + const consequence = updateIfElseContentBodyInBuilderLambda(statement.consequent, isExternal); + return arkts.factory.updateIfStatement(statement, statement.test, consequence!, alternate); + } + if (arkts.isBlockStatement(statement)) { + return arkts.factory.updateBlock( + statement, + statement.statements.map((st) => updateContentBodyInBuilderLambda(st, isExternal)) + ); + } + return statement; +} diff --git a/arkui-plugins/ui-plugins/component-transformer.ts b/arkui-plugins/ui-plugins/component-transformer.ts new file mode 100644 index 000000000..5208f9995 --- /dev/null +++ b/arkui-plugins/ui-plugins/component-transformer.ts @@ -0,0 +1,358 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { getInteropPath } from '../path'; +const interop = require(getInteropPath()); +const nullptr = interop.nullptr; +import { AbstractVisitor, VisitorOptions } from '../common/abstract-visitor'; +import { + CustomComponentNames, + getCustomComponentOptionsName, + createOptionalClassProperty, + findLocalImport, +} from './utils'; +import { isAnnotation, updateStructMetadata, backingField, expectName, annotation } from '../common/arkts-utils'; +import { EntryWrapperNames, findEntryWithStorageInClassAnnotations } from './entry-translators/utils'; +import { factory as entryFactory } from './entry-translators/factory'; +import { + hasDecorator, + DecoratorNames, + getStateManagementType, + collectPropertyDecorators, +} from './property-translators/utils'; +import { factory } from './ui-factory'; + +export interface ComponentTransformerOptions extends VisitorOptions { + arkui?: string; +} + +type ScopeInfo = { + name: string; + isEntry?: boolean; + isComponent?: boolean; + isReusable?: boolean; +}; + +interface ComponentContext { + structMembers: Map; +} + +export class ComponentTransformer extends AbstractVisitor { + private scopeInfos: ScopeInfo[] = []; + private componentInterfaceCollection: arkts.TSInterfaceDeclaration[] = []; + private entryNames: string[] = []; + private reusableNames: string[] = []; + private readonly arkui?: string; + private context: ComponentContext = { structMembers: new Map() }; + private isCustomComponentImported: boolean = false; + private isEntryPointImported: boolean = false; + + constructor(options?: ComponentTransformerOptions) { + const _options: ComponentTransformerOptions = options ?? {}; + super(_options); + this.arkui = _options.arkui; + } + + reset(): void { + super.reset(); + this.scopeInfos = []; + this.componentInterfaceCollection = []; + this.entryNames = []; + this.reusableNames = []; + this.context = { structMembers: new Map() }; + this.isCustomComponentImported = false; + this.isEntryPointImported = false; + } + + enter(node: arkts.AstNode) { + if (arkts.isStructDeclaration(node) && !!node.definition.ident) { + const scopeInfo: ScopeInfo = { name: node.definition.ident.name }; + node.definition.annotations.forEach((anno) => { + scopeInfo.isEntry ||= isAnnotation(anno, CustomComponentNames.ENTRY_ANNOTATION_NAME); + scopeInfo.isComponent ||= isAnnotation(anno, CustomComponentNames.COMPONENT_ANNOTATION_NAME); + scopeInfo.isReusable ||= isAnnotation(anno, CustomComponentNames.RESUABLE_ANNOTATION_NAME); + }); + this.scopeInfos.push(scopeInfo); + } + if (arkts.isETSImportDeclaration(node) && !this.isCustomComponentImported) { + this.isCustomComponentImported = !!findLocalImport( + node, + CustomComponentNames.COMPONENT_DEFAULT_IMPORT, + CustomComponentNames.COMPONENT_CLASS_NAME + ); + } + if (arkts.isETSImportDeclaration(node) && !this.isEntryPointImported) { + this.isEntryPointImported = !!findLocalImport( + node, + EntryWrapperNames.ENTRY_DEFAULT_IMPORT, + EntryWrapperNames.ENTRY_POINT_CLASS_NAME + ); + } + } + + exit(node: arkts.AstNode) { + if (arkts.isStructDeclaration(node) || arkts.isClassDeclaration(node)) { + if (!node.definition || !node.definition.ident || this.scopeInfos.length === 0) return; + if (this.scopeInfos[this.scopeInfos.length - 1]?.name === node.definition.ident.name) { + this.scopeInfos.pop(); + } + } + } + + isComponentStruct(): boolean { + if (this.scopeInfos.length === 0) return false; + const scopeInfo: ScopeInfo = this.scopeInfos[this.scopeInfos.length - 1]; + return !!scopeInfo.isComponent; + } + + createImportDeclaration(): void { + const source: arkts.StringLiteral = arkts.factory.create1StringLiteral( + this.arkui ?? CustomComponentNames.COMPONENT_DEFAULT_IMPORT + ); + const imported: arkts.Identifier = arkts.factory.createIdentifier(CustomComponentNames.COMPONENT_CLASS_NAME); + // Insert this import at the top of the script's statements. + if (!this.program) { + throw Error('Failed to insert import: Transformer has no program'); + } + factory.createAndInsertImportDeclaration( + source, + imported, + imported, + arkts.Es2pandaImportKinds.IMPORT_KINDS_VALUE, + this.program + ); + } + + processEtsScript(node: arkts.EtsScript): arkts.EtsScript { + if (this.isExternal && this.componentInterfaceCollection.length === 0 && this.entryNames.length === 0) { + return node; + } + let updateStatements: arkts.AstNode[] = []; + if (this.componentInterfaceCollection.length > 0) { + if (!this.isCustomComponentImported) this.createImportDeclaration(); + updateStatements.push(...this.componentInterfaceCollection); + } + + if (this.entryNames.length > 0) { + if (!this.isEntryPointImported) entryFactory.createAndInsertEntryPointImport(this.program); + // TODO: normally, we should only have at most one @Entry component in a single file. + // probably need to handle error message here. + updateStatements.push(...this.entryNames.map(entryFactory.generateEntryWrapper)); + } + if (updateStatements.length > 0) { + return arkts.factory.updateEtsScript(node, [...node.statements, ...updateStatements]); + } + return node; + } + + createStaticMethod(definition: arkts.ClassDefinition): arkts.MethodDefinition { + const param: arkts.ETSParameterExpression = arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier( + CustomComponentNames.OPTIONS, + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier(getCustomComponentOptionsName(definition.ident!.name)) + ) + ) + ), + undefined + ); + + const script = arkts.factory.createScriptFunction( + arkts.factory.createBlock([arkts.factory.createReturnStatement()]), + arkts.FunctionSignature.createFunctionSignature( + undefined, + [param], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_METHOD, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC | arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC + ); + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + arkts.factory.createIdentifier(CustomComponentNames.BUILDCOMPATIBLENODE), + arkts.factory.createFunctionExpression(script), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC | arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_STATIC, + false + ); + } + + processComponent( + node: arkts.ClassDeclaration | arkts.StructDeclaration + ): arkts.ClassDeclaration | arkts.StructDeclaration { + const scopeInfo = this.scopeInfos[this.scopeInfos.length - 1]; + const className = node.definition?.ident?.name; + if (!className || scopeInfo?.name !== className) { + return node; + } + + arkts.GlobalInfo.getInfoInstance().add(className); + + if (arkts.isStructDeclaration(node)) { + this.collectComponentMembers(node, className); + } + + if (scopeInfo.isReusable) { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(className); + currentStructInfo.isReusable = true; + arkts.GlobalInfo.getInfoInstance().setStructInfo(className, currentStructInfo); + } + + this.componentInterfaceCollection.push(this.generateComponentInterface(className, node.modifiers)); + + const definition: arkts.ClassDefinition = node.definition!; + const newDefinitionBody: arkts.AstNode[] = []; + if (scopeInfo.isEntry) { + this.entryNames.push(className); + const entryWithStorage: arkts.ClassProperty | undefined = + findEntryWithStorageInClassAnnotations(definition); + if (!!entryWithStorage) { + newDefinitionBody.push(entryFactory.createEntryLocalStorageInClass(entryWithStorage)); + } + } + const newDefinition: arkts.ClassDefinition = this.createNewDefinition( + node, + className, + definition, + newDefinitionBody + ); + + if (arkts.isStructDeclaration(node)) { + const _node = arkts.factory.createClassDeclaration(newDefinition); + _node.modifiers = node.modifiers; + return _node; + } else { + return arkts.factory.updateClassDeclaration(node, newDefinition); + } + } + + createNewDefinition( + node: arkts.ClassDeclaration | arkts.StructDeclaration, + className: string, + definition: arkts.ClassDefinition, + newDefinitionBody: arkts.AstNode[] + ): arkts.ClassDefinition { + const staticMethonBody: arkts.AstNode[] = []; + const hasExportFlag = + (node.modifiers & arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_EXPORT) === + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_EXPORT; + if (hasExportFlag) { + const buildCompatibleNode: arkts.MethodDefinition = this.createStaticMethod(definition); + if (!!buildCompatibleNode) { + staticMethonBody.push(buildCompatibleNode); + } + } + return arkts.factory.updateClassDefinition( + definition, + definition.ident, + undefined, + undefined, // superTypeParams doen't work + definition.implements, + undefined, + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier(CustomComponentNames.COMPONENT_CLASS_NAME), + arkts.factory.createTSTypeParameterInstantiation([ + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart(arkts.factory.createIdentifier(className)) + ), + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier( + `${CustomComponentNames.COMPONENT_INTERFACE_PREFIX}${className}` + ) + ) + ), + ]) + ) + ), + [...newDefinitionBody, ...definition.body, ...staticMethonBody], + definition.modifiers, + arkts.classDefinitionFlags(definition) | arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_FINAL + ); + } + + generateComponentInterface(name: string, modifiers: number): arkts.TSInterfaceDeclaration { + const interfaceNode = arkts.factory.createInterfaceDeclaration( + [], + arkts.factory.createIdentifier(getCustomComponentOptionsName(name)), + nullptr, // TODO: wtf + arkts.factory.createInterfaceBody([...(this.context.structMembers.get(name) || [])]), + false, + false + ); + interfaceNode.modifiers = modifiers; + return interfaceNode; + } + + collectComponentMembers(node: arkts.StructDeclaration, className: string): void { + const structInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(className); + if (!this.context.structMembers.has(className)) { + this.context.structMembers.set(className, []); + } + node.definition.body.map((it) => { + if (arkts.isClassProperty(it)) { + this.context.structMembers.get(className)!.push(...this.createInterfaceInnerMember(it, structInfo)); + } + }); + arkts.GlobalInfo.getInfoInstance().setStructInfo(className, structInfo); + } + + createInterfaceInnerMember(member: arkts.ClassProperty, structInfo: arkts.StructInfo): arkts.ClassProperty[] { + const originalName: string = expectName(member.key); + const newName: string = backingField(originalName); + + const properties = collectPropertyDecorators(member); + const hasStateManagementType = properties.length > 0; + updateStructMetadata(structInfo, originalName, properties, member.modifiers, hasStateManagementType); + + const originMember: arkts.ClassProperty = createOptionalClassProperty( + originalName, + member, + '', + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ); + if (member.annotations.length > 0 && !hasDecorator(member, DecoratorNames.BUILDER_PARAM)) { + const newMember: arkts.ClassProperty = createOptionalClassProperty( + newName, + member, + getStateManagementType(member), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ); + return [originMember, newMember]; + } + if (hasDecorator(member, DecoratorNames.BUILDER_PARAM)) { + originMember.setAnnotations([annotation('memo')]); + } + return [originMember]; + } + + visitor(node: arkts.AstNode): arkts.AstNode { + this.enter(node); + const newNode = this.visitEachChild(node); + if (arkts.isEtsScript(newNode)) { + return this.processEtsScript(newNode); + } + if (arkts.isStructDeclaration(newNode) && this.isComponentStruct()) { + const updateNode = this.processComponent(newNode); + this.exit(newNode); + return updateNode; + } + return newNode; + } +} diff --git a/arkui-plugins/ui-plugins/entry-translators/entry-transformer.ts b/arkui-plugins/ui-plugins/entry-translators/entry-transformer.ts new file mode 100644 index 000000000..49d46e67b --- /dev/null +++ b/arkui-plugins/ui-plugins/entry-translators/entry-transformer.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { AbstractVisitor } from '../../common/abstract-visitor'; +import { isEntryWrapperClass } from './utils'; +import { factory } from './factory'; + +export class EntryTransformer extends AbstractVisitor { + visitor(node: arkts.AstNode): arkts.AstNode { + const newNode = this.visitEachChild(node); + if (isEntryWrapperClass(newNode)) { + return factory.registerEntryFunction(newNode); + } + return newNode; + } +} diff --git a/arkui-plugins/ui-plugins/entry-translators/factory.ts b/arkui-plugins/ui-plugins/entry-translators/factory.ts new file mode 100644 index 000000000..e2d04b3d2 --- /dev/null +++ b/arkui-plugins/ui-plugins/entry-translators/factory.ts @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { getInteropPath } from '../../path'; +const interop = require(getInteropPath()); +const nullptr = interop.nullptr; +import { EntryWrapperNames } from './utils'; +import { annotation } from '../../common/arkts-utils'; +import { factory as uiFactory } from '../ui-factory'; + +export class factory { + /** + * insert an 'entry' method to an entry wrapper class. + * + * @param node entry wrapper class declaration node. + */ + static registerEntryFunction(node: arkts.ClassDeclaration): arkts.AstNode { + const definition: arkts.ClassDefinition | undefined = node.definition; + const classname = node?.definition?.ident?.name; + if (!definition || !classname) { + throw new Error('Node definition is undefined'); + } + const updateClassDef: arkts.ClassDefinition = arkts.factory.updateClassDefinition( + definition, + definition.ident, + definition.typeParams, + definition.superTypeParams, + definition.implements, + undefined, + definition.super, + [...definition.body, factory.generateEntryFunction(classname)], + definition.modifiers, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + ); + return arkts.factory.updateClassDeclaration(node, updateClassDef); + } + + /** + * insert an 'entry' property to an entry wrapper class. + * + * @param node entry wrapper class declaration node. + * @deprecated + */ + static registerEntryProperty(node: arkts.ClassDeclaration): arkts.AstNode { + const definition: arkts.ClassDefinition | undefined = node.definition; + const classname = node?.definition?.ident?.name; + if (!definition || !classname) { + throw new Error('Node definition is undefined'); + } + const updateClassDef: arkts.ClassDefinition = arkts.factory.updateClassDefinition( + definition, + definition.ident, + definition.typeParams, + definition.superTypeParams, + definition.implements, + undefined, + definition.super, + [...definition.body, factory.generateEntryProperty(classname)], + definition.modifiers, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + ); + return arkts.factory.updateClassDeclaration(node, updateClassDef); + } + + /** + * create `entry(): void { (); }` class method for the entry wrapper class, + * which calls the struct within the method. + * + * @param name class/struct name that has `@Entry` annotation. + */ + static generateEntryFunction(name: string): arkts.MethodDefinition { + const exp = arkts.factory.createExpressionStatement( + arkts.factory.createCallExpression( + arkts.factory.createIdentifier(name), + undefined, + [arkts.factory.createUndefinedLiteral()] // TODO: Add this undefined later + ) + ); + const key: arkts.Identifier = arkts.factory.createIdentifier(EntryWrapperNames.ENTRY_FUNC); + const block = arkts.factory.createBlock([exp]); + const entryScript = arkts.factory + .createScriptFunction( + block, + arkts.FunctionSignature.createFunctionSignature( + undefined, + [], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_METHOD, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ) + .setIdent(key); + + const def = arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + key, + arkts.factory.createFunctionExpression(entryScript), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + false + ); + + return def; + } + + static generateConstructor(): arkts.MethodDefinition { + const key: arkts.Identifier = arkts.factory.createIdentifier('constructor'); + const block = arkts.factory.createBlock([]); + const entryScript = arkts.factory + .createScriptFunction( + block, + arkts.FunctionSignature.createFunctionSignature(undefined, [], undefined, false), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_CONSTRUCTOR | + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_IMPLICIT_SUPER_CALL_NEEDED, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC | + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR + ) + .setIdent(key); + const def = arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_CONSTRUCTOR, + key, + arkts.factory.createFunctionExpression(entryScript), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + false + ); + return def; + } + + /** + * create `entry = (): void => { (); }` class property for the entry wrapper class, + * which calls the struct within the arrow function. + * + * @param name class/struct name that has `@Entry` annotation. + * @deprecated + */ + static generateEntryProperty(name: string): arkts.ClassProperty { + const exp = arkts.factory.createExpressionStatement( + arkts.factory.createCallExpression( + arkts.factory.createIdentifier(name), + undefined, + [arkts.factory.createUndefinedLiteral()] // TODO: Add this undefined later + ) + ); + const key: arkts.Identifier = arkts.factory.createIdentifier(EntryWrapperNames.ENTRY_FUNC); + const block: arkts.BlockStatement = arkts.factory.createBlock([exp]); + const signature: arkts.FunctionSignature = arkts.FunctionSignature.createFunctionSignature( + undefined, + [], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ); + const entryScript: arkts.ScriptFunction = arkts.factory + .createScriptFunction( + block, + signature, + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ) + .setIdent(key); + + const def = arkts.factory.createClassProperty( + key, + arkts.factory.createArrowFunction(entryScript), + arkts.factory.createFunctionType(signature, arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + false + ); + + return def; + } + + /** + * create `__EntryWrapper_Entry` entry wrapper class that contains an 'entry' method that + * calls the struct within the method. + * + * @param name class/struct name that has `@Entry` annotation. + */ + static generateEntryWrapper(name: string): arkts.ClassDeclaration { + const ctor = factory.generateConstructor(); + const definition: arkts.ClassDefinition = arkts.factory + .createClassDefinition( + arkts.factory.createIdentifier(EntryWrapperNames.WRAPPER_CLASS_NAME), + undefined, + undefined, + [], + undefined, + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier(EntryWrapperNames.ENTRY_POINT_CLASS_NAME) + ) + ), + [factory.generateEntryFunction(name), ctor], + arkts.Es2pandaClassDefinitionModifiers.CLASS_DEFINITION_MODIFIERS_CLASS_DECL | + arkts.Es2pandaClassDefinitionModifiers.CLASS_DEFINITION_MODIFIERS_DECLARATION | + arkts.Es2pandaClassDefinitionModifiers.CLASS_DEFINITION_MODIFIERS_ID_REQUIRED, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + ) + .setCtor(ctor as any); + const newClass = arkts.factory.createClassDeclaration(definition); + newClass.modifiers = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE; + return newClass; + } + + /** + * add `@memo` to all class methods that are named 'entry'. + * + * @param node class declaration node + */ + static addMemoToEntryWrapperClassMethods(node: arkts.ClassDeclaration): void { + node.definition?.body.forEach((member) => { + if ( + arkts.isMethodDefinition(member) && + !!member.scriptFunction.id && + member.scriptFunction.id.name === EntryWrapperNames.ENTRY_FUNC + ) { + member.scriptFunction.setAnnotations([annotation('memo')]); + } + }); + } + + /** + * add `@memo` to the class property's value (expecting an arrow function), where the property is named 'entry'. + * + * @param node class declaration node + * @deprecated + */ + static addMemoToEntryWrapperPropertyValue(node: arkts.ClassDeclaration): void { + node.definition?.body.forEach((member) => { + if ( + arkts.isClassProperty(member) && + !!member.value && + arkts.isArrowFunctionExpression(member.value) && + !!member.key && + arkts.isIdentifier(member.key) && + member.key.name === EntryWrapperNames.ENTRY_FUNC + ) { + member.setAnnotations([annotation('memo')]); + } + }); + } + + /** + * create `private _entry_local_storage_ = ;` class property + * from `{storage: ""}` in `@Entry`'s properties. + * + * @param annotation `@Entry` annotation. + */ + static createEntryLocalStorageInClass(property: arkts.ClassProperty) { + const value = property.value as arkts.StringLiteral; + return arkts.factory.createClassProperty( + arkts.factory.createIdentifier(EntryWrapperNames.ENTRY_STORAGE_LOCAL_STORAGE_PROPERTY_NAME), + arkts.factory.createIdentifier(value.str), + undefined, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE, + false + ); + } + + /** + * create and insert `import { EntryPoint as EntryPoint } from "@ohos.arkui.UserView";` + * to the top of script's statements. + */ + static createAndInsertEntryPointImport(program?: arkts.Program) { + const source: arkts.StringLiteral = arkts.factory.create1StringLiteral(EntryWrapperNames.ENTRY_DEFAULT_IMPORT); + const imported: arkts.Identifier = arkts.factory.createIdentifier(EntryWrapperNames.ENTRY_POINT_CLASS_NAME); + // Insert this import at the top of the script's statements. + if (!program) { + throw Error('Failed to insert import: Transformer has no program'); + } + uiFactory.createAndInsertImportDeclaration( + source, + imported, + imported, + arkts.Es2pandaImportKinds.IMPORT_KINDS_VALUE, + program + ); + } +} diff --git a/arkui-plugins/ui-plugins/entry-translators/utils.ts b/arkui-plugins/ui-plugins/entry-translators/utils.ts new file mode 100644 index 000000000..c3b1dfbef --- /dev/null +++ b/arkui-plugins/ui-plugins/entry-translators/utils.ts @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { factory } from './factory'; +import { isAnnotation } from '../../common/arkts-utils'; +import { CustomComponentNames } from '../utils'; + +export enum EntryWrapperNames { + ENTRY_FUNC = 'entry', + WRAPPER_CLASS_NAME = '__EntryWrapper', + ENTRY_STORAGE_ANNOTATION_KEY = 'storage', + ENTRY_STORAGE_LOCAL_STORAGE_PROPERTY_NAME = '_entry_local_storage_', + ENTRY_DEFAULT_IMPORT = '@ohos.arkui.component', + ENTRY_POINT_CLASS_NAME = 'EntryPoint', +} + +/** + * @deprecated + */ +export class EntryHandler { + private entryDefClassName: Set; + + private static instance: EntryHandler; + + private constructor() { + this.entryDefClassName = new Set(); + } + + public static getInstance(): EntryHandler { + if (!this.instance) { + this.instance = new EntryHandler(); + } + return this.instance; + } + + public rememberEntryFunction(classname: string): void { + this.entryDefClassName.add(classname); + } + + public createEntryWrapper(): arkts.ClassDeclaration[] { + let result: arkts.ClassDeclaration[] = []; + this.entryDefClassName.forEach((classname) => { + result.push(factory.generateEntryWrapper(classname)); + }); + return result; + } +} + +export function isEntryWrapperClass(node: arkts.AstNode): node is arkts.ClassDeclaration { + if (!arkts.isClassDeclaration(node)) return false; + const className = node?.definition?.ident?.name; + if (!className) return false; + return className === EntryWrapperNames.WRAPPER_CLASS_NAME; +} + +/** + * find `{storage: ""}` in `@Entry({storage: ""})` (i.e. annotation's properties). + * + * @param node class definition node + */ +export function findEntryWithStorageInClassAnnotations(node: arkts.ClassDefinition): arkts.ClassProperty | undefined { + const annotation = node.annotations.find((anno) => { + if (!isAnnotation(anno, CustomComponentNames.ENTRY_ANNOTATION_NAME)) return false; + const property = anno.properties?.at(0); + if (!property || !arkts.isClassProperty(property)) return false; + if (!property.key || !arkts.isIdentifier(property.key)) return false; + if (!property.value || !arkts.isStringLiteral(property.value)) return false; + return property.key.name === EntryWrapperNames.ENTRY_STORAGE_ANNOTATION_KEY; + }); + return annotation?.properties?.at(0) as arkts.ClassProperty | undefined; +} diff --git a/arkui-plugins/ui-plugins/index.ts b/arkui-plugins/ui-plugins/index.ts new file mode 100644 index 000000000..76e2e6883 --- /dev/null +++ b/arkui-plugins/ui-plugins/index.ts @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { ComponentTransformer } from './component-transformer'; +import { PreprocessorTransformer } from './preprocessor-transform'; +import { CheckedTransformer } from './checked-transformer'; +import { Plugins, PluginContext } from '../common/plugin-context'; +import { ProgramVisitor } from '../common/program-visitor'; +import { EXTERNAL_SOURCE_PREFIX_NAMES } from '../common/predefines'; +import { debugDump, debugLog, getDumpFileName } from '../common/debug'; + +export function uiTransform(): Plugins { + return { + name: 'ui-plugin', + parsed: parsedTransform, + checked: checkedTransform, + clean() { + arkts.arktsGlobal.clearContext(); + }, + }; +} + +function parsedTransform(this: PluginContext): arkts.EtsScript | undefined { + let script: arkts.EtsScript | undefined; + console.log('[UI PLUGIN] AFTER PARSED ENTER'); + const contextPtr = arkts.arktsGlobal.compilerContext?.peer ?? this.getContextPtr(); + if (!!contextPtr) { + let program = arkts.getOrUpdateGlobalContext(contextPtr).program; + script = program.astNode; + const cachePath: string | undefined = this.getProjectConfig()?.cachePath; + debugLog('[BEFORE PARSED SCRIPT] script: ', script.dumpSrc()); + debugDump( + script.dumpSrc(), + getDumpFileName(0, 'SRC', 1, 'UI_AfterParse_Begin'), + true, + cachePath, + program.programFileNameWithExtension + ); + arkts.Performance.getInstance().createEvent('ui-parsed'); + const componentTransformer = new ComponentTransformer(); + const preprocessorTransformer = new PreprocessorTransformer(); + const programVisitor = new ProgramVisitor({ + pluginName: uiTransform.name, + state: arkts.Es2pandaContextState.ES2PANDA_STATE_PARSED, + visitors: [componentTransformer, preprocessorTransformer], + skipPrefixNames: EXTERNAL_SOURCE_PREFIX_NAMES, + pluginContext: this, + }); + program = programVisitor.programVisitor(program); + script = program.astNode; + arkts.Performance.getInstance().stopEvent('ui-parsed', true); + debugLog('[AFTER PARSED SCRIPT] script: ', script.dumpSrc()); + debugDump( + script.dumpSrc(), + getDumpFileName(0, 'SRC', 2, 'UI_AfterParse_End'), + true, + cachePath, + program.programFileNameWithExtension + ); + this.setArkTSAst(script); + console.log('[UI PLUGIN] AFTER PARSED EXIT'); + return script; + } + console.log('[UI PLUGIN] AFTER PARSED EXIT WITH NO TRANSFORM'); + return script; +} + +function checkedTransform(this: PluginContext): arkts.EtsScript | undefined { + let script: arkts.EtsScript | undefined; + console.log('[UI PLUGIN] AFTER CHECKED ENTER'); + const contextPtr = arkts.arktsGlobal.compilerContext?.peer ?? this.getContextPtr(); + if (!!contextPtr) { + let program = arkts.getOrUpdateGlobalContext(contextPtr).program; + script = program.astNode; + const cachePath: string | undefined = this.getProjectConfig()?.cachePath; + debugLog('[BEFORE STRUCT SCRIPT] script: ', script.dumpSrc()); + debugDump( + script.dumpSrc(), + getDumpFileName(0, 'SRC', 3, 'UI_AfterCheck_Begin'), + true, + cachePath, + program.programFileNameWithExtension + ); + arkts.Performance.getInstance().createEvent('ui-checked'); + const checkedTransformer = new CheckedTransformer(this.getProjectConfig()); + const programVisitor = new ProgramVisitor({ + pluginName: uiTransform.name, + state: arkts.Es2pandaContextState.ES2PANDA_STATE_CHECKED, + visitors: [checkedTransformer], + skipPrefixNames: EXTERNAL_SOURCE_PREFIX_NAMES, + pluginContext: this, + }); + program = programVisitor.programVisitor(program); + script = program.astNode; + arkts.Performance.getInstance().stopEvent('ui-checked', true); + debugLog('[AFTER STRUCT SCRIPT] script: ', script.dumpSrc()); + debugDump( + script.dumpSrc(), + getDumpFileName(0, 'SRC', 4, 'UI_AfterCheck_End'), + true, + cachePath, + program.programFileNameWithExtension + ); + arkts.GlobalInfo.getInfoInstance().reset(); + arkts.Performance.getInstance().createEvent('ui-recheck'); + arkts.recheckSubtree(script); + arkts.Performance.getInstance().stopEvent('ui-recheck', true); + arkts.Performance.getInstance().clearAllEvents(); + this.setArkTSAst(script); + console.log('[UI PLUGIN] AFTER CHECKED EXIT'); + return script; + } + console.log('[UI PLUGIN] AFTER CHECKED EXIT WITH NO TRANSFORM'); + return script; +} diff --git a/arkui-plugins/ui-plugins/name-collector.ts b/arkui-plugins/ui-plugins/name-collector.ts new file mode 100644 index 000000000..60d29a3e0 --- /dev/null +++ b/arkui-plugins/ui-plugins/name-collector.ts @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { AbstractVisitor } from '../common/abstract-visitor'; +import { hasBuilderLambdaAnnotation } from './builder-lambda-translators/utils'; + +interface ComponentInfo { + argsNum: number; +} + +type ComponentCollection = Map; + +export class NameCollector extends AbstractVisitor { + private components: ComponentCollection; + private static instance: NameCollector; + + private constructor() { + super(); + this.components = new Map(); + } + + static getInstance(): NameCollector { + if (!this.instance) { + this.instance = new NameCollector(); + } + return this.instance; + } + + getComponents(): string[] { + return Array.from(this.components.keys()); + } + + getComponentInfo(componentName: string): ComponentInfo | undefined { + return this.components.get(componentName); + } + + collectInfoFromComponentFunction(component: arkts.ScriptFunction): void { + if (!component.id) return; + + const name: string = component.id.name; + const argsNum: number = component.params.length; + this.components.set(name, { argsNum }); + } + + reset(): void { + super.reset(); + this.components.clear(); + } + + findComponentFunction(node: arkts.FunctionDeclaration): arkts.ScriptFunction | undefined { + const isDeclareAndExport: boolean = arkts.hasModifierFlag( + node, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE | arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_EXPORT + ); + if (!isDeclareAndExport) return undefined; + + const isComponentBuilder = hasBuilderLambdaAnnotation(node); + if (!isComponentBuilder) return undefined; + if (!node.scriptFunction.id) return undefined; + + return node.scriptFunction; + } + + visitor(node: arkts.AstNode): arkts.AstNode { + const newNode = this.visitEachChild(node); + if (arkts.isFunctionDeclaration(newNode)) { + const component = this.findComponentFunction(newNode); + if (!!component) { + this.collectInfoFromComponentFunction(component); + } + } + return newNode; + } +} diff --git a/arkui-plugins/ui-plugins/preprocessor-transform.ts b/arkui-plugins/ui-plugins/preprocessor-transform.ts new file mode 100644 index 000000000..394b2327b --- /dev/null +++ b/arkui-plugins/ui-plugins/preprocessor-transform.ts @@ -0,0 +1,257 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { AbstractVisitor, VisitorOptions } from '../common/abstract-visitor'; +import { CustomComponentNames } from './utils'; +import { factory } from './ui-factory'; +import { ARKUI_COMPONENT_IMPORT_NAME, IMPORT_SOURCE_MAP, OUTPUT_DEPENDENCY_MAP } from '../common/predefines'; +import { NameCollector } from './name-collector'; + +interface MemoImportCollection { + memo: boolean; + memoContextType: boolean; + memoIdType: boolean; +} + +export class PreprocessorTransformer extends AbstractVisitor { + private outNameArr: string[] = []; + private memoNameArr: string[] = []; + private structInterfaceImport: arkts.ETSImportDeclaration[] = []; + private memoImportCollection: Partial = {}; + private localComponentNames: string[] = []; + private isMemoImportOnce: boolean = false; + + private readonly nameCollector: NameCollector; + + constructor(options?: VisitorOptions) { + super(options); + this.nameCollector = NameCollector.getInstance(); + } + + reset(): void { + super.reset(); + this.outNameArr = []; + this.memoNameArr = []; + this.structInterfaceImport = []; + this.memoImportCollection = {}; + this.localComponentNames = []; + this.isMemoImportOnce = false; + } + + isCustomConponentDecl(node: arkts.CallExpression): boolean { + const structCollection: Set = arkts.GlobalInfo.getInfoInstance().getStructCollection(); + const nodeName: string = node.expression.dumpSrc(); + if (structCollection.has(nodeName)) { + return true; + } + return false; + } + + isComponentFunctionCall(node: arkts.CallExpression): boolean { + if (!node || !arkts.isIdentifier(node.expression)) return false; + return this.localComponentNames.includes(node.expression.name); + } + + transformComponentCall(node: arkts.CallExpression): arkts.TSAsExpression | arkts.CallExpression { + if (arkts.isObjectExpression(node.arguments[0])) { + const componentName: string = `${CustomComponentNames.COMPONENT_INTERFACE_PREFIX}${node.expression.dumpSrc()}`; + const newArg = arkts.factory.createTSAsExpression( + node.arguments[0].clone(), + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart(arkts.factory.createIdentifier(componentName)) + ), + true + ); + return arkts.factory + .updateCallExpression(node, node.expression, node.typeArguments, [newArg, ...node.arguments.slice(1)]) + .setTralingBlock(node.trailingBlock); + } else { + return node; + } + } + + transformComponentFunctionCall(node: arkts.CallExpression) { + if (!node || !arkts.isIdentifier(node.expression)) return node; + + const componentInfo = this.nameCollector.getComponentInfo(node.expression.name); + if (!componentInfo) return node; + if (componentInfo.argsNum === 0) return node; + if (node.arguments.length >= componentInfo.argsNum - 1) return node; + + const defaultArgs: arkts.UndefinedLiteral[] = []; + let count = 0; + while (count < componentInfo.argsNum - node.arguments.length - 1) { + defaultArgs.push(arkts.factory.createUndefinedLiteral()); + count++; + } + return arkts.factory.updateCallExpression(node, node.expression, node.typeArguments, [ + ...node.arguments, + ...defaultArgs, + ]); + } + + addDependencesImport(node: arkts.ETSImportDeclaration): void { + if (!node.source) return; + + const isFromCompImport: boolean = node.source.str === ARKUI_COMPONENT_IMPORT_NAME; + const structCollection: Set = arkts.GlobalInfo.getInfoInstance().getStructCollection(); + node.specifiers.forEach((item: arkts.AstNode) => { + if (!arkts.isImportSpecifier(item) || !item.imported?.name) return; + + const importName: string = item.imported.name; + this.memoImportCollection.memo ||= importName === 'memo'; + this.memoImportCollection.memoContextType ||= importName === '__memo_context_type'; + this.memoImportCollection.memoIdType ||= importName === '__memo_id_type'; + if (isFromCompImport && this.nameCollector.getComponents().includes(importName)) { + this.localComponentNames.push(item.local?.name ?? importName); + } + + if (structCollection.has(importName) && this.isExternal === false) { + const interfaceName: string = CustomComponentNames.COMPONENT_INTERFACE_PREFIX + importName; + const newImport: arkts.ETSImportDeclaration = arkts.factory.createImportDeclaration( + node.source?.clone(), + [factory.createAdditionalImportSpecifier(interfaceName, interfaceName)], + arkts.Es2pandaImportKinds.IMPORT_KINDS_VALUE + ); + this.structInterfaceImport.push(newImport); + } else { + this.addImportWithSpecifier(item, node.source!); + } + }); + } + + getSourceDependency(sourceName: string): string { + let dependencyName: string = ''; + IMPORT_SOURCE_MAP.forEach((value: Set, key: string) => { + if (value.has(sourceName)) { + dependencyName = key; + } + }); + return dependencyName; + } + + updateSourceDependencyMap(key: string, value: string[]): void { + const newValue: Set = IMPORT_SOURCE_MAP.get(key) ?? new Set(); + for (const v of value) { + newValue.add(v); + } + IMPORT_SOURCE_MAP.set(key, newValue); + } + + getOutDependencyName(inputName: string): string[] { + const sourceName: string[] = []; + if (OUTPUT_DEPENDENCY_MAP.has(inputName)) { + OUTPUT_DEPENDENCY_MAP.get(inputName)!.forEach((item: string) => { + sourceName.push(item); + }); + } + return sourceName; + } + + updateOutDependencyMap(key: string, value: string[]): void { + const oldValue: string[] = OUTPUT_DEPENDENCY_MAP.get(key) ?? []; + const newValue: string[] = [...value, ...oldValue]; + OUTPUT_DEPENDENCY_MAP.set(key, newValue); + } + + clearGenSymInOutDependencyMap(genSymKey: string): void { + if (OUTPUT_DEPENDENCY_MAP.has(genSymKey)) { + OUTPUT_DEPENDENCY_MAP.delete(genSymKey); + } + } + + prepareDependencyMap(node: arkts.ImportSpecifier, source: arkts.StringLiteral): void { + if (!node.imported?.name) return; + + // Handling component imports + const importName: string = node.imported.name; + const sourceName: string = source.str; + if (this.nameCollector.getComponents().includes(importName) && sourceName === ARKUI_COMPONENT_IMPORT_NAME) { + const newDependencies = [`${importName}Attribute`]; + this.updateOutDependencyMap(importName, newDependencies); + this.updateSourceDependencyMap(sourceName, newDependencies); + } + } + + prepareMemoImports(): void { + const newDependencies = []; + if (!this.memoImportCollection.memo) { + newDependencies.push('memo'); + } + if (!this.memoImportCollection.memoContextType) { + newDependencies.push('__memo_context_type'); + } + if (!this.memoImportCollection.memoIdType) { + newDependencies.push('__memo_id_type'); + } + if (newDependencies.length > 0) { + this.memoNameArr.push(...newDependencies); + this.isMemoImportOnce = true; + } + } + + addImportWithSpecifier(node: arkts.ImportSpecifier, source: arkts.StringLiteral): void { + if (!node.imported?.name) return; + + this.prepareDependencyMap(node, source); + const outName: string[] = this.getOutDependencyName(node.imported?.name); + this.outNameArr.push(...outName); + } + + updateScriptWithImport(): void { + if (!this.program) { + throw Error('Failed to insert import: Transformer has no program'); + } + + const outNames = new Set([...this.outNameArr, ...this.memoNameArr]); + outNames.forEach((item: string) => { + const source: string = this.getSourceDependency(item); + const newImport: arkts.ETSImportDeclaration = arkts.factory.createImportDeclaration( + arkts.factory.create1StringLiteral(source), + [factory.createAdditionalImportSpecifier(item, item)], + arkts.Es2pandaImportKinds.IMPORT_KINDS_VALUE + ); + arkts.importDeclarationInsert(newImport, this.program!); + }); + this.structInterfaceImport.forEach((element: arkts.ETSImportDeclaration) => { + arkts.importDeclarationInsert(element, this.program!); + }); + } + + enter(node: arkts.AstNode): void { + if (this.isExternal && arkts.isFunctionDeclaration(node)) { + const component = this.nameCollector.findComponentFunction(node); + if (!!component) this.nameCollector.collectInfoFromComponentFunction(component); + } + } + + visitor(node: arkts.AstNode): arkts.AstNode { + this.enter(node); + const newNode = this.visitEachChild(node); + if (arkts.isCallExpression(newNode) && this.isCustomConponentDecl(newNode)) { + return this.transformComponentCall(newNode); + } else if (arkts.isCallExpression(newNode) && this.isComponentFunctionCall(newNode)) { + return this.transformComponentFunctionCall(newNode); + } + if (arkts.isETSImportDeclaration(node)) { + this.addDependencesImport(node); + } else if (arkts.isEtsScript(node)) { + if (!this.isMemoImportOnce) this.prepareMemoImports(); + this.updateScriptWithImport(); + } + return newNode; + } +} diff --git a/arkui-plugins/ui-plugins/printer-transformer.ts b/arkui-plugins/ui-plugins/printer-transformer.ts new file mode 100644 index 000000000..2ccab0b0e --- /dev/null +++ b/arkui-plugins/ui-plugins/printer-transformer.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { PrintVisitor } from '../common/print-visitor'; + +export interface TransformerOptions { + trace?: boolean; +} + +export default function printerTransformer(userPluginOptions?: TransformerOptions) { + return (node: arkts.EtsScript) => { + return new PrintVisitor().visitor(node); + }; +} diff --git a/arkui-plugins/ui-plugins/property-translators/base.ts b/arkui-plugins/ui-plugins/property-translators/base.ts new file mode 100644 index 000000000..4be00d1c8 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/base.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { createGetter, createSetter, getStageManagementIdent } from './utils'; +import { createOptionalClassProperty } from '../utils'; + +export abstract class PropertyTranslator { + constructor( + protected property: arkts.ClassProperty, + protected structName: string + ) {} + + abstract translateMember(): arkts.AstNode[]; + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field = createOptionalClassProperty( + newName, + this.property, + getStageManagementIdent(this.property), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE + ); + + const member = arkts.factory.createTSNonNullExpression( + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ) + ); + const thisValue: arkts.MemberExpression = arkts.factory.createMemberExpression( + member, + arkts.factory.createIdentifier('value'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); + + const getter: arkts.MethodDefinition = this.translateGetter( + originalName, + this.property.typeAnnotation, + thisValue + ); + const setter: arkts.MethodDefinition = this.translateSetter( + originalName, + this.property.typeAnnotation, + thisValue + ); + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.MemberExpression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + left: arkts.MemberExpression + ): arkts.MethodDefinition { + const right: arkts.CallExpression = arkts.factory.createCallExpression( + arkts.factory.createIdentifier('observableProxy'), + undefined, + [arkts.factory.createIdentifier('value')] + ); + return createSetter(originalName, typeAnnotation, left, right); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/builderParam.ts b/arkui-plugins/ui-plugins/property-translators/builderParam.ts new file mode 100644 index 000000000..f6b08b836 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/builderParam.ts @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { + createGetter, + createSetter, + generateThisBackingValue, + generateThisBacking, + getValueInAnnotation, + DecoratorNames, +} from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; +import { createOptionalClassProperty } from '../utils'; +import { factory } from './factory'; + +export class BuilderParamTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const mutableThis: arkts.Expression = generateThisBacking(newName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(mutableThis, originalName); + // const updateStruct: arkts.AstNode = this.generateUpdateStruct(mutableThis, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + // currentStructInfo.updateBody.push(updateStruct); + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field: arkts.ClassProperty = createOptionalClassProperty( + newName, + this.property, + '', + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE + ); + const thisGetValue: arkts.Expression = generateThisBacking(newName, false, true); + const thisSetValue: arkts.Expression = generateThisBacking(newName, false, false); + const getter: arkts.MethodDefinition = this.translateGetter( + originalName, + this.property.typeAnnotation, + thisGetValue + ); + const setter: arkts.MethodDefinition = this.translateSetter( + originalName, + this.property.typeAnnotation, + thisSetValue + ); + + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + left: arkts.Expression + ): arkts.MethodDefinition { + const right: arkts.Identifier = arkts.factory.createIdentifier('value'); + return createSetter(originalName, typeAnnotation, left, right, true); + } + + generateInitializeStruct(mutableThis: arkts.Expression, originalName: string): arkts.AstNode { + return arkts.factory.createAssignmentExpression( + mutableThis, + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + factory.createBlockStatementForOptionalExpression( + arkts.factory.createIdentifier('initializers'), + originalName + ) + ); + } + + generateUpdateStruct(mutableThis: arkts.Expression, originalName: string): arkts.AstNode { + const right: arkts.MemberExpression = arkts.factory.createMemberExpression( + arkts.factory.createIdentifier('initializers'), + arkts.factory.createIdentifier(originalName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + true + ); + return arkts.factory.createAssignmentExpression( + mutableThis, + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + right + ); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/consume.ts b/arkui-plugins/ui-plugins/property-translators/consume.ts new file mode 100644 index 000000000..ac7491b70 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/consume.ts @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { + createGetter, + createSetter, + generateThisBackingValue, + generateThisBacking, + getValueInAnnotation, + DecoratorNames, +} from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; +import { createOptionalClassProperty } from '../utils'; + +export class ConsumeTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field: arkts.ClassProperty = createOptionalClassProperty( + newName, + this.property, + 'MutableState', + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE + ); + const thisValue: arkts.MemberExpression = generateThisBackingValue(newName, false, true); + const getter: arkts.MethodDefinition = this.translateGetter( + originalName, + this.property.typeAnnotation, + thisValue + ); + const setter: arkts.MethodDefinition = this.translateSetter( + originalName, + this.property.typeAnnotation, + thisValue + ); + + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.MemberExpression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + left: arkts.MemberExpression + ): arkts.MethodDefinition { + const right: arkts.CallExpression = arkts.factory.createCallExpression( + arkts.factory.createIdentifier('observableProxy'), + undefined, + [arkts.factory.createIdentifier('value')] + ); + + return createSetter(originalName, typeAnnotation, left, right); + } + + generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { + let consumeValueStr: string | undefined = getValueInAnnotation(this.property, DecoratorNames.CONSUME); + if (!consumeValueStr) { + consumeValueStr = originalName; + } + const right: arkts.CallExpression = arkts.factory.createCallExpression( + arkts.factory.createIdentifier('contextLocal'), + this.property.typeAnnotation ? [this.property.typeAnnotation] : undefined, + [arkts.factory.create1StringLiteral(consumeValueStr)] + ); + return arkts.factory.createAssignmentExpression( + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + right + ); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/factory.ts b/arkui-plugins/ui-plugins/property-translators/factory.ts new file mode 100644 index 000000000..7125b11c7 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/factory.ts @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { getInteropPath } from '../../path'; +import { GenSymGenerator } from '../../common/gensym-generator'; +import { factory as UIFactory } from '../ui-factory'; +const interop = require(getInteropPath()); +const nullptr = interop.nullptr; + +export class factory { + /** + * generate an substitution for optional expression ?., e.g. `{let _tmp = xxx; _tmp == null ? undefined : xxx}`. + * + * @param object item before ?.. + * @param key item after ?.. + */ + static createBlockStatementForOptionalExpression( + object: arkts.AstNode, + key: string, + isCall: boolean = false + ): arkts.Expression { + let id = GenSymGenerator.getInstance().id(key); + const statements: arkts.Statement[] = [ + factory.generateLetVariableDecl(arkts.factory.createIdentifier(id), object), + factory.generateTernaryExpression(id, key, isCall), + ]; + return arkts.factory.createBlockExpression(statements); + } + + /** + * generate a variable declaration, e.g. `let = `; + * + * @param left left expression. + * @param right right expression. + */ + static generateLetVariableDecl(left: arkts.Identifier, right: arkts.AstNode): arkts.VariableDeclaration { + return arkts.factory.createVariableDeclaration( + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + arkts.Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_LET, + [ + arkts.factory.createVariableDeclarator( + arkts.Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_LET, + left, + right + ), + ] + ); + } + + /** + * generate a ternary expression, e.g. ` ? : `; + * + * @param testLeft the left hand of the test condition. + * @param key item after ?. + */ + static generateTernaryExpression( + testLeft: string, + key: string, + isCall: boolean = false + ): arkts.ExpressionStatement { + const test = arkts.factory.createBinaryExpression( + arkts.factory.createIdentifier(testLeft), + arkts.factory.createNullLiteral(), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_EQUAL + ); + const consequent: arkts.Expression = arkts.factory.createUndefinedLiteral(); + const alternate: arkts.MemberExpression = arkts.factory.createMemberExpression( + arkts.factory.createIdentifier(testLeft), + arkts.factory.createIdentifier(key), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); + return arkts.factory.createExpressionStatement( + arkts.factory.createConditionalExpression( + test, + consequent, + isCall ? arkts.factory.createCallExpression(alternate, undefined, undefined) : alternate + ) + ); + } + + /** + * generate an substitution for two optional expression ?., e.g. a?.b?.c. + * + * @param node entry wrapper class declaration node. + */ + static createDoubleBlockStatementForOptionalExpression( + object: arkts.AstNode, + key1: string, + key2: string + ): arkts.Expression { + let id = GenSymGenerator.getInstance().id(key1); + let initial: arkts.Expression = factory.createBlockStatementForOptionalExpression(object, key1); + const statements: arkts.Statement[] = [ + factory.generateLetVariableDecl(arkts.factory.createIdentifier(id), initial), + factory.generateTernaryExpression(id, key2), + ]; + return arkts.factory.createBlockExpression(statements); + } + + /** + * generate an memberExpression with nonNull or optional, e.g. object.property, object?.property or object!.property + * + * @param object item before point. + * @param property item after point. + */ + static createNonNullOrOptionalMemberExpression( + object: string, + property: string, + optional: boolean, + nonNull: boolean + ): arkts.Expression { + const objectNode: arkts.Identifier = arkts.factory.createIdentifier(object); + return arkts.factory.createMemberExpression( + nonNull ? arkts.factory.createTSNonNullExpression(objectNode) : objectNode, + arkts.factory.createIdentifier(property), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + optional + ); + } + + /* + * create `(): => { }`. + */ + static createArrowFunctionWithParamsAndBody( + typeParams: arkts.TSTypeParameterDeclaration | undefined, + params: arkts.Expression[] | undefined, + returnType: arkts.TypeNode | undefined, + hasReceiver: boolean, + bodyStatementsList: arkts.Statement[] + ): arkts.ArrowFunctionExpression { + return arkts.factory.createArrowFunction( + arkts.factory.createScriptFunction( + arkts.BlockStatement.createBlockStatement(bodyStatementsList), + arkts.factory.createFunctionSignature(typeParams, params ? params : [], returnType, hasReceiver), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE + ) + ); + } + + /* + * create @Watch callback, e.g. (propertyName: string): void => {this.(propertyName)}. + */ + static createWatchCallback(callbackName: string): arkts.ArrowFunctionExpression { + return factory.createArrowFunctionWithParamsAndBody( + undefined, + [ + arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier('_', UIFactory.createTypeReferenceFromString('string')), + undefined + ), + ], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false, + [ + arkts.factory.createExpressionStatement( + arkts.factory.createCallExpression(factory.generateThisCall(callbackName), undefined, [ + arkts.factory.createIdentifier('_'), + ]) + ), + ] + ); + } + + /* + * create this. with optional or nonNullable. + */ + static generateThisCall(name: string, optional: boolean = false, nonNull: boolean = false): arkts.Expression { + const member: arkts.Expression = arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(`${name}`), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + optional + ); + return nonNull ? arkts.factory.createTSNonNullExpression(member) : member; + } + + /* + * create `initializers!.!.()`. + */ + static createBackingGetOrSetCall( + newName: string, + getOrSet: string, + args: arkts.AstNode[] | undefined + ): arkts.CallExpression { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createTSNonNullExpression( + factory.createNonNullOrOptionalMemberExpression('initializers', newName, false, true) + ), + arkts.factory.createIdentifier(getOrSet), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + undefined, + args + ); + } + + /* + * create `new ()`. + */ + static createNewDecoratedInstantiate( + className: string, + typeAnnotation: arkts.TypeNode | undefined, + args: arkts.Expression[] | undefined + ): arkts.ETSNewClassInstanceExpression { + return arkts.factory.createETSNewClassInstanceExpression( + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier(className), + arkts.factory.createTSTypeParameterInstantiation(typeAnnotation ? [typeAnnotation.clone()] : []) + ) + ), + args?.length ? args : [] + ); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/index.ts b/arkui-plugins/ui-plugins/property-translators/index.ts new file mode 100644 index 000000000..c30ace4fc --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/index.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { PropertyTranslator } from './base'; +import { DecoratorNames, hasDecorator } from './utils'; +import { StateTranslator } from './state'; +import { PropTranslator } from './prop'; +import { StorageLinkTranslator } from './storagelink'; +import { LocalStorageLinkTranslator } from './localstoragelink'; +import { LinkTranslator } from './link'; +import { ObjectLinkTranslator } from './objectlink'; +import { LocalStoragePropTranslator } from './localstorageprop'; +import { regularPropertyTranslator } from './regularProperty'; +import { staticPropertyTranslator } from './staticProperty'; +import { isStatic } from '../utils'; +import { StoragePropTranslator } from './storageProp'; +import { ConsumeTranslator } from './consume'; +import { ProvideTranslator } from './provide'; +import { BuilderParamTranslator } from './builderParam'; + +export { PropertyTranslator }; + +export function classifyProperty(member: arkts.AstNode, structName: string): PropertyTranslator | undefined { + if (!arkts.isClassProperty(member)) return undefined; + if (isStatic(member)) return new staticPropertyTranslator(member, structName); + + if (hasDecorator(member, DecoratorNames.STATE)) { + return new StateTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.STORAGE_LINK)) { + return new StorageLinkTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.LOCAL_STORAGE_LINK)) { + return new LocalStorageLinkTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.LINK)) { + return new LinkTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.OBJECT_LINK)) { + return new ObjectLinkTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.LOCAL_STORAGE_PROP)) { + return new LocalStoragePropTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.STORAGE_PROP)) { + return new StoragePropTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.PROP)) { + return new PropTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.PROVIDE)) { + return new ProvideTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.CONSUME)) { + return new ConsumeTranslator(member, structName); + } + if (hasDecorator(member, DecoratorNames.BUILDER_PARAM)) { + return new BuilderParamTranslator(member, structName); + } + + return new regularPropertyTranslator(member, structName); +} diff --git a/arkui-plugins/ui-plugins/property-translators/link.ts b/arkui-plugins/ui-plugins/property-translators/link.ts new file mode 100644 index 000000000..eafd90c95 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/link.ts @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { + generateToRecord, + createGetter, + createSetter2, + generateThisBacking, + generateGetOrSetCall, + judgeIfAddWatchFunc, +} from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; +import { factory } from './factory'; +import { createOptionalClassProperty } from '../utils'; + +export class LinkTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + if (currentStructInfo.isReusable) { + const toRecord = generateToRecord(newName, originalName); + currentStructInfo.toRecordBody.push(toRecord); + } + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + generateInitializeStruct(newName: string, originalName: string) { + const test = factory.createBlockStatementForOptionalExpression( + arkts.factory.createIdentifier('initializers'), + newName + ); + + const args: arkts.Expression[] = [ + arkts.factory.create1StringLiteral(originalName), + arkts.factory.createTSNonNullExpression( + factory.createNonNullOrOptionalMemberExpression('initializers', newName, false, true) + ), + ]; + judgeIfAddWatchFunc(args, this.property); + const consequent = arkts.BlockStatement.createBlockStatement([ + arkts.factory.createExpressionStatement( + arkts.factory.createAssignmentExpression( + generateThisBacking(newName, false, false), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + factory.createNewDecoratedInstantiate('LinkDecoratedVariable', this.property.typeAnnotation, args) + ) + ), + ]); + + return arkts.factory.createExpressionStatement(arkts.factory.createIfStatement(test, consequent)); + } + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field: arkts.ClassProperty = createOptionalClassProperty( + newName, + this.property, + 'LinkDecoratedVariable', + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE + ); + const thisValue: arkts.Expression = generateThisBacking(newName, false, true); + const thisGet: arkts.CallExpression = generateGetOrSetCall(thisValue, 'get'); + const thisSet: arkts.ExpressionStatement = arkts.factory.createExpressionStatement( + generateGetOrSetCall(thisValue, 'set') + ); + const getter: arkts.MethodDefinition = this.translateGetter( + originalName, + this.property.typeAnnotation, + thisGet + ); + const setter: arkts.MethodDefinition = this.translateSetter( + originalName, + this.property.typeAnnotation, + thisSet + ); + + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + statement: arkts.AstNode + ): arkts.MethodDefinition { + return createSetter2(originalName, typeAnnotation, statement); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/localstoragelink.ts b/arkui-plugins/ui-plugins/property-translators/localstoragelink.ts new file mode 100755 index 000000000..a050e9852 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/localstoragelink.ts @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { backingField, expectName } from '../../common/arkts-utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { DecoratorNames, generateToRecord } from './utils'; + +function getLocalStorageLinkValueStr(node: arkts.AstNode): string | undefined { + if (!arkts.isClassProperty(node) || !node.value) return undefined; + return arkts.isStringLiteral(node.value) ? node.value.str : undefined; +} + +function getLocalStorageLinkAnnotationValue(anno: arkts.AnnotationUsage): string | undefined { + const isStorageLinkAnnotation: boolean = + !!anno.expr && arkts.isIdentifier(anno.expr) && anno.expr.name === DecoratorNames.LOCAL_STORAGE_LINK; + + if (isStorageLinkAnnotation && anno.properties.length === 1) { + return getLocalStorageLinkValueStr(anno.properties.at(0)!); + } + return undefined; +} + +function getLocalStorageLinkValueInAnnotation(node: arkts.ClassProperty): string | undefined { + const annotations: readonly arkts.AnnotationUsage[] = node.annotations; + + for (let i = 0; i < annotations.length; i++) { + const anno: arkts.AnnotationUsage = annotations[i]; + const str: string | undefined = getLocalStorageLinkAnnotationValue(anno); + if (!!str) { + return str; + } + } + + return undefined; +} + +export class LocalStorageLinkTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + + if (currentStructInfo.isReusable) { + const toRecord = generateToRecord(newName, originalName); + currentStructInfo.toRecordBody.push(toRecord); + } + + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { + const localStorageLinkValueStr: string | undefined = getLocalStorageLinkValueInAnnotation(this.property); + if (!localStorageLinkValueStr) { + throw new Error('LocalStorageLink required only one value!!'); // TODO: replace this with proper error message. + } + + const call = arkts.factory.createCallExpression( + arkts.factory.createIdentifier('StorageLinkState'), + this.property.typeAnnotation ? [this.property.typeAnnotation] : [], + [ + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier('_entry_local_storage_'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.factory.createStringLiteral(localStorageLinkValueStr), + this.property.value ?? arkts.factory.createUndefinedLiteral(), + ] + ); + + return arkts.factory.createAssignmentExpression( + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + call + ); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/localstorageprop.ts b/arkui-plugins/ui-plugins/property-translators/localstorageprop.ts new file mode 100644 index 000000000..d20d982cd --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/localstorageprop.ts @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { DecoratorNames, generateToRecord } from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; + +function getLocalStorageporpValueStr(node: arkts.AstNode): string | undefined { + if (!arkts.isClassProperty(node) || !node.value) return undefined; + + return arkts.isStringLiteral(node.value) ? node.value.str : undefined; +} +function getLocalStorageporpAnnotationValue(anno: arkts.AnnotationUsage): string | undefined { + const isLocalStorageporpAnnotation: boolean = + !!anno.expr && arkts.isIdentifier(anno.expr) && anno.expr.name === DecoratorNames.LOCAL_STORAGE_PROP; + + if (isLocalStorageporpAnnotation && anno.properties.length === 1) { + return getLocalStorageporpValueStr(anno.properties.at(0)!); + } + return undefined; +} + +function getLocalStorageporpValueInAnnotation(node: arkts.ClassProperty): string | undefined { + const annotations: readonly arkts.AnnotationUsage[] = node.annotations; + + for (let i = 0; i < annotations.length; i++) { + const anno: arkts.AnnotationUsage = annotations[i]; + const str: string | undefined = getLocalStorageporpAnnotationValue(anno); + if (!!str) { + return str; + } + } + + return undefined; +} + +export class LocalStoragePropTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + const updateStruct: arkts.AstNode = this.generateUpdateStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + currentStructInfo.updateBody.push(updateStruct); + + if (currentStructInfo.isReusable) { + const toRecord = generateToRecord(newName, originalName); + currentStructInfo.toRecordBody.push(toRecord); + } + + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { + const localStorageporpValueStr: string | undefined = getLocalStorageporpValueInAnnotation(this.property); + if (!localStorageporpValueStr) { + throw new Error('LocalStorageProp required only one value!!'); // TODO: replace this with proper error message. + } + const insideMember = arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier('_entry_local_storage_'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); + const binaryItem = arkts.factory.createCallExpression( + arkts.factory.createIdentifier('StorageLinkState'), + this.property.typeAnnotation ? [this.property.typeAnnotation] : [], + [ + insideMember, + arkts.factory.createStringLiteral(localStorageporpValueStr), + this.property.value ?? arkts.factory.createUndefinedLiteral(), + ] + ); + const call = arkts.factory.createCallExpression( + arkts.factory.createIdentifier('propState'), + this.property.typeAnnotation ? [this.property.typeAnnotation] : [], + [ + arkts.factory.createMemberExpression( + binaryItem, + arkts.factory.createIdentifier('value'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + ] + ); + return arkts.factory.createAssignmentExpression( + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + call + ); + } + + generateUpdateStruct(newName: string, originalName: string): arkts.AstNode { + const localStorageporpValueStr: string | undefined = getLocalStorageporpValueInAnnotation(this.property); + if (!localStorageporpValueStr) { + throw new Error('StorageLink required only one value!!'); // TODO: replace this with proper error message. + } + + const StorageLinkStateValue = arkts.factory.createMemberExpression( + arkts.factory.createCallExpression( + arkts.factory.createIdentifier('StorageLinkState'), + this.property.typeAnnotation ? [this.property.typeAnnotation] : [], + [ + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier('_entry_local_storage_'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.factory.createStringLiteral(localStorageporpValueStr), + this.property.value ?? arkts.factory.createUndefinedLiteral(), + ] + ), + arkts.factory.createIdentifier('value'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); + + const test = arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); + + const consequent = arkts.BlockStatement.createBlockStatement([ + arkts.factory.createExpressionStatement( + arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createTSNonNullExpression(test), + arkts.factory.createIdentifier('update'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + undefined, + [StorageLinkStateValue] + ) + ), + ]); + + return arkts.factory.createExpressionStatement(arkts.factory.createIfStatement(test, consequent)); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/objectlink.ts b/arkui-plugins/ui-plugins/property-translators/objectlink.ts new file mode 100644 index 000000000..49b177d4f --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/objectlink.ts @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { generateToRecord } from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; +import { factory } from './factory'; + +export class ObjectLinkTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + const updateStruct: arkts.AstNode = this.generateUpdateStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + currentStructInfo.updateBody.push(updateStruct); + + if (currentStructInfo.isReusable) { + const toRecord = generateToRecord(newName, originalName); + currentStructInfo.toRecordBody.push(toRecord); + } + + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { + const call = arkts.factory.createCallExpression( + arkts.factory.createIdentifier('objectLinkState'), + this.property.typeAnnotation ? [this.property.typeAnnotation] : [], + [] + ); + return arkts.factory.createAssignmentExpression( + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + call + ); + } + + generateUpdateStruct(newName: string, originalName: string): arkts.AstNode { + const test = arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); + + const consequent = arkts.BlockStatement.createBlockStatement([ + arkts.factory.createExpressionStatement( + arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + arkts.factory.createTSNonNullExpression(test), + arkts.factory.createIdentifier('update'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + undefined, + [ + factory.createBlockStatementForOptionalExpression( + arkts.factory.createIdentifier('initializers'), + originalName + ), + ] + ) + ), + ]); + return arkts.factory.createExpressionStatement(arkts.factory.createIfStatement(test, consequent)); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/prop.ts b/arkui-plugins/ui-plugins/property-translators/prop.ts new file mode 100644 index 000000000..b8bb3d991 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/prop.ts @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { + generateToRecord, + createGetter, + createSetter2, + generateGetOrSetCall, + generateThisBacking, + judgeIfAddWatchFunc, +} from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; +import { createOptionalClassProperty } from '../utils'; +import { factory } from './factory'; + +export class PropTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const mutableThis: arkts.Expression = generateThisBacking(newName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + const updateStruct: arkts.AstNode = this.generateUpdateStruct(mutableThis, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + currentStructInfo.updateBody.push(updateStruct); + if (currentStructInfo.isReusable) { + const toRecord = generateToRecord(newName, originalName); + currentStructInfo.toRecordBody.push(toRecord); + } + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field: arkts.ClassProperty = createOptionalClassProperty( + newName, + this.property, + 'PropDecoratedVariable', + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE + ); + const thisValue: arkts.Expression = generateThisBacking(newName, false, true); + const thisGet: arkts.CallExpression = generateGetOrSetCall(thisValue, 'get'); + const thisSet: arkts.ExpressionStatement = arkts.factory.createExpressionStatement( + generateGetOrSetCall(thisValue, 'set') + ); + const getter: arkts.MethodDefinition = this.translateGetter( + originalName, + this.property.typeAnnotation, + thisGet + ); + const setter: arkts.MethodDefinition = this.translateSetter( + originalName, + this.property.typeAnnotation, + thisSet + ); + + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + statement: arkts.AstNode + ): arkts.MethodDefinition { + return createSetter2(originalName, typeAnnotation, statement); + } + + generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { + const binaryItem = arkts.factory.createBinaryExpression( + factory.createBlockStatementForOptionalExpression( + arkts.factory.createIdentifier('initializers'), + originalName + ), + this.property.value ?? arkts.factory.createUndefinedLiteral(), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_NULLISH_COALESCING + ); + const args: arkts.Expression[] = [ + arkts.factory.create1StringLiteral(originalName), + this.property.value + ? binaryItem + : arkts.factory.createTSAsExpression( + factory.createNonNullOrOptionalMemberExpression('initializers', originalName, false, true), + this.property.typeAnnotation ? this.property.typeAnnotation.clone() : undefined, + false + ), + ]; + judgeIfAddWatchFunc(args, this.property); + const right = arkts.factory.createETSNewClassInstanceExpression( + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier('PropDecoratedVariable'), + arkts.factory.createTSTypeParameterInstantiation( + this.property.typeAnnotation ? [this.property.typeAnnotation] : [] + ) + ) + ), + args + ); + const assign: arkts.AssignmentExpression = arkts.factory.createAssignmentExpression( + generateThisBacking(newName), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + right + ); + return arkts.factory.createExpressionStatement(assign); + } + + generateUpdateStruct(mutableThis: arkts.Expression, originalName: string): arkts.AstNode { + const binaryItem = arkts.factory.createBinaryExpression( + factory.createBlockStatementForOptionalExpression( + arkts.factory.createIdentifier('initializers'), + originalName + ), + arkts.factory.createUndefinedLiteral(), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_NOT_STRICT_EQUAL + ); + const member: arkts.MemberExpression = arkts.factory.createMemberExpression( + arkts.factory.createTSNonNullExpression(mutableThis), + arkts.factory.createIdentifier('update'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); + return arkts.factory.createIfStatement( + binaryItem, + arkts.factory.createBlock([ + arkts.factory.createExpressionStatement( + arkts.factory.createCallExpression(member, undefined, [ + arkts.factory.createTSAsExpression( + factory.createNonNullOrOptionalMemberExpression('initializers', originalName, false, true), + this.property.typeAnnotation ? this.property.typeAnnotation.clone() : undefined, + false + ), + ]) + ), + ]) + ); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/provide.ts b/arkui-plugins/ui-plugins/property-translators/provide.ts new file mode 100644 index 000000000..ced49cefa --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/provide.ts @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { createGetter, createSetter, generateThisBackingValue, getValueInAnnotation, DecoratorNames } from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; +import { createOptionalClassProperty } from '../utils'; +import { factory } from './factory'; + +export class ProvideTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field: arkts.ClassProperty = createOptionalClassProperty( + newName, + this.property, + 'MutableState', + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE + ); + const thisValue: arkts.MemberExpression = generateThisBackingValue(newName, false, true); + const getter: arkts.MethodDefinition = this.translateGetter( + originalName, + this.property.typeAnnotation, + thisValue + ); + const setter: arkts.MethodDefinition = this.translateSetter( + originalName, + this.property.typeAnnotation, + thisValue + ); + + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.MemberExpression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + left: arkts.MemberExpression + ): arkts.MethodDefinition { + const right: arkts.CallExpression = arkts.factory.createCallExpression( + arkts.factory.createIdentifier('observableProxy'), + undefined, + [arkts.factory.createIdentifier('value')] + ); + + return createSetter(originalName, typeAnnotation, left, right); + } + + generateInitializeStruct(newName: string, originName: string): arkts.AstNode { + let provideValueStr: string | undefined = getValueInAnnotation(this.property, DecoratorNames.PROVIDE); + if (!provideValueStr) { + provideValueStr = originName; + } + const memExp: arkts.Expression = factory.createDoubleBlockStatementForOptionalExpression( + arkts.factory.createIdentifier('initializers'), + newName, + 'value' + ); + const body: arkts.BlockStatement = arkts.factory.createBlock([ + arkts.factory.createReturnStatement( + arkts.factory.createBinaryExpression( + memExp, + this.property.value, + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_NULLISH_COALESCING + ) + ), + ]); + const script = arkts.factory.createScriptFunction( + body, + arkts.FunctionSignature.createFunctionSignature(undefined, [], this.property.typeAnnotation, false), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ); + const right: arkts.CallExpression = arkts.factory.createCallExpression( + arkts.factory.createIdentifier('contextLocalStateOf'), + this.property.typeAnnotation ? [this.property.typeAnnotation] : undefined, + [arkts.factory.create1StringLiteral(provideValueStr), arkts.factory.createArrowFunction(script)] + ); + return arkts.factory.createExpressionStatement( + arkts.factory.createAssignmentExpression( + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + right + ) + ); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/regularProperty.ts b/arkui-plugins/ui-plugins/property-translators/regularProperty.ts new file mode 100644 index 000000000..0d87d638a --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/regularProperty.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { createGetter, createSetter } from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; + +export class regularPropertyTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void {} + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + return [this.property]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + left: arkts.MemberExpression + ): arkts.MethodDefinition { + const right: arkts.Identifier = arkts.factory.createUndefinedLiteral(); + return createSetter(originalName, typeAnnotation, left, right); + } + + generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { + return arkts.factory.createAssignmentExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier('this'), + arkts.factory.createIdentifier(originalName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + this.property.value ?? arkts.factory.createUndefinedLiteral() + ); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/state.ts b/arkui-plugins/ui-plugins/property-translators/state.ts new file mode 100644 index 000000000..667fabac7 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/state.ts @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { + generateToRecord, + createGetter, + createSetter2, + generateThisBacking, + generateGetOrSetCall, + judgeIfAddWatchFunc, +} from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; +import { createOptionalClassProperty } from '../utils'; +import { factory } from './factory'; + +export class StateTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + if (currentStructInfo.isReusable) { + const toRecord = generateToRecord(newName, originalName); + currentStructInfo.toRecordBody.push(toRecord); + } + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field: arkts.ClassProperty = createOptionalClassProperty( + newName, + this.property, + 'StateDecoratedVariable', + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE + ); + const thisValue: arkts.Expression = generateThisBacking(newName, false, true); + const thisGet: arkts.CallExpression = generateGetOrSetCall(thisValue, 'get'); + const thisSet: arkts.ExpressionStatement = arkts.factory.createExpressionStatement( + generateGetOrSetCall(thisValue, 'set') + ); + const getter: arkts.MethodDefinition = this.translateGetter( + originalName, + this.property.typeAnnotation, + thisGet + ); + const setter: arkts.MethodDefinition = this.translateSetter( + originalName, + this.property.typeAnnotation, + thisSet + ); + + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + statement: arkts.AstNode + ): arkts.MethodDefinition { + return createSetter2(originalName, typeAnnotation, statement); + } + + generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { + const binaryItem = arkts.factory.createBinaryExpression( + factory.createBlockStatementForOptionalExpression( + arkts.factory.createIdentifier('initializers'), + originalName + ), + this.property.value ?? arkts.factory.createUndefinedLiteral(), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_NULLISH_COALESCING + ); + const args: arkts.Expression[] = [arkts.factory.create1StringLiteral(originalName), binaryItem]; + judgeIfAddWatchFunc(args, this.property); + const right = arkts.factory.createETSNewClassInstanceExpression( + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier('StateDecoratedVariable'), + arkts.factory.createTSTypeParameterInstantiation( + this.property.typeAnnotation ? [this.property.typeAnnotation] : [] + ) + ) + ), + args + ); + const assign: arkts.AssignmentExpression = arkts.factory.createAssignmentExpression( + generateThisBacking(newName), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + right + ); + return arkts.factory.createExpressionStatement(assign); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/staticProperty.ts b/arkui-plugins/ui-plugins/property-translators/staticProperty.ts new file mode 100644 index 000000000..12e9535c5 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/staticProperty.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { createGetter, createSetter } from './utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { backingField, expectName } from '../../common/arkts-utils'; + +export class staticPropertyTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void {} + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + return [this.property]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + left: arkts.MemberExpression + ): arkts.MethodDefinition { + const right: arkts.Identifier = arkts.factory.createIdentifier('value'); + return createSetter(originalName, typeAnnotation, left, right); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/storageProp.ts b/arkui-plugins/ui-plugins/property-translators/storageProp.ts new file mode 100644 index 000000000..2693f749d --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/storageProp.ts @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { backingField, expectName } from '../../common/arkts-utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { + DecoratorNames, + generateToRecord, + createGetter, + createSetter2, + generateThisBacking, + generateGetOrSetCall, + judgeIfAddWatchFunc, +} from './utils'; +import { createOptionalClassProperty } from '../utils'; + +function getStoragePropValueStr(node: arkts.AstNode): string | undefined { + if (!arkts.isClassProperty(node) || !node.value) return undefined; + + return arkts.isStringLiteral(node.value) ? node.value.str : undefined; +} + +function getStoragePropAnnotationValue(anno: arkts.AnnotationUsage): string | undefined { + const isStoragePropAnnotation: boolean = + !!anno.expr && arkts.isIdentifier(anno.expr) && anno.expr.name === DecoratorNames.STORAGE_PROP; + + if (isStoragePropAnnotation && anno.properties.length === 1) { + return getStoragePropValueStr(anno.properties.at(0)!); + } + return undefined; +} + +function getStoragePropValueInAnnotation(node: arkts.ClassProperty): string | undefined { + const annotations: readonly arkts.AnnotationUsage[] = node.annotations; + + for (let i = 0; i < annotations.length; i++) { + const anno: arkts.AnnotationUsage = annotations[i]; + const str: string | undefined = getStoragePropAnnotationValue(anno); + if (!!str) { + return str; + } + } + return undefined; +} + +export class StoragePropTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + + if (currentStructInfo.isReusable) { + const toRecord = generateToRecord(newName, originalName); + currentStructInfo.toRecordBody.push(toRecord); + } + + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { + const storagePropValueStr: string | undefined = getStoragePropValueInAnnotation(this.property); + if (!storagePropValueStr) { + throw new Error('StorageProp required only one value!!'); // TODO: replace this with proper error message. + } + + const args: arkts.Expression[] = [ + arkts.factory.createStringLiteral(storagePropValueStr), + arkts.factory.create1StringLiteral(originalName), + this.property.value ?? arkts.factory.createUndefinedLiteral(), + ]; + judgeIfAddWatchFunc(args, this.property); + + const newClass = arkts.factory.createETSNewClassInstanceExpression( + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier('StoragePropDecoratedVariable'), + arkts.factory.createTSTypeParameterInstantiation( + this.property.typeAnnotation ? [this.property.typeAnnotation] : [] + ) + ) + ), + args + ); + + return arkts.factory.createAssignmentExpression( + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + newClass + ); + } + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field = createOptionalClassProperty( + newName, + this.property, + 'StoragePropDecoratedVariable', + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE + ); + const thisValue: arkts.Expression = generateThisBacking(newName, false, true); + const thisGet: arkts.CallExpression = generateGetOrSetCall(thisValue, 'get'); + const thisSet: arkts.ExpressionStatement = arkts.factory.createExpressionStatement( + generateGetOrSetCall(thisValue, 'set') + ); + const getter: arkts.MethodDefinition = this.translateGetter( + originalName, + this.property.typeAnnotation, + thisGet + ); + const setter: arkts.MethodDefinition = this.translateSetter( + originalName, + this.property.typeAnnotation, + thisSet + ); + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + statement: arkts.AstNode + ): arkts.MethodDefinition { + return createSetter2(originalName, typeAnnotation, statement); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/storagelink.ts b/arkui-plugins/ui-plugins/property-translators/storagelink.ts new file mode 100644 index 000000000..efd83e9d6 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/storagelink.ts @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +import { backingField, expectName } from '../../common/arkts-utils'; +import { PropertyTranslator } from './base'; +import { GetterSetter, InitializerConstructor } from './types'; +import { + DecoratorNames, + generateToRecord, + createGetter, + createSetter2, + generateThisBacking, + generateGetOrSetCall, + judgeIfAddWatchFunc, +} from './utils'; +import { createOptionalClassProperty } from '../utils'; + +function getStorageLinkValueStr(node: arkts.AstNode): string | undefined { + if (!arkts.isClassProperty(node) || !node.value) return undefined; + + return arkts.isStringLiteral(node.value) ? node.value.str : undefined; +} + +function getStorageLinkAnnotationValue(anno: arkts.AnnotationUsage): string | undefined { + const isStorageLinkAnnotation: boolean = + !!anno.expr && arkts.isIdentifier(anno.expr) && anno.expr.name === DecoratorNames.STORAGE_LINK; + + if (isStorageLinkAnnotation && anno.properties.length === 1) { + return getStorageLinkValueStr(anno.properties.at(0)!); + } + return undefined; +} + +function getStorageLinkValueInAnnotation(node: arkts.ClassProperty): string | undefined { + const annotations: readonly arkts.AnnotationUsage[] = node.annotations; + + for (let i = 0; i < annotations.length; i++) { + const anno: arkts.AnnotationUsage = annotations[i]; + const str: string | undefined = getStorageLinkAnnotationValue(anno); + if (!!str) { + return str; + } + } + return undefined; +} + +export class StorageLinkTranslator extends PropertyTranslator implements InitializerConstructor, GetterSetter { + translateMember(): arkts.AstNode[] { + const originalName: string = expectName(this.property.key); + const newName: string = backingField(originalName); + + this.cacheTranslatedInitializer(newName, originalName); // TODO: need to release cache after some point... + return this.translateWithoutInitializer(newName, originalName); + } + + cacheTranslatedInitializer(newName: string, originalName: string): void { + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(this.structName); + const initializeStruct: arkts.AstNode = this.generateInitializeStruct(newName, originalName); + currentStructInfo.initializeBody.push(initializeStruct); + + if (currentStructInfo.isReusable) { + const toRecord = generateToRecord(newName, originalName); + currentStructInfo.toRecordBody.push(toRecord); + } + + arkts.GlobalInfo.getInfoInstance().setStructInfo(this.structName, currentStructInfo); + } + + generateInitializeStruct(newName: string, originalName: string): arkts.AstNode { + const storageLinkValueStr: string | undefined = getStorageLinkValueInAnnotation(this.property); + if (!storageLinkValueStr) { + throw new Error('StorageLink required only one value!!'); // TODO: replace this with proper error message. + } + + const args: arkts.Expression[] = [ + arkts.factory.createStringLiteral(storageLinkValueStr), + arkts.factory.create1StringLiteral(originalName), + this.property.value ?? arkts.factory.createUndefinedLiteral(), + ]; + judgeIfAddWatchFunc(args, this.property); + + const newClass = arkts.factory.createETSNewClassInstanceExpression( + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier('StorageLinkDecoratedVariable'), + arkts.factory.createTSTypeParameterInstantiation( + this.property.typeAnnotation ? [this.property.typeAnnotation] : [] + ) + ) + ), + args + ); + + return arkts.factory.createAssignmentExpression( + arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(newName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + newClass + ); + } + + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[] { + const field = createOptionalClassProperty( + newName, + this.property, + 'StorageLinkDecoratedVariable', + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PRIVATE + ); + const thisValue: arkts.Expression = generateThisBacking(newName, false, true); + const thisGet: arkts.CallExpression = generateGetOrSetCall(thisValue, 'get'); + const thisSet: arkts.ExpressionStatement = arkts.factory.createExpressionStatement( + generateGetOrSetCall(thisValue, 'set') + ); + const getter: arkts.MethodDefinition = this.translateGetter( + originalName, + this.property.typeAnnotation, + thisGet + ); + const setter: arkts.MethodDefinition = this.translateSetter( + originalName, + this.property.typeAnnotation, + thisSet + ); + return [field, getter, setter]; + } + + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition { + return createGetter(originalName, typeAnnotation, returnValue); + } + + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + statement: arkts.AstNode + ): arkts.MethodDefinition { + return createSetter2(originalName, typeAnnotation, statement); + } +} diff --git a/arkui-plugins/ui-plugins/property-translators/types.ts b/arkui-plugins/ui-plugins/property-translators/types.ts new file mode 100644 index 000000000..b791a7da1 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/types.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +export interface GetterSetter { + translateGetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + returnValue: arkts.Expression + ): arkts.MethodDefinition; + translateSetter( + originalName: string, + typeAnnotation: arkts.TypeNode | undefined, + left: arkts.MemberExpression + ): arkts.MethodDefinition; +} + +export interface InitializerConstructor { + cacheTranslatedInitializer(newName: string, originalName: string): void; + translateWithoutInitializer(newName: string, originalName: string): arkts.AstNode[]; +} diff --git a/arkui-plugins/ui-plugins/property-translators/utils.ts b/arkui-plugins/ui-plugins/property-translators/utils.ts new file mode 100644 index 000000000..95b8d8be0 --- /dev/null +++ b/arkui-plugins/ui-plugins/property-translators/utils.ts @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { annotation } from '../../common/arkts-utils'; +import { factory } from './factory'; + +export enum DecoratorNames { + STATE = 'State', + STORAGE_LINK = 'StorageLink', + STORAGE_PROP = 'StorageProp', + LINK = 'Link', + PROP = 'Prop', + PROVIDE = 'Provide', + CONSUME = 'Consume', + OBJECT_LINK = 'ObjectLink', + OBSERVED = 'Observed', + WATCH = 'Watch', + BUILDER_PARAM = 'BuilderParam', + BUILDER = 'Builder', + CUSTOM_DIALOG = 'CustomDialog', + LOCAL_STORAGE_PROP = 'LocalStorageProp', + LOCAL_STORAGE_LINK = 'LocalStorageLink', + REUSABLE = 'Reusable', +} + +export function collectPropertyDecorators(property: arkts.ClassProperty): string[] { + const properties: string[] = []; + property.annotations.forEach((anno) => { + if (!!anno.expr && arkts.isIdentifier(anno.expr)) { + properties.push(anno.expr.name); + } + }); + return properties; +} + +export function isDecoratorAnnotation(anno: arkts.AnnotationUsage, decoratorName: DecoratorNames): boolean { + return !!anno.expr && arkts.isIdentifier(anno.expr) && anno.expr.name === decoratorName; +} + +export function hasDecorator( + property: arkts.ClassProperty | arkts.ClassDefinition | arkts.MethodDefinition, + decoratorName: DecoratorNames +): boolean { + if (arkts.isMethodDefinition(property)) { + return property.scriptFunction.annotations.some((anno) => isDecoratorAnnotation(anno, decoratorName)); + } + return property.annotations.some((anno) => isDecoratorAnnotation(anno, decoratorName)); +} + +export function getStateManagementType(node: arkts.ClassProperty): string { + if (hasDecorator(node, DecoratorNames.STATE)) { + return 'StateDecoratedVariable'; + } else if (hasDecorator(node, DecoratorNames.LINK)) { + return 'DecoratedV1VariableBase'; + } else if (hasDecorator(node, DecoratorNames.PROP)) { + return 'PropDecoratedVariable'; + } else if (hasDecorator(node, DecoratorNames.STORAGE_LINK)) { + return 'StorageLinkDecoratedVariable'; + } else if (hasDecorator(node, DecoratorNames.STORAGE_PROP)) { + return 'StoragePropDecoratedVariable'; + } else if ( + hasDecorator(node, DecoratorNames.LOCAL_STORAGE_PROP) || + hasDecorator(node, DecoratorNames.OBJECT_LINK) + ) { + return 'SyncedProperty'; + } + return 'MutableState'; +} + +export function createGetter( + name: string, + type: arkts.TypeNode | undefined, + returns: arkts.Expression +): arkts.MethodDefinition { + const body = arkts.factory.createBlock([arkts.factory.createReturnStatement(returns)]); + + const scriptFunction = arkts.factory.createScriptFunction( + body, + arkts.FunctionSignature.createFunctionSignature(undefined, [], type?.clone(), false), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_GETTER, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ); + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_GET, + arkts.factory.createIdentifier(name), + arkts.factory.createFunctionExpression(scriptFunction), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + false + ); +} + +export function createSetter( + name: string, + type: arkts.TypeNode | undefined, + left: arkts.Expression, + right: arkts.AstNode, + needMemo: boolean = false +): arkts.MethodDefinition { + const body = arkts.factory.createBlock([ + arkts.factory.createExpressionStatement( + arkts.factory.createAssignmentExpression( + left, + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION, + right + ) + ), + ]); + const param: arkts.ETSParameterExpression = arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier('value', type?.clone()), + undefined + ); + if (needMemo) { + param.annotations = [annotation('memo')]; + } + const scriptFunction = arkts.factory.createScriptFunction( + body, + arkts.FunctionSignature.createFunctionSignature(undefined, [param], undefined, false), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_SETTER, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ); + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_SET, + arkts.factory.createIdentifier(name), + arkts.factory.createFunctionExpression(scriptFunction), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + false + ); +} + +export function createSetter2( + name: string, + type: arkts.TypeNode | undefined, + statement: arkts.AstNode +): arkts.MethodDefinition { + const body = arkts.factory.createBlock([statement]); + const param: arkts.ETSParameterExpression = arkts.factory.createParameterDeclaration( + arkts.factory.createIdentifier('value', type?.clone()), + undefined + ); + const scriptFunction = arkts.factory.createScriptFunction( + body, + arkts.FunctionSignature.createFunctionSignature(undefined, [param], undefined, false), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_SETTER, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ); + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_SET, + arkts.factory.createIdentifier(name), + arkts.factory.createFunctionExpression(scriptFunction), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC, + false + ); +} + +export function generateThisBackingValue( + name: string, + optional: boolean = false, + nonNull: boolean = false +): arkts.MemberExpression { + const member: arkts.Expression = generateThisBacking(name, optional, nonNull); + return arkts.factory.createMemberExpression( + member, + arkts.factory.createIdentifier('value'), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ); +} + +export function generateThisBacking( + name: string, + optional: boolean = false, + nonNull: boolean = false +): arkts.Expression { + const member: arkts.Expression = arkts.factory.createMemberExpression( + arkts.factory.createThisExpression(), + arkts.factory.createIdentifier(`${name}`), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + optional + ); + return nonNull ? arkts.factory.createTSNonNullExpression(member) : member; +} + +function getValueStr(node: arkts.AstNode): string | undefined { + if (!arkts.isClassProperty(node) || !node.value) return undefined; + return arkts.isStringLiteral(node.value) ? node.value.str : undefined; +} + +function getAnnotationValue(anno: arkts.AnnotationUsage, decoratorName: DecoratorNames): string | undefined { + const isSuitableAnnotation: boolean = + !!anno.expr && arkts.isIdentifier(anno.expr) && anno.expr.name === decoratorName; + if (isSuitableAnnotation && anno.properties.length === 1) { + return getValueStr(anno.properties.at(0)!); + } + return undefined; +} + +export function getValueInAnnotation(node: arkts.ClassProperty, decoratorName: DecoratorNames): string | undefined { + const annotations: readonly arkts.AnnotationUsage[] = node.annotations; + for (let i = 0; i < annotations.length; i++) { + const anno: arkts.AnnotationUsage = annotations[i]; + const str: string | undefined = getAnnotationValue(anno, decoratorName); + if (!!str) { + return str; + } + } + return undefined; +} + +function getWatchValueStr(node: arkts.AstNode): string | undefined { + if (!arkts.isClassProperty(node) || !node.value) { + return undefined; + } + return arkts.isStringLiteral(node.value) ? node.value.str : undefined; +} + +function getWatchAnnotationValue(anno: arkts.AnnotationUsage): string | undefined { + const isWatchAnnotation: boolean = + !!anno.expr && arkts.isIdentifier(anno.expr) && anno.expr.name === DecoratorNames.WATCH; + + if (isWatchAnnotation && anno.properties.length === 1) { + return getWatchValueStr(anno.properties.at(0)!); + } + return undefined; +} + +function getWatchValueInAnnotation(node: arkts.ClassProperty): string | undefined { + const annotations: readonly arkts.AnnotationUsage[] = node.annotations; + + for (let i = 0; i < annotations.length; i++) { + const anno: arkts.AnnotationUsage = annotations[i]; + const str: string | undefined = getWatchAnnotationValue(anno); + if (!!str) { + return str; + } + } + + return undefined; +} + +export function judgeIfAddWatchFunc(args: arkts.Expression[], property: arkts.ClassProperty): void { + if (hasDecorator(property, DecoratorNames.WATCH)) { + const watchStr: string | undefined = getWatchValueInAnnotation(property); + if (watchStr) { + args.push(factory.createWatchCallback(watchStr)); + } + } +} + +export function generateGetOrSetCall(beforCall: arkts.AstNode, type: string) { + return arkts.factory.createCallExpression( + arkts.factory.createMemberExpression( + beforCall, + arkts.factory.createIdentifier(type), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + undefined, + type === 'set' ? [arkts.factory.createIdentifier('value')] : undefined, + undefined + ); +} + +export function generateToRecord(newName: string, originalName: string): arkts.Property { + return arkts.Property.createProperty( + arkts.factory.createStringLiteral(originalName), + arkts.factory.createBinaryExpression( + arkts.factory.createMemberExpression( + arkts.factory.createIdentifier('paramsCasted'), + arkts.factory.createIdentifier(originalName), + arkts.Es2pandaMemberExpressionKind.MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS, + false, + false + ), + arkts.ETSNewClassInstanceExpression.createETSNewClassInstanceExpression( + arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart(arkts.factory.createIdentifier('Object')) + ), + [] + ), + arkts.Es2pandaTokenType.TOKEN_TYPE_PUNCTUATOR_NULLISH_COALESCING + ) + ); +} + +export function getStageManagementIdent(property: arkts.ClassProperty): string { + const useMutableState: boolean = + hasDecorator(property, DecoratorNames.STATE) || + hasDecorator(property, DecoratorNames.STORAGE_LINK) || + hasDecorator(property, DecoratorNames.PROVIDE) || + hasDecorator(property, DecoratorNames.CONSUME) || + hasDecorator(property, DecoratorNames.LINK) || + hasDecorator(property, DecoratorNames.LOCAL_STORAGE_LINK) || + hasDecorator(property, DecoratorNames.LINK); + const useSyncedProperty: boolean = + hasDecorator(property, DecoratorNames.PROP) || + hasDecorator(property, DecoratorNames.STORAGE_PROP) || + hasDecorator(property, DecoratorNames.LOCAL_STORAGE_PROP) || + hasDecorator(property, DecoratorNames.OBJECT_LINK); + if (useMutableState) { + return 'MutableState'; + } else if (useSyncedProperty) { + return 'SyncedProperty'; + } else { + return ''; + } +} diff --git a/arkui-plugins/ui-plugins/struct-translators/factory.ts b/arkui-plugins/ui-plugins/struct-translators/factory.ts new file mode 100644 index 000000000..4b2d08594 --- /dev/null +++ b/arkui-plugins/ui-plugins/struct-translators/factory.ts @@ -0,0 +1,277 @@ +/* + * Copyright (C) 2025 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 * as arkts from '@koalaui/libarkts'; +import { CustomComponentNames, Dollars } from '../utils'; +import { factory as uiFactory } from '../ui-factory'; +import { annotation } from '../../common/arkts-utils'; + +export class factory { + /* + * create `constructor() {}`. + */ + static createConstructorMethod(member: arkts.MethodDefinition): arkts.MethodDefinition { + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_CONSTRUCTOR, + member.name, + arkts.factory.createFunctionExpression(member.scriptFunction), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR, + false + ); + } + + /* + * create _build menthod. + */ + static transformBuildMethodWithOriginBuild( + method: arkts.MethodDefinition, + typeName: string, + optionsName: string, + isDecl?: boolean + ): arkts.MethodDefinition { + const updateKey: arkts.Identifier = arkts.factory.createIdentifier(CustomComponentNames.COMPONENT_BUILD); + + const scriptFunction: arkts.ScriptFunction = method.scriptFunction; + const updateScriptFunction = arkts.factory + .createScriptFunction( + scriptFunction.body, + arkts.FunctionSignature.createFunctionSignature( + scriptFunction.typeParams, + [ + uiFactory.createStyleParameter(typeName), + uiFactory.createContentParameter(), + uiFactory.createInitializersOptionsParameter(optionsName), + ], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + scriptFunction.flags, + scriptFunction.modifiers + ) + .setAnnotations([annotation('memo')]); + + const modifiers: arkts.Es2pandaModifierFlags = isDecl + ? arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_ABSTRACT + : arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC; + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + updateKey, + arkts.factory.createFunctionExpression(updateScriptFunction), + modifiers, + false + ); + } + + /* + * generate _r() or _rawfile(). + */ + static generateTransformedResource( + resourceNode: arkts.CallExpression, + newArgs: arkts.AstNode[] + ): arkts.CallExpression { + const transformedKey: string = + resourceNode.expression.dumpSrc() === Dollars.DOLLAR_RESOURCE ? '_r' : '_rawfile'; + return arkts.factory.updateCallExpression( + resourceNode, + arkts.factory.createIdentifier(transformedKey), + resourceNode.typeArguments, + newArgs + ); + } + + /* + * create __initializeStruct menthod. + */ + static createInitializeStruct( + structInfo: arkts.StructInfo, + optionsTypeName: string, + isDecl?: boolean + ): arkts.MethodDefinition { + const updateKey: arkts.Identifier = arkts.factory.createIdentifier( + CustomComponentNames.COMPONENT_INITIALIZE_STRUCT + ); + + let body: arkts.BlockStatement | undefined; + let modifiers: arkts.Es2pandaModifierFlags = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_ABSTRACT; + if (!isDecl) { + body = arkts.factory.createBlock(structInfo.initializeBody); + modifiers = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC; + } + const scriptFunction: arkts.ScriptFunction = arkts.factory + .createScriptFunction( + body, + arkts.FunctionSignature.createFunctionSignature( + undefined, + [uiFactory.createInitializersOptionsParameter(optionsTypeName), uiFactory.createContentParameter()], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_METHOD, + modifiers + ) + .setIdent(updateKey); + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + updateKey, + arkts.factory.createFunctionExpression(scriptFunction), + modifiers, + false + ); + } + + /* + * create __updateStruct menthod. + */ + static createUpdateStruct( + structInfo: arkts.StructInfo, + optionsTypeName: string, + isDecl?: boolean + ): arkts.MethodDefinition { + const updateKey: arkts.Identifier = arkts.factory.createIdentifier( + CustomComponentNames.COMPONENT_UPDATE_STRUCT + ); + + let body: arkts.BlockStatement | undefined; + let modifiers: arkts.Es2pandaModifierFlags = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_ABSTRACT; + if (!isDecl) { + body = arkts.factory.createBlock(structInfo.updateBody); + modifiers = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC; + } + + const scriptFunction: arkts.ScriptFunction = arkts.factory + .createScriptFunction( + body, + arkts.FunctionSignature.createFunctionSignature( + undefined, + [uiFactory.createInitializersOptionsParameter(optionsTypeName)], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_METHOD, + modifiers + ) + .setIdent(updateKey); + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + updateKey, + arkts.factory.createFunctionExpression(scriptFunction), + modifiers, + false + ); + } + + /* + * create __toRecord menthod when the component is decorated with @Reusable. + */ + static toRecord(optionsTypeName: string, toRecordBody: arkts.Property[]): arkts.MethodDefinition { + const paramsCasted = factory.generateParamsCasted(optionsTypeName); + const returnRecord = arkts.factory.createReturnStatement( + arkts.ObjectExpression.createObjectExpression( + arkts.Es2pandaAstNodeType.AST_NODE_TYPE_OBJECT_EXPRESSION, + toRecordBody, + false + ) + ); + const body: arkts.BlockStatement = arkts.factory.createBlock([paramsCasted, returnRecord]); + + const params = arkts.ETSParameterExpression.create( + arkts.factory.createIdentifier('params', factory.generateTypeReferenceWithTypeName('Object')), + undefined + ); + + const toRecordScriptFunction = arkts.factory.createScriptFunction( + body, + arkts.FunctionSignature.createFunctionSignature(undefined, [params], factory.generateTypeRecord(), false), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_METHOD, + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC + ); + + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_CONSTRUCTOR, + arkts.factory.createIdentifier('__toRecord'), + arkts.factory.createFunctionExpression(toRecordScriptFunction), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_OVERRIDE, + false + ); + } + + /* + * generate `const paramsCasted = (params as )`. + */ + static generateParamsCasted(optionsTypeName: string): arkts.VariableDeclaration { + return arkts.factory.createVariableDeclaration( + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_NONE, + arkts.Es2pandaVariableDeclarationKind.VARIABLE_DECLARATION_KIND_CONST, + [ + arkts.factory.createVariableDeclarator( + arkts.Es2pandaVariableDeclaratorFlag.VARIABLE_DECLARATOR_FLAG_CONST, + arkts.factory.createIdentifier('paramsCasted'), + arkts.TSAsExpression.createTSAsExpression( + arkts.factory.createIdentifier('params'), + factory.generateTypeReferenceWithTypeName(optionsTypeName), + false + ) + ), + ] + ); + } + + /* + * generate Record type. + */ + static generateTypeRecord(): arkts.ETSTypeReference { + return arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier('Record'), + arkts.factory.createTSTypeParameterInstantiation([ + factory.generateTypeReferenceWithTypeName('string'), + factory.generateTypeReferenceWithTypeName('Object'), + ]) + ) + ); + } + + /* + * create type reference with type name, e.g. number. + */ + static generateTypeReferenceWithTypeName(typeName: string): arkts.ETSTypeReference { + return arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart(arkts.factory.createIdentifier(typeName)) + ); + } + + /* + * create type reference with type name, e.g. number. + */ + static updateCustomComponentClass( + definition: arkts.ClassDefinition, + members: arkts.AstNode[] + ): arkts.ClassDefinition { + return arkts.factory.updateClassDefinition( + definition, + definition.ident, + definition.typeParams, + definition.superTypeParams, + definition.implements, + undefined, + definition.super, + members, + definition.modifiers, + arkts.classDefinitionFlags(definition) + ); + } +} diff --git a/arkui-plugins/ui-plugins/struct-translators/struct-transformer.ts b/arkui-plugins/ui-plugins/struct-translators/struct-transformer.ts new file mode 100644 index 000000000..b280b0ad5 --- /dev/null +++ b/arkui-plugins/ui-plugins/struct-translators/struct-transformer.ts @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2022-2025 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 * as arkts from '@koalaui/libarkts'; +import { AbstractVisitor } from '../../common/abstract-visitor'; +import { annotation, collect, filterDefined } from '../../common/arkts-utils'; +import { ProjectConfig } from '../../common/plugin-context'; +import { classifyProperty, PropertyTranslator } from '../property-translators'; +import { + CustomComponentNames, + getCustomComponentOptionsName, + getTypeNameFromTypeParameter, + getTypeParamsFromClassDecl, +} from '../utils'; +import { isCustomComponentClass, isKnownMethodDefinition, isEtsGlobalClass, isReourceNode } from './utils'; +import { factory as uiFactory } from '../ui-factory'; +import { factory } from './factory'; +import { isEntryWrapperClass } from '../entry-translators/utils'; +import { factory as entryFactory } from '../entry-translators/factory'; +import { DecoratorNames, hasDecorator } from '../property-translators/utils'; +import { ScopeInfo } from './utils'; + +function tranformPropertyMembers( + className: string, + propertyTranslators: PropertyTranslator[], + optionsTypeName: string, + isDecl?: boolean, + scope?: ScopeInfo +): arkts.AstNode[] { + const propertyMembers = propertyTranslators.map((translator) => translator.translateMember()); + const currentStructInfo: arkts.StructInfo = arkts.GlobalInfo.getInfoInstance().getStructInfo(className); + const collections = []; + if (!scope?.hasInitializeStruct) { + collections.push(factory.createInitializeStruct(currentStructInfo, optionsTypeName, isDecl)); + } + if (!scope?.hasUpdateStruct) { + collections.push(factory.createUpdateStruct(currentStructInfo, optionsTypeName, isDecl)); + } + if (currentStructInfo.isReusable) { + collections.push(factory.toRecord(optionsTypeName, currentStructInfo.toRecordBody)); + } + return collect(...collections, ...propertyMembers); +} + +function transformEtsGlobalClassMembers(node: arkts.ClassDeclaration): arkts.ClassDeclaration { + if (!node.definition) { + return node; + } + node.definition.body.map((member: arkts.AstNode) => { + if (arkts.isMethodDefinition(member) && hasDecorator(member, DecoratorNames.BUILDER)) { + member.scriptFunction.setAnnotations([annotation('memo')]); + } + return member; + }); + return node; +} + +function transformOtherMembersInClass( + member: arkts.AstNode, + classTypeName: string | undefined, + classOptionsName: string | undefined, + className: string, + isDecl?: boolean +): arkts.AstNode { + if (arkts.isMethodDefinition(member) && hasDecorator(member, DecoratorNames.BUILDER)) { + member.scriptFunction.setAnnotations([annotation('memo')]); + return member; + } + if ( + arkts.isMethodDefinition(member) && + isKnownMethodDefinition(member, CustomComponentNames.COMPONENT_CONSTRUCTOR_ORI) && + !isDecl + ) { + return uiFactory.createConstructorMethod(member); + } + if (arkts.isMethodDefinition(member) && isKnownMethodDefinition(member, CustomComponentNames.COMPONENT_BUILD_ORI)) { + return factory.transformBuildMethodWithOriginBuild( + member, + classTypeName ?? className, + classOptionsName ?? getCustomComponentOptionsName(className), + isDecl + ); + } + return member; +} + +function tranformClassMembers( + node: arkts.ClassDeclaration, + isDecl?: boolean, + scope?: ScopeInfo +): arkts.ClassDeclaration { + if (!node.definition) { + return node; + } + + let classTypeName: string | undefined; + let classOptionsName: string | undefined; + if (isDecl) { + const [classType, classOptions] = getTypeParamsFromClassDecl(node); + classTypeName = getTypeNameFromTypeParameter(classType); + classOptionsName = getTypeNameFromTypeParameter(classOptions); + } + const definition: arkts.ClassDefinition = node.definition; + const className: string | undefined = node.definition.ident?.name; + if (!className) { + throw new Error('Non Empty className expected for Component'); + } + + const propertyTranslators: PropertyTranslator[] = filterDefined( + definition.body.map((it) => classifyProperty(it, className)) + ); + const translatedMembers: arkts.AstNode[] = tranformPropertyMembers( + className, + propertyTranslators, + classOptionsName ?? getCustomComponentOptionsName(className), + isDecl, + scope + ); + const updateMembers: arkts.AstNode[] = definition.body + .filter((member) => !arkts.isClassProperty(member)) + .map((member: arkts.AstNode) => + transformOtherMembersInClass(member, classTypeName, classOptionsName, className, isDecl) + ); + + const updateClassDef: arkts.ClassDefinition = factory.updateCustomComponentClass(definition, [ + ...translatedMembers, + ...updateMembers, + ]); + return arkts.factory.updateClassDeclaration(node, updateClassDef); +} + +function transformResource( + resourceNode: arkts.CallExpression, + projectConfig: ProjectConfig | undefined +): arkts.CallExpression { + const newArgs: arkts.AstNode[] = [ + arkts.factory.create1StringLiteral(projectConfig?.bundleName ? projectConfig.bundleName : ''), + arkts.factory.create1StringLiteral(projectConfig?.moduleName ? projectConfig.moduleName : ''), + ...resourceNode.arguments, + ]; + return factory.generateTransformedResource(resourceNode, newArgs); +} + +export class StructTransformer extends AbstractVisitor { + private scopeInfos: ScopeInfo[] = []; + projectConfig: ProjectConfig | undefined; + + constructor(projectConfig: ProjectConfig | undefined) { + super(); + this.projectConfig = projectConfig; + } + + reset(): void { + super.reset(); + this.scopeInfos = []; + } + + enter(node: arkts.AstNode): void { + if (arkts.isClassDeclaration(node) && isCustomComponentClass(node)) { + this.scopeInfos.push({ name: node.definition!.ident!.name }); + } + if (arkts.isMethodDefinition(node) && this.scopeInfos.length > 0) { + const name = node.name.name; + const scopeInfo = this.scopeInfos.pop()!; + scopeInfo.hasInitializeStruct ||= name === CustomComponentNames.COMPONENT_INITIALIZE_STRUCT; + scopeInfo.hasUpdateStruct ||= name === CustomComponentNames.COMPONENT_UPDATE_STRUCT; + scopeInfo.hasReusableRebind ||= name === CustomComponentNames.REUSABLE_COMPONENT_REBIND_STATE; + this.scopeInfos.push(scopeInfo); + } + } + + exit(node: arkts.AstNode): void { + if (arkts.isClassDeclaration(node) && isCustomComponentClass(node)) { + this.scopeInfos.pop(); + } + } + + visitor(beforeChildren: arkts.AstNode): arkts.AstNode { + this.enter(beforeChildren); + const node = this.visitEachChild(beforeChildren); + if (arkts.isClassDeclaration(node) && isCustomComponentClass(node)) { + let scope: ScopeInfo | undefined; + if (this.scopeInfos.length > 0) { + scope = this.scopeInfos[this.scopeInfos.length - 1]; + } + const newClass: arkts.ClassDeclaration = tranformClassMembers( + node, + arkts.hasModifierFlag(node, arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_DECLARE), + scope + ); + this.exit(beforeChildren); + return newClass; + } else if (isEntryWrapperClass(node)) { + entryFactory.addMemoToEntryWrapperClassMethods(node); + return node; + } else if (arkts.isClassDeclaration(node) && isEtsGlobalClass(node)) { + return transformEtsGlobalClassMembers(node); + } else if (arkts.isCallExpression(node) && isReourceNode(node)) { + return transformResource(node, this.projectConfig); + } + return node; + } +} diff --git a/arkui-plugins/ui-plugins/struct-translators/utils.ts b/arkui-plugins/ui-plugins/struct-translators/utils.ts new file mode 100644 index 000000000..502917ecf --- /dev/null +++ b/arkui-plugins/ui-plugins/struct-translators/utils.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; +import { Dollars } from '../utils'; +import { CustomComponentNames } from '../utils'; + +export type ScopeInfo = { + name: string; + hasInitializeStruct?: boolean; + hasUpdateStruct?: boolean; + hasReusableRebind?: boolean; +}; + +/** + * Determine whether it is a custom component. + * + * @param node class declaration node + */ +export function isCustomComponentClass(node: arkts.ClassDeclaration): boolean { + if (!node.definition?.ident?.name) { + return false; + } + const name: string = node.definition.ident.name; + const structCollection: Set = arkts.GlobalInfo.getInfoInstance().getStructCollection(); + return name === CustomComponentNames.COMPONENT_CLASS_NAME || structCollection.has(name); +} + +/** + * Determine whether it is method with specified name. + * + * @param method method definition node + * @param name specified method name + */ +export function isKnownMethodDefinition(method: arkts.MethodDefinition, name: string): boolean { + if (!method || !arkts.isMethodDefinition(method)) { + return false; + } + + // For now, we only considered matched method name. + const isNameMatched: boolean = method.name?.name === name; + return isNameMatched; +} + +/** + * Determine whether it is ETSGLOBAL class. + * + * @param node class declaration node + */ +export function isEtsGlobalClass(node: arkts.ClassDeclaration): boolean { + if (node.definition?.ident?.name === 'ETSGLOBAL') { + return true; + } + return false; +} + +/** + * Determine whether it is resource node begin with '$r' or '$rawfile'. + * + * @param node call expression node + */ +export function isReourceNode(node: arkts.CallExpression): boolean { + if (node.expression.dumpSrc() === Dollars.DOLLAR_RESOURCE || node.expression.dumpSrc() === Dollars.DOLLAR_RAWFILE) { + return true; + } + return false; +} diff --git a/arkui-plugins/ui-plugins/ui-factory.ts b/arkui-plugins/ui-plugins/ui-factory.ts new file mode 100644 index 000000000..3c0c59e6b --- /dev/null +++ b/arkui-plugins/ui-plugins/ui-factory.ts @@ -0,0 +1,229 @@ +/* + * Copyright (C) 2025 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 * as arkts from '@koalaui/libarkts'; +import { BuilderLambdaNames, CustomComponentNames } from './utils'; +import { annotation } from '../common/arkts-utils'; + +export class factory { + /** + * create `instance: ` as identifier + */ + static createInstanceIdentifier(typeName: string): arkts.Identifier { + return arkts.factory.createIdentifier( + BuilderLambdaNames.STYLE_ARROW_PARAM_NAME, + factory.createTypeReferenceFromString(typeName) + ); + } + + /** + * create `instance: ` as parameter + */ + static createInstanceParameter(typeName: string): arkts.ETSParameterExpression { + return arkts.factory.createParameterDeclaration(factory.createInstanceIdentifier(typeName), undefined); + } + + /** + * create `(instance: ) => void` + */ + static createStyleLambdaFunctionType(typeName: string): arkts.ETSFunctionType { + return arkts.factory.createFunctionType( + arkts.FunctionSignature.createFunctionSignature( + undefined, + [factory.createInstanceParameter(typeName)], + factory.createTypeReferenceFromString(typeName), + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW + ); + } + + /** + * create `style: ((instance: ) => void) | undefined` as identifier + */ + static createStyleIdentifier(typeName: string): arkts.Identifier { + return arkts.factory.createIdentifier( + BuilderLambdaNames.STYLE_PARAM_NAME, + arkts.factory.createUnionType([ + factory.createStyleLambdaFunctionType(typeName), + arkts.factory.createETSUndefinedType(), + ]) + ); + } + + /** + * create `@memo() style: ((instance: ) => void) | undefined` as parameter + */ + static createStyleParameter(typeName: string): arkts.ETSParameterExpression { + const styleParam: arkts.Identifier = factory.createStyleIdentifier(typeName); + const param = arkts.factory.createParameterDeclaration(styleParam, undefined); + param.annotations = [annotation('memo')]; + return param; + } + + /** + * create `initializers: | undefined` as identifier + */ + static createInitializerOptionsIdentifier(optionsName: string): arkts.Identifier { + return arkts.factory.createIdentifier( + CustomComponentNames.COMPONENT_INITIALIZERS_NAME, + arkts.factory.createUnionType([ + factory.createTypeReferenceFromString(optionsName), + arkts.factory.createETSUndefinedType(), + ]) + ); + } + + /** + * create `initializers: | undefined` as parameter + */ + static createInitializersOptionsParameter(optionsName: string): arkts.ETSParameterExpression { + return arkts.factory.createParameterDeclaration( + factory.createInitializerOptionsIdentifier(optionsName), + undefined + ); + } + + /** + * create `content: (() => void) | undefined` as identifier + */ + static createContentIdentifier(): arkts.Identifier { + return arkts.factory.createIdentifier( + BuilderLambdaNames.CONTENT_PARAM_NAME, + arkts.factory.createUnionType([factory.createLambdaFunctionType(), arkts.factory.createETSUndefinedType()]) + ); + } + + /** + * create `@memo() content: (() => void) | undefined` as parameter + */ + static createContentParameter(): arkts.ETSParameterExpression { + const contentParam: arkts.Identifier = factory.createContentIdentifier(); + const param = arkts.factory.createParameterDeclaration(contentParam, undefined); + param.annotations = [annotation('memo')]; + return param; + } + + /** + * create type from string + */ + static createTypeReferenceFromString(name: string): arkts.TypeNode { + return arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart(arkts.factory.createIdentifier(name)) + ); + } + + /** + * create `() => `. If returnType is not given, then using `void`. + */ + static createLambdaFunctionType( + params?: arkts.Expression[], + returnType?: arkts.TypeNode | undefined + ): arkts.ETSFunctionType { + return arkts.factory.createFunctionType( + arkts.FunctionSignature.createFunctionSignature( + undefined, + params ?? [], + returnType ?? arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + arkts.Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_ARROW + ); + } + + /** + * create and insert `import { as } from ` to the top of script's statements. + */ + static createAndInsertImportDeclaration( + source: arkts.StringLiteral, + imported: arkts.Identifier, + local: arkts.Identifier, + importKind: arkts.Es2pandaImportKinds, + program: arkts.Program + ): void { + const importDecl: arkts.ETSImportDeclaration = arkts.factory.createImportDeclaration( + source, + [arkts.factory.createImportSpecifier(imported, local)], + importKind + ); + arkts.importDeclarationInsert(importDecl, program); + return; + } + + /* + * create `import { as } ...`. + */ + static createAdditionalImportSpecifier(imported: string, local: string): arkts.ImportSpecifier { + return arkts.factory.createImportSpecifier( + arkts.factory.createIdentifier(imported), + arkts.factory.createIdentifier(local) + ); + } + + /* + * create `constructor() {}`. + */ + static createConstructorMethod(member: arkts.MethodDefinition): arkts.MethodDefinition { + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_CONSTRUCTOR, + member.name, + arkts.factory.createFunctionExpression(member.scriptFunction), + arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_CONSTRUCTOR, + false + ); + } + + /* + * create `@memo() _build(<>)`. + */ + static transformBuildMethodWithOriginBuild( + method: arkts.MethodDefinition, + typeName: string, + optionsName: string, + isDecl?: boolean + ): arkts.MethodDefinition { + const updateKey: arkts.Identifier = arkts.factory.createIdentifier(CustomComponentNames.COMPONENT_BUILD); + + const scriptFunction: arkts.ScriptFunction = method.scriptFunction; + const updateScriptFunction = arkts.factory + .createScriptFunction( + scriptFunction.body, + arkts.FunctionSignature.createFunctionSignature( + scriptFunction.typeParams, + [ + factory.createStyleParameter(typeName), + factory.createContentParameter(), + factory.createInitializersOptionsParameter(optionsName), + ], + arkts.factory.createPrimitiveType(arkts.Es2pandaPrimitiveType.PRIMITIVE_TYPE_VOID), + false + ), + scriptFunction.flags, + scriptFunction.modifiers + ) + .setAnnotations([annotation('memo')]); + + const modifiers: arkts.Es2pandaModifierFlags = isDecl + ? arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_ABSTRACT + : arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_PUBLIC; + return arkts.factory.createMethodDefinition( + arkts.Es2pandaMethodDefinitionKind.METHOD_DEFINITION_KIND_METHOD, + updateKey, + arkts.factory.createFunctionExpression(updateScriptFunction), + modifiers, + false + ); + } +} diff --git a/arkui-plugins/ui-plugins/utils.ts b/arkui-plugins/ui-plugins/utils.ts new file mode 100644 index 000000000..c73d54b14 --- /dev/null +++ b/arkui-plugins/ui-plugins/utils.ts @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2025 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 * as arkts from '@koalaui/libarkts'; + +export enum CustomComponentNames { + ENTRY_ANNOTATION_NAME = 'Entry', + COMPONENT_ANNOTATION_NAME = 'Component', + RESUABLE_ANNOTATION_NAME = 'Reusable', + COMPONENT_BUILD_ORI = 'build', + COMPONENT_CONSTRUCTOR_ORI = 'constructor', + COMPONENT_DEFAULT_IMPORT = '@ohos.arkui.component', + COMPONENT_CLASS_NAME = 'CustomComponent', + COMPONENT_INTERFACE_PREFIX = '__Options_', + COMPONENT_INITIALIZE_STRUCT = '__initializeStruct', + COMPONENT_UPDATE_STRUCT = '__updateStruct', + COMPONENT_BUILD = '_build', + REUSABLE_COMPONENT_REBIND_STATE = '__rebindStates', + COMPONENT_INITIALIZERS_NAME = 'initializers', + BUILDCOMPATIBLENODE = '_buildCompatibleNode', + OPTIONS = 'options', +} + +export enum BuilderLambdaNames { + ANNOTATION_NAME = 'ComponentBuilder', + ORIGIN_METHOD_NAME = '$_instantiate', + TRANSFORM_METHOD_NAME = '_instantiateImpl', + STYLE_PARAM_NAME = 'style', + STYLE_ARROW_PARAM_NAME = 'instance', + CONTENT_PARAM_NAME = 'content', +} + +export enum Dollars { + DOLLAR_RESOURCE = '$r', + DOLLAR_RAWFILE = '$rawfile', + DOLLAR_DOLLAR = '$$', +} + +export function findLocalImport( + node: arkts.ETSImportDeclaration, + sourceName: string, + importedName: string +): arkts.Identifier | undefined { + const isFromSource = !!node.source && node.source.str === sourceName; + if (!isFromSource) return undefined; + + const importSpecifier = node.specifiers.find( + (spec) => arkts.isImportSpecifier(spec) && !!spec.imported && spec.imported.name === importedName + ) as arkts.ImportSpecifier | undefined; + return importSpecifier?.local ?? importSpecifier?.imported; +} + +// TODO: currently, we forcely assume initializerOptions is named in pattern __Options_xxx +export function getCustomComponentNameFromInitializerOptions(name: string): string | undefined { + const prefix: string = CustomComponentNames.COMPONENT_INTERFACE_PREFIX; + if (name.startsWith(prefix)) { + return name.substring(prefix.length); + } +} + +export function getCustomComponentOptionsName(className: string): string { + return `${CustomComponentNames.COMPONENT_INTERFACE_PREFIX}${className}`; +} + +export function isStatic(node: arkts.AstNode): boolean { + return node.isStatic; +} + +export function getTypeParamsFromClassDecl(node: arkts.ClassDeclaration | undefined): readonly arkts.TSTypeParameter[] { + return node?.definition?.typeParams?.params ?? []; +} + +export function getTypeNameFromTypeParameter(node: arkts.TSTypeParameter | undefined): string | undefined { + return node?.name?.name; +} + +export function createOptionalClassProperty( + name: string, + property: arkts.ClassProperty, + stageManagementIdent: string, + modifiers: arkts.Es2pandaModifierFlags +): arkts.ClassProperty { + const newProperty = arkts.factory.createClassProperty( + arkts.factory.createIdentifier(name), + undefined, + stageManagementIdent.length + ? createStageManagementType(stageManagementIdent, property) + : property.typeAnnotation?.clone(), + modifiers, + false + ); + return arkts.classPropertySetOptional(newProperty, true); +} + +export function createStageManagementType( + stageManagementIdent: string, + property: arkts.ClassProperty +): arkts.ETSTypeReference { + return arkts.factory.createTypeReference( + arkts.factory.createTypeReferencePart( + arkts.factory.createIdentifier(stageManagementIdent), + arkts.factory.createTSTypeParameterInstantiation([ + property.typeAnnotation ? property.typeAnnotation.clone() : arkts.factory.createETSUndefinedType(), + ]) + ) + ); +} diff --git a/koala-wrapper/.gitignore b/koala-wrapper/.gitignore new file mode 100644 index 000000000..63c762360 --- /dev/null +++ b/koala-wrapper/.gitignore @@ -0,0 +1,5 @@ +build/ +**/*/build/ +node_modules/ + +package-lock.json diff --git a/koala-wrapper/.gitlab-ci.yml b/koala-wrapper/.gitlab-ci.yml new file mode 100644 index 000000000..b2c7957b2 --- /dev/null +++ b/koala-wrapper/.gitlab-ci.yml @@ -0,0 +1,96 @@ +# Copyright (c) 2022-2025 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. + +regenerate plugin-api: + interruptible: true + stage: build + extends: .linux-vm-shell-task + before_script: + - !reference [ .setup, script ] + - cd arkoala-arkts/libarkts + - npm run panda:sdk:install + script: + - npm run regenerate + needs: + - install node modules (arkoala-arkts) + - install node modules (incremental) + - install node modules (interop) + +build plugin-api: + interruptible: true + stage: build + extends: .linux-vm-shell-task + before_script: + - !reference [ .setup, script ] + - cd arkoala-arkts/libarkts + - npm run panda:sdk:install + - npm run regenerate + script: + - npm run compile + needs: + - install node modules (arkoala-arkts) + - install node modules (incremental) + - install node modules (interop) + - regenerate plugin-api + +test plugin-api: + interruptible: true + stage: test + extends: .linux-vm-shell-task + before_script: + - !reference [ .setup, script ] + - cd arkoala-arkts/libarkts + - npm run panda:sdk:install + - npm run regenerate + script: + - npm run test + needs: + - install node modules (arkoala-arkts) + - install node modules (incremental) + - install node modules (interop) + - regenerate plugin-api + +test example arkts-plugin: + interruptible: true + stage: test + extends: .linux-vm-shell-task + before_script: + - !reference [ .setup, script ] + - cd arkoala-arkts/libarkts + - npm run panda:sdk:install + - npm run regenerate + script: + - npm run run + needs: + - install node modules (arkoala-arkts) + - install node modules (incremental) + - install node modules (interop) + +test libarkts playground: + interruptible: true + stage: test + extends: .linux-vm-shell-task + before_script: + - !reference [ .setup, script ] + - cd arkoala-arkts/libarkts + - npm run panda:sdk:install + - npm run regenerate + script: + - npm run run:playground + needs: + - install node modules (arkoala-arkts) + - install node modules (incremental) + - install node modules (interop) + - regenerate plugin-api + + diff --git a/koala-wrapper/.mocharc.json b/koala-wrapper/.mocharc.json new file mode 100644 index 000000000..62699a6cd --- /dev/null +++ b/koala-wrapper/.mocharc.json @@ -0,0 +1,11 @@ +{ + "ui": "tdd", + "spec": "./test/arkts-api/**/*.test.ts", + "extension": [ + "ts" + ], + "require": [ + "../../incremental/test-utils/scripts/register" + ], + "timeout": 10000 +} diff --git a/koala-wrapper/BUILD.gn b/koala-wrapper/BUILD.gn new file mode 100644 index 000000000..d9ad69899 --- /dev/null +++ b/koala-wrapper/BUILD.gn @@ -0,0 +1,45 @@ +# Copyright (c) 2021-2022 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("//build/ohos.gni") + +npm_path = "//prebuilts/build-tools/common/nodejs/current/bin/npm" + +action("gen_sdk_ts_wrapper") { + script = "build_ts_wrapper.py" + deps = [ "./native:es2panda" ] + args = [ + "--source_path", + rebase_path(get_path_info(".", "abspath")), + "--output_path", + rebase_path("$target_gen_dir"), + "--npm", + rebase_path(npm_path), + "--current_os", + "$current_os", + "--root_out_dir", + rebase_path(root_out_dir), + ] + + outputs = [ "$target_gen_dir" ] +} + +ohos_copy("ets2panda_koala_wrapper") { + deps = [ ":gen_sdk_ts_wrapper" ] + sources = [ rebase_path("$target_gen_dir") ] + outputs = [ target_out_dir + "/$target_name" ] + module_source_dir = target_out_dir + "/$target_name" + module_install_name = "" + subsystem_name = "developtools" + part_name = "ace_ets2bundle" +} diff --git a/koala-wrapper/arktsconfig-memo.json b/koala-wrapper/arktsconfig-memo.json new file mode 100644 index 000000000..d3645627b --- /dev/null +++ b/koala-wrapper/arktsconfig-memo.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "package0": "@koalaui/example", + "outDir": "./abc", + "baseUrl": ".", + "paths": { + "@koalaui/runtime": [ + "../memo-plugin/runtime-api" + ] + }, + "plugins": [ + { + "transform": "@koalaui/memo-plugin", + "stage": "checked" + } + ] + } +} diff --git a/koala-wrapper/arktsconfig-print-only.json b/koala-wrapper/arktsconfig-print-only.json new file mode 100644 index 000000000..2a4e2059c --- /dev/null +++ b/koala-wrapper/arktsconfig-print-only.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "outDir": "./abc", + "baseUrl": ".", + "comment": "This is a simplest config to run visitors on both stages", + "plugins": [ + { + "transform": "./plugins/build/src/printer-plugin.js", + "stage": "parsed" + }, + { + "transform": "./plugins/build/src/parsed-stage-plugin.js", + "stage": "parsed" + }, + { + "transform": "./plugins/build/src/checked-stage-plugin.js", + "stage": "checked" + } + ] + } +} diff --git a/koala-wrapper/arktsconfig.json b/koala-wrapper/arktsconfig.json new file mode 100644 index 000000000..85e9e51f6 --- /dev/null +++ b/koala-wrapper/arktsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "outDir": "./abc", + "baseUrl": ".", + "plugins": [ + { + "transform": "./plugins/build/src/printer-plugin.js", + "stage": "parsed" + }, + { + "transform": "./plugins/build/src/parsed-stage-plugin.js", + "stage": "parsed", + "arkui": "../../../arkui/src/sts" + + }, + { + "transform": "./plugins/build/src/checked-stage-plugin.js", + "stage": "checked" + } + ] + } +} diff --git a/koala-wrapper/babel.config.js b/koala-wrapper/babel.config.js new file mode 100644 index 000000000..9d68286e3 --- /dev/null +++ b/koala-wrapper/babel.config.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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. + */ + +module.exports = function(api) { + api.cache(true); + + const presets = ['@babel/typescript']; + const plugins = [ + '@babel/plugin-transform-modules-commonjs', + '@babel/plugin-proposal-class-properties', + [ + '@babel/plugin-transform-arrow-functions', + { + spec: true + } + ], + './koalaui-transform' + ]; + + return { + presets, + plugins + }; + }; + \ No newline at end of file diff --git a/koala-wrapper/build_ts_wrapper.py b/koala-wrapper/build_ts_wrapper.py new file mode 100755 index 000000000..178f8772f --- /dev/null +++ b/koala-wrapper/build_ts_wrapper.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (c) 2025 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 argparse +import os +import shutil +import subprocess +import sys +import tarfile + + +def copy_files(source_path, dest_path, is_file=False): + try: + if is_file: + os.makedirs(os.path.dirname(dest_path), exist_ok=True) + shutil.copy(source_path, dest_path) + else: + shutil.copytree(source_path, dest_path, dirs_exist_ok=True, + symlinks=True) + except Exception as err: + raise Exception("Copy files failed. Error: " + str(err)) from err + + +def run_cmd(cmd, execution_path=None): + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stdin=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=execution_path) + stdout, stderr = proc.communicate(timeout=1000) + if proc.returncode != 0: + raise Exception(stdout.decode() + stderr.decode()) + + +def build(options): + build_cmd = [options.npm, 'run', 'compile:tsc'] + run_cmd(build_cmd, options.source_path) + + +def copy_output(options): + run_cmd(['rm', '-rf', options.output_path]) + copy_files(os.path.join(options.source_path, 'build/lib'), + os.path.join(options.output_path, 'build/lib')) + + copy_files(os.path.join(options.source_path, 'koalaui'), + os.path.join(options.output_path, 'koalaui')) + + copy_files(os.path.join(options.source_path, 'package.json'), + os.path.join(options.output_path, 'package.json'), True) + + if options.current_os == "mingw" : + copy_files(os.path.join(options.root_out_dir, 'libes2panda.dll'), + os.path.join(options.output_path, 'build/native/es2panda.node'), True) + copy_files(os.path.join(options.root_out_dir, 'libes2panda.dll'), + os.path.join(options.source_path, 'build/native/es2panda.node'), True) + + if options.current_os == "linux" or options.current_os == "mac" : + copy_files(os.path.join(options.root_out_dir, 'libes2panda.node'), + os.path.join(options.output_path, 'build/native/es2panda.node'), True) + copy_files(os.path.join(options.root_out_dir, 'libes2panda.node'), + os.path.join(options.source_path, 'build/native/es2panda.node'), True) + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--npm', help='path to a npm exetuable') + parser.add_argument('--source_path', help='path to build system source') + parser.add_argument('--output_path', help='path to output') + parser.add_argument('--root_out_dir', help='path to root out') + parser.add_argument('--current_os', help='current_os') + + options = parser.parse_args() + return options + + +def main(): + options = parse_args() + + build(options) + copy_output(options) + + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file diff --git a/koala-wrapper/koalaui-transform.js b/koala-wrapper/koalaui-transform.js new file mode 100644 index 000000000..6fdfc2a03 --- /dev/null +++ b/koala-wrapper/koalaui-transform.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 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. + */ + + +module.exports = function (babel) { + const { types: t } = babel; + + function replacePath(source) { + if (source) { + const sourceValue = source.value; + const prefix = '@koalaui/'; + if (sourceValue.startsWith(prefix)) { + source.value = '#koalaui/' + sourceValue.slice(prefix.length); + } + } + } + + return { + visitor: { + ImportDeclaration(path) { + const source = path.node.source; + replacePath(source); + }, + ExportNamedDeclaration(path) { + const source = path.node.source; + replacePath(source); + }, + ExportAllDeclaration(path) { + const source = path.node.source; + replacePath(source); + } + } + }; +}; \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/bridges/ohos/chai/index.d.ts b/koala-wrapper/koalaui/common/dist/bridges/ohos/chai/index.d.ts new file mode 100644 index 000000000..05dac46d7 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/bridges/ohos/chai/index.d.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022-2025 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 interface Assert { + (expression: any, message?: string): asserts expression; + /** + * Asserts non-strict equality (==) of actual and expected. + */ + equal(actual: T, expected: T, message?: string): void; + /** + * Asserts non-strict inequality (!=) of actual and expected. + */ + notEqual(actual: T, expected: T, message?: string): void; + /** + * Asserts strict equality (===) of actual and expected. + */ + strictEqual(actual: T, expected: T, message?: string): void; + /** + * Asserts strict inequality (!==) of actual and expected. + */ + notStrictEqual(actual: T, expected: T, message?: string): void; + deepEqual(actual: any, expected: any, message?: string): void; + notDeepEqual(actual: any, expected: any, message?: string): void; + isTrue(value: any, message?: string): void; + isFalse(value: any, message?: string): void; + closeTo(actual: number, expected: number, delta: number, message?: string): void; + fail(message?: string): void; + isNull(value: any, message?: string): void; + isNotNull(value: any, message?: string): void; + instanceOf(value: any, constructor: Function, message?: string): void; + isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void; + exists(value: any, message?: string): void; + throw(fn: () => void, message?: string): void; + throws(fn: () => void, message?: string): void; + isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void; + isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void; + match(value: string, regexp: RegExp, message?: string): void; + isDefined(value: any, message?: string): void; + isUndefined(value: any, message?: string): void; + isEmpty(object: any, message?: string): void; + isNotEmpty(object: any, message?: string): void; +} +export declare var assert: Assert; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/bridges/ohos/chai/index.js b/koala-wrapper/koalaui/common/dist/bridges/ohos/chai/index.js new file mode 100644 index 000000000..d1716b7f8 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/bridges/ohos/chai/index.js @@ -0,0 +1,124 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.assert = void 0; +const hypium_1 = require("@ohos/hypium"); +// todo: the 'message' arg is ignored +exports.assert = ((expression, message) => { + (0, hypium_1.expect)(Boolean(expression)).assertTrue(); +}); +exports.assert.equal = (actual, expected, message) => { + (0, hypium_1.expect)(actual).assertEqual(expected); +}; +exports.assert.notEqual = (actual, expected, message) => { + // todo: not accurate impl, because compared values are not printed + (0, hypium_1.expect)(actual != expected).assertTrue(); +}; +exports.assert.strictEqual = (actual, expected, message) => { + // todo: not accurate impl, because compared values are not printed + (0, hypium_1.expect)(actual === expected).assertTrue(); +}; +exports.assert.notStrictEqual = (actual, expected, message) => { + // todo: not accurate impl, because compared values are not printed + (0, hypium_1.expect)(actual !== expected).assertTrue(); +}; +exports.assert.deepEqual = (actual, expected, message) => { + // todo: implement + (0, hypium_1.expect)(actual).assertEqual(actual /*expected*/); +}; +exports.assert.notDeepEqual = (actual, expected, message) => { + // todo: implement + (0, hypium_1.expect)(actual).assertEqual(actual /*expected*/); +}; +exports.assert.isTrue = (value, message) => { + (0, hypium_1.expect)(value).assertTrue(); +}; +exports.assert.isFalse = (value, message) => { + (0, hypium_1.expect)(value).assertFalse(); +}; +exports.assert.closeTo = (actual, expected, delta, message) => { + // implementation of 'assertClose' does not fit: + // expect(actual).assertClose(expected, delta) + const diff = Math.abs(actual - expected); + if (diff == delta) + (0, hypium_1.expect)(diff).assertEqual(delta); + else + (0, hypium_1.expect)(diff).assertLess(delta); +}; +exports.assert.fail = (message) => { + (0, hypium_1.expect)().assertFail(); +}; +exports.assert.isNull = (value, message) => { + (0, hypium_1.expect)(value).assertNull(); +}; +exports.assert.isNotNull = (value, message) => { + (0, hypium_1.expect)(value ? null : value).assertNull(); +}; +exports.assert.instanceOf = (value, constructor, message) => { + // todo: not accurate impl + // expect(value).assertInstanceOf(constructor.name) + (0, hypium_1.expect)(value instanceof constructor).assertTrue(); +}; +exports.assert.isAtLeast = (valueToCheck, valueToBeAtLeast, message) => { + if (valueToCheck == valueToBeAtLeast) + (0, hypium_1.expect)(valueToCheck).assertEqual(valueToBeAtLeast); + else + (0, hypium_1.expect)(valueToCheck).assertLarger(valueToBeAtLeast); +}; +exports.assert.exists = (value, message) => { + // todo: not accurate impl + (0, hypium_1.expect)(value == null).assertFalse(); +}; +exports.assert.throw = (fn, message) => { + let fnWrapper = () => { + try { + fn(); + } + catch (e) { + throw new Error("fn thrown exception"); + } + }; + (0, hypium_1.expect)(fnWrapper).assertThrowError("fn thrown exception"); +}; +exports.assert.throws = (fn, message) => { + exports.assert.throw(fn, message); +}; +exports.assert.isAbove = (valueToCheck, valueToBeAbove, message) => { + (0, hypium_1.expect)(valueToCheck).assertLarger(valueToBeAbove); +}; +exports.assert.isBelow = (valueToCheck, valueToBeBelow, message) => { + (0, hypium_1.expect)(valueToCheck).assertLess(valueToBeBelow); +}; +exports.assert.match = (value, regexp, message) => { + // todo: not accurate impl + (0, hypium_1.expect)(regexp.test(value)).assertTrue(); +}; +exports.assert.isDefined = (value, message) => { + // todo: not accurate impl + (0, hypium_1.expect)(value === undefined).assertFalse(); +}; +exports.assert.isUndefined = (value, message) => { + (0, hypium_1.expect)(value).assertUndefined(); +}; +exports.assert.isEmpty = (object, message) => { + // todo: implement + (0, hypium_1.expect)(object !== undefined).assertTrue(); +}; +exports.assert.isNotEmpty = (object, message) => { + // todo: implement + (0, hypium_1.expect)(object !== undefined).assertTrue(); +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/bridges/ohos/index.d.ts b/koala-wrapper/koalaui/common/dist/bridges/ohos/index.d.ts new file mode 100644 index 000000000..46a1ecc14 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/bridges/ohos/index.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022-2025 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 { startTests } from "./mocha"; +export * from "./chai"; +import "./mocha"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/bridges/ohos/index.js b/koala-wrapper/koalaui/common/dist/bridges/ohos/index.js new file mode 100644 index 000000000..2fcb7de3e --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/bridges/ohos/index.js @@ -0,0 +1,36 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.startTests = void 0; +var mocha_1 = require("./mocha"); +Object.defineProperty(exports, "startTests", { enumerable: true, get: function () { return mocha_1.startTests; } }); +__exportStar(require("./chai"), exports); +require("./mocha"); // globals +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/bridges/ohos/mocha/index.d.ts b/koala-wrapper/koalaui/common/dist/bridges/ohos/mocha/index.d.ts new file mode 100644 index 000000000..99c5ebee5 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/bridges/ohos/mocha/index.d.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022-2025 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 declare function startTests(generateGolden?: boolean): void; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/bridges/ohos/mocha/index.js b/koala-wrapper/koalaui/common/dist/bridges/ohos/mocha/index.js new file mode 100644 index 000000000..b95b9f3ee --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/bridges/ohos/mocha/index.js @@ -0,0 +1,47 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.startTests = void 0; +const hypium_1 = require("@ohos/hypium"); +globalThis.__OpenHarmony = true; +const suiteMap = new Map(); +suite = (title, fn) => { + suiteMap.set(title, fn); +}; +suiteSetup = (title, fn) => { + (0, hypium_1.beforeEach)(fn); +}; +test = ((title, fn) => { + (0, hypium_1.it)(fn ? title : `[SKIP] ${title}`, hypium_1.Size.MEDIUMTEST, fn ? fn : () => { }); +}); +test.skip = (title, fn) => { + (0, hypium_1.it)(`[SKIP] ${title}`, hypium_1.Size.MEDIUMTEST, () => { }); +}; +performance = { + now: () => { + return Date.now(); + } +}; +function startTests(generateGolden = false) { + globalThis.__generateGolden = generateGolden; + suiteMap.forEach((fn, title) => { + (0, hypium_1.describe)(title, function () { + fn(); + }); + }); +} +exports.startTests = startTests; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Errors.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/Errors.d.ts new file mode 100644 index 000000000..e367bc336 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Errors.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022-2025 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 declare function assertion(condition: boolean, message: string): void; +export declare function ensure(value: T | undefined, message: string): T; +//# sourceMappingURL=Errors.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Errors.js b/koala-wrapper/koalaui/common/dist/lib/src/Errors.js new file mode 100644 index 000000000..4f05c8cef --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Errors.js @@ -0,0 +1,36 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ensure = exports.assertion = void 0; +// "assert" is a reserved keyword in ArkTS :-( +function assertion(condition, message) { + if (!condition) + throw new Error(message); +} +exports.assertion = assertion; +// The unknonwn type support in ArkTS compiler is not ready yet. +// When it is ready move from +// ensure(value, message) +// to +// value ?? error(message) +// which is much more readable +function ensure(value, message) { + if (value == undefined) + throw new Error(message); + return value; +} +exports.ensure = ensure; +//# sourceMappingURL=Errors.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Finalization.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/Finalization.d.ts new file mode 100644 index 000000000..5fc9fef68 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Finalization.d.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022-2025 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 { Thunk } from "#koalaui/compat"; +export { Thunk } from "#koalaui/compat"; +export declare function finalizerRegister(target: object, thunk: Thunk): void; +export declare function finalizerRegisterWithCleaner(target: object, cleaner: () => void): void; +export declare function finalizerUnregister(target: object): void; +//# sourceMappingURL=Finalization.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Finalization.js b/koala-wrapper/koalaui/common/dist/lib/src/Finalization.js new file mode 100644 index 000000000..8b8f9e9b1 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Finalization.js @@ -0,0 +1,39 @@ +"use strict"; +/* + * Copyright (c) 2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.finalizerUnregister = exports.finalizerRegisterWithCleaner = exports.finalizerRegister = void 0; +const compat_1 = require("#koalaui/compat"); +function finalizerRegister(target, thunk) { + (0, compat_1.finalizerRegister)(target, thunk); +} +exports.finalizerRegister = finalizerRegister; +function finalizerRegisterWithCleaner(target, cleaner) { + (0, compat_1.finalizerRegister)(target, new CleanerThunk(cleaner)); +} +exports.finalizerRegisterWithCleaner = finalizerRegisterWithCleaner; +function finalizerUnregister(target) { + (0, compat_1.finalizerUnregister)(target); +} +exports.finalizerUnregister = finalizerUnregister; +class CleanerThunk { + constructor(cleaner) { + this.cleaner = cleaner; + } + clean() { + this.cleaner(); + } +} +//# sourceMappingURL=Finalization.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/KoalaProfiler.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/KoalaProfiler.d.ts new file mode 100644 index 000000000..a78eaad53 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/KoalaProfiler.d.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/compat"; +export declare class KoalaProfiler { + private static readonly map; + static nodeCreated(nodeType: int32, node: Object): void; + static nodeDisposed(nodeType: int32, node: Object): void; + static counters: KoalaProfiler | undefined; + private invalidations; + private computes; + private builds; + private nodes; + private realDraws; + private cachedDraws; + private measures; + private layouts; + private frames; + private lastTime; + private lastFPS; + private updateEnterTime; + private updateExitTime; + private updateTime; + private buildEnterTime; + private buildExitTime; + private buildTime; + private layoutEnterTime; + private layoutExitTime; + private layoutTime; + private drawEnterTime; + private drawExitTime; + private drawTime; + private updatableStates; + private mutableStates; + private computableValues; + static enable(): void; + static disable(): void; + static enabled(): boolean; + reset(): void; + report(): void; + getReport(): string; + invalidation(): void; + compute(): void; + build(): void; + node(): void; + realDraw(): void; + cachedDraw(): void; + layout(): void; + measure(): void; + frame(ms: number): void; + buildRootEnter(): void; + buildRootExit(): void; + layoutEnter(): void; + layoutExit(): void; + drawEnter(): void; + drawExit(): void; + updateSnapshotEnter(): void; + updateSnapshotExit(): void; + updateSnapshot(modified: int32, all?: int32): void; +} +//# sourceMappingURL=KoalaProfiler.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/KoalaProfiler.js b/koala-wrapper/koalaui/common/dist/lib/src/KoalaProfiler.js new file mode 100644 index 000000000..664840fdd --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/KoalaProfiler.js @@ -0,0 +1,177 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KoalaProfiler = void 0; +/** + * Adds statistics for constructing/disposing of the TreeNode instances. + * It is disabled by default because collecting such data affects performance. + */ +const DEBUG_WITH_NODE_STATS = false; +class KoalaProfiler { + constructor() { + this.invalidations = 0; + this.computes = 0; + this.builds = 0; + this.nodes = 0; + this.realDraws = 0; + this.cachedDraws = 0; + this.measures = 0; + this.layouts = 0; + this.frames = 0; + this.lastTime = 0.0; + this.lastFPS = 0; + this.updateEnterTime = 0.0; + this.updateExitTime = 0.0; + this.updateTime = 0.0; + this.buildEnterTime = 0.0; + this.buildExitTime = 0.0; + this.buildTime = 0.0; + this.layoutEnterTime = 0.0; + this.layoutExitTime = 0.0; + this.layoutTime = 0.0; + this.drawEnterTime = 0.0; + this.drawExitTime = 0.0; + this.drawTime = 0.0; + this.updatableStates = 0; + this.mutableStates = 0; + this.computableValues = 0; + } + static nodeCreated(nodeType, node) { + if (KoalaProfiler.map === undefined) + return; + let set = KoalaProfiler.map.get(nodeType); + if (set === undefined) { + set = new Set(); + KoalaProfiler.map.set(nodeType, set); + } + set.add(node); + } + static nodeDisposed(nodeType, node) { + if (KoalaProfiler.map === undefined) + return; + let set = KoalaProfiler.map.get(nodeType); + if (set === undefined) + throw new Error("node never existed"); + if (!set.delete(node)) + console.log("node is already disposed"); + } + static enable() { + KoalaProfiler.counters = new KoalaProfiler(); + } + static disable() { + KoalaProfiler.counters = undefined; + } + static enabled() { + return KoalaProfiler.counters != undefined; + } + reset() { + this.invalidations = 0; + this.computes = 0; + this.builds = 0; + this.nodes = 0; + this.realDraws = 0; + this.cachedDraws = 0; + this.layouts = 0; + this.measures = 0; + this.updateEnterTime = 0; + this.updateExitTime = 0; + this.updatableStates = 0; + this.mutableStates = 0; + this.computableValues = 0; + } + report() { + console.log(this.getReport()); + } + getReport() { + var _a; + const updateTime = Math.round(1000 * (this.updateExitTime - this.updateEnterTime)); + const buildTime = Math.round(1000 * (this.buildExitTime - this.buildEnterTime)); + const layoutTime = Math.round(1000 * (this.layoutExitTime - this.layoutEnterTime)); + const drawTime = Math.round(1000 * (this.drawExitTime - this.drawEnterTime)); + if (this.updateTime < updateTime) + this.updateTime = updateTime; + if (this.buildTime < buildTime) + this.buildTime = buildTime; + if (this.layoutTime < layoutTime) + this.layoutTime = layoutTime; + if (this.drawTime < drawTime) + this.drawTime = drawTime; + // TODO: OHOS does not properly handle \n in template literals + const array = Array.of(`invalidations: ${this.invalidations}`, `modified states: ${this.mutableStates}/${this.updatableStates} + ${this.computableValues}`, `update states (mks): ${this.updateTime} / ${updateTime}`, `build root node (mks): ${this.buildTime} / ${buildTime}`, `layout view (mks): ${this.layoutTime} / ${layoutTime}`, `draw view (mks): ${this.drawTime} / ${drawTime}`, `computes: ${this.computes}`, `builds: ${this.builds}`, `nodes: ${this.nodes}`, `realDraws: ${this.realDraws}`, `cachedDraws: ${this.cachedDraws}`, `measures: ${this.measures}`, `layouts: ${this.layouts}`, `FPS: ${this.lastFPS}`); + (_a = KoalaProfiler.map) === null || _a === void 0 ? void 0 : _a.forEach((set, kind) => { + if (set.size > 0) + array.push(kind + ":" + set.size); + }); + return array.join("\n"); + } + invalidation() { this.invalidations++; } + compute() { this.computes++; } + build() { this.builds++; } + node() { this.nodes++; } + realDraw() { this.realDraws++; } + cachedDraw() { this.cachedDraws++; } + layout() { this.layouts++; } + measure() { this.measures++; } + frame(ms) { + if (ms - this.lastTime <= 1000) { + this.frames++; + } + else { + this.lastFPS = Math.round(this.frames * 1000 / (ms - this.lastTime)); + this.frames = 1; + this.lastTime = ms; + } + } + buildRootEnter() { + this.buildEnterTime = Date.now(); + } + buildRootExit() { + this.buildExitTime = Date.now(); + } + layoutEnter() { + this.layoutEnterTime = Date.now(); + } + layoutExit() { + this.layoutExitTime = Date.now(); + } + drawEnter() { + this.drawEnterTime = Date.now(); + } + drawExit() { + this.drawExitTime = Date.now(); + } + updateSnapshotEnter() { + this.updateEnterTime = Date.now(); + } + updateSnapshotExit() { + this.updateExitTime = Date.now(); + } + updateSnapshot(modified, all) { + if (all === undefined) { + this.computableValues = modified - this.mutableStates; + } + else { + this.mutableStates = modified; + this.updatableStates = all; + } + } +} +exports.KoalaProfiler = KoalaProfiler; +KoalaProfiler.map = DEBUG_WITH_NODE_STATS + ? new Map() + : undefined; +KoalaProfiler.counters = undefined; +//# sourceMappingURL=KoalaProfiler.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/LifecycleEvent.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/LifecycleEvent.d.ts new file mode 100644 index 000000000..e72ef9fae --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/LifecycleEvent.d.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022-2025 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 declare enum LifecycleEventKind { + SHOW_FRAME = 0, + HIDE_FRAME = 1, + CLOSE_FRAME = 2, + ON_APPEAR = 3, + ON_DISAPPEAR = 4, + SHOW_COMPONENT = 5, + HIDE_COMPONENT = 6, + BACK = 7, + FOCUS_FRAME = 8, + UNFOCUS_FRAME = 9 +} +export declare class LifecycleEvent { + kind: LifecycleEventKind; + constructor(kind: LifecycleEventKind); +} +//# sourceMappingURL=LifecycleEvent.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/LifecycleEvent.js b/koala-wrapper/koalaui/common/dist/lib/src/LifecycleEvent.js new file mode 100644 index 000000000..2b1f275d8 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/LifecycleEvent.js @@ -0,0 +1,37 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.LifecycleEvent = exports.LifecycleEventKind = void 0; +var LifecycleEventKind; +(function (LifecycleEventKind) { + LifecycleEventKind[LifecycleEventKind["SHOW_FRAME"] = 0] = "SHOW_FRAME"; + LifecycleEventKind[LifecycleEventKind["HIDE_FRAME"] = 1] = "HIDE_FRAME"; + LifecycleEventKind[LifecycleEventKind["CLOSE_FRAME"] = 2] = "CLOSE_FRAME"; + LifecycleEventKind[LifecycleEventKind["ON_APPEAR"] = 3] = "ON_APPEAR"; + LifecycleEventKind[LifecycleEventKind["ON_DISAPPEAR"] = 4] = "ON_DISAPPEAR"; + LifecycleEventKind[LifecycleEventKind["SHOW_COMPONENT"] = 5] = "SHOW_COMPONENT"; + LifecycleEventKind[LifecycleEventKind["HIDE_COMPONENT"] = 6] = "HIDE_COMPONENT"; + LifecycleEventKind[LifecycleEventKind["BACK"] = 7] = "BACK"; + LifecycleEventKind[LifecycleEventKind["FOCUS_FRAME"] = 8] = "FOCUS_FRAME"; + LifecycleEventKind[LifecycleEventKind["UNFOCUS_FRAME"] = 9] = "UNFOCUS_FRAME"; +})(LifecycleEventKind = exports.LifecycleEventKind || (exports.LifecycleEventKind = {})); +class LifecycleEvent { + constructor(kind) { + this.kind = kind; + } +} +exports.LifecycleEvent = LifecycleEvent; +//# sourceMappingURL=LifecycleEvent.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/MarkableQueue.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/MarkableQueue.d.ts new file mode 100644 index 000000000..075ed627f --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/MarkableQueue.d.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022-2025 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 interface MarkableQueue { + /** Sets the new marker to the queue. */ + setMarker(): void; + /** Adds the given callback to the queue. */ + addCallback(callback: () => void): void; + /** Calls all accumulated callbacks to the latest set marker. */ + callCallbacks(): void; + /** Clears the queue. */ + clear(): void; +} +/** + * Creates a new markable queue to safely process callbacks across several threads or tasks. + * @param reversed - `true` changes the order of calling callbacks + */ +export declare function markableQueue(reversed?: boolean): MarkableQueue; +//# sourceMappingURL=MarkableQueue.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/MarkableQueue.js b/koala-wrapper/koalaui/common/dist/lib/src/MarkableQueue.js new file mode 100644 index 000000000..a956f4620 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/MarkableQueue.js @@ -0,0 +1,94 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.markableQueue = void 0; +const compat_1 = require("#koalaui/compat"); +/** + * Creates a new markable queue to safely process callbacks across several threads or tasks. + * @param reversed - `true` changes the order of calling callbacks + */ +function markableQueue(reversed = false) { + return reversed ? new ReversedQueue() : new DefaultQueue(); +} +exports.markableQueue = markableQueue; +class DefaultQueue { + constructor() { + this.last = new compat_1.AtomicRef(new Block()); + this.first = new compat_1.AtomicRef(this.last.value); + this.marker = new compat_1.AtomicRef(undefined); + } + setMarker() { + const marker = new Block(); + this.last.getAndSet(marker).next.value = marker; + this.marker.value = marker; + } + addCallback(callback) { + const block = new Block(callback); + this.last.getAndSet(block).next.value = block; + } + callCallbacks() { + var _a; + const marker = this.marker.getAndSet(undefined); + if (marker) { + let block = this.first.getAndSet(marker); + while (block !== marker) { + (_a = block.callback) === null || _a === void 0 ? void 0 : _a.call(block); + block = block.next.value; + } + } + } + clear() { + this.last.value = this.first.value; + this.marker.value = undefined; + } +} +class ReversedQueue { + constructor() { + this.last = new compat_1.AtomicRef(undefined); + this.marker = new compat_1.AtomicRef(undefined); + } + setMarker() { + const marker = new Block(); + marker.next.value = this.last.getAndSet(marker); + this.marker.value = marker; + } + addCallback(callback) { + const block = new Block(callback); + block.next.value = this.last.getAndSet(block); + } + callCallbacks() { + var _a, _b; + const marker = this.marker.getAndSet(undefined); + if (marker) { + let block = marker.next.getAndSet(undefined); + while (block) { + (_b = (_a = block).callback) === null || _b === void 0 ? void 0 : _b.call(_a); + block = block.next.value; + } + } + } + clear() { + this.last.value = undefined; + this.marker.value = undefined; + } +} +class Block { + constructor(callback) { + this.next = new compat_1.AtomicRef(undefined); + this.callback = callback; + } +} +//# sourceMappingURL=MarkableQueue.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Matrix33.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/Matrix33.d.ts new file mode 100644 index 000000000..8fff5dd79 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Matrix33.d.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-2025 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 { float32 } from "#koalaui/compat"; +export declare function mat33(array?: Float32Array): Matrix33; +export declare class Matrix33 { + readonly array: Float32Array; + constructor(array?: Float32Array); + static zero(): Matrix33; + static makeTranslate(dx: float32, dy: float32): Matrix33; + static makeScale(dx: float32, dy?: float32): Matrix33; + static makeRotate(degrees: float32, pivotX?: float32, pivotY?: float32): Matrix33; + static makeSkew(sx: float32, sy: float32): Matrix33; + makeConcat(rhs: Matrix33): Matrix33; + makeTranspose(): Matrix33; +} +//# sourceMappingURL=Matrix33.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Matrix33.js b/koala-wrapper/koalaui/common/dist/lib/src/Matrix33.js new file mode 100644 index 000000000..0c68024b3 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Matrix33.js @@ -0,0 +1,83 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Matrix33 = exports.mat33 = void 0; +const compat_1 = require("#koalaui/compat"); +function mat33(array) { + return (array == undefined) ? new Matrix33() : new Matrix33(array); +} +exports.mat33 = mat33; +const tolerance = (1.0 / (1 << 12)); +class Matrix33 { + constructor(array = new Float32Array((0, compat_1.Array_from_number)([ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 + ]))) { + this.array = array.slice(); + } + static zero() { + return new Matrix33(new Float32Array((0, compat_1.Array_from_number)([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]))); + } + static makeTranslate(dx, dy) { + return new Matrix33(new Float32Array((0, compat_1.Array_from_number)([1.0, 0.0, dx, 0.0, 1.0, dy, 0.0, 0.0, 1.0]))); + } + static makeScale(dx, dy = dx) { + return new Matrix33(new Float32Array((0, compat_1.Array_from_number)([dx, 0.0, 0.0, 0.0, dy, 0.0, 0.0, 0.0, 1.0]))); + } + static makeRotate(degrees, pivotX, pivotY) { + let rads = degrees * Math.PI / 180; + let cos = Math.cos(rads); + let sin = Math.sin(rads); + if (Math.abs(sin) <= tolerance) + sin = 0.0; + if (Math.abs(cos) <= tolerance) + cos = 0.0; + if (pivotX !== undefined && pivotY != undefined) { + let dx = pivotX - pivotX * cos + pivotY * sin; + let dy = pivotY - pivotY * cos - pivotX * sin; + return new Matrix33(new Float32Array((0, compat_1.Array_from_number)([cos, -sin, dx, sin, cos, dy, 0.0, 0.0, 1.0]))); + } + else { + return new Matrix33(new Float32Array((0, compat_1.Array_from_number)([cos, -sin, 0.0, sin, cos, 0.0, 0.0, 0.0, 1.0]))); + } + } + static makeSkew(sx, sy) { + return new Matrix33(new Float32Array((0, compat_1.Array_from_number)([1.0, sx, 0.0, sy, 1.0, 0.0, 0.0, 0.0, 1.0]))); + } + makeConcat(rhs) { + return new Matrix33(new Float32Array((0, compat_1.Array_from_number)([ + this.array[0] * rhs.array[0] + this.array[1] * rhs.array[3] + this.array[2] * rhs.array[6], + this.array[0] * rhs.array[1] + this.array[1] * rhs.array[4] + this.array[2] * rhs.array[7], + this.array[0] * rhs.array[2] + this.array[1] * rhs.array[5] + this.array[2] * rhs.array[8], + this.array[3] * rhs.array[0] + this.array[4] * rhs.array[3] + this.array[5] * rhs.array[6], + this.array[3] * rhs.array[1] + this.array[4] * rhs.array[4] + this.array[5] * rhs.array[7], + this.array[3] * rhs.array[2] + this.array[4] * rhs.array[5] + this.array[5] * rhs.array[8], + this.array[6] * rhs.array[0] + this.array[7] * rhs.array[3] + this.array[8] * rhs.array[6], + this.array[6] * rhs.array[1] + this.array[7] * rhs.array[4] + this.array[8] * rhs.array[7], + this.array[6] * rhs.array[2] + this.array[7] * rhs.array[5] + this.array[8] * rhs.array[8], + ]))); + } + makeTranspose() { + return new Matrix33(new Float32Array((0, compat_1.Array_from_number)([ + this.array[0], this.array[3], this.array[6], + this.array[1], this.array[4], this.array[7], + this.array[2], this.array[5], this.array[8] + ]))); + } +} +exports.Matrix33 = Matrix33; +//# sourceMappingURL=Matrix33.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Matrix44.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/Matrix44.d.ts new file mode 100644 index 000000000..0524b6b5a --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Matrix44.d.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2022-2025 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 { float32 } from "#koalaui/compat"; +import { Matrix33 } from "./Matrix33"; +import { Point3 } from "./Point3"; +export interface RotateOptions { + angle?: float32; + x?: float32; + y?: float32; + z?: float32; + pivotX?: float32; + pivotY?: float32; + pivotZ?: float32; +} +export interface ScaleOptions { + x?: float32; + y?: float32; + z?: float32; + pivotX?: float32; + pivotY?: float32; + pivotZ?: float32; +} +export interface TranslateOptions { + x?: float32; + y?: float32; + z?: float32; +} +export declare function mat44(array?: Float32Array): Matrix44; +/** + * 4x4 matrix with right-handed coordinate system: + * +x goes to the right + * +y goes down + * +z goes into the screen (away from the viewer) + */ +export declare class Matrix44 { + readonly array: Float32Array; + constructor(array?: Float32Array); + static identity(): Matrix44; + static zero(): Matrix44; + static lookAt(eye: Point3, center: Point3, up: Point3): Matrix44; + static perspective(depth: float32): Matrix44; + static perspectiveFov(fov: float32, near: float32, far: float32): Matrix44; + /** + * Returns new matrix, made from Matrix33. + * + * @param matrix - 3x3 matrix + * @returns the new instance of Matrix44 + * + */ + static makeFromMatrix33(matrix: Matrix33): Matrix44; + /** + * Returns new 3x3 matrix, made from this matrix by dropping the third row and the third column. + * + * @returns the new instance of Matrix33 + * + */ + asMatrix33(): Matrix33; + copy(): Matrix44; + concat(matrix: Matrix44): Matrix44; + scale(options: ScaleOptions): Matrix44; + rotate(options: RotateOptions): Matrix44; + translate(options: TranslateOptions): Matrix44; + invert(): Matrix44; + transpose(): Matrix44; + skew(x?: float32, y?: float32): Matrix44; +} +//# sourceMappingURL=Matrix44.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Matrix44.js b/koala-wrapper/koalaui/common/dist/lib/src/Matrix44.js new file mode 100644 index 000000000..4f727e450 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Matrix44.js @@ -0,0 +1,311 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Matrix44 = exports.mat44 = void 0; +const compat_1 = require("#koalaui/compat"); +const Matrix33_1 = require("./Matrix33"); +const Point3_1 = require("./Point3"); +// TODO: this is because ArkTS doesn allow interface literal instances. +class TranslateOptionsImpl { + get x() { return this._x; } + get y() { return this._y; } + get z() { return this._z; } + set x(x) { this._x = x; } + set y(y) { this._y = y; } + set z(z) { this._z = z; } + constructor(x, y, z) { + this._x = x; + this._y = y; + this._z = z; + } +} +function mat44(array) { + return (array == undefined) ? new Matrix44() : new Matrix44(array); +} +exports.mat44 = mat44; +/** + * 4x4 matrix with right-handed coordinate system: + * +x goes to the right + * +y goes down + * +z goes into the screen (away from the viewer) + */ +class Matrix44 { + constructor(array = new Float32Array((0, compat_1.Array_from_number)([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 + ]))) { + this.array = array.slice(); + } + static identity() { + return mat44(); + } + static zero() { + return mat44(new Float32Array((0, compat_1.Array_from_number)([ + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + ]))); + } + static lookAt(eye, center, up) { + const f = center.subtract(eye).normalize(); + const u = up.normalize(); + const s = f.cross(u).normalize(); + const sf = s.cross(f); + return new Matrix44(new Float32Array((0, compat_1.Array_from_number)([ + s.x, sf.x, -f.x, eye.x, + s.y, sf.y, -f.y, eye.y, + s.z, sf.z, -f.z, eye.z, + 0, 0, 0, 1, + ]))).invert(); + } + static perspective(depth) { + return new Matrix44(new Float32Array((0, compat_1.Array_from_number)([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, -1.0 / depth, 1.0, + ]))); + } + static perspectiveFov(fov, near, far) { + const denomInv = (far - near); + const halfAngle = fov * 0.5; + const cot = Math.cos(halfAngle) / Math.sin(halfAngle); + return new Matrix44(new Float32Array((0, compat_1.Array_from_number)([ + cot, 0.0, 0.0, 0.0, + 0.0, cot, 0.0, 0.0, + 0.0, 0.0, (far + near) * denomInv, 2 * far * near * denomInv, + 0.0, 0.0, -1.0, 0.0, + ]))); + } + /** + * Returns new matrix, made from Matrix33. + * + * @param matrix - 3x3 matrix + * @returns the new instance of Matrix44 + * + */ + static makeFromMatrix33(matrix) { + return new Matrix44(new Float32Array((0, compat_1.Array_from_number)([ + matrix.array[0], matrix.array[1], 0.0, matrix.array[2], + matrix.array[3], matrix.array[4], 0.0, matrix.array[5], + 0.0, 0.0, 1.0, 0.0, + matrix.array[6], matrix.array[7], 0.0, matrix.array[8] + ]))); + } + /** + * Returns new 3x3 matrix, made from this matrix by dropping the third row and the third column. + * + * @returns the new instance of Matrix33 + * + */ + asMatrix33() { + return new Matrix33_1.Matrix33(new Float32Array((0, compat_1.Array_from_number)([ + this.array[0], this.array[1], this.array[3], + this.array[4], this.array[5], this.array[7], + this.array[12], this.array[13], this.array[15] + ]))); + } + copy() { + return new Matrix44(new Float32Array((0, compat_1.Array_from_number)([ + this.array[0], this.array[1], this.array[2], this.array[3], + this.array[4], this.array[5], this.array[6], this.array[7], + this.array[8], this.array[9], this.array[10], this.array[11], + this.array[12], this.array[13], this.array[14], this.array[15] + ]))); + } + concat(matrix) { + const result = new Float32Array((0, compat_1.Array_from_number)([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + ])); + for (let row = 0; row < 4; row++) { + for (let col = 0; col < 4; col++) { + let num = 0; + for (let k = 0; k < 4; k++) { + num += this.array[row * 4 + k] * matrix.array[col + 4 * k]; + } + result[row * 4 + col] = num; + } + } + for (let i = 0; i < this.array.length; i++) { + this.array[i] = result[i]; + } + return this; + } + scale(options) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j; + const scaled = new Matrix44(); + scaled.array[0] = (_a = options.x) !== null && _a !== void 0 ? _a : 1.0; + scaled.array[5] = (_b = options.y) !== null && _b !== void 0 ? _b : 1.0; + scaled.array[10] = (_c = options.z) !== null && _c !== void 0 ? _c : 1.0; + this.translate(new TranslateOptionsImpl(-((_d = options.pivotX) !== null && _d !== void 0 ? _d : 0.0) * ((_e = options.x) !== null && _e !== void 0 ? _e : 1.0) + ((_f = options.pivotX) !== null && _f !== void 0 ? _f : 0.0), -((_g = options.pivotY) !== null && _g !== void 0 ? _g : 0.0) * ((_h = options.y) !== null && _h !== void 0 ? _h : 1.0) + ((_j = options.pivotY) !== null && _j !== void 0 ? _j : 0.0), undefined)).concat(scaled); + return this; + } + rotate(options) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; + const translationToPivot = mat44().translate(new TranslateOptionsImpl(((_a = options.pivotX) !== null && _a !== void 0 ? _a : 0.0), ((_b = options.pivotY) !== null && _b !== void 0 ? _b : 0.0), ((_c = options.pivotZ) !== null && _c !== void 0 ? _c : 0.0))); + const translationToBack = mat44().translate(new TranslateOptionsImpl(-((_d = options.pivotX) !== null && _d !== void 0 ? _d : 0.0), -((_e = options.pivotY) !== null && _e !== void 0 ? _e : 0.0), -((_f = options.pivotZ) !== null && _f !== void 0 ? _f : 0.0))); + const vec = new Point3_1.Point3((_g = options.x) !== null && _g !== void 0 ? _g : 0.0, (_h = options.y) !== null && _h !== void 0 ? _h : 0.0, (_j = options.z) !== null && _j !== void 0 ? _j : 0.0).normalize(); + const rads = ((_k = options.angle) !== null && _k !== void 0 ? _k : 0.0) * Math.PI / 180; + let c = Math.cos(rads); + let s = Math.sin(rads); + const tolerance = (1.0 / (1 << 12)); + if (Math.abs(s) <= tolerance) + s = 0.0; + if (Math.abs(c) <= tolerance) + c = 0.0; + let t = 1 - c; + const x = vec.x; + const y = vec.y; + const z = vec.z; + const rotation = mat44(); + rotation.array[0] = t * x * x + c; + rotation.array[1] = t * x * y - s * z; + rotation.array[2] = t * x * z + s * y; + rotation.array[3] = 0; + rotation.array[4] = t * x * y + s * z; + rotation.array[5] = t * y * y + c; + rotation.array[6] = t * y * z - s * x; + rotation.array[7] = 0; + rotation.array[8] = t * x * z - s * y; + rotation.array[9] = t * y * z + s * x; + rotation.array[10] = t * z * z + c; + rotation.array[11] = 0; + rotation.array[12] = 0; + rotation.array[13] = 0; + rotation.array[14] = 0; + rotation.array[15] = 1; + this.concat(translationToPivot).concat(rotation).concat(translationToBack); + return this; + } + translate(options) { + var _a, _b, _c; + this.array[3] = (_a = options.x) !== null && _a !== void 0 ? _a : 0.0; + this.array[7] = (_b = options.y) !== null && _b !== void 0 ? _b : 0.0; + this.array[11] = (_c = options.z) !== null && _c !== void 0 ? _c : 0.0; + return this; + } + invert() { + const result = new Float32Array(16); + let a00 = this.array[0]; + let a01 = this.array[1]; + let a02 = this.array[2]; + let a03 = this.array[3]; + let a10 = this.array[4]; + let a11 = this.array[5]; + let a12 = this.array[6]; + let a13 = this.array[7]; + let a20 = this.array[8]; + let a21 = this.array[9]; + let a22 = this.array[10]; + let a23 = this.array[11]; + let a30 = this.array[12]; + let a31 = this.array[13]; + let a32 = this.array[14]; + let a33 = this.array[15]; + let b00 = a00 * a11 - a01 * a10; + let b01 = a00 * a12 - a02 * a10; + let b02 = a00 * a13 - a03 * a10; + let b03 = a01 * a12 - a02 * a11; + let b04 = a01 * a13 - a03 * a11; + let b05 = a02 * a13 - a03 * a12; + let b06 = a20 * a31 - a21 * a30; + let b07 = a20 * a32 - a22 * a30; + let b08 = a20 * a33 - a23 * a30; + let b09 = a21 * a32 - a22 * a31; + let b10 = a21 * a33 - a23 * a31; + let b11 = a22 * a33 - a23 * a32; + let determinant = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + let invdet = 1.0 / determinant; + b00 *= invdet; + b01 *= invdet; + b02 *= invdet; + b03 *= invdet; + b04 *= invdet; + b05 *= invdet; + b06 *= invdet; + b07 *= invdet; + b08 *= invdet; + b09 *= invdet; + b10 *= invdet; + b11 *= invdet; + result[0] = a11 * b11 - a12 * b10 + a13 * b09; + result[1] = a02 * b10 - a01 * b11 - a03 * b09; + result[2] = a31 * b05 - a32 * b04 + a33 * b03; + result[3] = a22 * b04 - a21 * b05 - a23 * b03; + result[4] = a12 * b08 - a10 * b11 - a13 * b07; + result[5] = a00 * b11 - a02 * b08 + a03 * b07; + result[6] = a32 * b02 - a30 * b05 - a33 * b01; + result[7] = a20 * b05 - a22 * b02 + a23 * b01; + result[8] = a10 * b10 - a11 * b08 + a13 * b06; + result[9] = a01 * b08 - a00 * b10 - a03 * b06; + result[10] = a30 * b04 - a31 * b02 + a33 * b00; + result[11] = a21 * b02 - a20 * b04 - a23 * b00; + result[12] = a11 * b07 - a10 * b09 - a12 * b06; + result[13] = a00 * b09 - a01 * b07 + a02 * b06; + result[14] = a31 * b01 - a30 * b03 - a32 * b00; + result[15] = a20 * b03 - a21 * b01 + a22 * b00; + // If 1/det overflows to infinity (i.e. det is denormalized) or any of the inverted matrix + // values is non-finite, return zero to indicate a non-invertible matrix. + let prod = 0; + for (let i = 0; i < result.length; ++i) { + prod *= result[i]; + } + // At this point, prod will either be NaN or 0 + // if prod is NaN, this check will return false + if (prod == 0) { + for (let i = 0; i < this.array.length; i++) { + this.array[i] = result[i]; + } + } + return this; + } + transpose() { + const result = new Float32Array(16); + result[0] = this.array[0]; + result[1] = this.array[4]; + result[2] = this.array[8]; + result[3] = this.array[12]; + result[4] = this.array[1]; + result[5] = this.array[5]; + result[6] = this.array[9]; + result[7] = this.array[13]; + result[8] = this.array[2]; + result[9] = this.array[6]; + result[10] = this.array[10]; + result[11] = this.array[14]; + result[12] = this.array[3]; + result[13] = this.array[7]; + result[14] = this.array[11]; + result[15] = this.array[15]; + for (let i = 0; i < this.array.length; i++) { + this.array[i] = result[i]; + } + return this; + } + skew(x, y) { + this.array[1] += x !== null && x !== void 0 ? x : 0.0; + this.array[4] += y !== null && y !== void 0 ? y : 0.0; + return this; + } +} +exports.Matrix44 = Matrix44; +//# sourceMappingURL=Matrix44.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/PerfProbe.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/PerfProbe.d.ts new file mode 100644 index 000000000..7d860cc4c --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/PerfProbe.d.ts @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2022-2025 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 interface PerfProbe { + /** + * The name of the probe. + */ + readonly name: string; + /** + * Whether this is a dummy probe which does not measure (a noop). + * + * @see MainPerfProbe.getProbe + */ + readonly dummy: boolean; + /** + * Exists the probe. + * + * @param log log the gathered statistics. + * @see MainPerfProbe.enterProbe + */ + exit(log: boolean | undefined): void; + /** + * Cancels measuring the probe and its children probes. + */ + cancel(): void; + /** + * User-defined data associated with the probe. + */ + userData: string | undefined; + /** + * Whether the probe was canceled. + */ + readonly canceled: boolean; +} +/** + * The main (root) {@link PerfProbe}. + * + * This probe is used to enter the main activity. + * + * Calling {@link PerfProbe.cancel} removes the main probe and disposes all its resources. + * + * Calling {@link PerfProbe.exit} exits the main probe, cancels it and when the log option is provided + * logs the gathered statistics. + * + * @see enterMainPerfProbe + * @see getMainPerfProbe + */ +export interface MainPerfProbe extends PerfProbe { + /** + * Enters a child probe referenced by the {@link name} and measures it. + * If the probe does not exist, returns a dummy instance. + * + * If the probe already performs a recursive call is counted. + * + * @see PerfProbe.exit + * @see exitProbe + */ + enterProbe(name: string): PerfProbe; + /** + * Exits a child probe referenced by the {@link name}. + * If the probe does not exist, returns a dummy instance. + * + * This is an equivalent of calling {@link getProbe} and then {@link PerfProbe.exit}. + */ + exitProbe(name: string): PerfProbe; + /** + * Returns the child probe referenced by the {@link name} if it exists, + * otherwise a dummy instance. + * + * @see PerfProbe.dummy + */ + getProbe(name: string): PerfProbe; + /** + * Performs the {@link func} of a child probe referenced by the {@link name} and measures it. + * + * This is an equivalent of calling {@link enterProbe} and then {@link exitProbe}. + * + * If the probe already performs a recursive call is counted. + */ + performProbe(name: string, func: () => T): T; + /** + * Returns true if the probe referenced by the {@link name} has been performed + * (entered and exited all the recursive calls). + */ + probePerformed(name: string): boolean; +} +/** + * Creates a {@link MainPerfProbe} instance with the {@link name} and enters its main probe. + * + * If a {@link MainPerfProbe} with this {@link name} already exists then it is canceled and the new one is created. + * + * Exit it with {@link MainPerfProbe.exit}. + */ +export declare function enterMainPerfProbe(name: string): MainPerfProbe; +/** + * Returns {@link MainPerfProbe} instance with the {@link name} if it exists, + * otherwise a dummy instance. + * + * @see MainPerfProbe.dummy + */ +export declare function getMainPerfProbe(name: string): MainPerfProbe; +//# sourceMappingURL=PerfProbe.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/PerfProbe.js b/koala-wrapper/koalaui/common/dist/lib/src/PerfProbe.js new file mode 100644 index 000000000..06e957f97 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/PerfProbe.js @@ -0,0 +1,279 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getMainPerfProbe = exports.enterMainPerfProbe = void 0; +const compat_1 = require("#koalaui/compat"); +/** + * Creates a {@link MainPerfProbe} instance with the {@link name} and enters its main probe. + * + * If a {@link MainPerfProbe} with this {@link name} already exists then it is canceled and the new one is created. + * + * Exit it with {@link MainPerfProbe.exit}. + */ +function enterMainPerfProbe(name) { + return new MainPerfProbeImpl(name); +} +exports.enterMainPerfProbe = enterMainPerfProbe; +/** + * Returns {@link MainPerfProbe} instance with the {@link name} if it exists, + * otherwise a dummy instance. + * + * @see MainPerfProbe.dummy + */ +function getMainPerfProbe(name) { + const instance = MainPerfProbeImpl.mainProbes.get(name); + return instance ? instance : MainPerfProbeImpl.DUMMY; +} +exports.getMainPerfProbe = getMainPerfProbe; +class DummyPerfProbe { + get name() { return "dummy"; } + get dummy() { return true; } + exit(log) { } + cancel() { } + get canceled() { return false; } + enterProbe(name) { return PerfProbeImpl.DUMMY; } + exitProbe(name) { return PerfProbeImpl.DUMMY; } + getProbe(name) { return PerfProbeImpl.DUMMY; } + //performProbe: (_: string, func: () => T) => func(), + performProbe(name, func) { return func(); } + probePerformed(_) { return false; } + get userData() { + return undefined; + } + set userData(_) { } +} +class PerfProbeImpl { + constructor(name, main, parent, remainder = false) { + this.children = new Array(); + this.childrenSorted = false; + this.index = 0; + this.startTime = 0.0; + this.totalTime = 0.0; + this.callCount = 0; + this.currentRecursionDepth = 0; + this.recursiveCallCount = 0; + this._canceled = false; + this._name = name; + this._main = main; + this.parent = parent; + this.remainder = remainder; + } + get name() { + return this._name; + } + get dummy() { + return false; + } + get main() { + return this._main; + } + get performing() { + return this.startTime > 0; + } + get userData() { + return this._userData; + } + set userData(value) { + this._userData = value; + } + exit(log) { + if (this.canceled) + return; + if (this.currentRecursionDepth == 0) { + this.totalTime += (0, compat_1.timeNow)() - this.startTime; + this.startTime = 0; + } + else { + this.currentRecursionDepth--; + } + if (!this.performing) { + this.main.pop(this); + } + if (log) + this.log(); + } + cancel(cancelChildren = true) { + this._canceled = true; + if (cancelChildren) + this.maybeCancelChildren(); + } + maybeCancelChildren() { + MainPerfProbeImpl.visit(this, false, (probe, depth) => { + if (probe.performing) + probe.cancel(false); + }); + } + get canceled() { + return this._canceled; + } + toString() { + if (this.canceled) { + return `[${this.name}] canceled`; + } + if (this.performing) { + return `[${this.name}] still performing...`; + } + const mainProbe = this.main.probes.get(this.main.name); + const percentage = mainProbe.totalTime > 0 ? Math.round((100 / mainProbe.totalTime) * this.totalTime) : 0; + let result = `[${this.name}] call count: ${this.callCount}` + + ` | recursive call count: ${this.recursiveCallCount}` + + ` | time: ${this.totalTime}ms ${percentage}%`; + if (this.userData) { + result += ` | user data: ${this.userData}`; + } + return result; + } + log(prefix) { + console.log(prefix ? `${prefix}${this.toString()}` : this.toString()); + } +} +PerfProbeImpl.DUMMY = new DummyPerfProbe(); +class MainPerfProbeImpl extends PerfProbeImpl { + constructor(name) { + super(name); + this.probes = new Map(); + const prev = MainPerfProbeImpl.mainProbes.get(name); + if (prev) + prev.cancel(); + MainPerfProbeImpl.mainProbes.set(name, this); + this.currentProbe = this.enterProbe(name); + } + createProbe(name) { + const probes = name == this.name ? this : new PerfProbeImpl(name, this); + this.push(probes); + return probes; + } + get main() { + return this; + } + push(probe) { + probe.parent = this.currentProbe; + probe.index = probe.parent ? probe.parent.children.length : 0; + if (probe.parent) + probe.parent.children.push(probe); + this.currentProbe = probe; + } + pop(probe) { + if (probe.parent) { + this.currentProbe = probe.parent; + } + } + performProbe(name, func) { + const probe = this.enterProbe(name); + try { + return func(); + } + finally { + probe.exit(); + } + } + enterProbe(name) { + let probe = this.probes.get(name); + if (!probe) { + probe = this.createProbe(name); + this.probes.set(name, probe); + } + probe._canceled = false; + if (probe.performing) { + probe.recursiveCallCount++; + probe.currentRecursionDepth++; + } + else { + probe.startTime = (0, compat_1.timeNow)(); + probe.callCount++; + } + return probe; + } + exitProbe(name) { + const probe = this.getProbe(name); + probe.exit(undefined); + return probe; + } + getProbe(name) { + const probe = this.probes.get(name); + return probe !== undefined ? probe : PerfProbeImpl.DUMMY; + } + probePerformed(name) { + const probe = this.probes.get(name); + return probe != undefined && !probe.performing && !probe.canceled; + } + exit(log) { + super.exit(); + if (log) + this.log(); + this.cancel(); + } + cancel() { + MainPerfProbeImpl.mainProbes.delete(this.name); + } + static visit(root, logging, apply) { + let current = root; + let index = 0; + let depth = 0; + let visiting = true; + while (true) { + if (visiting) { + current.index = 0; + apply(current, depth); + } + if (index >= current.children.length) { + if (!current.parent) { + break; + } + current = current.parent; + index = ++current.index; + depth--; + visiting = false; + continue; + } + visiting = true; + if (logging && !current.childrenSorted) { + current.childrenSorted = true; + current.children = current.children.sort((p1, p2) => p2.totalTime - p1.totalTime); + if (depth == 0) { + // a special probe to log the time remained + current.children.push(new PerfProbeImpl("", root.main, current, true)); + } + } + current = current.children[index]; + index = 0; + depth++; + } + } + log(prefix) { + prefix = prefix !== undefined ? `${prefix}: ` : ""; + console.log(`${prefix}perf probes:`); + MainPerfProbeImpl.visit(this.main, true, (probe, depth) => { + let indent = "\t"; + for (let i = 0; i < depth; i++) + indent += "\t"; + if (probe.remainder) { + const parentTime = probe.parent.totalTime; + let childrenTime = 0; + probe.parent.children.forEach((a) => { childrenTime += a.totalTime; }); + probe.totalTime = Math.max(0, parentTime - childrenTime); + const percentage = parentTime > 0 ? Math.round((100 / parentTime) * probe.totalTime) : 0; + console.log(`${prefix}${indent}[${probe.name}] time: ${(0, compat_1.numberToFixed)(probe.totalTime, 2)}ms ${percentage}%`); + } + else { + console.log(`${prefix}${indent}${probe.toString()}`); + } + }); + } +} +MainPerfProbeImpl.mainProbes = new Map(); +MainPerfProbeImpl.DUMMY = new DummyPerfProbe(); +//# sourceMappingURL=PerfProbe.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Point.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/Point.d.ts new file mode 100644 index 000000000..f35d2561b --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Point.d.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022-2025 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 { float32 } from "#koalaui/compat"; +export declare class Point { + coordinates: Float32Array; + constructor(x: float32, y: float32); + get x(): float32; + get y(): float32; + offsetXY(dx: float32, dy: float32): Point; + offset(vec: Point): Point; + scale(scale: float32): Point; + scaleXY(sx: float32, sy: float32): Point; + static ZERO: Point; + toArray(): Float32Array; + static flattenArray(points: Array): Float32Array; + static fromArray(points: Float32Array): Array; +} +//# sourceMappingURL=Point.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Point.js b/koala-wrapper/koalaui/common/dist/lib/src/Point.js new file mode 100644 index 000000000..1b5080bfa --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Point.js @@ -0,0 +1,65 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Point = void 0; +class Point { + constructor(x, y) { + this.coordinates = new Float32Array(2); + this.coordinates[0] = x; + this.coordinates[1] = y; + } + get x() { + return this.coordinates[0]; + } + get y() { + return this.coordinates[1]; + } + offsetXY(dx, dy) { + return new Point(this.x + dx, this.y + dy); + } + offset(vec) { + return this.offsetXY(vec.x, vec.y); + } + scale(scale) { + return this.scaleXY(scale, scale); + } + scaleXY(sx, sy) { + return new Point(this.x * sx, this.y * sy); + } + toArray() { + return this.coordinates; + } + static flattenArray(points) { + let array = new Float32Array(points.length * 2); + for (let i = 0; i < points.length; i++) { + array[i * 2] = points[i].x; + array[i * 2 + 1] = points[i].y; + } + return array; + } + static fromArray(points) { + if (points.length % 2 != 0) + throw new Error("Expected " + points.length + " % 2 == 0"); + let array = new Array(points.length / 2); + for (let i = 0; i < points.length / 2; i++) { + array[i] = new Point(points[i * 2], points[i * 2 + 1]); + } + return array; + } +} +exports.Point = Point; +Point.ZERO = new Point(0.0, 0.0); +//# sourceMappingURL=Point.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Point3.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/Point3.d.ts new file mode 100644 index 000000000..d6121d56d --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Point3.d.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022-2025 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 { float32 } from "#koalaui/compat"; +export declare class Point3 { + x: float32; + y: float32; + z: float32; + constructor(x: float32, y: float32, z: float32); + subtract(value: Point3): Point3; + cross(value: Point3): Point3; + normalize(): Point3; +} +//# sourceMappingURL=Point3.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/Point3.js b/koala-wrapper/koalaui/common/dist/lib/src/Point3.js new file mode 100644 index 000000000..de748e8e1 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/Point3.js @@ -0,0 +1,41 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Point3 = void 0; +class Point3 { + constructor(x, y, z) { + this.x = x; + this.y = y; + this.z = z; + } + subtract(value) { + return new Point3(this.x - value.x, this.y - value.y, this.z - value.z); + } + cross(value) { + return new Point3(this.y * value.z - this.z * value.y, this.z * value.x - this.x * value.z, this.x * value.y - this.y * value.x); + } + normalize() { + const mag = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + const tolerance = (1.0 / (1 << 12)); + if (mag < tolerance) { + // This semicolon after return this is a workaround for ArkTS bug + return this; + } + return new Point3(this.x / mag, this.y / mag, this.z / mag); + } +} +exports.Point3 = Point3; +//# sourceMappingURL=Point3.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/index.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/index.d.ts new file mode 100644 index 000000000..8b816b3c4 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/index.d.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022-2025 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 { int8, uint8, int32, uint32, int64, uint64, float32, float64, asArray, asFloat64, float32FromBits, int32BitsFromFloat, Array_from_set, AtomicRef, CustomTextDecoder, CustomTextEncoder, className, lcClassName, functionOverValue, Observed, Observable, ObservableHandler, observableProxy, observableProxyArray, isFunction, propDeepCopy, refEqual, int8Array, unsafeCast } from "#koalaui/compat"; +export { clamp, lerp, modulo, parseNumber, isFiniteNumber, getDistancePx } from "./math"; +export { hashCodeFromString } from "./stringUtils"; +export { KoalaProfiler } from "./KoalaProfiler"; +export * from "./PerfProbe"; +export * from "./Errors"; +export * from "./LifecycleEvent"; +export * from "./Finalization"; +export * from "./MarkableQueue"; +export * from "./Matrix33"; +export * from "./Matrix44"; +export * from "./Point3"; +export * from "./Point"; +export { SHA1Hash, createSha1 } from "./sha1"; +export { UniqueId } from "./uniqueId"; +export * from "./koalaKey"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/index.js b/koala-wrapper/koalaui/common/dist/lib/src/index.js new file mode 100644 index 000000000..e50e6f07a --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/index.js @@ -0,0 +1,79 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueId = exports.createSha1 = exports.SHA1Hash = exports.KoalaProfiler = exports.hashCodeFromString = exports.getDistancePx = exports.isFiniteNumber = exports.parseNumber = exports.modulo = exports.lerp = exports.clamp = exports.unsafeCast = exports.int8Array = exports.refEqual = exports.propDeepCopy = exports.isFunction = exports.observableProxyArray = exports.observableProxy = exports.ObservableHandler = exports.Observed = exports.functionOverValue = exports.lcClassName = exports.className = exports.CustomTextEncoder = exports.CustomTextDecoder = exports.AtomicRef = exports.Array_from_set = exports.int32BitsFromFloat = exports.float32FromBits = exports.asFloat64 = exports.asArray = void 0; +var compat_1 = require("#koalaui/compat"); +Object.defineProperty(exports, "asArray", { enumerable: true, get: function () { return compat_1.asArray; } }); +Object.defineProperty(exports, "asFloat64", { enumerable: true, get: function () { return compat_1.asFloat64; } }); +Object.defineProperty(exports, "float32FromBits", { enumerable: true, get: function () { return compat_1.float32FromBits; } }); +Object.defineProperty(exports, "int32BitsFromFloat", { enumerable: true, get: function () { return compat_1.int32BitsFromFloat; } }); +Object.defineProperty(exports, "Array_from_set", { enumerable: true, get: function () { return compat_1.Array_from_set; } }); +Object.defineProperty(exports, "AtomicRef", { enumerable: true, get: function () { return compat_1.AtomicRef; } }); +Object.defineProperty(exports, "CustomTextDecoder", { enumerable: true, get: function () { return compat_1.CustomTextDecoder; } }); +Object.defineProperty(exports, "CustomTextEncoder", { enumerable: true, get: function () { return compat_1.CustomTextEncoder; } }); +Object.defineProperty(exports, "className", { enumerable: true, get: function () { return compat_1.className; } }); +Object.defineProperty(exports, "lcClassName", { enumerable: true, get: function () { return compat_1.lcClassName; } }); +Object.defineProperty(exports, "functionOverValue", { enumerable: true, get: function () { return compat_1.functionOverValue; } }); +Object.defineProperty(exports, "Observed", { enumerable: true, get: function () { return compat_1.Observed; } }); +Object.defineProperty(exports, "ObservableHandler", { enumerable: true, get: function () { return compat_1.ObservableHandler; } }); +Object.defineProperty(exports, "observableProxy", { enumerable: true, get: function () { return compat_1.observableProxy; } }); +Object.defineProperty(exports, "observableProxyArray", { enumerable: true, get: function () { return compat_1.observableProxyArray; } }); +Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return compat_1.isFunction; } }); +Object.defineProperty(exports, "propDeepCopy", { enumerable: true, get: function () { return compat_1.propDeepCopy; } }); +Object.defineProperty(exports, "refEqual", { enumerable: true, get: function () { return compat_1.refEqual; } }); +Object.defineProperty(exports, "int8Array", { enumerable: true, get: function () { return compat_1.int8Array; } }); +Object.defineProperty(exports, "unsafeCast", { enumerable: true, get: function () { return compat_1.unsafeCast; } }); +var math_1 = require("./math"); +Object.defineProperty(exports, "clamp", { enumerable: true, get: function () { return math_1.clamp; } }); +Object.defineProperty(exports, "lerp", { enumerable: true, get: function () { return math_1.lerp; } }); +Object.defineProperty(exports, "modulo", { enumerable: true, get: function () { return math_1.modulo; } }); +Object.defineProperty(exports, "parseNumber", { enumerable: true, get: function () { return math_1.parseNumber; } }); +Object.defineProperty(exports, "isFiniteNumber", { enumerable: true, get: function () { return math_1.isFiniteNumber; } }); +Object.defineProperty(exports, "getDistancePx", { enumerable: true, get: function () { return math_1.getDistancePx; } }); +var stringUtils_1 = require("./stringUtils"); +Object.defineProperty(exports, "hashCodeFromString", { enumerable: true, get: function () { return stringUtils_1.hashCodeFromString; } }); +var KoalaProfiler_1 = require("./KoalaProfiler"); +Object.defineProperty(exports, "KoalaProfiler", { enumerable: true, get: function () { return KoalaProfiler_1.KoalaProfiler; } }); +__exportStar(require("./PerfProbe"), exports); +__exportStar(require("./Errors"), exports); +__exportStar(require("./LifecycleEvent"), exports); +__exportStar(require("./Finalization"), exports); +__exportStar(require("./MarkableQueue"), exports); +__exportStar(require("./Matrix33"), exports); +__exportStar(require("./Matrix44"), exports); +__exportStar(require("./Point3"), exports); +__exportStar(require("./Point"), exports); +var sha1_1 = require("./sha1"); +Object.defineProperty(exports, "SHA1Hash", { enumerable: true, get: function () { return sha1_1.SHA1Hash; } }); +Object.defineProperty(exports, "createSha1", { enumerable: true, get: function () { return sha1_1.createSha1; } }); +var uniqueId_1 = require("./uniqueId"); +Object.defineProperty(exports, "UniqueId", { enumerable: true, get: function () { return uniqueId_1.UniqueId; } }); +__exportStar(require("./koalaKey"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/koalaKey.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/koalaKey.d.ts new file mode 100644 index 000000000..1b2e1e4ed --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/koalaKey.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/compat"; +export type KoalaCallsiteKey = int32; +export declare class KoalaCallsiteKeys { + static readonly empty: KoalaCallsiteKey; + static combine(key1: KoalaCallsiteKey, key2: KoalaCallsiteKey): KoalaCallsiteKey; + static asString(key: KoalaCallsiteKey): string; +} +//# sourceMappingURL=koalaKey.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/koalaKey.js b/koala-wrapper/koalaui/common/dist/lib/src/koalaKey.js new file mode 100644 index 000000000..458a2c260 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/koalaKey.js @@ -0,0 +1,28 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KoalaCallsiteKeys = void 0; +class KoalaCallsiteKeys { + static combine(key1, key2) { + return key1 + key2; + } + static asString(key) { + return new Number(key).toString(16); + } +} +exports.KoalaCallsiteKeys = KoalaCallsiteKeys; +KoalaCallsiteKeys.empty = 0; +//# sourceMappingURL=koalaKey.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/math.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/math.d.ts new file mode 100644 index 000000000..f114cb459 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/math.d.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022-2025 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 { float64 } from "#koalaui/compat"; +/** + * Computes the linear interpolation between `source` and `target` based on `weight`. + * + * @param weight - interpolation factor in the range [0..1] + * @param source - a value corresponding to weight 0 + * @param target - a value corresponding to weight 1 + * @returns interpolated value + */ +export declare function lerp(weight: float64, source: float64, target: float64): float64; +/** + * Clamps a {@link value} within the specified range. + * + * @param value - a value to clamp + * @param min - the lower boundary of the range + * @param max - the upper boundary of the range + * @returns `min` if `value` is less than `min`, + * `max` if `value` is greater than `max`, + * `value` otherwise + */ +export declare function clamp(value: float64, min: float64, max: float64): float64; +/** + * Calculates the difference between the argument and + * the largest (closest to positive infinity) integer value + * that is less than or equal to the argument. + * + * @param value a floating-point value to process + * @returns a floor modulus of the given value in the range [0..1) + */ +export declare function modulo(value: float64): float64; +/** + * @param str a string to parse + * @param name a name for error message + * @param verify whether to verify parsing validity + * @returns a floating-point number + * @throws Error if `str` cannot be parsed + */ +export declare function parseNumber(str: string, name?: string, verify?: boolean): float64; +/** + * An ArkTS-compliant replacement for {@link isFinite}. + */ +export declare function isFiniteNumber(number: float64): boolean; +export declare function getDistancePx(startX: float64, startY: float64, endX: float64, endY: float64): float64; +//# sourceMappingURL=math.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/math.js b/koala-wrapper/koalaui/common/dist/lib/src/math.js new file mode 100644 index 000000000..474003ae9 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/math.js @@ -0,0 +1,100 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getDistancePx = exports.isFiniteNumber = exports.parseNumber = exports.modulo = exports.clamp = exports.lerp = void 0; +const compat_1 = require("#koalaui/compat"); +/** + * Computes the linear interpolation between `source` and `target` based on `weight`. + * + * @param weight - interpolation factor in the range [0..1] + * @param source - a value corresponding to weight 0 + * @param target - a value corresponding to weight 1 + * @returns interpolated value + */ +function lerp(weight, source, target) { + return source * (1.0 - weight) + target * weight; +} +exports.lerp = lerp; +/** + * Clamps a {@link value} within the specified range. + * + * @param value - a value to clamp + * @param min - the lower boundary of the range + * @param max - the upper boundary of the range + * @returns `min` if `value` is less than `min`, + * `max` if `value` is greater than `max`, + * `value` otherwise + */ +function clamp(value, min, max) { + return value <= min ? min : value >= max ? max : value; +} +exports.clamp = clamp; +/** + * Calculates the difference between the argument and + * the largest (closest to positive infinity) integer value + * that is less than or equal to the argument. + * + * @param value a floating-point value to process + * @returns a floor modulus of the given value in the range [0..1) + */ +function modulo(value) { + // The casts below are needed since floor returns double in ArkTS + const modulo = value - Math.floor(value); + return (modulo < 1.0) ? modulo : 0.0; +} +exports.modulo = modulo; +/** + * @param str a string to parse + * @param name a name for error message + * @param verify whether to verify parsing validity + * @returns a floating-point number + * @throws Error if `str` cannot be parsed + */ +function parseNumber(str, name = "number", verify = false) { + if (str != "") { // do not parse empty string to 0 + // ArkTS does not support NaN, isNaN, parseFloat + const value = (0, compat_1.asFloat64)(str); + if (verify) { + const reverseStr = (0, compat_1.asString)(value); + if (reverseStr !== undefined && (reverseStr === null || reverseStr === void 0 ? void 0 : reverseStr.length) == str.length && reverseStr == str) { + return value; + } + } + else { + return value; + } + } + throw new Error(`cannot parse ${name}: "${str}"`); +} +exports.parseNumber = parseNumber; +/** + * An ArkTS-compliant replacement for {@link isFinite}. + */ +function isFiniteNumber(number) { + // With Node.js: + // isFiniteNumber(Number.NEGATIVE_INFINITY) == false + // isFiniteNumber(Number.POSITIVE_INFINITY) == false + // isFiniteNumber(NaN) == false + return number >= Number.MIN_SAFE_INTEGER && number <= Number.MAX_SAFE_INTEGER; +} +exports.isFiniteNumber = isFiniteNumber; +function getDistancePx(startX, startY, endX, endY) { + const cathetA = Math.abs(endX - startX); + const cathetB = Math.abs(endY - startY); + return Math.sqrt(cathetA * cathetA + cathetB * cathetB); +} +exports.getDistancePx = getDistancePx; +//# sourceMappingURL=math.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/sha1.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/sha1.d.ts new file mode 100644 index 000000000..7efad4ed5 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/sha1.d.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/compat"; +export declare function createSha1(): SHA1Hash; +export declare class SHA1Hash { + private A; + private B; + private C; + private D; + private E; + private readonly _byte; + private readonly _word; + private _size; + private _sp; + constructor(); + updateString(data: string, encoding?: string): SHA1Hash; + updateInt32(data: int32): SHA1Hash; + update(data: Int32Array | Float32Array | Uint32Array | Uint8Array): SHA1Hash; + private _uint8; + private _utf8; + private _int32; + digest(encoding?: string): Uint8Array | string; + private _hex; + private _bin; +} +//# sourceMappingURL=sha1.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/sha1.js b/koala-wrapper/koalaui/common/dist/lib/src/sha1.js new file mode 100644 index 000000000..597c33707 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/sha1.js @@ -0,0 +1,311 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SHA1Hash = exports.createSha1 = void 0; +const compat_1 = require("#koalaui/compat"); +const K = [ + (0x5a827999 | 0), + (0x6ed9eba1 | 0), + (0x8f1bbcdc | 0), + (0xca62c1d6 | 0), +]; +const inputBytes = 64; +const inputWords = inputBytes / 4; +const highIndex = inputWords - 2; +const lowIndex = inputWords - 1; +const workWords = 80; +const allocBytes = 80; +const allocWords = allocBytes / 4; +const allocTotal = allocBytes * 100; +function createSha1() { + return new SHA1Hash(); +} +exports.createSha1 = createSha1; +class SHA1Hash { + constructor() { + this.A = (0x67452301 | 0); + this.B = (0xefcdab89 | 0); + this.C = (0x98badcfe | 0); + this.D = (0x10325476 | 0); + this.E = (0xc3d2e1f0 | 0); + this._size = 0; + this._sp = 0; // surrogate pair + if (!sharedBuffer || sharedOffset >= allocTotal) { + sharedBuffer = new ArrayBuffer(allocTotal); + sharedOffset = 0; + } + this._byte = new Uint8Array(sharedBuffer, sharedOffset, allocBytes); + this._word = new Int32Array(sharedBuffer, sharedOffset, allocWords); + sharedOffset += allocBytes; + } + updateString(data, encoding) { + return this._utf8(data); + } + updateInt32(data) { + const buffer = new Int32Array(1); + buffer[0] = data; + return this.update(buffer); + } + update(data) { + if (data == null) { + throw new TypeError("SHA1Hash expected non-null data: "); + } + let byteOffset = 0; + let length = 0; + let buffer = undefined; + // TODO: an attempt to wrie this in a generic form causes + // es2panda to segfault. + if (data instanceof Int32Array) { + byteOffset = data.byteOffset; + length = data.byteLength; + buffer = data.buffer; + } + else if (data instanceof Uint32Array) { + byteOffset = data.byteOffset; + length = data.byteLength; + buffer = data.buffer; + } + else if (data instanceof Float32Array) { + byteOffset = data.byteOffset; + length = data.byteLength; + buffer = data.buffer; + } + else if (data instanceof Uint8Array) { + byteOffset = data.byteOffset; + length = data.byteLength; + buffer = data.buffer; + } + let blocks = ((length / inputBytes) | 0); + let offset = 0; + // longer than 1 block + if ((blocks != 0) && !(byteOffset & 3) && !(this._size % inputBytes)) { + const block = new Int32Array(buffer, byteOffset, blocks * inputWords); + while (blocks--) { + this._int32(block, offset >> 2); + offset += inputBytes; + } + this._size += offset; + } + // data: TypedArray | DataView + const BYTES_PER_ELEMENT = data.BYTES_PER_ELEMENT; + if ((BYTES_PER_ELEMENT != 1) && buffer != undefined) { + const rest = new Uint8Array(buffer, byteOffset + offset, length - offset); + return this._uint8(rest); + } + // no more bytes + if (offset == length) + return this; + return this._uint8(new Uint8Array(buffer), offset); + } + _uint8(data, offset) { + const _byte = this._byte; + const _word = this._word; + const length = data.length; + offset = ((offset !== null && offset !== void 0 ? offset : 0) | 0); + while (offset < length) { + const start = this._size % inputBytes; + let index = start; + while (offset < length && index < inputBytes) { + _byte[index++] = data[offset++]; + } + if (index >= inputBytes) { + this._int32(_word); + } + this._size += index - start; + } + return this; + } + _utf8(text) { + const _byte = this._byte; + const _word = this._word; + const length = text.length; + let surrogate = this._sp; + for (let offset = 0; offset < length;) { + const start = this._size % inputBytes; + let index = start; + while (offset < length && index < inputBytes) { + let code = text.charCodeAt(offset++) | 0; + if (code < 0x80) { + // ASCII characters + _byte[index++] = code; + } + else if (code < 0x800) { + // 2 bytes + _byte[index++] = 0xC0 | (code >>> 6); + _byte[index++] = 0x80 | (code & 0x3F); + } + else if (code < 0xD800 || code > 0xDFFF) { + // 3 bytes + _byte[index++] = 0xE0 | (code >>> 12); + _byte[index++] = 0x80 | ((code >>> 6) & 0x3F); + _byte[index++] = 0x80 | (code & 0x3F); + } + else if (surrogate) { + // 4 bytes - surrogate pair + code = ((surrogate & 0x3FF) << 10) + (code & 0x3FF) + 0x10000; + _byte[index++] = 0xF0 | (code >>> 18); + _byte[index++] = 0x80 | ((code >>> 12) & 0x3F); + _byte[index++] = 0x80 | ((code >>> 6) & 0x3F); + _byte[index++] = 0x80 | (code & 0x3F); + surrogate = 0; + } + else { + surrogate = code; + } + } + if (index >= inputBytes) { + this._int32(_word); + _word[0] = _word[inputWords]; + } + this._size += index - start; + } + this._sp = surrogate; + return this; + } + _int32(data, offset) { + let A = this.A; + let B = this.B; + let C = this.C; + let D = this.D; + let E = this.E; + let i = 0; + offset = ((offset !== null && offset !== void 0 ? offset : 0) | 0); + while (i < inputWords) { + W[i++] = swap32(data[offset++]); + } + for (i = inputWords; i < workWords; i++) { + W[i] = rotate1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]); + } + for (i = 0; i < workWords; i++) { + const S = (i / 20) | 0; + const T = (rotate5(A) + ft(S, B, C, D) + E + W[i] + K[S]) | 0; + E = D; + D = C; + C = rotate30(B); + B = A; + A = T; + } + this.A = (A + this.A) | 0; + this.B = (B + this.B) | 0; + this.C = (C + this.C) | 0; + this.D = (D + this.D) | 0; + this.E = (E + this.E) | 0; + } + // digest(): Uint8Array + // digest(encoding: string): string + digest(encoding) { + const _byte = this._byte; + const _word = this._word; + let i = (this._size % inputBytes) | 0; + _byte[i++] = 0x80; + // pad 0 for current word + while (i & 3) { + _byte[i++] = 0; + } + i >>= 2; + if (i > highIndex) { + while (i < inputWords) { + _word[i++] = 0; + } + i = 0; + this._int32(_word); + } + // pad 0 for rest words + while (i < inputWords) { + _word[i++] = 0; + } + // input size + const bits64 = this._size * 8; + const low32 = ((bits64 & 0xffffffff) >>> 0); + const high32 = ((bits64 - low32) / 0x100000000); + if (high32) + _word[highIndex] = swap32(high32); + if (low32) + _word[lowIndex] = swap32(low32); + this._int32(_word); + return (encoding === "hex") ? this._hex() : this._bin(); + } + _hex() { + let A = this.A; + let B = this.B; + let C = this.C; + let D = this.D; + let E = this.E; + return hex32Str(A, B, C, D, E); + } + _bin() { + let A = this.A; + let B = this.B; + let C = this.C; + let D = this.D; + let E = this.E; + const _byte = this._byte; + const _word = this._word; + _word[0] = swap32(A); + _word[1] = swap32(B); + _word[2] = swap32(C); + _word[3] = swap32(D); + _word[4] = swap32(E); + return _byte.slice(0, 20); + } +} +exports.SHA1Hash = SHA1Hash; +const W = new Int32Array(workWords); +let sharedBuffer; +let sharedOffset = 0; +const swapLE = ((c) => (((c << 24) & 0xff000000) | ((c << 8) & 0xff0000) | ((c >> 8) & 0xff00) | ((c >> 24) & 0xff))); +const swapBE = ((c) => c); +const swap32 = isBE() ? swapBE : swapLE; +const rotate1 = (num) => (num << 1) | (num >>> 31); +const rotate5 = (num) => (num << 5) | (num >>> 27); +const rotate30 = (num) => (num << 30) | (num >>> 2); +function isBE() { + let a16 = new Uint16Array(1); + a16[0] = 0xFEFF; + let a8 = new Uint8Array(a16.buffer); + return a8[0] == 0xFE; // BOM +} +function ft(s, b, c, d) { + if (s == 0) + return (b & c) | ((~b) & d); + if (s == 2) + return (b & c) | (b & d) | (c & d); + return b ^ c ^ d; +} +const hex32Decoder = new compat_1.CustomTextDecoder(); +const hex32DecodeBuffer = new Uint8Array(40); +function hex32Str(A, B, C, D, E) { + writeIntAsHexUTF8(A, hex32DecodeBuffer, 0); + writeIntAsHexUTF8(B, hex32DecodeBuffer, 8); + writeIntAsHexUTF8(C, hex32DecodeBuffer, 16); + writeIntAsHexUTF8(D, hex32DecodeBuffer, 24); + writeIntAsHexUTF8(E, hex32DecodeBuffer, 32); + return hex32Decoder.decode(hex32DecodeBuffer); +} +function writeIntAsHexUTF8(value, buffer, byteOffset) { + buffer[byteOffset++] = nibbleToHexCode((value >> 28) & 0xF); + buffer[byteOffset++] = nibbleToHexCode((value >> 24) & 0xF); + buffer[byteOffset++] = nibbleToHexCode((value >> 20) & 0xF); + buffer[byteOffset++] = nibbleToHexCode((value >> 16) & 0xF); + buffer[byteOffset++] = nibbleToHexCode((value >> 12) & 0xF); + buffer[byteOffset++] = nibbleToHexCode((value >> 8) & 0xF); + buffer[byteOffset++] = nibbleToHexCode((value >> 4) & 0xF); + buffer[byteOffset++] = nibbleToHexCode((value >> 0) & 0xF); +} +function nibbleToHexCode(nibble) { + return nibble > 9 ? nibble + 87 : nibble + 48; +} +//# sourceMappingURL=sha1.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/stringUtils.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/stringUtils.d.ts new file mode 100644 index 000000000..d8101efbf --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/stringUtils.d.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/compat"; +/** + * Computes a hash code from the string {@link value}. + */ +export declare function hashCodeFromString(value: string): int32; +//# sourceMappingURL=stringUtils.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/stringUtils.js b/koala-wrapper/koalaui/common/dist/lib/src/stringUtils.js new file mode 100644 index 000000000..06850d000 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/stringUtils.js @@ -0,0 +1,30 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.hashCodeFromString = void 0; +/** + * Computes a hash code from the string {@link value}. + */ +function hashCodeFromString(value) { + let hash = 5381; + for (let i = 0; i < value.length; i++) { + hash = (hash * 33) ^ value.charCodeAt(i); + hash |= 0; + } + return hash; +} +exports.hashCodeFromString = hashCodeFromString; +//# sourceMappingURL=stringUtils.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/uniqueId.d.ts b/koala-wrapper/koalaui/common/dist/lib/src/uniqueId.d.ts new file mode 100644 index 000000000..0d00f1dd1 --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/uniqueId.d.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/compat"; +export declare class UniqueId { + private sha; + addString(data: string): UniqueId; + addI32(data: int32): UniqueId; + addF32Array(data: Float32Array): UniqueId; + addI32Array(data: Int32Array): UniqueId; + addU32Array(data: Uint32Array): UniqueId; + addU8Array(data: Uint8Array): UniqueId; + addPtr(data: Uint32Array | number): UniqueId; + compute(): string; +} +//# sourceMappingURL=uniqueId.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/dist/lib/src/uniqueId.js b/koala-wrapper/koalaui/common/dist/lib/src/uniqueId.js new file mode 100644 index 000000000..6269d042c --- /dev/null +++ b/koala-wrapper/koalaui/common/dist/lib/src/uniqueId.js @@ -0,0 +1,58 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UniqueId = void 0; +const sha1_1 = require("./sha1"); +class UniqueId { + constructor() { + this.sha = (0, sha1_1.createSha1)(); + } + addString(data) { + this.sha.updateString(data); + return this; + } + addI32(data) { + this.sha.updateInt32(data); + return this; + } + addF32Array(data) { + this.sha.update(data); + return this; + } + addI32Array(data) { + this.sha.update(data); + return this; + } + addU32Array(data) { + this.sha.update(data); + return this; + } + addU8Array(data) { + this.sha.update(data); + return this; + } + addPtr(data) { + if (data instanceof Uint32Array) { + return this.addU32Array(data); + } + return this.addI32(data); + } + compute() { + return this.sha.digest("hex"); + } +} +exports.UniqueId = UniqueId; +//# sourceMappingURL=uniqueId.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/oh-package.json5 b/koala-wrapper/koalaui/common/oh-package.json5 new file mode 100644 index 000000000..a1d31c737 --- /dev/null +++ b/koala-wrapper/koalaui/common/oh-package.json5 @@ -0,0 +1,50 @@ +{ + "name": "@koalaui/common", + "version": "1.4.1+devel", + "description": "", + "main": "build/lib/src/index.js", + "types": "./index.d.ts", + "files": [ + "build/lib/**/*.js", + "build/lib/**/*.d.ts", + "build/bridges/ohos/**/*.js", + "build/bridges/ohos/**/*.d.ts" + ], + "exports": { + ".": "./build/lib/src/index.js", + "./golden": "./test/golden.js", + "./bridges": { + "ark": "./build/bridges/ohos/index.js", + "default": null + } + }, + "typesVersions": { + "*": { + "bridges": ["build/bridges/ohos/index.d.ts"], + "*": ["build/lib/src/*", "build/lib/typescript/*"] + } + }, + "scripts": { + "compile": "tsc -b .", + "clean": "rimraf build dist", + "test": "mocha", + "test:coverage": "nyc mocha", + "compile:arkts": "bash ../tools/panda/arkts/arktsc --arktsconfig arktsconfig.json --ets-module" + }, + "keywords": [], + "dependencies": { + "@koalaui/compat": "../compat" + }, + "devDependencies": { + "@ohos/hypium": "^1.0.5", + "@types/chai": "^4.3.1", + "@types/mocha": "^9.1.0", + "@typescript-eslint/eslint-plugin": "^5.20.0", + "@typescript-eslint/parser": "^5.20.0", + "chai": "^4.3.6", + "eslint": "^8.13.0", + "eslint-plugin-unused-imports": "^2.0.0", + "mocha": "^9.2.2", + "source-map-support": "^0.5.21" + } +} diff --git a/koala-wrapper/koalaui/common/src/Errors.ts b/koala-wrapper/koalaui/common/src/Errors.ts new file mode 100644 index 000000000..d57ea750a --- /dev/null +++ b/koala-wrapper/koalaui/common/src/Errors.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022-2025 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. + */ + + +// "assert" is a reserved keyword in ArkTS :-( +export function assertion(condition: boolean, message: string) { + if (!condition) throw new Error(message) +} + +// The unknonwn type support in ArkTS compiler is not ready yet. +// When it is ready move from +// ensure(value, message) +// to +// value ?? error(message) +// which is much more readable +export function ensure(value: T|undefined, message: string): T { + if (value == undefined) throw new Error(message) + return value as T +} diff --git a/koala-wrapper/koalaui/common/src/Finalization.ts b/koala-wrapper/koalaui/common/src/Finalization.ts new file mode 100644 index 000000000..30be27994 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/Finalization.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 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 { finalizerRegister as finalizerRegisterCompat, finalizerUnregister as finalizerUnregisterCompat, Thunk } from "@koalaui/compat" + +export { Thunk } from "@koalaui/compat" + +export function finalizerRegister(target: object, thunk: Thunk) { + finalizerRegisterCompat(target, thunk) +} + +export function finalizerRegisterWithCleaner(target: object, cleaner: () => void) { + finalizerRegisterCompat(target, new CleanerThunk(cleaner)) +} + +export function finalizerUnregister(target: object) { + finalizerUnregisterCompat(target) +} + +class CleanerThunk implements Thunk { + private cleaner: () => void + constructor(cleaner: () => void) { + this.cleaner = cleaner + } + clean() { + this.cleaner() + } +} diff --git a/koala-wrapper/koalaui/common/src/KoalaProfiler.ts b/koala-wrapper/koalaui/common/src/KoalaProfiler.ts new file mode 100644 index 000000000..0e8f704f0 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/KoalaProfiler.ts @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/compat" + +/** + * Adds statistics for constructing/disposing of the TreeNode instances. + * It is disabled by default because collecting such data affects performance. + */ +const DEBUG_WITH_NODE_STATS = false + +export class KoalaProfiler { + private static readonly map = DEBUG_WITH_NODE_STATS + ? new Map>() + : undefined + + static nodeCreated(nodeType: int32, node: Object) { + if (KoalaProfiler.map === undefined) return + let set = KoalaProfiler.map!.get(nodeType) + if (set === undefined) { + set = new Set() + KoalaProfiler.map!.set(nodeType, set) + } + set.add(node) + } + + static nodeDisposed(nodeType: int32, node: Object) { + if (KoalaProfiler.map === undefined) return + let set = KoalaProfiler.map!.get(nodeType) + if (set === undefined) throw new Error("node never existed") + if (!set.delete(node)) console.log("node is already disposed") + } + + public static counters: KoalaProfiler | undefined = undefined + + private invalidations = 0 + private computes = 0 + private builds = 0 + private nodes = 0 + private realDraws = 0 + private cachedDraws = 0 + private measures = 0 + private layouts = 0 + private frames = 0 + private lastTime = 0.0 + private lastFPS = 0 + private updateEnterTime = 0.0 + private updateExitTime = 0.0 + private updateTime = 0.0 + private buildEnterTime = 0.0 + private buildExitTime = 0.0 + private buildTime = 0.0 + private layoutEnterTime = 0.0 + private layoutExitTime = 0.0 + private layoutTime = 0.0 + private drawEnterTime = 0.0 + private drawExitTime = 0.0 + private drawTime = 0.0 + private updatableStates = 0 + private mutableStates = 0 + private computableValues = 0 + + static enable() { + KoalaProfiler.counters = new KoalaProfiler() + } + + static disable() { + KoalaProfiler.counters = undefined + } + + static enabled(): boolean { + return KoalaProfiler.counters != undefined + } + + reset() { + this.invalidations = 0 + this.computes = 0 + this.builds = 0 + this.nodes = 0 + this.realDraws = 0 + this.cachedDraws = 0 + this.layouts = 0 + this.measures = 0 + this.updateEnterTime = 0 + this.updateExitTime = 0 + this.updatableStates = 0 + this.mutableStates = 0 + this.computableValues = 0 + } + + report() { + console.log(this.getReport()) + } + + getReport(): string { + const updateTime = Math.round(1000 * (this.updateExitTime - this.updateEnterTime)) + const buildTime = Math.round(1000 * (this.buildExitTime - this.buildEnterTime)) + const layoutTime = Math.round(1000 * (this.layoutExitTime - this.layoutEnterTime)) + const drawTime = Math.round(1000 * (this.drawExitTime - this.drawEnterTime)) + if (this.updateTime < updateTime) this.updateTime = updateTime + if (this.buildTime < buildTime) this.buildTime = buildTime + if (this.layoutTime < layoutTime) this.layoutTime = layoutTime + if (this.drawTime < drawTime) this.drawTime = drawTime + + // TODO: OHOS does not properly handle \n in template literals + const array = Array.of( + `invalidations: ${this.invalidations}`, + `modified states: ${this.mutableStates}/${this.updatableStates} + ${this.computableValues}`, + `update states (mks): ${this.updateTime} / ${updateTime}`, + `build root node (mks): ${this.buildTime} / ${buildTime}`, + `layout view (mks): ${this.layoutTime} / ${layoutTime}`, + `draw view (mks): ${this.drawTime} / ${drawTime}`, + `computes: ${this.computes}`, + `builds: ${this.builds}`, + `nodes: ${this.nodes}`, + `realDraws: ${this.realDraws}`, + `cachedDraws: ${this.cachedDraws}`, + `measures: ${this.measures}`, + `layouts: ${this.layouts}`, + `FPS: ${this.lastFPS}`, + ) + KoalaProfiler.map?.forEach((set:Set, kind:int32) => { + if (set.size > 0) array.push(kind + ":" + set.size) + }) + return array.join("\n") + } + + invalidation() { this.invalidations++ } + compute() { this.computes++ } + build() { this.builds++ } + node() { this.nodes++ } + realDraw() { this.realDraws++ } + cachedDraw() { this.cachedDraws++ } + layout() { this.layouts++ } + measure() { this.measures++ } + frame(ms: number) { + if (ms - this.lastTime <= 1000) { + this.frames++ + } else { + this.lastFPS = Math.round(this.frames * 1000 / (ms - this.lastTime)) as int32 + this.frames = 1 + this.lastTime = ms + } + } + buildRootEnter() { + this.buildEnterTime = Date.now() + } + buildRootExit() { + this.buildExitTime = Date.now() + } + layoutEnter() { + this.layoutEnterTime = Date.now() + } + layoutExit() { + this.layoutExitTime = Date.now() + } + drawEnter() { + this.drawEnterTime = Date.now() + } + drawExit() { + this.drawExitTime = Date.now() + } + updateSnapshotEnter() { + this.updateEnterTime = Date.now() + } + updateSnapshotExit() { + this.updateExitTime = Date.now() + } + updateSnapshot(modified: int32, all?: int32) { + if (all === undefined) { + this.computableValues = modified - this.mutableStates + + } else { + this.mutableStates = modified + this.updatableStates = all + } + } +} diff --git a/koala-wrapper/koalaui/common/src/LifecycleEvent.ts b/koala-wrapper/koalaui/common/src/LifecycleEvent.ts new file mode 100644 index 000000000..aa67f2312 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/LifecycleEvent.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022-2025 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 enum LifecycleEventKind { + SHOW_FRAME, + HIDE_FRAME, + CLOSE_FRAME, + ON_APPEAR, + ON_DISAPPEAR, + SHOW_COMPONENT, + HIDE_COMPONENT, + BACK, + FOCUS_FRAME, + UNFOCUS_FRAME +} + +export class LifecycleEvent { + kind: LifecycleEventKind + constructor(kind: LifecycleEventKind) { + this.kind = kind + } +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/src/MarkableQueue.ts b/koala-wrapper/koalaui/common/src/MarkableQueue.ts new file mode 100644 index 000000000..6d6efa518 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/MarkableQueue.ts @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2022-2025 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 { AtomicRef } from "@koalaui/compat" + +/** + * A markable queue that allows to accumulate callbacks and to call them to the latest set marker. + */ +export interface MarkableQueue { + /** Sets the new marker to the queue. */ + setMarker(): void + /** Adds the given callback to the queue. */ + addCallback(callback: () => void): void + /** Calls all accumulated callbacks to the latest set marker. */ + callCallbacks(): void + /** Clears the queue. */ + clear(): void +} + +/** + * Creates a new markable queue to safely process callbacks across several threads or tasks. + * @param reversed - `true` changes the order of calling callbacks + */ +export function markableQueue(reversed: boolean = false): MarkableQueue { + return reversed ? new ReversedQueue() : new DefaultQueue() +} + +class DefaultQueue implements MarkableQueue { + private readonly last = new AtomicRef(new Block()) + private readonly first = new AtomicRef(this.last.value) + private readonly marker = new AtomicRef(undefined) + + setMarker(): void { + const marker = new Block() + this.last.getAndSet(marker).next.value = marker + this.marker.value = marker + } + + addCallback(callback: () => void): void { + const block = new Block(callback) + this.last.getAndSet(block).next.value = block + } + + callCallbacks(): void { + const marker = this.marker.getAndSet(undefined) + if (marker) { + let block = this.first.getAndSet(marker) + while (block !== marker) { + block.callback?.() + block = block.next.value! + } + } + } + + clear(): void { + this.last.value = this.first.value + this.marker.value = undefined + } +} + +class ReversedQueue implements MarkableQueue { + private readonly last = new AtomicRef(undefined) + private readonly marker = new AtomicRef(undefined) + + setMarker(): void { + const marker = new Block() + marker.next.value = this.last.getAndSet(marker) + this.marker.value = marker + } + + addCallback(callback: () => void): void { + const block = new Block(callback) + block.next.value = this.last.getAndSet(block) + } + + callCallbacks(): void { + const marker = this.marker.getAndSet(undefined) + if (marker) { + let block = marker.next.getAndSet(undefined) + while (block) { + block!.callback?.() + block = block!.next.value + } + } + } + + clear(): void { + this.last.value = undefined + this.marker.value = undefined + } +} + +class Block { + readonly next = new AtomicRef(undefined) + readonly callback: (() => void) | undefined + + constructor(callback?: () => void) { + this.callback = callback + } +} diff --git a/koala-wrapper/koalaui/common/src/Matrix33.ts b/koala-wrapper/koalaui/common/src/Matrix33.ts new file mode 100644 index 000000000..978e3a907 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/Matrix33.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022-2025 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 { Array_from_number, float32, float64 } from "@koalaui/compat" + +export function mat33(array?: Float32Array): Matrix33 { + return (array == undefined) ? new Matrix33 () : new Matrix33(array) +} + +const tolerance: float32 = (1.0 / (1 << 12)) + +export class Matrix33 { + public readonly array: Float32Array + constructor (array: Float32Array = new Float32Array(Array_from_number([ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 + ]))) { + this.array = array.slice() + } + + static zero(): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]))) + } + + static makeTranslate(dx: float32, dy: float32): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([1.0, 0.0, dx as float64, 0.0, 1.0, dy as float64, 0.0, 0.0, 1.0]))) + } + + static makeScale(dx: float32, dy: float32 = dx): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([dx as float64, 0.0, 0.0, 0.0, dy as float64, 0.0, 0.0, 0.0, 1.0]))) + } + + static makeRotate(degrees: float32, pivotX?: float32, pivotY?: float32): Matrix33 { + let rads = degrees * Math.PI / 180 + let cos = Math.cos(rads) + let sin = Math.sin(rads) + if (Math.abs(sin) <= tolerance) sin = 0.0 + if (Math.abs(cos) <= tolerance) cos = 0.0 + if (pivotX !== undefined && pivotY != undefined) { + let dx = pivotX - pivotX * cos + pivotY * sin + let dy = pivotY - pivotY * cos - pivotX * sin + return new Matrix33(new Float32Array(Array_from_number([cos, -sin, dx, sin, cos, dy, 0.0, 0.0, 1.0]))) + } else { + return new Matrix33(new Float32Array(Array_from_number([cos, -sin, 0.0, sin, cos, 0.0, 0.0, 0.0, 1.0]))) + } + } + + static makeSkew(sx: float32, sy: float32): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([1.0, sx, 0.0, sy, 1.0, 0.0, 0.0, 0.0, 1.0]))) + } + + makeConcat(rhs: Matrix33): Matrix33 { + return new Matrix33(new Float32Array(Array_from_number([ + this.array[0] * rhs.array[0] + this.array[1] * rhs.array[3] + this.array[2] * rhs.array[6], + this.array[0] * rhs.array[1] + this.array[1] * rhs.array[4] + this.array[2] * rhs.array[7], + this.array[0] * rhs.array[2] + this.array[1] * rhs.array[5] + this.array[2] * rhs.array[8], + this.array[3] * rhs.array[0] + this.array[4] * rhs.array[3] + this.array[5] * rhs.array[6], + this.array[3] * rhs.array[1] + this.array[4] * rhs.array[4] + this.array[5] * rhs.array[7], + this.array[3] * rhs.array[2] + this.array[4] * rhs.array[5] + this.array[5] * rhs.array[8], + this.array[6] * rhs.array[0] + this.array[7] * rhs.array[3] + this.array[8] * rhs.array[6], + this.array[6] * rhs.array[1] + this.array[7] * rhs.array[4] + this.array[8] * rhs.array[7], + this.array[6] * rhs.array[2] + this.array[7] * rhs.array[5] + this.array[8] * rhs.array[8], + ]))) + } + + makeTranspose(): Matrix33{ + return new Matrix33(new Float32Array(Array_from_number([ + this.array[0], this.array[3], this.array[6], + this.array[1], this.array[4], this.array[7], + this.array[2], this.array[5], this.array[8] + ]))) + } +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/src/Matrix44.ts b/koala-wrapper/koalaui/common/src/Matrix44.ts new file mode 100644 index 000000000..163b53949 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/Matrix44.ts @@ -0,0 +1,381 @@ +/* + * Copyright (c) 2022-2025 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 { Array_from_number, float32 } from "@koalaui/compat" +import { Matrix33 } from "./Matrix33" +import { Point3 } from "./Point3" + + +export interface RotateOptions { + angle?: float32 + x?: float32 + y?: float32 + z?: float32 + pivotX?: float32 + pivotY?: float32 + pivotZ?: float32 +} + +export interface ScaleOptions { + x?: float32 + y?: float32 + z?: float32 + pivotX?: float32 + pivotY?: float32 + pivotZ?: float32 +} + +export interface TranslateOptions { + x?: float32 + y?: float32 + z?: float32 +} + +// TODO: this is because ArkTS doesn allow interface literal instances. +class TranslateOptionsImpl implements TranslateOptions { + _x: float32 | undefined + _y: float32 | undefined + _z: float32 | undefined + + get x(): float32 | undefined { return this._x } + get y(): float32 | undefined { return this._y } + get z(): float32 | undefined { return this._z } + + set x(x: float32 | undefined) { this._x = x } + set y(y: float32 | undefined) { this._y = y } + set z(z: float32 | undefined) { this._z = z } + + constructor( + x: float32 | undefined, + y: float32 | undefined, + z: float32 | undefined + ) { + this._x = x + this._y = y + this._z = z + } +} + +export function mat44(array?: Float32Array): Matrix44 { + return (array == undefined)? new Matrix44() : new Matrix44(array) +} +/** + * 4x4 matrix with right-handed coordinate system: + * +x goes to the right + * +y goes down + * +z goes into the screen (away from the viewer) + */ +export class Matrix44 { + public readonly array: Float32Array + constructor (array: Float32Array = new Float32Array(Array_from_number([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 + ]))) { + this.array = array.slice() + } + + public static identity(): Matrix44 { + return mat44() + } + + static zero(): Matrix44 { + return mat44(new Float32Array(Array_from_number([ + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, + ]))) + } + + public static lookAt(eye: Point3, center: Point3, up: Point3): Matrix44 { + const f = center.subtract(eye).normalize() + const u = up.normalize() + const s = f.cross(u).normalize() + const sf = s.cross(f) + return new Matrix44(new Float32Array(Array_from_number([ + s.x, sf.x, -f.x, eye.x, + s.y, sf.y, -f.y, eye.y, + s.z, sf.z, -f.z, eye.z, + 0, 0, 0, 1, + ]))).invert() + } + + public static perspective(depth: float32): Matrix44 { + return new Matrix44(new Float32Array(Array_from_number([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, -1.0 / depth, 1.0, + ]))) + } + + public static perspectiveFov(fov: float32, near: float32, far: float32): Matrix44 { + const denomInv = (far - near) + const halfAngle = fov * 0.5; + const cot = Math.cos(halfAngle) / Math.sin(halfAngle) + return new Matrix44(new Float32Array(Array_from_number([ + cot, 0.0, 0.0, 0.0, + 0.0, cot, 0.0, 0.0, + 0.0, 0.0, (far + near) * denomInv, 2 * far * near * denomInv, + 0.0, 0.0, -1.0, 0.0, + ]))) + } + + /** + * Returns new matrix, made from Matrix33. + * + * @param matrix - 3x3 matrix + * @returns the new instance of Matrix44 + * + */ + public static makeFromMatrix33(matrix: Matrix33): Matrix44{ + return new Matrix44(new Float32Array(Array_from_number([ + matrix.array[0], matrix.array[1], 0.0, matrix.array[2], + matrix.array[3], matrix.array[4], 0.0, matrix.array[5], + 0.0, 0.0, 1.0, 0.0, + matrix.array[6], matrix.array[7], 0.0, matrix.array[8] + ]))) + } + + /** + * Returns new 3x3 matrix, made from this matrix by dropping the third row and the third column. + * + * @returns the new instance of Matrix33 + * + */ + public asMatrix33(): Matrix33{ + return new Matrix33(new Float32Array(Array_from_number([ + this.array[0], this.array[1], this.array[3], + this.array[4], this.array[5], this.array[7], + this.array[12], this.array[13], this.array[15] + ]))) + } + + public copy(): Matrix44 { + return new Matrix44(new Float32Array(Array_from_number([ + this.array[0], this.array[1], this.array[2], this.array[3], + this.array[4], this.array[5], this.array[6], this.array[7], + this.array[8], this.array[9], this.array[10], this.array[11], + this.array[12], this.array[13], this.array[14], this.array[15] + ]))) + } + + concat(matrix: Matrix44): Matrix44 { + const result: Float32Array = new Float32Array(Array_from_number([ + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + ])) + for (let row = 0; row < 4; row++) { + for (let col = 0; col < 4; col++) { + let num: float32 = 0 + for (let k = 0; k < 4; k++) { + num += this.array[row * 4 + k] * matrix.array[col + 4 * k] + } + result[row * 4 + col] = num + } + } + for (let i = 0; i < this.array.length; i++) { + this.array[i] = result[i] + } + return this + } + + public scale(options: ScaleOptions): Matrix44 { + const scaled = new Matrix44() + scaled.array[0] = options.x ?? 1.0 as float32 + scaled.array[5] = options.y ?? 1.0 as float32 + scaled.array[10] = options.z ?? 1.0 as float32 + + this.translate(new TranslateOptionsImpl( + -(options.pivotX ?? 0.0 as float32) * (options.x ?? 1.0 as float32) + (options.pivotX ?? 0.0 as float32), + -(options.pivotY ?? 0.0 as float32) * (options.y ?? 1.0 as float32) + (options.pivotY ?? 0.0 as float32), + undefined + )).concat(scaled) + + return this + } + + public rotate(options: RotateOptions): Matrix44 { + const translationToPivot = mat44().translate(new TranslateOptionsImpl( + (options.pivotX ?? 0.0 as float32), + (options.pivotY ?? 0.0 as float32), + (options.pivotZ ?? 0.0 as float32), + )) + const translationToBack = mat44().translate(new TranslateOptionsImpl( + -(options.pivotX ?? 0.0 as float32), + -(options.pivotY ?? 0.0 as float32), + -(options.pivotZ ?? 0.0 as float32), + )) + + const vec = new Point3(options.x ?? 0.0 as float32, options.y ?? 0.0 as float32, options.z ?? 0.0 as float32).normalize() + const rads = (options.angle ?? 0.0 as float32) * Math.PI / 180 + let c = Math.cos(rads) + let s = Math.sin(rads) + const tolerance = (1.0 / (1 << 12)) + if (Math.abs(s) <= tolerance) s = 0.0 + if (Math.abs(c) <= tolerance) c = 0.0 + let t = 1 - c + const x = vec.x + const y = vec.y + const z = vec.z + + const rotation = mat44() + rotation.array[0] = t * x * x + c + rotation.array[1] = t * x * y - s * z + rotation.array[2] = t * x * z + s * y + rotation.array[3] = 0 + rotation.array[4] = t * x * y + s * z + rotation.array[5] = t * y * y + c + rotation.array[6] = t * y * z - s * x + rotation.array[7] = 0 + rotation.array[8] = t * x * z - s * y + rotation.array[9] = t * y * z + s * x + rotation.array[10] = t * z * z + c + rotation.array[11] = 0 + rotation.array[12] = 0 + rotation.array[13] = 0 + rotation.array[14] = 0 + rotation.array[15] = 1 + + this.concat(translationToPivot).concat(rotation).concat(translationToBack) + + return this + } + + public translate(options: TranslateOptions): Matrix44 { + this.array[3] = options.x ?? 0.0 as float32 + this.array[7] = options.y ?? 0.0 as float32 + this.array[11] = options.z ?? 0.0 as float32 + return this + } + + public invert(): Matrix44 { + const result: Float32Array = new Float32Array(16) + + let a00 = this.array[0] + let a01 = this.array[1] + let a02 = this.array[2] + let a03 = this.array[3] + let a10 = this.array[4] + let a11 = this.array[5] + let a12 = this.array[6] + let a13 = this.array[7] + let a20 = this.array[8] + let a21 = this.array[9] + let a22 = this.array[10] + let a23 = this.array[11] + let a30 = this.array[12] + let a31 = this.array[13] + let a32 = this.array[14] + let a33 = this.array[15] + + let b00 = a00 * a11 - a01 * a10 + let b01 = a00 * a12 - a02 * a10 + let b02 = a00 * a13 - a03 * a10 + let b03 = a01 * a12 - a02 * a11 + let b04 = a01 * a13 - a03 * a11 + let b05 = a02 * a13 - a03 * a12 + let b06 = a20 * a31 - a21 * a30 + let b07 = a20 * a32 - a22 * a30 + let b08 = a20 * a33 - a23 * a30 + let b09 = a21 * a32 - a22 * a31 + let b10 = a21 * a33 - a23 * a31 + let b11 = a22 * a33 - a23 * a32 + + let determinant = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06 + let invdet = 1.0 / determinant + b00 *= invdet + b01 *= invdet + b02 *= invdet + b03 *= invdet + b04 *= invdet + b05 *= invdet + b06 *= invdet + b07 *= invdet + b08 *= invdet + b09 *= invdet + b10 *= invdet + b11 *= invdet + + result[0] = a11 * b11 - a12 * b10 + a13 * b09 + result[1] = a02 * b10 - a01 * b11 - a03 * b09 + result[2] = a31 * b05 - a32 * b04 + a33 * b03 + result[3] = a22 * b04 - a21 * b05 - a23 * b03 + result[4] = a12 * b08 - a10 * b11 - a13 * b07 + result[5] = a00 * b11 - a02 * b08 + a03 * b07 + result[6] = a32 * b02 - a30 * b05 - a33 * b01 + result[7] = a20 * b05 - a22 * b02 + a23 * b01 + result[8] = a10 * b10 - a11 * b08 + a13 * b06 + result[9] = a01 * b08 - a00 * b10 - a03 * b06 + result[10] = a30 * b04 - a31 * b02 + a33 * b00 + result[11] = a21 * b02 - a20 * b04 - a23 * b00 + result[12] = a11 * b07 - a10 * b09 - a12 * b06 + result[13] = a00 * b09 - a01 * b07 + a02 * b06 + result[14] = a31 * b01 - a30 * b03 - a32 * b00 + result[15] = a20 * b03 - a21 * b01 + a22 * b00 + + // If 1/det overflows to infinity (i.e. det is denormalized) or any of the inverted matrix + // values is non-finite, return zero to indicate a non-invertible matrix. + let prod = 0 + for (let i = 0; i < result.length; ++i) { + prod *= result[i] + } + // At this point, prod will either be NaN or 0 + // if prod is NaN, this check will return false + if (prod == 0) { + for (let i = 0; i < this.array.length; i++) { + this.array[i] = result[i] + } + } + return this + } + + public transpose(): Matrix44 { + const result: Float32Array = new Float32Array(16) + + result[0] = this.array[0] + result[1] = this.array[4] + result[2] = this.array[8] + result[3] = this.array[12] + result[4] = this.array[1] + result[5] = this.array[5] + result[6] = this.array[9] + result[7] = this.array[13] + result[8] = this.array[2] + result[9] = this.array[6] + result[10] = this.array[10] + result[11] = this.array[14] + result[12] = this.array[3] + result[13] = this.array[7] + result[14] = this.array[11] + result[15] = this.array[15] + + for (let i = 0; i < this.array.length; i++) { + this.array[i] = result[i] + } + + return this + } + + public skew(x?: float32, y?: float32): Matrix44 { + this.array[1] += x ?? 0.0 as float32 + this.array[4] += y ?? 0.0 as float32 + return this + } +} diff --git a/koala-wrapper/koalaui/common/src/PerfProbe.ts b/koala-wrapper/koalaui/common/src/PerfProbe.ts new file mode 100644 index 000000000..063d4d590 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/PerfProbe.ts @@ -0,0 +1,431 @@ +/* + * Copyright (c) 2022-2025 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 { float64, int32, timeNow, numberToFixed } from "@koalaui/compat" + +/** + * A probe to measure performance. + * + * A probe can measure performance of any activity which has an entry and an exit points. + * Such activity can be a method call, or a sequence of actions, possibly asynchronous. + * + * A probe which has been entered and exited is considered a performed probe (see {@link MainPerfProbe.probePerformed}). + * A probe can be entered recursively. When all the recursive calls exits the probe becomes a performed probe. + * + * All performing probes form a hierarchy which is rooted at the main probe (see {@link enterMainPerfProbe}). + * A last started probe (see {@link MainPerfProbe.enterProbe}) which has not yet performed becomes a parent + * for the next started probe. It's the responsibility of the API caller to keep this parent-child relationship valid, + * that is: a child probe should exit before its parent probe exits. + * + * Statistics gathered by a probe: + * - call count + * - recursive call count + * - total time and percentage relative to the main (root) probe + */ +export interface PerfProbe { + /** + * The name of the probe. + */ + readonly name: string + + /** + * Whether this is a dummy probe which does not measure (a noop). + * + * @see MainPerfProbe.getProbe + */ + readonly dummy: boolean + + /** + * Exists the probe. + * + * @param log log the gathered statistics. + * @see MainPerfProbe.enterProbe + */ + exit(log: boolean|undefined): void + + /** + * Cancels measuring the probe and its children probes. + */ + cancel(): void + + /** + * User-defined data associated with the probe. + */ + userData: string | undefined + + /** + * Whether the probe was canceled. + */ + readonly canceled: boolean +} + +/** + * The main (root) {@link PerfProbe}. + * + * This probe is used to enter the main activity. + * + * Calling {@link PerfProbe.cancel} removes the main probe and disposes all its resources. + * + * Calling {@link PerfProbe.exit} exits the main probe, cancels it and when the log option is provided + * logs the gathered statistics. + * + * @see enterMainPerfProbe + * @see getMainPerfProbe + */ +export interface MainPerfProbe extends PerfProbe { + /** + * Enters a child probe referenced by the {@link name} and measures it. + * If the probe does not exist, returns a dummy instance. + * + * If the probe already performs a recursive call is counted. + * + * @see PerfProbe.exit + * @see exitProbe + */ + enterProbe(name: string): PerfProbe + + /** + * Exits a child probe referenced by the {@link name}. + * If the probe does not exist, returns a dummy instance. + * + * This is an equivalent of calling {@link getProbe} and then {@link PerfProbe.exit}. + */ + exitProbe(name: string): PerfProbe + + /** + * Returns the child probe referenced by the {@link name} if it exists, + * otherwise a dummy instance. + * + * @see PerfProbe.dummy + */ + getProbe(name: string): PerfProbe + + /** + * Performs the {@link func} of a child probe referenced by the {@link name} and measures it. + * + * This is an equivalent of calling {@link enterProbe} and then {@link exitProbe}. + * + * If the probe already performs a recursive call is counted. + */ + performProbe(name: string, func: () => T): T + + /** + * Returns true if the probe referenced by the {@link name} has been performed + * (entered and exited all the recursive calls). + */ + probePerformed(name: string): boolean +} + +/** + * Creates a {@link MainPerfProbe} instance with the {@link name} and enters its main probe. + * + * If a {@link MainPerfProbe} with this {@link name} already exists then it is canceled and the new one is created. + * + * Exit it with {@link MainPerfProbe.exit}. + */ +export function enterMainPerfProbe(name: string): MainPerfProbe { + return new MainPerfProbeImpl(name) +} + +/** + * Returns {@link MainPerfProbe} instance with the {@link name} if it exists, + * otherwise a dummy instance. + * + * @see MainPerfProbe.dummy + */ +export function getMainPerfProbe(name: string): MainPerfProbe { + const instance = MainPerfProbeImpl.mainProbes.get(name) + return instance ? instance : MainPerfProbeImpl.DUMMY +} + +class DummyPerfProbe implements MainPerfProbe { + get name(): string { return "dummy" } + get dummy(): boolean { return true } + exit(log: boolean|undefined): void {} + cancel () {} + get canceled(): boolean { return false } + enterProbe(name: string): PerfProbe { return PerfProbeImpl.DUMMY } + exitProbe (name: string): PerfProbe { return PerfProbeImpl.DUMMY } + getProbe(name: string): PerfProbe { return PerfProbeImpl.DUMMY } + //performProbe: (_: string, func: () => T) => func(), + performProbe(name: string, func: () => T): T { return func() } + probePerformed(_: string): boolean { return false } + + get userData(): string | undefined { + return undefined + } + set userData(_: string | undefined) {} +} + +class PerfProbeImpl implements PerfProbe { + constructor( + name: string, + main?: MainPerfProbeImpl, + parent?: PerfProbeImpl, + remainder: boolean = false + ) { + this._name = name + this._main = main + this.parent = parent + this.remainder = remainder + } + + private readonly _name: string + private readonly _main: MainPerfProbeImpl|undefined + public parent: PerfProbeImpl|undefined + public readonly remainder: boolean + + children: Array = new Array() + childrenSorted: boolean = false + index: int32 = 0 + startTime: float64 = 0.0 + totalTime: float64 = 0.0 + callCount: int32 = 0 + currentRecursionDepth: int32 = 0 + recursiveCallCount: int32 = 0 + _canceled: boolean = false + private _userData?: string + + get name(): string { + return this._name + } + + get dummy(): boolean { + return false + } + + get main(): MainPerfProbeImpl { + return this._main! + } + + get performing(): boolean { + return this.startTime > 0 + } + + get userData(): string | undefined { + return this._userData + } + + set userData(value: string | undefined) { + this._userData = value + } + + exit(log?: boolean): void { + if (this.canceled) return + + if (this.currentRecursionDepth == 0) { + this.totalTime += timeNow() - this.startTime + this.startTime = 0 + } else { + this.currentRecursionDepth-- + } + if (!this.performing) { + this.main.pop(this) + } + if (log) this.log() + } + + cancel(cancelChildren: boolean = true) { + this._canceled = true + if (cancelChildren) this.maybeCancelChildren() + } + + private maybeCancelChildren() { + MainPerfProbeImpl.visit(this, false, (probe: PerfProbeImpl, depth: int32) => { + if (probe.performing) probe.cancel(false) + }) + } + + get canceled(): boolean { + return this._canceled + } + + toString(): string { + if (this.canceled) { + return `[${this.name}] canceled` + } + if (this.performing) { + return `[${this.name}] still performing...` + } + const mainProbe = this.main.probes.get(this.main.name)! + const percentage = mainProbe.totalTime > 0 ? Math.round((100 / mainProbe.totalTime) * this.totalTime) : 0 + + let result = `[${this.name}] call count: ${this.callCount}` + + ` | recursive call count: ${this.recursiveCallCount}` + + ` | time: ${this.totalTime}ms ${percentage}%` + + if (this.userData) { + result += ` | user data: ${this.userData}` + } + + return result + } + + protected log(prefix?: string) { + console.log(prefix ? `${prefix}${this.toString()}` : this.toString()) + } + + static readonly DUMMY: PerfProbe = new DummyPerfProbe() +} + +class MainPerfProbeImpl extends PerfProbeImpl implements MainPerfProbe { + constructor( + name: string + ) { + super(name) + const prev = MainPerfProbeImpl.mainProbes.get(name) + if (prev) prev.cancel() + MainPerfProbeImpl.mainProbes.set(name, this) + this.currentProbe = this.enterProbe(name) + } + + static readonly mainProbes: Map = new Map() + + currentProbe: PerfProbeImpl + probes: Map = new Map() + + private createProbe(name: string): PerfProbeImpl { + const probes = name == this.name ? this : new PerfProbeImpl(name, this) + this.push(probes) + return probes + } + + get main(): MainPerfProbeImpl { + return this + } + + push(probe: PerfProbeImpl) { + probe.parent = this.currentProbe + probe.index = probe.parent ? probe.parent!.children.length as int32 : 0 + if (probe.parent) probe.parent!.children.push(probe) + this.currentProbe = probe + } + + pop(probe: PerfProbeImpl) { + if (probe.parent) { + this.currentProbe = probe.parent! + } + } + + performProbe(name: string, func: () => T): T { + const probe = this.enterProbe(name) + try { + return func() + } finally { + probe.exit() + } + } + + enterProbe(name: string): PerfProbeImpl { + let probe = this.probes.get(name) + if (!probe) { + probe = this.createProbe(name) + this.probes.set(name, probe) + } + probe._canceled = false + + if (probe.performing) { + probe.recursiveCallCount++ + probe.currentRecursionDepth++ + } else { + probe.startTime = timeNow() + probe.callCount++ + } + return probe + } + + exitProbe(name: string): PerfProbe { + const probe = this.getProbe(name) + probe.exit(undefined) + return probe + } + + getProbe(name: string): PerfProbe { + const probe = this.probes.get(name) + return probe !== undefined ? probe : PerfProbeImpl.DUMMY + } + + probePerformed(name: string): boolean { + const probe = this.probes.get(name) + return probe != undefined && !probe!.performing && !probe!.canceled + } + + exit(log?: boolean) { + super.exit() + if (log) this.log() + this.cancel() + } + + cancel() { + MainPerfProbeImpl.mainProbes.delete(this.name) + } + + static visit(root: PerfProbeImpl, logging: boolean, apply: (probe: PerfProbeImpl, depth: int32) => void) { + let current: PerfProbeImpl = root + let index = 0 + let depth = 0 + let visiting = true + while (true) { + if (visiting) { + current.index = 0 + apply(current, depth) + } + if (index >= current.children.length) { + if (!current.parent) { + break + } + current = current.parent! + index = ++current.index + depth-- + visiting = false + continue + } + visiting = true + if (logging && !current.childrenSorted) { + current.childrenSorted = true + current.children = current.children.sort((p1: PerfProbeImpl, p2: PerfProbeImpl):number => p2.totalTime - p1.totalTime) + if (depth == 0) { + // a special probe to log the time remained + current.children.push(new PerfProbeImpl("", root.main, current, true)) + } + } + current = current.children[index] + index = 0 + depth++ + } + } + + protected log(prefix?: string) { + prefix = prefix !== undefined ? `${prefix}: ` : "" + console.log(`${prefix}perf probes:`) + + MainPerfProbeImpl.visit(this.main, true, (probe, depth):void => { + let indent = "\t" + for (let i = 0; i < depth; i++) indent += "\t" + if (probe.remainder) { + const parentTime = probe.parent!.totalTime + let childrenTime = 0 + probe.parent!.children.forEach((a: PerfProbeImpl):void => { childrenTime += a.totalTime }) + probe.totalTime = Math.max(0, parentTime - childrenTime) as int32 + const percentage = parentTime > 0 ? Math.round((100 / parentTime) * probe.totalTime) : 0 + console.log(`${prefix}${indent}[${probe.name}] time: ${numberToFixed(probe.totalTime, 2)}ms ${percentage}%`) + } else { + console.log(`${prefix}${indent}${probe.toString()}`) + } + }) + } + + static readonly DUMMY: MainPerfProbe = new DummyPerfProbe() +} diff --git a/koala-wrapper/koalaui/common/src/Point.ts b/koala-wrapper/koalaui/common/src/Point.ts new file mode 100644 index 000000000..1a89eadcd --- /dev/null +++ b/koala-wrapper/koalaui/common/src/Point.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2022-2025 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 { float32 } from "@koalaui/compat" + +export class Point { + coordinates: Float32Array + + constructor (x: float32, y: float32) { + this.coordinates = new Float32Array(2) + this.coordinates[0] = x + this.coordinates[1] = y + } + + get x(): float32 { + return this.coordinates[0] as float32 + } + + get y(): float32 { + return this.coordinates[1] as float32 + } + + offsetXY(dx: float32, dy: float32): Point { + return new Point(this.x + dx, this.y + dy) + } + + offset(vec: Point): Point { + return this.offsetXY(vec.x, vec.y) + } + + scale(scale: float32): Point { + return this.scaleXY(scale, scale) + } + + scaleXY(sx: float32, sy: float32): Point { + return new Point(this.x * sx, this.y * sy) + } + + static ZERO = new Point(0.0 as float32, 0.0 as float32) + + toArray(): Float32Array { + return this.coordinates + } + + static flattenArray(points: Array): Float32Array { + let array = new Float32Array(points.length * 2) + for (let i = 0; i < points.length; i++) { + array[i * 2] = points[i].x + array[i * 2 + 1] = points[i].y + } + return array + } + + static fromArray(points: Float32Array): Array { + if (points.length % 2 != 0) + throw new Error("Expected " + points.length + " % 2 == 0") + + let array = new Array(points.length / 2) + for (let i = 0; i < points.length / 2; i++) { + array[i] = new Point(points[i * 2] as float32, points[i * 2 + 1] as float32) + } + return array + } +} diff --git a/koala-wrapper/koalaui/common/src/Point3.ts b/koala-wrapper/koalaui/common/src/Point3.ts new file mode 100644 index 000000000..04e86ee2a --- /dev/null +++ b/koala-wrapper/koalaui/common/src/Point3.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022-2025 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 { float32 } from "@koalaui/compat" + +export class Point3 { + x: float32 + y: float32 + z: float32 + constructor(x: float32, y: float32, z: float32) { + this.x = x + this.y = y + this.z = z + } + + subtract(value: Point3): Point3 { + return new Point3( + this.x - value.x, + this.y - value.y, + this.z - value.z + ) + } + + cross(value: Point3): Point3 { + return new Point3( + this.y * value.z - this.z * value.y, + this.z * value.x - this.x * value.z, + this.x * value.y - this.y * value.x + ) + } + + normalize(): Point3 { + const mag = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z) as float32 + const tolerance = (1.0 / (1 << 12)) + if (mag < tolerance) { + // This semicolon after return this is a workaround for ArkTS bug + return this; + } + return new Point3(this.x / mag, this.y / mag, this.z / mag) + } +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/src/index.ts b/koala-wrapper/koalaui/common/src/index.ts new file mode 100644 index 000000000..471b714b3 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/index.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022-2025 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 { + int8, uint8, + int32, uint32, + int64, uint64, + float32, float64, + asArray, + asFloat64, + float32FromBits, + int32BitsFromFloat, + Array_from_set, + AtomicRef, + CustomTextDecoder, + CustomTextEncoder, + className, lcClassName, + functionOverValue, + Observed, + Observable, + ObservableHandler, + observableProxy, + observableProxyArray, + isFunction, + propDeepCopy, + refEqual, + int8Array, + unsafeCast +} from "@koalaui/compat" +export { clamp, lerp, modulo, parseNumber, isFiniteNumber, getDistancePx } from "./math" +export { hashCodeFromString } from "./stringUtils" +export { KoalaProfiler } from "./KoalaProfiler" +export * from "./PerfProbe" +export * from "./Errors" +export * from "./LifecycleEvent" +export * from "./Finalization" +export * from "./MarkableQueue" +export * from "./Matrix33" +export * from "./Matrix44" +export * from "./Point3" +export * from "./Point" +export { SHA1Hash, createSha1 } from "./sha1" +export { UniqueId } from "./uniqueId" +export * from "./koalaKey" diff --git a/koala-wrapper/koalaui/common/src/koalaKey.ts b/koala-wrapper/koalaui/common/src/koalaKey.ts new file mode 100644 index 000000000..94c00f336 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/koalaKey.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/compat" + +export type KoalaCallsiteKey = int32 + +export class KoalaCallsiteKeys { + static readonly empty: KoalaCallsiteKey = 0 as int32 + + static combine (key1: KoalaCallsiteKey, key2: KoalaCallsiteKey): KoalaCallsiteKey { + return key1 + key2 + } + + static asString(key: KoalaCallsiteKey): string { + return new Number(key).toString(16) + } +} diff --git a/koala-wrapper/koalaui/common/src/math.ts b/koala-wrapper/koalaui/common/src/math.ts new file mode 100644 index 000000000..9b8b15d87 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/math.ts @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2022-2025 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 { asFloat64, asString, float64 } from "@koalaui/compat" + +/** + * Computes the linear interpolation between `source` and `target` based on `weight`. + * + * @param weight - interpolation factor in the range [0..1] + * @param source - a value corresponding to weight 0 + * @param target - a value corresponding to weight 1 + * @returns interpolated value + */ +export function lerp(weight: float64, source: float64, target: float64): float64 { + return source * (1.0 - weight) + target * weight +} + +/** + * Clamps a {@link value} within the specified range. + * + * @param value - a value to clamp + * @param min - the lower boundary of the range + * @param max - the upper boundary of the range + * @returns `min` if `value` is less than `min`, + * `max` if `value` is greater than `max`, + * `value` otherwise + */ +export function clamp(value: float64, min: float64, max: float64): float64 { + return value <= min ? min : value >= max ? max : value +} + +/** + * Calculates the difference between the argument and + * the largest (closest to positive infinity) integer value + * that is less than or equal to the argument. + * + * @param value a floating-point value to process + * @returns a floor modulus of the given value in the range [0..1) + */ +export function modulo(value: float64): float64 { + // The casts below are needed since floor returns double in ArkTS + const modulo: float64 = value - Math.floor(value) + return (modulo < 1.0) ? modulo : 0.0 +} + +/** + * @param str a string to parse + * @param name a name for error message + * @param verify whether to verify parsing validity + * @returns a floating-point number + * @throws Error if `str` cannot be parsed + */ +export function parseNumber(str: string, name: string = "number", verify: boolean = false): float64 { + if (str != "") { // do not parse empty string to 0 + // ArkTS does not support NaN, isNaN, parseFloat + const value = asFloat64(str) + if (verify) { + const reverseStr = asString(value) + if (reverseStr !== undefined && reverseStr?.length == str.length && reverseStr == str) { + return value + } + } + else { + return value + } + } + throw new Error(`cannot parse ${name}: "${str}"`) +} + +/** + * An ArkTS-compliant replacement for {@link isFinite}. + */ +export function isFiniteNumber(number: float64): boolean { + // With Node.js: + // isFiniteNumber(Number.NEGATIVE_INFINITY) == false + // isFiniteNumber(Number.POSITIVE_INFINITY) == false + // isFiniteNumber(NaN) == false + return number >= Number.MIN_SAFE_INTEGER && number <= Number.MAX_SAFE_INTEGER +} + +export function getDistancePx(startX: float64, startY: float64, endX: float64, endY: float64): float64 { + const cathetA = Math.abs(endX - startX) + const cathetB = Math.abs(endY - startY) + return Math.sqrt(cathetA * cathetA + cathetB * cathetB) as float64 +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/common/src/sha1.ts b/koala-wrapper/koalaui/common/src/sha1.ts new file mode 100644 index 000000000..11af4b187 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/sha1.ts @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2022-2025 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 { CustomTextDecoder } from "@koalaui/compat" +import { int32 } from "@koalaui/compat" + +const K = [ + (0x5a827999 | 0) as int32, + (0x6ed9eba1 | 0) as int32, + (0x8f1bbcdc | 0) as int32, + (0xca62c1d6 | 0) as int32, +] + +const inputBytes = 64 +const inputWords = inputBytes / 4 +const highIndex = inputWords - 2 +const lowIndex = inputWords - 1 +const workWords = 80 +const allocBytes = 80 +const allocWords = allocBytes / 4 +const allocTotal = allocBytes * 100 + +export function createSha1(): SHA1Hash { + return new SHA1Hash() +} + +export class SHA1Hash { + private A = (0x67452301 | 0) as int32 + private B = (0xefcdab89 | 0) as int32 + private C = (0x98badcfe | 0) as int32 + private D = (0x10325476 | 0) as int32 + private E = (0xc3d2e1f0 | 0) as int32 + private readonly _byte: Uint8Array + private readonly _word: Int32Array + private _size = 0 + private _sp = 0 // surrogate pair + + constructor() { + if (!sharedBuffer || sharedOffset >= allocTotal) { + sharedBuffer = new ArrayBuffer(allocTotal) + sharedOffset = 0 + } + + this._byte = new Uint8Array(sharedBuffer, sharedOffset, allocBytes) + this._word = new Int32Array(sharedBuffer, sharedOffset, allocWords) + sharedOffset += allocBytes + } + + updateString(data: string, encoding?: string): SHA1Hash { + return this._utf8(data) + } + updateInt32(data: int32): SHA1Hash { + const buffer = new Int32Array(1) + buffer[0] = data + return this.update(buffer) + } + + update(data: Int32Array | Float32Array | Uint32Array | Uint8Array): SHA1Hash { + if (data == null) { + throw new TypeError("SHA1Hash expected non-null data: ") + } + + let byteOffset: int32 = 0 + let length: int32 = 0 + let buffer: ArrayBufferLike | undefined = undefined + + // TODO: an attempt to wrie this in a generic form causes + // es2panda to segfault. + if (data instanceof Int32Array) { + byteOffset = data.byteOffset as int32 + length = data.byteLength as int32 + buffer = data.buffer + } else if (data instanceof Uint32Array) { + byteOffset = data.byteOffset as int32 + length = data.byteLength as int32 + buffer = data.buffer + } else if (data instanceof Float32Array) { + byteOffset = data.byteOffset as int32 + length = data.byteLength as int32 + buffer = data.buffer + } else if (data instanceof Uint8Array) { + byteOffset = data.byteOffset as int32 + length = data.byteLength as int32 + buffer = data.buffer + } + + let blocks: int32 = ((length / inputBytes) | 0) as int32 + let offset: int32 = 0 + + // longer than 1 block + if ((blocks != 0) && !(byteOffset & 3) && !(this._size % inputBytes)) { + const block = new Int32Array(buffer!, byteOffset, blocks * inputWords) + while (blocks--) { + this._int32(block, offset >> 2) + offset += inputBytes + } + this._size += offset + } + + // data: TypedArray | DataView + const BYTES_PER_ELEMENT = (data as Uint8Array).BYTES_PER_ELEMENT as int32 + if ((BYTES_PER_ELEMENT != 1) && buffer != undefined) { + const rest = new Uint8Array(buffer, byteOffset + offset, length - offset) + return this._uint8(rest) + } + + // no more bytes + if (offset == length) return this + + return this._uint8(new Uint8Array(buffer!), offset) + } + + private _uint8(data: Uint8Array, offset?: int32): SHA1Hash { + const _byte = this._byte + const _word = this._word + const length = data.length + offset = ((offset ?? 0) | 0) as int32 + + while (offset < length) { + const start = this._size % inputBytes + let index = start + + while (offset < length && index < inputBytes) { + _byte[index++] = data[offset++] + } + + if (index >= inputBytes) { + this._int32(_word) + } + + this._size += index - start + } + + return this + } + + private _utf8(text: string): SHA1Hash { + const _byte = this._byte + const _word = this._word + const length = text.length + let surrogate = this._sp + + for (let offset = 0; offset < length; ) { + const start = this._size % inputBytes + let index = start + + while (offset < length && index < inputBytes) { + let code = text.charCodeAt(offset++) | 0 + if (code < 0x80) { + // ASCII characters + _byte[index++] = code + } else if (code < 0x800) { + // 2 bytes + _byte[index++] = 0xC0 | (code >>> 6) + _byte[index++] = 0x80 | (code & 0x3F) + } else if (code < 0xD800 || code > 0xDFFF) { + // 3 bytes + _byte[index++] = 0xE0 | (code >>> 12) + _byte[index++] = 0x80 | ((code >>> 6) & 0x3F) + _byte[index++] = 0x80 | (code & 0x3F) + } else if (surrogate) { + // 4 bytes - surrogate pair + code = ((surrogate & 0x3FF) << 10) + (code & 0x3FF) + 0x10000 + _byte[index++] = 0xF0 | (code >>> 18) + _byte[index++] = 0x80 | ((code >>> 12) & 0x3F) + _byte[index++] = 0x80 | ((code >>> 6) & 0x3F) + _byte[index++] = 0x80 | (code & 0x3F) + surrogate = 0 + } else { + surrogate = code + } + } + + if (index >= inputBytes) { + this._int32(_word) + _word[0] = _word[inputWords] + } + + this._size += index - start + } + + this._sp = surrogate + return this + } + + private _int32(data: Int32Array, offset?: int32): void { + let A = this.A + let B = this.B + let C = this.C + let D = this.D + let E = this.E + let i = 0 + offset = ((offset ?? 0) | 0) as int32 + + while (i < inputWords) { + W[i++] = swap32(data[offset++] as int32) + } + + for (i = inputWords; i < workWords; i++) { + W[i] = rotate1((W[i - 3] as int32) ^ (W[i - 8] as int32) ^ (W[i - 14] as int32) ^ (W[i - 16] as int32)) + } + + for (i = 0; i < workWords; i++) { + const S = (i / 20) | 0 + const T = ((rotate5(A) + ft(S, B, C, D) + E + W[i] + K[S]) as int32) | 0 + E = D + D = C + C = rotate30(B) + B = A + A = T + } + + this.A = (A + this.A) | 0 + this.B = (B + this.B) | 0 + this.C = (C + this.C) | 0 + this.D = (D + this.D) | 0 + this.E = (E + this.E) | 0 + } + + // digest(): Uint8Array + // digest(encoding: string): string + digest(encoding?: string): Uint8Array | string { + const _byte = this._byte + const _word = this._word + let i = (this._size % inputBytes) | 0 + _byte[i++] = 0x80 + + // pad 0 for current word + while (i & 3) { + _byte[i++] = 0 + } + i >>= 2 + + if (i > highIndex) { + while (i < inputWords) { + _word[i++] = 0 + } + i = 0 + this._int32(_word) + } + + // pad 0 for rest words + while (i < inputWords) { + _word[i++] = 0 + } + + // input size + const bits64: int32 = this._size * 8 + const low32: int32 = ((bits64 & 0xffffffff) as int32 >>> 0) as int32 + const high32: int32 = ((bits64 - low32) as int32 / 0x100000000) as int32 + if (high32) _word[highIndex] = swap32(high32) as int32 + if (low32) _word[lowIndex] = swap32(low32) as int32 + + this._int32(_word) + + return (encoding === "hex") ? this._hex() : this._bin() + } + + private _hex(): string { + let A = this.A + let B = this.B + let C = this.C + let D = this.D + let E = this.E + + return hex32Str(A, B, C, D, E) + } + + private _bin(): Uint8Array { + let A = this.A + let B = this.B + let C = this.C + let D = this.D + let E = this.E + const _byte = this._byte + const _word = this._word + + _word[0] = swap32(A) + _word[1] = swap32(B) + _word[2] = swap32(C) + _word[3] = swap32(D) + _word[4] = swap32(E) + + return _byte.slice(0, 20) + } +} + +type NS = (num: int32) => string +type NN = (num: int32) => int32 + +const W = new Int32Array(workWords) + +let sharedBuffer: ArrayBuffer +let sharedOffset: int32 = 0 + +const swapLE: NN = ((c:int32):int32 => (((c << 24) & 0xff000000) | ((c << 8) & 0xff0000) | ((c >> 8) & 0xff00) | ((c >> 24) & 0xff))) +const swapBE: NN = ((c:int32):int32 => c) +const swap32: NN = isBE() ? swapBE : swapLE +const rotate1: NN = (num: int32): int32 => (num << 1) | (num >>> 31) +const rotate5: NN = (num: int32): int32 => (num << 5) | (num >>> 27) +const rotate30: NN = (num: int32): int32 => (num << 30) | (num >>> 2) + +function isBE(): boolean { + let a16 = new Uint16Array(1) + a16[0] = 0xFEFF + let a8 = new Uint8Array(a16.buffer) + return a8[0] == 0xFE // BOM +} + + +function ft(s: int32, b: int32, c: int32, d: int32) { + if (s == 0) return (b & c) | ((~b) & d) + if (s == 2) return (b & c) | (b & d) | (c & d) + return b ^ c ^ d +} + +const hex32Decoder = new CustomTextDecoder() +const hex32DecodeBuffer = new Uint8Array(40) +function hex32Str(A: int32, B: int32, C: int32, D: int32, E: int32): string { + writeIntAsHexUTF8(A, hex32DecodeBuffer, 0) + writeIntAsHexUTF8(B, hex32DecodeBuffer, 8) + writeIntAsHexUTF8(C, hex32DecodeBuffer, 16) + writeIntAsHexUTF8(D, hex32DecodeBuffer, 24) + writeIntAsHexUTF8(E, hex32DecodeBuffer, 32) + return hex32Decoder.decode(hex32DecodeBuffer) +} + +function writeIntAsHexUTF8(value: int32, buffer: Uint8Array, byteOffset: int32) { + buffer[byteOffset++] = nibbleToHexCode((value >> 28) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 24) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 20) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 16) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 12) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 8 ) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 4 ) & 0xF) + buffer[byteOffset++] = nibbleToHexCode((value >> 0 ) & 0xF) +} + +function nibbleToHexCode(nibble: int32) { + return nibble > 9 ? nibble + 87 : nibble + 48 +} diff --git a/koala-wrapper/koalaui/common/src/stringUtils.ts b/koala-wrapper/koalaui/common/src/stringUtils.ts new file mode 100644 index 000000000..e9ec1a790 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/stringUtils.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/compat" + + +/** + * Computes a hash code from the string {@link value}. + */ +export function hashCodeFromString(value: string): int32 { + let hash = 5381 + for(let i = 0; i < value.length; i++) { + hash = (hash * 33) ^ value.charCodeAt(i) + hash |= 0 + } + return hash +} diff --git a/koala-wrapper/koalaui/common/src/uniqueId.ts b/koala-wrapper/koalaui/common/src/uniqueId.ts new file mode 100644 index 000000000..b32441905 --- /dev/null +++ b/koala-wrapper/koalaui/common/src/uniqueId.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/compat" +import { createSha1 } from "./sha1"; + +export class UniqueId { + private sha = createSha1() + + public addString(data: string): UniqueId { + this.sha.updateString(data) + return this + } + + public addI32(data: int32): UniqueId { + this.sha.updateInt32(data) + return this + } + + public addF32Array(data: Float32Array): UniqueId { + this.sha.update(data) + return this + } + + public addI32Array(data: Int32Array): UniqueId { + this.sha.update(data) + return this + } + + public addU32Array(data: Uint32Array): UniqueId { + this.sha.update(data) + return this + } + + public addU8Array(data: Uint8Array): UniqueId { + this.sha.update(data) + return this + } + + public addPtr(data: Uint32Array | number): UniqueId { + if (data instanceof Uint32Array) { + return this.addU32Array(data) + } + return this.addI32(data as int32) + } + + public compute(): string { + return this.sha.digest("hex") as string + } +} diff --git a/koala-wrapper/koalaui/compat/README.md b/koala-wrapper/koalaui/compat/README.md new file mode 100644 index 000000000..5bd0a1951 --- /dev/null +++ b/koala-wrapper/koalaui/compat/README.md @@ -0,0 +1,4 @@ +This is a typescript and ArkTS compatibility library. + +It abstracts out such things as reflection which are quite different in typescript and ArkTS. + diff --git a/koala-wrapper/koalaui/compat/dist/src/index.d.ts b/koala-wrapper/koalaui/compat/dist/src/index.d.ts new file mode 100644 index 000000000..6a50786d6 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/index.d.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022-2025 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 { asArray, Array_from_set, Array_from_int32, Array_from_number, AtomicRef, asFloat64, asString, float32FromBits, int32BitsFromFloat, Thunk, finalizerRegister, finalizerUnregister, timeNow, numberToFixed, Observed, Observable, ObservableHandler, observableProxy, observableProxyArray, propDeepCopy, lcClassName, CustomTextEncoder, CustomTextDecoder, className, isFunction, functionOverValue, refEqual, isNotPrimitive, uint8, int8, int16, int32, uint32, int64, uint64, float32, float64, int8Array, unsafeCast, } from "#platform"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/index.js b/koala-wrapper/koalaui/compat/dist/src/index.js new file mode 100644 index 000000000..cfaa72b41 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/index.js @@ -0,0 +1,47 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.unsafeCast = exports.int8Array = exports.isNotPrimitive = exports.refEqual = exports.functionOverValue = exports.isFunction = exports.className = exports.CustomTextDecoder = exports.CustomTextEncoder = exports.lcClassName = exports.propDeepCopy = exports.observableProxyArray = exports.observableProxy = exports.ObservableHandler = exports.Observed = exports.numberToFixed = exports.timeNow = exports.finalizerUnregister = exports.finalizerRegister = exports.int32BitsFromFloat = exports.float32FromBits = exports.asString = exports.asFloat64 = exports.AtomicRef = exports.Array_from_number = exports.Array_from_int32 = exports.Array_from_set = exports.asArray = void 0; +var _platform_1 = require("#platform"); +Object.defineProperty(exports, "asArray", { enumerable: true, get: function () { return _platform_1.asArray; } }); +Object.defineProperty(exports, "Array_from_set", { enumerable: true, get: function () { return _platform_1.Array_from_set; } }); +Object.defineProperty(exports, "Array_from_int32", { enumerable: true, get: function () { return _platform_1.Array_from_int32; } }); +Object.defineProperty(exports, "Array_from_number", { enumerable: true, get: function () { return _platform_1.Array_from_number; } }); +Object.defineProperty(exports, "AtomicRef", { enumerable: true, get: function () { return _platform_1.AtomicRef; } }); +Object.defineProperty(exports, "asFloat64", { enumerable: true, get: function () { return _platform_1.asFloat64; } }); +Object.defineProperty(exports, "asString", { enumerable: true, get: function () { return _platform_1.asString; } }); +Object.defineProperty(exports, "float32FromBits", { enumerable: true, get: function () { return _platform_1.float32FromBits; } }); +Object.defineProperty(exports, "int32BitsFromFloat", { enumerable: true, get: function () { return _platform_1.int32BitsFromFloat; } }); +Object.defineProperty(exports, "finalizerRegister", { enumerable: true, get: function () { return _platform_1.finalizerRegister; } }); +Object.defineProperty(exports, "finalizerUnregister", { enumerable: true, get: function () { return _platform_1.finalizerUnregister; } }); +Object.defineProperty(exports, "timeNow", { enumerable: true, get: function () { return _platform_1.timeNow; } }); +Object.defineProperty(exports, "numberToFixed", { enumerable: true, get: function () { return _platform_1.numberToFixed; } }); +Object.defineProperty(exports, "Observed", { enumerable: true, get: function () { return _platform_1.Observed; } }); +Object.defineProperty(exports, "ObservableHandler", { enumerable: true, get: function () { return _platform_1.ObservableHandler; } }); +Object.defineProperty(exports, "observableProxy", { enumerable: true, get: function () { return _platform_1.observableProxy; } }); +Object.defineProperty(exports, "observableProxyArray", { enumerable: true, get: function () { return _platform_1.observableProxyArray; } }); +Object.defineProperty(exports, "propDeepCopy", { enumerable: true, get: function () { return _platform_1.propDeepCopy; } }); +Object.defineProperty(exports, "lcClassName", { enumerable: true, get: function () { return _platform_1.lcClassName; } }); +Object.defineProperty(exports, "CustomTextEncoder", { enumerable: true, get: function () { return _platform_1.CustomTextEncoder; } }); +Object.defineProperty(exports, "CustomTextDecoder", { enumerable: true, get: function () { return _platform_1.CustomTextDecoder; } }); +Object.defineProperty(exports, "className", { enumerable: true, get: function () { return _platform_1.className; } }); +Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return _platform_1.isFunction; } }); +Object.defineProperty(exports, "functionOverValue", { enumerable: true, get: function () { return _platform_1.functionOverValue; } }); +Object.defineProperty(exports, "refEqual", { enumerable: true, get: function () { return _platform_1.refEqual; } }); +Object.defineProperty(exports, "isNotPrimitive", { enumerable: true, get: function () { return _platform_1.isNotPrimitive; } }); +Object.defineProperty(exports, "int8Array", { enumerable: true, get: function () { return _platform_1.int8Array; } }); +Object.defineProperty(exports, "unsafeCast", { enumerable: true, get: function () { return _platform_1.unsafeCast; } }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/array.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/array.d.ts new file mode 100644 index 000000000..df8d52c6b --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/array.d.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022-2025 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 { float64, int32, int8 } from "./types"; +export declare function asArray(value: T[]): Array; +export declare function Array_from_set(set: Set): Array; +export declare function Array_from_int32(data: Int32Array): int32[]; +export declare function Array_from_number(data: float64[]): Array; +export declare function int8Array(size: int32): int8[]; +//# sourceMappingURL=array.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/array.js b/koala-wrapper/koalaui/compat/dist/src/typescript/array.js new file mode 100644 index 000000000..c391e6c4f --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/array.js @@ -0,0 +1,38 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.int8Array = exports.Array_from_number = exports.Array_from_int32 = exports.Array_from_set = exports.asArray = void 0; +function asArray(value) { + return value; +} +exports.asArray = asArray; +function Array_from_set(set) { + return Array.from(set); +} +exports.Array_from_set = Array_from_set; +function Array_from_int32(data) { + return Array.from(data); +} +exports.Array_from_int32 = Array_from_int32; +function Array_from_number(data) { + return data; +} +exports.Array_from_number = Array_from_number; +function int8Array(size) { + return []; +} +exports.int8Array = int8Array; +//# sourceMappingURL=array.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/atomic.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/atomic.d.ts new file mode 100644 index 000000000..d799b95b0 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/atomic.d.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2025 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 declare class AtomicRef { + value: Value; + /** + * Creates a new reference object with the given initial value. + * @param value - the new value + */ + constructor(value: Value); + /** + * Atomically sets the reference value to the given value and returns the previous one. + * @param value - the new value + * @returns the previous value + */ + getAndSet(value: Value): Value; +} +//# sourceMappingURL=atomic.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/atomic.js b/koala-wrapper/koalaui/compat/dist/src/typescript/atomic.js new file mode 100644 index 000000000..2aa1b1ad4 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/atomic.js @@ -0,0 +1,41 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AtomicRef = void 0; +/** + * A reference that may be updated atomically. + */ +class AtomicRef { + /** + * Creates a new reference object with the given initial value. + * @param value - the new value + */ + constructor(value) { + this.value = value; + } + /** + * Atomically sets the reference value to the given value and returns the previous one. + * @param value - the new value + * @returns the previous value + */ + getAndSet(value) { + const result = this.value; + this.value = value; + return result; + } +} +exports.AtomicRef = AtomicRef; +//# sourceMappingURL=atomic.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/double.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/double.d.ts new file mode 100644 index 000000000..71c40c89b --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/double.d.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022-2025 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 { float64, int32, float32 } from "./types"; +export declare function asFloat64(value: string): float64; +export declare function asString(value: float64 | undefined): string | undefined; +export declare function float32FromBits(value: int32): float32; +export declare function int32BitsFromFloat(value: float32): int32; +//# sourceMappingURL=double.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/double.js b/koala-wrapper/koalaui/compat/dist/src/typescript/double.js new file mode 100644 index 000000000..ea84b6e5d --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/double.js @@ -0,0 +1,35 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.int32BitsFromFloat = exports.float32FromBits = exports.asString = exports.asFloat64 = void 0; +function asFloat64(value) { + return Number(value); +} +exports.asFloat64 = asFloat64; +function asString(value) { + return value === null || value === void 0 ? void 0 : value.toString(); +} +exports.asString = asString; +function float32FromBits(value) { + return value; +} +exports.float32FromBits = float32FromBits; +function int32BitsFromFloat(value) { + return value; +} +exports.int32BitsFromFloat = int32BitsFromFloat; +//# sourceMappingURL=double.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/finalization.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/finalization.d.ts new file mode 100644 index 000000000..8047a3aec --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/finalization.d.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022-2025 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 interface Thunk { + clean(): void; +} +export declare function finalizerRegister(target: object, thunk: object): void; +export declare function finalizerUnregister(target: object): void; +//# sourceMappingURL=finalization.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/finalization.js b/koala-wrapper/koalaui/compat/dist/src/typescript/finalization.js new file mode 100644 index 000000000..4d605cb72 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/finalization.js @@ -0,0 +1,29 @@ +"use strict"; +/* + * Copyright (c) 2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.finalizerUnregister = exports.finalizerRegister = void 0; +const registry = new FinalizationRegistry((thunk) => { + thunk.clean(); +}); +function finalizerRegister(target, thunk) { + registry.register(target, thunk); +} +exports.finalizerRegister = finalizerRegister; +function finalizerUnregister(target) { + registry.unregister(target); +} +exports.finalizerUnregister = finalizerUnregister; +//# sourceMappingURL=finalization.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/index.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/index.d.ts new file mode 100644 index 000000000..11311543c --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/index.d.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2025 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 * from "./array"; +export * from "./atomic"; +export * from "./double"; +export * from "./finalization"; +export * from "./observable"; +export * from "./performance"; +export * from "./prop-deep-copy"; +export * from "./reflection"; +export * from "./strings"; +export * from "./ts-reflection"; +export * from "./types"; +export * from "./utils"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/index.js b/koala-wrapper/koalaui/compat/dist/src/typescript/index.js new file mode 100644 index 000000000..17c1bf11d --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/index.js @@ -0,0 +1,43 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./array"), exports); +__exportStar(require("./atomic"), exports); +__exportStar(require("./double"), exports); +__exportStar(require("./finalization"), exports); +__exportStar(require("./observable"), exports); +__exportStar(require("./performance"), exports); +__exportStar(require("./prop-deep-copy"), exports); +__exportStar(require("./reflection"), exports); +__exportStar(require("./strings"), exports); +__exportStar(require("./ts-reflection"), exports); +__exportStar(require("./types"), exports); +__exportStar(require("./utils"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/observable.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/observable.d.ts new file mode 100644 index 000000000..28df03087 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/observable.d.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022-2025 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 declare function getObservableTarget(proxy: Object): Object; +/** + * Data class decorator that makes all child fields trackable. + */ +export declare function Observed(constructorFunction: Function): void; +/** @internal */ +export interface Observable { + /** It is called when the observable value is accessed. */ + onAccess(): void; + /** It is called when the observable value is modified. */ + onModify(): void; +} +/** @internal */ +export declare class ObservableHandler implements Observable { + private static handlers; + private parents; + private children; + private readonly observables; + private _modified; + readonly observed: boolean; + constructor(parent?: ObservableHandler, observed?: boolean); + onAccess(): void; + onModify(): void; + static dropModified(value: Value): boolean; + /** Adds the specified `observable` to the handler corresponding to the given `value`. */ + static attach(value: Value, observable: Observable): void; + /** Deletes the specified `observable` from the handler corresponding to the given `value`. */ + static detach(value: Value, observable: Observable): void; + /** @returns the handler corresponding to the given `value` if it was installed */ + private static findIfObject; + /** + * @param value - any non-null object including arrays + * @returns an observable handler or `undefined` if it is not installed + */ + static find(value: Object): ObservableHandler | undefined; + /** + * @param value - any non-null object including arrays + * @param observable - a handler to install on this object + * @throws an error if observable handler cannot be installed + */ + static installOn(value: Object, observable?: ObservableHandler): void; + addParent(parent: ObservableHandler): void; + removeParent(parent: ObservableHandler): void; + removeChild(value: Value): void; + private collect; + static contains(observable: ObservableHandler, guards?: Set): boolean; +} +/** @internal */ +export declare function observableProxyArray(...value: Value[]): Array; +/** @internal */ +export declare function observableProxy(value: Value, parent?: ObservableHandler, observed?: boolean, strict?: boolean): Value; +//# sourceMappingURL=observable.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/observable.js b/koala-wrapper/koalaui/compat/dist/src/typescript/observable.js new file mode 100644 index 000000000..5de62790f --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/observable.js @@ -0,0 +1,406 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.observableProxy = exports.observableProxyArray = exports.ObservableHandler = exports.Observed = exports.getObservableTarget = void 0; +const OBSERVABLE_TARGET = "__proxy_observable_target__"; +function getObservableTarget(proxy) { + var _a; + return (_a = getPropertyValue(OBSERVABLE_TARGET, proxy)) !== null && _a !== void 0 ? _a : proxy; +} +exports.getObservableTarget = getObservableTarget; +function getPropertyValue(name, object) { + return object[name]; +} +/** + * Data class decorator that makes all child fields trackable. + */ +function Observed(constructorFunction) { + constructorFunction.prototype[OBSERVED] = true; +} +exports.Observed = Observed; +const OBSERVED = "__ObservedByArkUI__"; +function isObserved(value) { + return value[OBSERVED] === true; +} +/** @internal */ +class ObservableHandler { + constructor(parent, observed = false) { + this.parents = new Set(); + this.children = new Map(); + this.observables = new Set(); + this._modified = false; + this.observed = observed; + if (parent) + this.addParent(parent); + } + onAccess() { + var _a; + if (this.observables.size > 0) { + const it = this.observables.keys(); + while (true) { + const result = it.next(); + if (result.done) + break; + (_a = result.value) === null || _a === void 0 ? void 0 : _a.onAccess(); + } + } + } + onModify() { + const set = new Set(); + this.collect(true, set); + set.forEach((handler) => { + var _a; + handler._modified = true; + if (handler.observables.size > 0) { + const it = handler.observables.keys(); + while (true) { + const result = it.next(); + if (result.done) + break; + (_a = result.value) === null || _a === void 0 ? void 0 : _a.onModify(); + } + } + }); + } + static dropModified(value) { + const handler = ObservableHandler.findIfObject(value); + if (handler === undefined) + return false; + const result = handler._modified; + handler._modified = false; + return result; + } + /** Adds the specified `observable` to the handler corresponding to the given `value`. */ + static attach(value, observable) { + const handler = ObservableHandler.findIfObject(value); + if (handler) + handler.observables.add(observable); + } + /** Deletes the specified `observable` from the handler corresponding to the given `value`. */ + static detach(value, observable) { + const handler = ObservableHandler.findIfObject(value); + if (handler) + handler.observables.delete(observable); + } + /** @returns the handler corresponding to the given `value` if it was installed */ + static findIfObject(value) { + const handlers = ObservableHandler.handlers; + return handlers !== undefined && value instanceof Object ? handlers.get(getObservableTarget(value)) : undefined; + } + /** + * @param value - any non-null object including arrays + * @returns an observable handler or `undefined` if it is not installed + */ + static find(value) { + const handlers = ObservableHandler.handlers; + return handlers ? handlers.get(getObservableTarget(value)) : undefined; + } + /** + * @param value - any non-null object including arrays + * @param observable - a handler to install on this object + * @throws an error if observable handler cannot be installed + */ + static installOn(value, observable) { + let handlers = ObservableHandler.handlers; + if (handlers === undefined) { + handlers = new WeakMap(); + ObservableHandler.handlers = handlers; + } + observable + ? handlers.set(getObservableTarget(value), observable) + : handlers.delete(getObservableTarget(value)); + } + addParent(parent) { + var _a; + const count = (_a = parent.children.get(this)) !== null && _a !== void 0 ? _a : 0; + parent.children.set(this, count + 1); + this.parents.add(parent); + } + removeParent(parent) { + var _a; + const count = (_a = parent.children.get(this)) !== null && _a !== void 0 ? _a : 0; + if (count > 1) { + parent.children.set(this, count - 1); + } + else if (count == 1) { + parent.children.delete(this); + this.parents.delete(parent); + } + } + removeChild(value) { + const child = ObservableHandler.findIfObject(value); + if (child) + child.removeParent(this); + } + collect(all, guards = new Set()) { + if (guards.has(this)) + return guards; // already collected + guards.add(this); // handler is already guarded + this.parents.forEach(handler => handler.collect(all, guards)); + if (all) + this.children.forEach((_count, handler) => handler.collect(all, guards)); + return guards; + } + static contains(observable, guards) { + if (observable.observed) + return true; + if (guards === undefined) + guards = new Set(); // create if needed + else if (guards.has(observable)) + return false; // already checked + guards.add(observable); // handler is already guarded + for (const it of observable.parents.keys()) { + if (ObservableHandler.contains(it, guards)) + return true; + } + return false; + } +} +exports.ObservableHandler = ObservableHandler; +ObservableHandler.handlers = undefined; +/** @internal */ +function observableProxyArray(...value) { + return observableProxy(value); +} +exports.observableProxyArray = observableProxyArray; +/** @internal */ +function observableProxy(value, parent, observed, strict = true) { + if (value instanceof ObservableHandler) + return value; // do not proxy a marker itself + if (value === null || !(value instanceof Object)) + return value; // only non-null object can be observable + const observable = ObservableHandler.find(value); + if (observable) { + if (parent) { + if (strict) + observable.addParent(parent); + if (observed === undefined) + observed = ObservableHandler.contains(parent); + } + if (observed) { + if (Array.isArray(value)) { + for (let index = 0; index < value.length; index++) { + value[index] = observableProxy(value[index], observable, observed, false); + } + } + else { + proxyFields(value, false, observable); + } + } + return value; + } + if (Array.isArray(value)) { + const handler = new ObservableHandler(parent); + const array = proxyChildrenOnly(value, handler, observed); + copyWithinObservable(array); + fillObservable(array); + popObservable(array); + pushObservable(array); + reverseObservable(array); + shiftObservable(array); + sortObservable(array); + spliceObservable(array); + unshiftObservable(array); + return proxyObject(array, handler); + } + if (value instanceof Date) { + const valueAsAny = value; + const handler = new ObservableHandler(parent); + const setMethods = new Set([ + "setFullYear", "setMonth", "setDate", "setHours", "setMinutes", "setSeconds", + "setMilliseconds", "setTime", "setUTCFullYear", "setUTCMonth", "setUTCDate", + "setUTCHours", "setUTCMinutes", "setUTCSeconds", "setUTCMilliseconds" + ]); + setMethods.forEach((method) => { + const originalMethod = method + 'Original'; + if (valueAsAny[originalMethod] !== undefined) { + return; + } + valueAsAny[originalMethod] = valueAsAny[method]; + valueAsAny[method] = function (...args) { + var _a; + (_a = ObservableHandler.find(this)) === null || _a === void 0 ? void 0 : _a.onModify(); + return this[originalMethod](...args); + }; + }); + return proxyObject(value, handler); + } + // TODO: support set/map + const handler = new ObservableHandler(parent, isObserved(value)); + if (handler.observed || observed) + proxyFields(value, true, handler); + return proxyObject(value, handler); +} +exports.observableProxy = observableProxy; +function proxyObject(value, observable) { + ObservableHandler.installOn(value, observable); + return new Proxy(value, { + get(target, property, receiver) { + var _a; + if (property == OBSERVABLE_TARGET) + return target; + const value = Reflect.get(target, property, receiver); + (_a = ObservableHandler.find(target)) === null || _a === void 0 ? void 0 : _a.onAccess(); + return typeof value == "function" + ? value.bind(target) + : value; + }, + set(target, property, value, receiver) { + const old = Reflect.get(target, property, receiver); + if (value === old) + return true; + const observable = ObservableHandler.find(target); + if (observable) { + observable.onModify(); + observable.removeChild(old); + const observed = ObservableHandler.contains(observable); + if (observed || Array.isArray(target)) { + value = observableProxy(value, observable, observed); + } + } + return Reflect.set(target, property, value, receiver); + }, + deleteProperty(target, property) { + var _a; + (_a = ObservableHandler.find(target)) === null || _a === void 0 ? void 0 : _a.onModify(); + delete target[property]; + return true; + }, + }); +} +function proxyFields(value, strict, parent) { + for (const name of Object.getOwnPropertyNames(value)) { + const descriptor = Object.getOwnPropertyDescriptor(value, name); + if (descriptor === null || descriptor === void 0 ? void 0 : descriptor.writable) + value[name] = observableProxy(value[name], parent, true, strict); + } +} +function proxyChildrenOnly(array, parent, observed) { + if (observed === undefined) + observed = ObservableHandler.contains(parent); + return array.map(it => observableProxy(it, parent, observed)); +} +function copyWithinObservable(array) { + if (array.copyWithinOriginal === undefined) { + array.copyWithinOriginal = array.copyWithin; + array.copyWithin = function (target, start, end) { + const observable = ObservableHandler.find(this); + observable === null || observable === void 0 ? void 0 : observable.onModify(); + return this.copyWithinOriginal(target, start, end); + }; + } +} +function fillObservable(array) { + if (array.fillOriginal === undefined) { + array.fillOriginal = array.fill; + array.fill = function (value, start, end) { + const observable = ObservableHandler.find(this); + observable === null || observable === void 0 ? void 0 : observable.onModify(); + if (observable) + value = observableProxy(value, observable); + return this.fillOriginal(value, start, end); + }; + } +} +function popObservable(array) { + if (array.popOriginal === undefined) { + array.popOriginal = array.pop; + array.pop = function (...args) { + const observable = ObservableHandler.find(this); + observable === null || observable === void 0 ? void 0 : observable.onModify(); + const result = this.popOriginal(...args); + if (observable) + observable.removeChild(result); + return result; + }; + } +} +function pushObservable(array) { + if (array.pushOriginal === undefined) { + array.pushOriginal = array.push; + array.push = function (...args) { + const observable = ObservableHandler.find(this); + observable === null || observable === void 0 ? void 0 : observable.onModify(); + if (observable) + args = proxyChildrenOnly(args, observable); + return this.pushOriginal(...args); + }; + } +} +function reverseObservable(array) { + if (array.reverseOriginal === undefined) { + array.reverseOriginal = array.reverse; + array.reverse = function () { + const observable = ObservableHandler.find(this); + observable === null || observable === void 0 ? void 0 : observable.onModify(); + return this.reverseOriginal(); + }; + } +} +function shiftObservable(array) { + if (array.shiftOriginal === undefined) { + array.shiftOriginal = array.shift; + array.shift = function (...args) { + const observable = ObservableHandler.find(this); + observable === null || observable === void 0 ? void 0 : observable.onModify(); + const result = this.shiftOriginal(...args); + if (observable) + observable.removeChild(result); + return result; + }; + } +} +function sortObservable(array) { + if (array.sortOriginal === undefined) { + array.sortOriginal = array.sort; + array.sort = function (compareFn) { + const observable = ObservableHandler.find(this); + observable === null || observable === void 0 ? void 0 : observable.onModify(); + return this.sortOriginal(compareFn); + }; + } +} +function spliceObservable(array) { + if (array.spliceOriginal === undefined) { + array.spliceOriginal = array.splice; + array.splice = function (start, deleteCount, ...items) { + const observable = ObservableHandler.find(this); + observable === null || observable === void 0 ? void 0 : observable.onModify(); + if (observable) + items = proxyChildrenOnly(items, observable); + if (deleteCount === undefined) + deleteCount = array.length; + const result = this.spliceOriginal(start, deleteCount, ...items); + if (observable && Array.isArray(result)) { + result.forEach(it => observable.removeChild(it)); + } + return result; + }; + } +} +function unshiftObservable(array) { + if (array.unshiftOriginal === undefined) { + array.unshiftOriginal = array.unshift; + array.unshift = function (...items) { + const observable = ObservableHandler.find(this); + observable === null || observable === void 0 ? void 0 : observable.onModify(); + if (observable) + items = proxyChildrenOnly(items, observable); + return this.unshiftOriginal(...items); + }; + } +} +//# sourceMappingURL=observable.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/performance.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/performance.d.ts new file mode 100644 index 000000000..ffff2ebb8 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/performance.d.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +/** + * @returns the number of milliseconds elapsed since midnight, + * January 1, 1970 Universal Coordinated Time (UTC). + */ +export declare function timeNow(): number; +/** + * @param fractionDigits - number of digits after the decimal point [0 - 20] + * @returns a string representing a number in fixed-point notation + */ +export declare function numberToFixed(value: number, fractionDigits: number): string; +//# sourceMappingURL=performance.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/performance.js b/koala-wrapper/koalaui/compat/dist/src/typescript/performance.js new file mode 100644 index 000000000..faf020971 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/performance.js @@ -0,0 +1,34 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.numberToFixed = exports.timeNow = void 0; +/** + * @returns the number of milliseconds elapsed since midnight, + * January 1, 1970 Universal Coordinated Time (UTC). + */ +function timeNow() { + return performance.now(); +} +exports.timeNow = timeNow; +/** + * @param fractionDigits - number of digits after the decimal point [0 - 20] + * @returns a string representing a number in fixed-point notation + */ +function numberToFixed(value, fractionDigits) { + return value.toFixed(fractionDigits); +} +exports.numberToFixed = numberToFixed; +//# sourceMappingURL=performance.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/prop-deep-copy.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/prop-deep-copy.d.ts new file mode 100644 index 000000000..5248eba2d --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/prop-deep-copy.d.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022-2025 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 declare function propDeepCopy(sourceObject: T): T; +//# sourceMappingURL=prop-deep-copy.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/prop-deep-copy.js b/koala-wrapper/koalaui/compat/dist/src/typescript/prop-deep-copy.js new file mode 100644 index 000000000..157cb42df --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/prop-deep-copy.js @@ -0,0 +1,88 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.propDeepCopy = void 0; +const observable_1 = require("./observable"); +/* + When decorating variables of complex types, + @Prop makes a deep copy, during which all types, + except primitive types, Map, Set, Date, and Array, will be lost. + */ +function propDeepCopy(sourceObject) { + if (!sourceObject || typeof sourceObject !== 'object') { + return sourceObject; + } + const copiedObjects = new Map(); + return recursiveDeepCopy(sourceObject); + function recursiveDeepCopy(sourceObject) { + if (!sourceObject || typeof sourceObject !== 'object') { + return sourceObject; + } + const storedObject = copiedObjects.get(sourceObject); + if (storedObject !== undefined) { + return storedObject; + } + const copy = copyDeepTrackable(sourceObject); + const objectToCopyFrom = (0, observable_1.getObservableTarget)(sourceObject); + Object.keys(objectToCopyFrom) + .forEach((key) => { + const property = objectToCopyFrom[key]; + if (typeof property === "function") { + Reflect.set(copy, key, property); + copy[key] = copy[key].bind(copy); + return; + } + Reflect.set(copy, key, recursiveDeepCopy(property)); + }); + return copy; + } + function copyDeepTrackable(sourceObject) { + if (sourceObject instanceof Set) { + const copy = new Set(); + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)); + copiedObjects.set(sourceObject, copy); + for (const setKey of sourceObject.keys()) { + copy.add(recursiveDeepCopy(setKey)); + } + return copy; + } + if (sourceObject instanceof Map) { + const copy = new Map(); + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)); + copiedObjects.set(sourceObject, copy); + for (const mapKey of sourceObject.keys()) { + copy.set(mapKey, recursiveDeepCopy(sourceObject.get(mapKey))); + } + return copy; + } + if (sourceObject instanceof Date) { + const copy = new Date(); + copy.setTime(sourceObject.getTime()); + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)); + copiedObjects.set(sourceObject, copy); + return copy; + } + if (sourceObject instanceof Object) { + const copy = Array.isArray(sourceObject) ? [] : {}; + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)); + copiedObjects.set(sourceObject, copy); + return copy; + } + return sourceObject; + } +} +exports.propDeepCopy = propDeepCopy; +//# sourceMappingURL=prop-deep-copy.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/reflection.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/reflection.d.ts new file mode 100644 index 000000000..231d7b525 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/reflection.d.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022-2025 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 declare function lcClassName(object: Object): string; +//# sourceMappingURL=reflection.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/reflection.js b/koala-wrapper/koalaui/compat/dist/src/typescript/reflection.js new file mode 100644 index 000000000..73b3ff9e7 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/reflection.js @@ -0,0 +1,24 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.lcClassName = void 0; +const ts_reflection_1 = require("./ts-reflection"); +function lcClassName(object) { + return (0, ts_reflection_1.className)(object).toLowerCase(); +} +exports.lcClassName = lcClassName; +//# sourceMappingURL=reflection.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/strings.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/strings.d.ts new file mode 100644 index 000000000..3af44f725 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/strings.d.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "./types"; +interface SystemTextEncoder { + encode(input?: string): Uint8Array; + encodeInto(src: string, dest: Uint8Array): void; +} +interface WithStreamOption { + stream?: boolean | undefined; +} +interface SystemTextDecoder { + decode(input?: ArrayBuffer | null, options?: WithStreamOption): string; +} +export declare class CustomTextEncoder { + static readonly HeaderLen: int32; + constructor(encoder?: SystemTextEncoder | undefined); + private readonly encoder; + static stringLength(input: string): int32; + encodedLength(input: string): int32; + private addLength; + static getHeaderLength(array: Uint8Array, offset?: int32): int32; + encode(input: string | undefined, addLength?: boolean): Uint8Array; + encodeArray(strings: Array): Uint8Array; + encodeInto(input: string, result: Uint8Array, position: int32): Uint8Array; +} +export declare class CustomTextDecoder { + static cpArrayMaxSize: number; + constructor(decoder?: SystemTextDecoder | undefined); + private readonly decoder; + decode(input: Uint8Array): string; +} +export {}; +//# sourceMappingURL=strings.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/strings.js b/koala-wrapper/koalaui/compat/dist/src/typescript/strings.js new file mode 100644 index 000000000..a2419d0a2 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/strings.js @@ -0,0 +1,189 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CustomTextDecoder = exports.CustomTextEncoder = void 0; +class CustomTextEncoder { + constructor(encoder = ((typeof TextEncoder != "undefined") ? new TextEncoder() : undefined)) { + this.encoder = encoder; + } + static stringLength(input) { + let length = 0; + for (let i = 0; i < input.length; i++) { + length++; + let cp = input.codePointAt(i); + if (cp >= 0x10000) { + i++; + } + } + return length; + } + encodedLength(input) { + let length = 0; + for (let i = 0; i < input.length; i++) { + let cp = input.codePointAt(i); + if (cp < 0x80) { + length += 1; + } + else if (cp < 0x800) { + length += 2; + } + else if (cp < 0x10000) { + length += 3; + } + else { + length += 4; + i++; + } + } + return length; + } + addLength(array, offset, len) { + array[offset] = (len & 0xff); + array[offset + 1] = ((len >> 8) & 0xff); + array[offset + 2] = ((len >> 16) & 0xff); + array[offset + 3] = ((len >> 24) & 0xff); + } + static getHeaderLength(array, offset = 0) { + return (array[offset] | (array[offset + 1] << 8) | (array[offset + 2] << 16) | (array[offset + 3] << 24)); + } + // Produces array of bytes with encoded string headed by 4 bytes (little endian) size information: + // [s0][s1][s2][s3] [c_0] ... [c_size-1] + encode(input, addLength = true) { + let headerLen = addLength ? CustomTextEncoder.HeaderLen : 0; + let result; + if (!input) { + result = new Uint8Array(headerLen); + } + else if (this.encoder !== undefined) { + result = this.encoder.encode('s'.repeat(headerLen) + input); + } + else { + let length = this.encodedLength(input); + result = new Uint8Array(length + headerLen); + this.encodeInto(input, result, headerLen); + } + if (addLength) { + this.addLength(result, 0, result.length - headerLen); + } + return result; + } + // Produces encoded array of strings with size information. + encodeArray(strings) { + let totalBytes = CustomTextEncoder.HeaderLen; + let lengths = new Int32Array(strings.length); + for (let i = 0; i < lengths.length; i++) { + let len = this.encodedLength(strings[i]); + lengths[i] = len; + totalBytes += len + CustomTextEncoder.HeaderLen; + } + let array = new Uint8Array(totalBytes); + let position = 0; + this.addLength(array, position, lengths.length); + position += CustomTextEncoder.HeaderLen; + for (let i = 0; i < lengths.length; i++) { + this.addLength(array, position, lengths[i]); + position += CustomTextEncoder.HeaderLen; + this.encodeInto(strings[i], array, position); + position += lengths[i]; + } + return array; + } + encodeInto(input, result, position) { + if (this.encoder !== undefined) { + this.encoder.encodeInto(input, result.subarray(position, result.length)); + return result; + } + let index = position; + for (let stringPosition = 0; stringPosition < input.length; stringPosition++) { + let cp = input.codePointAt(stringPosition); + if (cp < 0x80) { + result[index++] = (cp | 0); + } + else if (cp < 0x800) { + result[index++] = ((cp >> 6) | 0xc0); + result[index++] = ((cp & 0x3f) | 0x80); + } + else if (cp < 0x10000) { + result[index++] = ((cp >> 12) | 0xe0); + result[index++] = (((cp >> 6) & 0x3f) | 0x80); + result[index++] = ((cp & 0x3f) | 0x80); + } + else { + result[index++] = ((cp >> 18) | 0xf0); + result[index++] = (((cp >> 12) & 0x3f) | 0x80); + result[index++] = (((cp >> 6) & 0x3f) | 0x80); + result[index++] = ((cp & 0x3f) | 0x80); + stringPosition++; + } + } + result[index] = 0; + return result; + } +} +exports.CustomTextEncoder = CustomTextEncoder; +CustomTextEncoder.HeaderLen = Int32Array.BYTES_PER_ELEMENT; +class CustomTextDecoder { + constructor(decoder = ((typeof TextDecoder != "undefined") ? new TextDecoder() : undefined)) { + this.decoder = decoder; + } + decode(input) { + if (this.decoder !== undefined) { + return this.decoder.decode(input); + } + const cpSize = Math.min(CustomTextDecoder.cpArrayMaxSize, input.length); + let codePoints = new Int32Array(cpSize); + let cpIndex = 0; + let index = 0; + let result = ""; + while (index < input.length) { + let elem = input[index]; + let lead = elem & 0xff; + let count = 0; + let value = 0; + if (lead < 0x80) { + count = 1; + value = elem; + } + else if ((lead >> 5) == 0x6) { + value = ((elem << 6) & 0x7ff) + (input[index + 1] & 0x3f); + count = 2; + } + else if ((lead >> 4) == 0xe) { + value = ((elem << 12) & 0xffff) + ((input[index + 1] << 6) & 0xfff) + + (input[index + 2] & 0x3f); + count = 3; + } + else if ((lead >> 3) == 0x1e) { + value = ((elem << 18) & 0x1fffff) + ((input[index + 1] << 12) & 0x3ffff) + + ((input[index + 2] << 6) & 0xfff) + (input[index + 3] & 0x3f); + count = 4; + } + codePoints[cpIndex++] = value; + if (cpIndex == cpSize) { + cpIndex = 0; + result += String.fromCodePoint(...codePoints); + } + index += count; + } + if (cpIndex > 0) { + result += String.fromCodePoint(...codePoints.slice(0, cpIndex)); + } + return result; + } +} +exports.CustomTextDecoder = CustomTextDecoder; +CustomTextDecoder.cpArrayMaxSize = 128; +//# sourceMappingURL=strings.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/ts-reflection.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/ts-reflection.d.ts new file mode 100644 index 000000000..3d013c4d5 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/ts-reflection.d.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022-2025 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 declare function className(object?: Object): string; +export declare function isFunction(object?: Object): boolean; +export declare function functionOverValue(value: Value | (() => Value)): boolean; +export declare function refEqual(a: Value, b: Value): boolean; +export declare function isNotPrimitive(value: Object): boolean; +//# sourceMappingURL=ts-reflection.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/ts-reflection.js b/koala-wrapper/koalaui/compat/dist/src/typescript/ts-reflection.js new file mode 100644 index 000000000..c2ba31757 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/ts-reflection.js @@ -0,0 +1,40 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isNotPrimitive = exports.refEqual = exports.functionOverValue = exports.isFunction = exports.className = void 0; +function className(object) { + var _a; + return (_a = object === null || object === void 0 ? void 0 : object.constructor.name) !== null && _a !== void 0 ? _a : ""; +} +exports.className = className; +function isFunction(object) { + return typeof object === 'function'; +} +exports.isFunction = isFunction; +// TODO: this is to match arkts counterpart +function functionOverValue(value) { + return typeof value === 'function'; +} +exports.functionOverValue = functionOverValue; +function refEqual(a, b) { + return a === b; +} +exports.refEqual = refEqual; +function isNotPrimitive(value) { + return true; +} +exports.isNotPrimitive = isNotPrimitive; +//# sourceMappingURL=ts-reflection.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/types.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/types.d.ts new file mode 100644 index 000000000..3a8beb40c --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/types.d.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022-2025 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 type uint8 = int; +export type int8 = int; +export type int16 = int; +export type int32 = int; +export type uint32 = int; +export type int64 = long; +export type uint64 = long; +export type float32 = float; +export type float64 = double; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/types.js b/koala-wrapper/koalaui/compat/dist/src/typescript/types.js new file mode 100644 index 000000000..af49665f4 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/types.js @@ -0,0 +1,18 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +/// +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/utils.d.ts b/koala-wrapper/koalaui/compat/dist/src/typescript/utils.d.ts new file mode 100644 index 000000000..f359d5f17 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/utils.d.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022-2025 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 declare function unsafeCast(value: unknown): T; +//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/dist/src/typescript/utils.js b/koala-wrapper/koalaui/compat/dist/src/typescript/utils.js new file mode 100644 index 000000000..ec1727664 --- /dev/null +++ b/koala-wrapper/koalaui/compat/dist/src/typescript/utils.js @@ -0,0 +1,22 @@ +"use strict"; +/* + * Copyright (c) 2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.unsafeCast = void 0; +function unsafeCast(value) { + return value; +} +exports.unsafeCast = unsafeCast; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/compat/src/arkts/array.ts b/koala-wrapper/koalaui/compat/src/arkts/array.ts new file mode 100644 index 000000000..123dd33d7 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/array.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022-2025 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 { float64, int32, int8 } from "./types" + +// TODO: this can be a performance disaster +// just wait for the library to provide the proper functionality. +export function asArray(value: T[]): Array { + return Array.of(...value) +} + +// TODO: this can be a performance disaster +// just wait for the library to provide the proper functionality. +export function Array_from_set(set: Set): Array { + const array = new Array() // to avoid creation of undefined content + const values = set.values() + for (let it = values.next(); it.done != true; it = values.next()) { + array.push(it.value as T) + } + return array +} + +// TODO: this can be a performance disaster +// just wait for the library to provide the proper functionality. +export function Array_from_int32(data: Int32Array): number[] { + const result: number[] = [] + for (let i: int32 = 0; i < data.length; i++) { + result[i] = data.at(i) as number + } + return result +} + +// TODO: this can be a performance disaster +// just wait for the library to provide the proper functionality. +export function Array_from_number(data: float64[]): Array { + const result = new Array(data.length) + for (let i: int32 = 0; i < data.length; i++) { + result[i] = data[i] + } + return result +} + +export function int8Array(size: int32): int8[] { + return new int8[size] +} + diff --git a/koala-wrapper/koalaui/compat/src/arkts/atomic.ts b/koala-wrapper/koalaui/compat/src/arkts/atomic.ts new file mode 100644 index 000000000..241b0944c --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/atomic.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +/** + * A reference that may be updated atomically. + */ +export class AtomicRef { + value: Value + + /** + * Creates a new reference object with the given initial value. + * @param value - the new value + */ + constructor(value: Value) { + this.value = value + } + + /** + * Atomically sets the reference value to the given value and returns the previous one. + * @param value - the new value + * @returns the previous value + */ + getAndSet(value: Value): Value { + // TODO: replace with the implementation from ArkTS language when it is ready + const result = this.value + this.value = value + return result + } +} diff --git a/koala-wrapper/koalaui/compat/src/arkts/double.ts b/koala-wrapper/koalaui/compat/src/arkts/double.ts new file mode 100644 index 000000000..0dfb7fea3 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/double.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022-2025 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 { float64, int32, float32 } from "./types" + +export function asFloat64(value: string): float64 { + return (new Number(value)).valueOf() +} + +export function asString(value: float64 | undefined): string | undefined { + if (value === undefined) return undefined + return (new Number(value)).toString() +} + +export function float32FromBits(value: int32): float32 { + return Float.bitCastFromInt(value) +} + +export function int32BitsFromFloat(value: float32): int32 { + return Float.bitCastToInt(value) +} diff --git a/koala-wrapper/koalaui/compat/src/arkts/finalization.ts b/koala-wrapper/koalaui/compat/src/arkts/finalization.ts new file mode 100644 index 000000000..92ba81b14 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/finalization.ts @@ -0,0 +1,31 @@ + +/* + * Copyright (c) 2025 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 interface Thunk { + clean(): void +} + +const registry = new FinalizationRegistry((thunk: Thunk) => { + thunk.clean() +}) + +export function finalizerRegister(target: Object, thunk: Object) { + registry.register(target, thunk as Thunk) +} + +export function finalizerUnregister(target: Object) { + registry.unregister(target) +} diff --git a/koala-wrapper/koalaui/compat/src/arkts/index.ts b/koala-wrapper/koalaui/compat/src/arkts/index.ts new file mode 100644 index 000000000..c6077254c --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/index.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2025 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 * from "./array" +export * from "./atomic" +export * from "./double" +export * from "./finalization" +export * from "./performance" +export * from "./prop-deep-copy" +export * from "./observable" +export * from "./reflection" +export * from "./strings" +export * from "./ts-reflection" +export * from "./types" +export * from "./utils" diff --git a/koala-wrapper/koalaui/compat/src/arkts/observable.ts b/koala-wrapper/koalaui/compat/src/arkts/observable.ts new file mode 100644 index 000000000..4326f0122 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/observable.ts @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "./types" + +const OBSERVABLE_TARGET = "target" + +export function getObservableTarget(proxy: Object): Object { + try { + return Reflect.get(proxy, OBSERVABLE_TARGET) ?? proxy + } catch (error) { + return proxy + } +} + +/** + * Data class decorator that makes all child fields trackable. + */ +export function Observed() { + throw new Error("TypeScript class decorators are not supported yet") +} + +/** @internal */ +export interface Observable { + /** It is called when the observable value is accessed. */ + onAccess(): void + /** It is called when the observable value is modified. */ + onModify(): void +} + +/** @internal */ +export class ObservableHandler implements Observable { + private static handlers: WeakMap | undefined = undefined + + private parents = new Set() + private children = new Map() + + private readonly observables = new Set() + private _modified = false + + readonly observed: boolean + constructor(parent?: ObservableHandler, observed: boolean = false) { + this.observed = observed + if (parent) this.addParent(parent) + } + + onAccess(): void { + if (this.observables.size > 0) { + const it = this.observables.keys() + while (true) { + const result = it.next() + if (result.done) break + result.value?.onAccess() + } + } + } + + onModify(): void { + const set = new Set() + this.collect(true, set) + set.forEach((handler: ObservableHandler) => { + handler._modified = true + if (handler.observables.size > 0) { + const it = handler.observables.keys() + while (true) { + const result = it.next() + if (result.done) break + result.value?.onModify() + } + } + }) + } + + static dropModified(value: Value): boolean { + const handler = ObservableHandler.findIfObject(value) + if (handler === undefined) return false + const result = handler._modified + handler._modified = false + return result + } + + /** Adds the specified `observable` to the handler corresponding to the given `value`. */ + static attach(value: Value, observable: Observable): void { + const handler = ObservableHandler.findIfObject(value) + if (handler) handler.observables.add(observable) + } + + /** Deletes the specified `observable` from the handler corresponding to the given `value`. */ + static detach(value: Value, observable: Observable): void { + const handler = ObservableHandler.findIfObject(value) + if (handler) handler.observables.delete(observable) + } + + /** @returns the handler corresponding to the given `value` if it was installed */ + private static findIfObject(value: Value): ObservableHandler | undefined { + const handlers = ObservableHandler.handlers + return handlers !== undefined && value instanceof Object ? handlers.get(getObservableTarget(value as Object)) : undefined + } + + /** + * @param value - any non-null object including arrays + * @returns an observable handler or `undefined` if it is not installed + */ + static find(value: Object): ObservableHandler | undefined { + const handlers = ObservableHandler.handlers + return handlers ? handlers.get(getObservableTarget(value)) : undefined + } + + /** + * @param value - any non-null object including arrays + * @param observable - a handler to install on this object + * @throws an error if observable handler cannot be installed + */ + static installOn(value: Object, observable?: ObservableHandler): void { + let handlers = ObservableHandler.handlers + if (handlers === undefined) { + handlers = new WeakMap() + ObservableHandler.handlers = handlers + } + observable + ? handlers.set(getObservableTarget(value), observable) + : handlers.delete(getObservableTarget(value)) + } + + addParent(parent: ObservableHandler) { + const count = parent.children.get(this) ?? 0 + parent.children.set(this, count + 1) + this.parents.add(parent) + } + + removeParent(parent: ObservableHandler) { + const count = parent.children.get(this) ?? 0 + if (count > 1) { + parent.children.set(this, count - 1) + } + else if (count == 1) { + parent.children.delete(this) + this.parents.delete(parent) + } + } + + removeChild(value: Value) { + const child = ObservableHandler.findIfObject(value) + if (child) child.removeParent(this) + } + + private collect(all: boolean, guards: Set) { + if (guards.has(this)) return guards // already collected + guards.add(this) // handler is already guarded + this.parents.forEach((handler: ObservableHandler) => { handler.collect(all, guards) }) + if (all) this.children.forEach((_count: number, handler: ObservableHandler) => { handler.collect(all, guards) }) + return guards + } + + static contains(observable: ObservableHandler, guards?: Set) { + if (observable.observed) return true + if (guards === undefined) guards = new Set() // create if needed + else if (guards!.has(observable)) return false // already checked + guards.add(observable) // handler is already guarded + for (const it of observable.parents.keys()) { + if (ObservableHandler.contains(it, guards)) return true + } + return false + } +} + +/** @internal */ +export function observableProxyArray(...value: Value[]): Array { + return observableProxy(Array.of(...value)) +} + +const PROXY_DISABLED = true // because of ArkTS Reflection performance + +/** @internal */ +export function observableProxy(value: Value, parent?: ObservableHandler, observed?: boolean, strict: boolean = true): Value { + if (PROXY_DISABLED) return value + if (value instanceof ObservableHandler) return value as Value // do not proxy a marker itself + if (value == null || !(value instanceof Object)) return value as Value // only non-null object can be observable + const observable = ObservableHandler.find(value as Object) + if (observable) { + if (parent) { + if (strict) observable.addParent(parent) + if (observed === undefined) observed = ObservableHandler.contains(parent) + } + if (observed) { + if (value instanceof Array) { + for (let index = 0; index < value.length; index++) { + value[index] = observableProxy(value[index], observable, observed, false) + } + } else { + // TODO: proxy fields of the given object + } + } + return value as Value + } + if (value instanceof Array) { + const handler = new ObservableHandler(parent) + const array = proxyChildrenOnly(value, handler, observed) + ObservableHandler.installOn(array, handler) + return createProxyArray(array) as Value + } + // TODO: proxy the given object + return value as Value +} + +function createProxyArray(array: Array): Array { + return Proxy.create(array, new CustomArrayProxyHandler()) +} + +function proxyChildrenOnly(array: Array, parent: ObservableHandler, observed?: boolean): Array { + if (observed === undefined) observed = ObservableHandler.contains(parent) + return array.map((it: T) => observableProxy(it, parent, observed)) +} + +class CustomArrayProxyHandler extends DefaultArrayProxyHandler { + override get(target: Array, index: int32): T { + const observable = ObservableHandler.find(target) + if (observable) observable.onAccess() + return super.get(target, index) + } + + override set(target: Array, index: int32, value: T): boolean { + const observable = ObservableHandler.find(target) + if (observable) { + observable.onModify() + observable.removeChild(super.get(target, index)) + value = observableProxy(value, observable, ObservableHandler.contains(observable)) + } + return super.set(target, index, value) + } + + override get(target: Array, name: string): NullishType { + const observable = ObservableHandler.find(target) + if (observable) observable.onAccess() + return super.get(target, name) + } + + override set(target: Array, name: string, value: NullishType): boolean { + const observable = ObservableHandler.find(target) + if (observable) { + observable.onModify() + observable.removeChild(super.get(target, name)) + value = observableProxy(value, observable, ObservableHandler.contains(observable)) + } + return super.set(target, name, value) + } + + override invoke(target: Array, method: Method, args: NullishType[]): NullishType { + const observable = ObservableHandler.find(target) + if (observable) { + const name = method.getName() + if (name == "copyWithin" || name == "reverse" || name == "sort") { + observable.onModify() + return super.invoke(target, method, args) + } + if (name == "fill") { + observable.onModify() + if (args.length > 0) { + args[0] = observableProxy(args[0], observable) + } + return super.invoke(target, method, args) + } + if (name == "pop" || name == "shift") { + observable.onModify() + const result = super.invoke(target, method, args) + observable.removeChild(result) + return result + } + if (name == "push" || name == "unshift") { + observable.onModify() + if (args.length > 0) { + const items = args[0] + if (items instanceof Array) { + args[0] = proxyChildrenOnly(items, observable) + } + } + return super.invoke(target, method, args) + } + if (name == "splice") { + observable.onModify() + if (args.length > 2) { + const items = args[2] + if (items instanceof Array) { + args[2] = proxyChildrenOnly(items, observable) + } + } + const result = super.invoke(target, method, args) + if (result instanceof Array) { + for (let i = 0; i < result.length; i++) { + observable.removeChild(result[i]) + } + } + return result + } + observable.onAccess() + } + return super.invoke(target, method, args) + } +} diff --git a/koala-wrapper/koalaui/compat/src/arkts/performance.ts b/koala-wrapper/koalaui/compat/src/arkts/performance.ts new file mode 100644 index 000000000..2755960e8 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/performance.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +/** + * @returns the number of milliseconds elapsed since midnight, + * January 1, 1970 Universal Coordinated Time (UTC). + */ +export function timeNow(): number { + return Date.now() +} + +/** + * @param fractionDigits - number of digits after the decimal point [0 - 20] + * @returns a string representing a number in fixed-point notation + */ +export function numberToFixed(value: number, fractionDigits: number): string { + return new Number(value).toFixed(fractionDigits) +} diff --git a/koala-wrapper/koalaui/compat/src/arkts/prop-deep-copy.ts b/koala-wrapper/koalaui/compat/src/arkts/prop-deep-copy.ts new file mode 100644 index 000000000..25ec18c81 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/prop-deep-copy.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +/* + When decorating variables of complex types, + @Prop makes a deep copy, during which all types, + except primitive types, Map, Set, Date, and Array, will be lost. + */ + +export function propDeepCopy(sourceObject: T): T { + return sourceObject +} diff --git a/koala-wrapper/koalaui/compat/src/arkts/reflection.ts b/koala-wrapper/koalaui/compat/src/arkts/reflection.ts new file mode 100644 index 000000000..75bdadc33 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/reflection.ts @@ -0,0 +1,22 @@ + +/* + * Copyright (c) 2022-2025 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 { className } from "./ts-reflection" + +export function lcClassName(object: Object) { + return className(object).toLowerCase() +} + +export @interface Entry {} diff --git a/koala-wrapper/koalaui/compat/src/arkts/strings.ts b/koala-wrapper/koalaui/compat/src/arkts/strings.ts new file mode 100644 index 000000000..b0129c085 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/strings.ts @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2022-2025 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 { int32, uint8 } from "./types" +import { Array_from_int32 } from "./array" + + +interface SystemTextEncoder { + encode(input?: string): Uint8Array; + encodeInto(src: string, dest: Uint8Array): void; +} + +interface WithStreamOption { + stream: Boolean | undefined; +} + +interface SystemTextDecoder { + decode( + input: ArrayBuffer | null | undefined | Uint8Array, + options: WithStreamOption | undefined + ): string; +} + +export class CustomTextEncoder { + static readonly HeaderLen: int32 = Int32Array.BYTES_PER_ELEMENT + + constructor(encoder:SystemTextEncoder|undefined = undefined) { + this.encoder = encoder + } + + private readonly encoder: SystemTextEncoder|undefined + + public static stringLength(input: string): int32 { + let length = 0 + for (let i = 0; i < input.length; i++) { + length++ + let cp = input.codePointAt(i)! + if (cp >= 0x10000) { + i++ + } + } + return length + } + + encodedLength(input: string): int32 { + let length = 0 + for (let i = 0; i < input.length; i++) { + let cp = input.codePointAt(i)! + if (cp < 0x80) { + length += 1 + } else if (cp < 0x800) { + length += 2 + } else if (cp < 0x10000) { + length += 3 + } else { + length += 4 + i++ + } + } + return length + } + + private addLength(array: Uint8Array, offset: int32, length: int32 | number): void { + const len = length as int32 + array.set(offset, len & 0xff) + array.set(offset + 1, (len >> 8) & 0xff) + array.set(offset + 2, (len >> 16) & 0xff) + array.set(offset + 3, (len >> 24) & 0xff) + } + + static getHeaderLength(array: Uint8Array, offset: int32 = 0): int32 { + return ( + (array.at(offset) as int32) | + (array.at(((offset + 1) << 8)) as int32) | + (array.at((offset + 2) << 16) as int32) | + (array.at((offset + 3) << 24)) as int32) + } + + // Produces array of bytes with encoded string headed by 4 bytes (little endian) size information: + // [s0][s1][s2][s3] [c_0] ... [c_size-1] + encode(input: string | undefined, addLength: boolean = true): Uint8Array { + let headerLen = addLength ? CustomTextEncoder.HeaderLen : 0 + let result: Uint8Array + if (!input) { + result = new Uint8Array(headerLen) + } else if (this.encoder !== undefined) { + result = this.encoder!.encode('s'.repeat(headerLen) + input) + } else { + let length = this.encodedLength(input) + result = new Uint8Array(length + headerLen) + this.encodeInto(input, result, headerLen) + } + if (addLength) { + this.addLength(result, 0, (result.length - headerLen) as int32) + } + return result + } + + // Produces encoded array of strings with size information. + encodeArray(strings: Array): Uint8Array { + let totalBytes = CustomTextEncoder.HeaderLen + let lengths = new Int32Array(strings.length) + for (let i = 0; i < lengths.length; i++) { + let len = this.encodedLength(strings[i]) + lengths[i] = len + totalBytes += len + CustomTextEncoder.HeaderLen + } + let array = new Uint8Array(totalBytes) + let position = 0 + this.addLength(array, position, lengths.length as int32) + position += CustomTextEncoder.HeaderLen + for (let i = 0; i < lengths.length; i++) { + this.addLength(array, position, lengths[i] as int32) + position += CustomTextEncoder.HeaderLen + this.encodeInto(strings[i], array, position) + position += lengths[i] + } + return array + } + + encodeInto(input: string, result: Uint8Array, position: int32): Uint8Array { + if (this.encoder !== undefined) { + this.encoder!.encodeInto(input, result.subarray(position, result.length)) + return result + } + let index = position + for (let stringPosition = 0; stringPosition < input.length; stringPosition++) { + let cp = input.codePointAt(stringPosition)! + if (cp < 0x80) { + result[index++] = (cp | 0) + } else if (cp < 0x800) { + result[index++] = ((cp >> 6) | 0xc0) + result[index++] = ((cp & 0x3f) | 0x80) + } else if (cp < 0x10000) { + result[index++] = ((cp >> 12) | 0xe0) + result[index++] = (((cp >> 6) & 0x3f) | 0x80) + result[index++] = ((cp & 0x3f) | 0x80) + } else { + result[index++] = ((cp >> 18) | 0xf0) + result[index++] = (((cp >> 12) & 0x3f) | 0x80) + result[index++] = (((cp >> 6) & 0x3f) | 0x80) + result[index++] = ((cp & 0x3f) | 0x80) + stringPosition++ + } + } + result[index] = 0 + return result + } +} + +export class CustomTextDecoder { + static cpArrayMaxSize = 128 + constructor(decoder: SystemTextDecoder|undefined = undefined) { + this.decoder = decoder + } + + private readonly decoder: SystemTextDecoder|undefined + + decode(input: Uint8Array): string { + if (this.decoder !== undefined) { + return this.decoder!.decode(input, undefined) + } + + const cpSize = Math.min(CustomTextDecoder.cpArrayMaxSize, input.length) + let codePoints = new Int32Array(cpSize) + let cpIndex = 0; + let index = 0 + let result = "" + while (index < input.length) { + let elem = input[index] as uint8 + let lead = elem & 0xff + let count = 0 + let value = 0 + if (lead < 0x80) { + count = 1 + value = elem + } else if ((lead >> 5) == 0x6) { + value = (((elem << 6) & 0x7ff) + (input[index + 1] & 0x3f)) as int32 + count = 2 + } else if ((lead >> 4) == 0xe) { + value = (((elem << 12) & 0xffff) + ((input[index + 1] << 6) & 0xfff) + + (input[index + 2] & 0x3f)) as int32 + count = 3 + } else if ((lead >> 3) == 0x1e) { + value = (((elem << 18) & 0x1fffff) + ((input[index + 1] << 12) & 0x3ffff) + + ((input[index + 2] << 6) & 0xfff) + (input[index + 3] & 0x3f)) as int32 + count = 4 + } + codePoints[cpIndex++] = value + if (cpIndex == cpSize) { + cpIndex = 0 + //result += String.fromCodePoint(...codePoints) + result += String.fromCodePoint(...Array_from_int32(codePoints)) + } + index += count + } + if (cpIndex > 0) { + result += String.fromCodePoint(...Array_from_int32(codePoints.slice(0, cpIndex))) + } + return result + } +} diff --git a/koala-wrapper/koalaui/compat/src/arkts/ts-reflection.ts b/koala-wrapper/koalaui/compat/src/arkts/ts-reflection.ts new file mode 100644 index 000000000..0214ccf02 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/ts-reflection.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022-2025 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 className(object?: Object): string { + return object ? (Type.of(object) as ClassType).getName() : "null" +} + +export function isFunction(object?: Object): boolean { + return Type.of(object) instanceof FunctionType +} + +// TODO: This is an very ad hoc function, +// but I could not find in ArkTS stdlib enough functionality +// for a more generic way. +export function functionOverValue(value: Value|(()=>Value)): boolean { + return Type.of(value) instanceof FunctionType +} + +// Somehow es2panda only allows === on reference types. +export function refEqual(a: Value, b: Value): boolean { + return a == b +} + +export function isNotPrimitive(value: Object): boolean { + return !Type.of(value).isPrimitive() +} diff --git a/koala-wrapper/koalaui/compat/src/arkts/types.ts b/koala-wrapper/koalaui/compat/src/arkts/types.ts new file mode 100644 index 000000000..3f4d932f4 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/types.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2025 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 type uint8 = byte +export type int8 = byte +export type unt16 = short +export type int16 = short +export type int32 = int +export type uint32 = int +export type int64 = long +export type uint64 = long +export type float32 = float +export type float64 = double diff --git a/koala-wrapper/koalaui/compat/src/arkts/utils.ts b/koala-wrapper/koalaui/compat/src/arkts/utils.ts new file mode 100644 index 000000000..45c74d2e4 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/arkts/utils.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 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 +} diff --git a/koala-wrapper/koalaui/compat/src/index.ts b/koala-wrapper/koalaui/compat/src/index.ts new file mode 100644 index 000000000..e2760b0c7 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/index.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022-2025 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 { + asArray, + Array_from_set, + Array_from_int32, + Array_from_number, + AtomicRef, + asFloat64, + asString, + float32FromBits, + int32BitsFromFloat, + Thunk, + finalizerRegister, + finalizerUnregister, + timeNow, + numberToFixed, + Observed, + Observable, + ObservableHandler, + observableProxy, + observableProxyArray, + propDeepCopy, + lcClassName, + CustomTextEncoder, + CustomTextDecoder, + className, + isFunction, + functionOverValue, + refEqual, + isNotPrimitive, + uint8, + int8, + int16, + int32, + uint32, + int64, + uint64, + float32, + float64, + int8Array, + unsafeCast, +} from "#platform" diff --git a/koala-wrapper/koalaui/compat/src/ohos/index.ts b/koala-wrapper/koalaui/compat/src/ohos/index.ts new file mode 100644 index 000000000..b5bd901b4 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/ohos/index.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022-2025 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 { + asArray, + Array_from_set, + Array_from_int32, + Array_from_number, + AtomicRef, + asFloat64, + asString, + float32FromBits, + int32BitsFromFloat, + Thunk, + finalizerRegister, + finalizerUnregister, + Observed, + Observable, + ObservableHandler, + observableProxy, + observableProxyArray, + propDeepCopy, + lcClassName, + CustomTextEncoder, + CustomTextDecoder, + className, + isFunction, + functionOverValue, + refEqual, + isNotPrimitive, + uint8, + int8, + int16, + int32, + uint32, + int64, + uint64, + float32, + float64, + int8Array, + unsafeCast, +} from "../typescript" + +export { + timeNow, + numberToFixed, +} from "./performance" diff --git a/koala-wrapper/koalaui/compat/src/ohos/performance.ts b/koala-wrapper/koalaui/compat/src/ohos/performance.ts new file mode 100644 index 000000000..2755960e8 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/ohos/performance.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +/** + * @returns the number of milliseconds elapsed since midnight, + * January 1, 1970 Universal Coordinated Time (UTC). + */ +export function timeNow(): number { + return Date.now() +} + +/** + * @param fractionDigits - number of digits after the decimal point [0 - 20] + * @returns a string representing a number in fixed-point notation + */ +export function numberToFixed(value: number, fractionDigits: number): string { + return new Number(value).toFixed(fractionDigits) +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/Types.d.ts b/koala-wrapper/koalaui/compat/src/typescript/Types.d.ts new file mode 100644 index 000000000..6b3ee5d94 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/Types.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +type int = number +type long = number +type float = number +type double = number diff --git a/koala-wrapper/koalaui/compat/src/typescript/array.ts b/koala-wrapper/koalaui/compat/src/typescript/array.ts new file mode 100644 index 000000000..9392bb412 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/array.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022-2025 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 { float64, int32, int8 } from "./types" + +export function asArray(value: T[]): Array { + return value +} + +export function Array_from_set(set: Set): Array { + return Array.from(set) +} + +export function Array_from_int32(data: Int32Array): int32[] { + return Array.from(data) +} + +export function Array_from_number(data: float64[]): Array { + return data +} + +export function int8Array(size: int32): int8[] { + return [] +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/atomic.ts b/koala-wrapper/koalaui/compat/src/typescript/atomic.ts new file mode 100644 index 000000000..e6312b700 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/atomic.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +/** + * A reference that may be updated atomically. + */ +export class AtomicRef { + value: Value + + /** + * Creates a new reference object with the given initial value. + * @param value - the new value + */ + constructor(value: Value) { + this.value = value + } + + /** + * Atomically sets the reference value to the given value and returns the previous one. + * @param value - the new value + * @returns the previous value + */ + getAndSet(value: Value): Value { + const result = this.value + this.value = value + return result + } +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/double.ts b/koala-wrapper/koalaui/compat/src/typescript/double.ts new file mode 100644 index 000000000..ee4ad821e --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/double.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022-2025 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 { float64, int32, float32 } from "./types" + +export function asFloat64(value: string): float64 { + return Number(value) +} + +export function asString(value: float64 | undefined): string | undefined { + return value?.toString() +} + +export function float32FromBits(value: int32): float32 { + return value +} + +export function int32BitsFromFloat(value: float32): int32 { + return value +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/finalization.ts b/koala-wrapper/koalaui/compat/src/typescript/finalization.ts new file mode 100644 index 000000000..4aa68d116 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/finalization.ts @@ -0,0 +1,43 @@ + +/* + * Copyright (c) 2025 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 interface Thunk { + clean(): void +} + +interface FinalizationRegistry { + register(target: object, value: any, token?: object): void; + unregister(token: object): void; +} + +interface FinalizationRegistryConstructor { + readonly prototype: FinalizationRegistry; + new(callback: (value: any) => void): FinalizationRegistry; +} + +declare const FinalizationRegistry: FinalizationRegistryConstructor + +const registry = new FinalizationRegistry((thunk: Thunk) => { + thunk.clean() +}) + +export function finalizerRegister(target: object, thunk: object) { + registry.register(target, thunk) +} + +export function finalizerUnregister(target: object) { + registry.unregister(target) +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/index.ts b/koala-wrapper/koalaui/compat/src/typescript/index.ts new file mode 100644 index 000000000..84eed3cf9 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/index.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2025 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 * from "./array" +export * from "./atomic" +export * from "./double" +export * from "./finalization" +export * from "./observable" +export * from "./performance" +export * from "./prop-deep-copy" +export * from "./reflection" +export * from "./strings" +export * from "./ts-reflection" +export * from "./types" +export * from "./utils" diff --git a/koala-wrapper/koalaui/compat/src/typescript/observable.ts b/koala-wrapper/koalaui/compat/src/typescript/observable.ts new file mode 100644 index 000000000..fd40fcdcf --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/observable.ts @@ -0,0 +1,404 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +const OBSERVABLE_TARGET = "__proxy_observable_target__" + +export function getObservableTarget(proxy: Object): Object { + return getPropertyValue(OBSERVABLE_TARGET, proxy) ?? proxy +} + +function getPropertyValue(name: string, object: any): any { + return object[name] +} + +/** + * Data class decorator that makes all child fields trackable. + */ +export function Observed(constructorFunction: Function) { + constructorFunction.prototype[OBSERVED] = true +} + +const OBSERVED = "__ObservedByArkUI__" +function isObserved(value: any): boolean { + return value[OBSERVED] === true +} + +/** @internal */ +export interface Observable { + /** It is called when the observable value is accessed. */ + onAccess(): void + /** It is called when the observable value is modified. */ + onModify(): void +} + +/** @internal */ +export class ObservableHandler implements Observable { + private static handlers: WeakMap | undefined = undefined + + private parents = new Set() + private children = new Map() + + private readonly observables = new Set() + private _modified = false + + readonly observed: boolean + constructor(parent?: ObservableHandler, observed: boolean = false) { + this.observed = observed + if (parent) this.addParent(parent) + } + + onAccess(): void { + if (this.observables.size > 0) { + const it = this.observables.keys() + while (true) { + const result = it.next() + if (result.done) break + result.value?.onAccess() + } + } + } + + onModify(): void { + const set = new Set() + this.collect(true, set) + set.forEach((handler: ObservableHandler) => { + handler._modified = true + if (handler.observables.size > 0) { + const it = handler.observables.keys() + while (true) { + const result = it.next() + if (result.done) break + result.value?.onModify() + } + } + }) + } + + static dropModified(value: Value): boolean { + const handler = ObservableHandler.findIfObject(value) + if (handler === undefined) return false + const result = handler._modified + handler._modified = false + return result + } + + /** Adds the specified `observable` to the handler corresponding to the given `value`. */ + static attach(value: Value, observable: Observable): void { + const handler = ObservableHandler.findIfObject(value) + if (handler) handler.observables.add(observable) + } + + /** Deletes the specified `observable` from the handler corresponding to the given `value`. */ + static detach(value: Value, observable: Observable): void { + const handler = ObservableHandler.findIfObject(value) + if (handler) handler.observables.delete(observable) + } + + /** @returns the handler corresponding to the given `value` if it was installed */ + private static findIfObject(value: Value): ObservableHandler | undefined { + const handlers = ObservableHandler.handlers + return handlers !== undefined && value instanceof Object ? handlers.get(getObservableTarget(value as Object)) : undefined + } + + /** + * @param value - any non-null object including arrays + * @returns an observable handler or `undefined` if it is not installed + */ + static find(value: Object): ObservableHandler | undefined { + const handlers = ObservableHandler.handlers + return handlers ? handlers.get(getObservableTarget(value)) : undefined + } + + /** + * @param value - any non-null object including arrays + * @param observable - a handler to install on this object + * @throws an error if observable handler cannot be installed + */ + static installOn(value: Object, observable?: ObservableHandler): void { + let handlers = ObservableHandler.handlers + if (handlers === undefined) { + handlers = new WeakMap() + ObservableHandler.handlers = handlers + } + observable + ? handlers.set(getObservableTarget(value), observable) + : handlers.delete(getObservableTarget(value)) + } + + addParent(parent: ObservableHandler) { + const count = parent.children.get(this) ?? 0 + parent.children.set(this, count + 1) + this.parents.add(parent) + } + + removeParent(parent: ObservableHandler) { + const count = parent.children.get(this) ?? 0 + if (count > 1) { + parent.children.set(this, count - 1) + } + else if (count == 1) { + parent.children.delete(this) + this.parents.delete(parent) + } + } + + removeChild(value: Value) { + const child = ObservableHandler.findIfObject(value) + if (child) child.removeParent(this) + } + + private collect(all: boolean, guards = new Set()) { + if (guards.has(this)) return guards // already collected + guards.add(this) // handler is already guarded + this.parents.forEach(handler => handler.collect(all, guards)) + if (all) this.children.forEach((_count, handler) => handler.collect(all, guards)) + return guards + } + + static contains(observable: ObservableHandler, guards?: Set) { + if (observable.observed) return true + if (guards === undefined) guards = new Set() // create if needed + else if (guards.has(observable)) return false // already checked + guards.add(observable) // handler is already guarded + for (const it of observable.parents.keys()) { + if (ObservableHandler.contains(it, guards)) return true + } + return false + } +} + +/** @internal */ +export function observableProxyArray(...value: Value[]): Array { + return observableProxy(value) +} + +/** @internal */ +export function observableProxy(value: Value, parent?: ObservableHandler, observed?: boolean, strict = true): Value { + if (value instanceof ObservableHandler) return value // do not proxy a marker itself + if (value === null || !(value instanceof Object)) return value // only non-null object can be observable + const observable = ObservableHandler.find(value) + if (observable) { + if (parent) { + if (strict) observable.addParent(parent) + if (observed === undefined) observed = ObservableHandler.contains(parent) + } + if (observed) { + if (Array.isArray(value)) { + for (let index = 0; index < value.length; index++) { + value[index] = observableProxy(value[index], observable, observed, false) + } + } else { + proxyFields(value, false, observable) + } + } + return value + } + if (Array.isArray(value)) { + const handler = new ObservableHandler(parent) + const array = proxyChildrenOnly(value, handler, observed) + copyWithinObservable(array) + fillObservable(array) + popObservable(array) + pushObservable(array) + reverseObservable(array) + shiftObservable(array) + sortObservable(array) + spliceObservable(array) + unshiftObservable(array) + return proxyObject(array, handler) + } + if (value instanceof Date) { + const valueAsAny = (value as any) + const handler = new ObservableHandler(parent) + const setMethods = new Set([ + "setFullYear", "setMonth", "setDate", "setHours", "setMinutes", "setSeconds", + "setMilliseconds", "setTime", "setUTCFullYear", "setUTCMonth", "setUTCDate", + "setUTCHours", "setUTCMinutes", "setUTCSeconds", "setUTCMilliseconds" + ]) + setMethods.forEach((method: string) => { + const originalMethod = method + 'Original' + if (valueAsAny[originalMethod] !== undefined) { + return + } + valueAsAny[originalMethod] = valueAsAny[method] + valueAsAny[method] = function (...args: any[]) { + ObservableHandler.find(this)?.onModify() + return this[originalMethod](...args) + } + }) + return proxyObject(value, handler) + } + // TODO: support set/map + const handler = new ObservableHandler(parent, isObserved(value)) + if (handler.observed || observed) proxyFields(value, true, handler) + return proxyObject(value, handler) +} + +function proxyObject(value: any, observable: ObservableHandler) { + ObservableHandler.installOn(value, observable) + return new Proxy(value, { + get(target, property, receiver) { + if (property == OBSERVABLE_TARGET) return target + const value: any = Reflect.get(target, property, receiver) + ObservableHandler.find(target)?.onAccess() + return typeof value == "function" + ? value.bind(target) + : value + }, + set(target, property, value, receiver) { + const old = Reflect.get(target, property, receiver) + if (value === old) return true + const observable = ObservableHandler.find(target) + if (observable) { + observable.onModify() + observable.removeChild(old) + const observed = ObservableHandler.contains(observable) + if (observed || Array.isArray(target)) { + value = observableProxy(value, observable, observed) + } + } + return Reflect.set(target, property, value, receiver) + }, + deleteProperty(target, property) { + ObservableHandler.find(target)?.onModify() + delete target[property] + return true + }, + }) +} + +function proxyFields(value: any, strict: boolean, parent?: ObservableHandler) { + for (const name of Object.getOwnPropertyNames(value)) { + const descriptor = Object.getOwnPropertyDescriptor(value, name) + if (descriptor?.writable) value[name] = observableProxy(value[name], parent, true, strict) + } +} + +function proxyChildrenOnly(array: any[], parent: ObservableHandler, observed?: boolean): any[] { + if (observed === undefined) observed = ObservableHandler.contains(parent) + return array.map(it => observableProxy(it, parent, observed)) +} + +function copyWithinObservable(array: any) { + if (array.copyWithinOriginal === undefined) { + array.copyWithinOriginal = array.copyWithin + array.copyWithin = function (this, target: number, start: number, end?: number) { + const observable = ObservableHandler.find(this) + observable?.onModify() + return this.copyWithinOriginal(target, start, end) + } + } +} + +function fillObservable(array: any) { + if (array.fillOriginal === undefined) { + array.fillOriginal = array.fill + array.fill = function (this, value: any, start?: number, end?: number) { + const observable = ObservableHandler.find(this) + observable?.onModify() + if (observable) value = observableProxy(value, observable) + return this.fillOriginal(value, start, end) + } + } +} + +function popObservable(array: any) { + if (array.popOriginal === undefined) { + array.popOriginal = array.pop + array.pop = function (...args: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + const result = this.popOriginal(...args) + if (observable) observable.removeChild(result) + return result + } + } +} + +function pushObservable(array: any) { + if (array.pushOriginal === undefined) { + array.pushOriginal = array.push + array.push = function (this, ...args: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + if (observable) args = proxyChildrenOnly(args, observable) + return this.pushOriginal(...args) + } + } +} + +function reverseObservable(array: any) { + if (array.reverseOriginal === undefined) { + array.reverseOriginal = array.reverse + array.reverse = function (this) { + const observable = ObservableHandler.find(this) + observable?.onModify() + return this.reverseOriginal() + } + } +} + +function shiftObservable(array: any) { + if (array.shiftOriginal === undefined) { + array.shiftOriginal = array.shift + array.shift = function (this, ...args: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + const result = this.shiftOriginal(...args) + if (observable) observable.removeChild(result) + return result + } + } +} + +function sortObservable(array: any) { + if (array.sortOriginal === undefined) { + array.sortOriginal = array.sort + array.sort = function (this, compareFn?: (a: any, b: any) => number) { + const observable = ObservableHandler.find(this) + observable?.onModify() + return this.sortOriginal(compareFn) + } + } +} + +function spliceObservable(array: any) { + if (array.spliceOriginal === undefined) { + array.spliceOriginal = array.splice + array.splice = function (this, start: number, deleteCount: number, ...items: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + if (observable) items = proxyChildrenOnly(items, observable) + if (deleteCount === undefined) deleteCount = array.length + const result = this.spliceOriginal(start, deleteCount, ...items) + if (observable && Array.isArray(result)) { + result.forEach(it => observable.removeChild(it)) + } + return result + } + } +} + +function unshiftObservable(array: any) { + if (array.unshiftOriginal === undefined) { + array.unshiftOriginal = array.unshift + array.unshift = function (this, ...items: any[]) { + const observable = ObservableHandler.find(this) + observable?.onModify() + if (observable) items = proxyChildrenOnly(items, observable) + return this.unshiftOriginal(...items) + } + } +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/performance.ts b/koala-wrapper/koalaui/compat/src/typescript/performance.ts new file mode 100644 index 000000000..80ea8a14e --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/performance.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +/** + * @returns the number of milliseconds elapsed since midnight, + * January 1, 1970 Universal Coordinated Time (UTC). + */ +export function timeNow(): number { + return performance.now() +} + +/** + * @param fractionDigits - number of digits after the decimal point [0 - 20] + * @returns a string representing a number in fixed-point notation + */ +export function numberToFixed(value: number, fractionDigits: number): string { + return value.toFixed(fractionDigits) +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/prop-deep-copy.ts b/koala-wrapper/koalaui/compat/src/typescript/prop-deep-copy.ts new file mode 100644 index 000000000..8da5c4f71 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/prop-deep-copy.ts @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022-2025 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 { getObservableTarget } from "./observable" + +/* + When decorating variables of complex types, + @Prop makes a deep copy, during which all types, + except primitive types, Map, Set, Date, and Array, will be lost. + */ + +export function propDeepCopy(sourceObject: T): T { + if (!sourceObject || typeof sourceObject !== 'object') { + return sourceObject + } + + const copiedObjects = new Map() + return recursiveDeepCopy(sourceObject) as T + + function recursiveDeepCopy(sourceObject: Object): Object { + if (!sourceObject || typeof sourceObject !== 'object') { + return sourceObject + } + + const storedObject = copiedObjects.get(sourceObject) + if (storedObject !== undefined) { + return storedObject + } + + const copy: any = copyDeepTrackable(sourceObject) + + const objectToCopyFrom = getObservableTarget(sourceObject) + Object.keys(objectToCopyFrom) + .forEach((key) => { + const property = objectToCopyFrom[key as keyof Object] + + if (typeof property === "function") { + Reflect.set(copy, key, property) + copy[key] = copy[key].bind(copy) + return + } + Reflect.set(copy, key, recursiveDeepCopy(property)); + }) + + return copy + } + + function copyDeepTrackable(sourceObject: T): T { + if (sourceObject instanceof Set) { + const copy = new Set() + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)) + copiedObjects.set(sourceObject, copy) + for (const setKey of sourceObject.keys()) { + copy.add(recursiveDeepCopy(setKey)) + } + return copy as T + } + if (sourceObject instanceof Map) { + const copy = new Map() + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)) + copiedObjects.set(sourceObject, copy) + for (const mapKey of sourceObject.keys()) { + copy.set(mapKey, recursiveDeepCopy(sourceObject.get(mapKey))) + } + return copy as T + } + if (sourceObject instanceof Date) { + const copy = new Date() + copy.setTime(sourceObject.getTime()) + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)) + copiedObjects.set(sourceObject, copy) + return copy as T + } + if (sourceObject instanceof Object) { + const copy = Array.isArray(sourceObject) ? [] : {} + Object.setPrototypeOf(copy, Object.getPrototypeOf(sourceObject)) + copiedObjects.set(sourceObject, copy) + return copy as T + } + + return sourceObject + } +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/reflection.ts b/koala-wrapper/koalaui/compat/src/typescript/reflection.ts new file mode 100644 index 000000000..50e1863f0 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/reflection.ts @@ -0,0 +1,20 @@ + +/* + * Copyright (c) 2022-2025 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 { className } from "./ts-reflection" + +export function lcClassName(object: Object) { + return className(object).toLowerCase() +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/strings.ts b/koala-wrapper/koalaui/compat/src/typescript/strings.ts new file mode 100644 index 000000000..79ad7c2d6 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/strings.ts @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "./types" + +interface SystemTextEncoder { + encode(input?: string): Uint8Array; + encodeInto(src: string, dest: Uint8Array): void; +} + +interface WithStreamOption { + stream?: boolean | undefined; +} + +interface SystemTextDecoder { + decode( + input?: ArrayBuffer | null, + options?: WithStreamOption + ): string; +} + +export class CustomTextEncoder { + static readonly HeaderLen: int32 = Int32Array.BYTES_PER_ELEMENT + + constructor(encoder: SystemTextEncoder|undefined = ((typeof TextEncoder != "undefined") ? new TextEncoder() : undefined)) { + this.encoder = encoder + } + + private readonly encoder: SystemTextEncoder|undefined + + public static stringLength(input: string): int32 { + let length = 0 + for (let i = 0; i < input.length; i++) { + length++ + let cp = input.codePointAt(i)! + if (cp >= 0x10000) { + i++ + } + } + return length + } + + encodedLength(input: string): int32 { + let length = 0 + for (let i = 0; i < input.length; i++) { + let cp = input.codePointAt(i)! + if (cp < 0x80) { + length += 1 + } else if (cp < 0x800) { + length += 2 + } else if (cp < 0x10000) { + length += 3 + } else { + length += 4 + i++ + } + } + return length + } + + private addLength(array: Uint8Array, offset: int32, len: int32): void { + array[offset] = (len & 0xff) + array[offset + 1] = ((len >> 8) & 0xff) + array[offset + 2] = ((len >> 16) & 0xff) + array[offset + 3] = ((len >> 24) & 0xff) + } + + static getHeaderLength(array: Uint8Array, offset: int32 = 0): int32 { + return (array[offset] | (array[offset + 1] << 8) | (array[offset + 2] << 16) | (array[offset + 3] << 24)) + } + + // Produces array of bytes with encoded string headed by 4 bytes (little endian) size information: + // [s0][s1][s2][s3] [c_0] ... [c_size-1] + encode(input: string | undefined, addLength: boolean = true): Uint8Array { + let headerLen = addLength ? CustomTextEncoder.HeaderLen : 0 + let result: Uint8Array + if (!input) { + result = new Uint8Array(headerLen) + } else if (this.encoder !== undefined) { + result = this.encoder!.encode('s'.repeat(headerLen) + input) + } else { + let length = this.encodedLength(input) + result = new Uint8Array(length + headerLen) + this.encodeInto(input, result, headerLen) + } + if (addLength) { + this.addLength(result, 0, result.length - headerLen) + } + return result + } + + // Produces encoded array of strings with size information. + encodeArray(strings: Array): Uint8Array { + let totalBytes = CustomTextEncoder.HeaderLen + let lengths = new Int32Array(strings.length) + for (let i = 0; i < lengths.length; i++) { + let len = this.encodedLength(strings[i]) + lengths[i] = len + totalBytes += len + CustomTextEncoder.HeaderLen + } + let array = new Uint8Array(totalBytes) + let position = 0 + this.addLength(array, position, lengths.length) + position += CustomTextEncoder.HeaderLen + for (let i = 0; i < lengths.length; i++) { + this.addLength(array, position, lengths[i]) + position += CustomTextEncoder.HeaderLen + this.encodeInto(strings[i], array, position) + position += lengths[i] + } + return array + } + + encodeInto(input: string, result: Uint8Array, position: int32): Uint8Array { + if (this.encoder !== undefined) { + this.encoder!.encodeInto(input, result.subarray(position, result.length)) + return result + } + let index = position + for (let stringPosition = 0; stringPosition < input.length; stringPosition++) { + let cp = input.codePointAt(stringPosition)! + if (cp < 0x80) { + result[index++] = (cp | 0) + } else if (cp < 0x800) { + result[index++] = ((cp >> 6) | 0xc0) + result[index++] = ((cp & 0x3f) | 0x80) + } else if (cp < 0x10000) { + result[index++] = ((cp >> 12) | 0xe0) + result[index++] = (((cp >> 6) & 0x3f) | 0x80) + result[index++] = ((cp & 0x3f) | 0x80) + } else { + result[index++] = ((cp >> 18) | 0xf0) + result[index++] = (((cp >> 12) & 0x3f) | 0x80) + result[index++] = (((cp >> 6) & 0x3f) | 0x80) + result[index++] = ((cp & 0x3f) | 0x80) + stringPosition++ + } + } + result[index] = 0 + return result + } +} + +export class CustomTextDecoder { + static cpArrayMaxSize = 128 + constructor(decoder: SystemTextDecoder|undefined = ((typeof TextDecoder != "undefined") ? new TextDecoder() : undefined)) { + this.decoder = decoder + } + + private readonly decoder: SystemTextDecoder|undefined + + decode(input: Uint8Array): string { + if (this.decoder !== undefined) { + return this.decoder!.decode(input) + } + const cpSize = Math.min(CustomTextDecoder.cpArrayMaxSize, input.length) + let codePoints = new Int32Array(cpSize) + let cpIndex = 0; + let index = 0 + let result = "" + while (index < input.length) { + let elem = input[index] + let lead = elem & 0xff + let count = 0 + let value = 0 + if (lead < 0x80) { + count = 1 + value = elem + } else if ((lead >> 5) == 0x6) { + value = ((elem << 6) & 0x7ff) + (input[index + 1] & 0x3f) + count = 2 + } else if ((lead >> 4) == 0xe) { + value = ((elem << 12) & 0xffff) + ((input[index + 1] << 6) & 0xfff) + + (input[index + 2] & 0x3f) + count = 3 + } else if ((lead >> 3) == 0x1e) { + value = ((elem << 18) & 0x1fffff) + ((input[index + 1] << 12) & 0x3ffff) + + ((input[index + 2] << 6) & 0xfff) + (input[index + 3] & 0x3f) + count = 4 + } + codePoints[cpIndex++] = value + if (cpIndex == cpSize) { + cpIndex = 0 + result += String.fromCodePoint(...codePoints) + } + index += count + } + if (cpIndex > 0) { + result += String.fromCodePoint(...codePoints.slice(0, cpIndex)) + } + return result + } +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/ts-reflection.ts b/koala-wrapper/koalaui/compat/src/typescript/ts-reflection.ts new file mode 100644 index 000000000..f820e0045 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/ts-reflection.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-2025 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 className(object?: Object): string { + return object?.constructor.name ?? "" +} + +export function isFunction(object?: Object): boolean { + return typeof object === 'function' +} + +// TODO: this is to match arkts counterpart +export function functionOverValue(value: Value|(()=>Value)): boolean { + return typeof value === 'function' +} + +export function refEqual(a: Value, b: Value): boolean { + return a === b +} + +export function isNotPrimitive(value: Object): boolean { + return true +} diff --git a/koala-wrapper/koalaui/compat/src/typescript/types.ts b/koala-wrapper/koalaui/compat/src/typescript/types.ts new file mode 100644 index 000000000..4a2c8a411 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/types.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2025 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 type uint8 = int +export type int8 = int +export type int16 = int +export type int32 = int +export type uint32 = int +export type int64 = long +export type uint64 = long +export type float32 = float +export type float64 = double diff --git a/koala-wrapper/koalaui/compat/src/typescript/utils.ts b/koala-wrapper/koalaui/compat/src/typescript/utils.ts new file mode 100644 index 000000000..a689f8905 --- /dev/null +++ b/koala-wrapper/koalaui/compat/src/typescript/utils.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 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 +} diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/arkts/ResourceManager.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/arkts/ResourceManager.d.ts new file mode 100644 index 000000000..87813a2b6 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/arkts/ResourceManager.d.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/common"; +export type ResourceId = int32; +export declare class ResourceHolder { + private static nextResourceId; + private resources; + private static _instance; + static instance(): ResourceHolder; + hold(resourceId: ResourceId): void; + release(resourceId: ResourceId): void; + registerAndHold(resource: object): ResourceId; + get(resourceId: ResourceId): object; + has(resourceId: ResourceId): boolean; +} +//# sourceMappingURL=ResourceManager.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/arkts/ResourceManager.js b/koala-wrapper/koalaui/interop/dist/lib/src/arkts/ResourceManager.js new file mode 100644 index 000000000..3671e17e8 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/arkts/ResourceManager.js @@ -0,0 +1,61 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ResourceHolder = void 0; +class ResourceHolder { + constructor() { + this.resources = new Map(); + } + static instance() { + if (ResourceHolder._instance == undefined) { + ResourceHolder._instance = new ResourceHolder(); + } + return ResourceHolder._instance; + } + hold(resourceId) { + if (!this.resources.has(resourceId)) + throw new Error(`Resource ${resourceId} does not exists, can not hold`); + this.resources.get(resourceId).holdersCount++; + } + release(resourceId) { + if (!this.resources.has(resourceId)) + throw new Error(`Resource ${resourceId} does not exists, can not release`); + const resource = this.resources.get(resourceId); + resource.holdersCount--; + if (resource.holdersCount <= 0) + this.resources.delete(resourceId); + } + registerAndHold(resource) { + const resourceId = ResourceHolder.nextResourceId++; + this.resources.set(resourceId, { + resource: resource, + holdersCount: 1, + }); + return resourceId; + } + get(resourceId) { + if (!this.resources.has(resourceId)) + throw new Error(`Resource ${resourceId} does not exists`); + return this.resources.get(resourceId).resource; + } + has(resourceId) { + return this.resources.has(resourceId); + } +} +exports.ResourceHolder = ResourceHolder; +ResourceHolder.nextResourceId = 100; +ResourceHolder._instance = undefined; +//# sourceMappingURL=ResourceManager.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/DeserializerBase.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/DeserializerBase.d.ts new file mode 100644 index 000000000..5edd7608a --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/DeserializerBase.d.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022-2025 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 { float32, int32, int64 } from "#koalaui/common"; +import { CallbackResource } from "./SerializerBase"; +import { pointer } from "./InteropTypes"; +export declare class DeserializerBase { + private position; + private readonly buffer; + private readonly length; + private view; + private static textDecoder; + private static customDeserializers; + static registerCustomDeserializer(deserializer: CustomDeserializer): void; + constructor(buffer: ArrayBuffer, length: int32); + static get(factory: (args: Uint8Array, length: int32) => T, args: Uint8Array, length: int32): T; + asArray(position?: number, length?: number): Uint8Array; + currentPosition(): int32; + resetCurrentPosition(): void; + private checkCapacity; + readInt8(): int32; + readInt32(): int32; + readInt64(): int64; + readPointer(): pointer; + readFloat32(): float32; + readBoolean(): boolean; + readFunction(): any; + readMaterialized(): object; + readString(): string; + readCustomObject(kind: string): any; + readNumber(): number | undefined; + readCallbackResource(): CallbackResource; + static lengthUnitFromInt(unit: int32): string; + readBuffer(): ArrayBuffer; +} +export declare abstract class CustomDeserializer { + protected supported: Array; + protected constructor(supported: Array); + supports(kind: string): boolean; + abstract deserialize(serializer: DeserializerBase, kind: string): any; + next: CustomDeserializer | undefined; +} +//# sourceMappingURL=DeserializerBase.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/DeserializerBase.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/DeserializerBase.js new file mode 100644 index 000000000..4e72e82db --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/DeserializerBase.js @@ -0,0 +1,208 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CustomDeserializer = exports.DeserializerBase = void 0; +/* + * Copyright (c) 2025 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. + */ +const common_1 = require("#koalaui/common"); +const SerializerBase_1 = require("./SerializerBase"); +const InteropNativeModule_1 = require("./InteropNativeModule"); +class DeserializerBase { + static registerCustomDeserializer(deserializer) { + let current = DeserializerBase.customDeserializers; + if (current == undefined) { + DeserializerBase.customDeserializers = deserializer; + } + else { + while (current.next != undefined) { + current = current.next; + } + current.next = deserializer; + } + } + constructor(buffer, length) { + this.position = 0; + this.buffer = buffer; + this.length = length; + this.view = new DataView(this.buffer); + } + static get(factory, args, length) { + // TBD: Use cache + return factory(args, length); + } + asArray(position, length) { + return new Uint8Array(this.buffer, position, length); + } + currentPosition() { + return this.position; + } + resetCurrentPosition() { + this.position = 0; + } + checkCapacity(value) { + if (value > this.length) { + throw new Error(`${value} is less than remaining buffer length`); + } + } + readInt8() { + this.checkCapacity(1); + const value = this.view.getInt8(this.position); + this.position += 1; + return value; + } + readInt32() { + this.checkCapacity(4); + const value = this.view.getInt32(this.position, true); + this.position += 4; + return value; + } + readInt64() { + this.checkCapacity(8); + const value = this.view.getBigInt64(this.position, true); + this.position += 8; + return Number(value); + } + readPointer() { + this.checkCapacity(8); + const value = this.view.getBigInt64(this.position, true); + this.position += 8; + return value; + } + readFloat32() { + this.checkCapacity(4); + const value = this.view.getFloat32(this.position, true); + this.position += 4; + return value; + } + readBoolean() { + this.checkCapacity(1); + const value = this.view.getInt8(this.position); + this.position += 1; + return value == 1; + } + readFunction() { + // TODO: not exactly correct. + const id = this.readInt32(); + return id; + } + readMaterialized() { + const ptr = this.readPointer(); + return { ptr: ptr }; + } + readString() { + const length = this.readInt32(); + this.checkCapacity(length); + // read without null-terminated byte + const value = DeserializerBase.textDecoder.decode(this.asArray(this.position, length - 1)); + this.position += length; + return value; + } + readCustomObject(kind) { + let current = DeserializerBase.customDeserializers; + while (current) { + if (current.supports(kind)) { + return current.deserialize(this, kind); + } + current = current.next; + } + // consume tag + const tag = this.readInt8(); + return undefined; + } + readNumber() { + const tag = this.readInt8(); + switch (tag) { + case SerializerBase_1.Tags.UNDEFINED: + return undefined; + case SerializerBase_1.Tags.INT32: + return this.readInt32(); + case SerializerBase_1.Tags.FLOAT32: + return this.readFloat32(); + default: + throw new Error(`Unknown number tag: ${tag}`); + break; + } + } + readCallbackResource() { + return { + resourceId: this.readInt32(), + hold: this.readPointer(), + release: this.readPointer(), + }; + } + static lengthUnitFromInt(unit) { + let suffix; + switch (unit) { + case 0: + suffix = "px"; + break; + case 1: + suffix = "vp"; + break; + case 3: + suffix = "%"; + break; + case 4: + suffix = "lpx"; + break; + default: + suffix = ""; + } + return suffix; + } + readBuffer() { + const resource = this.readCallbackResource(); + const data = this.readPointer(); + const length = this.readInt64(); + return InteropNativeModule_1.InteropNativeModule._MaterializeBuffer(data, length, resource.resourceId, resource.hold, resource.release); + } +} +exports.DeserializerBase = DeserializerBase; +DeserializerBase.textDecoder = new common_1.CustomTextDecoder(); +DeserializerBase.customDeserializers = undefined; +class CustomDeserializer { + constructor(supported) { + this.supported = supported; + this.next = undefined; + } + supports(kind) { + return this.supported.includes(kind); + } +} +exports.CustomDeserializer = CustomDeserializer; +class DateDeserializer extends CustomDeserializer { + constructor() { + super(["Date"]); + } + deserialize(serializer, kind) { + return new Date(serializer.readString()); + } +} +DeserializerBase.registerCustomDeserializer(new DateDeserializer()); +//# sourceMappingURL=DeserializerBase.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/Finalizable.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Finalizable.d.ts new file mode 100644 index 000000000..2df1edf89 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Finalizable.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022-2025 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 { Wrapper } from "./Wrapper"; +import { Thunk } from "#koalaui/common"; +import { pointer } from "./InteropTypes"; +export declare class NativeThunk implements Thunk { + finalizer: pointer; + obj: pointer; + name: string | undefined; + constructor(obj: pointer, finalizer: pointer, name?: string); + clean(): void; + destroyNative(ptr: pointer, finalizer: pointer): void; +} +/** + * Class with the custom finalizer, usually used to release a native peer. + * Do not use directly, only via subclasses. + */ +export declare class Finalizable extends Wrapper { + finalizer: pointer; + cleaner?: NativeThunk; + managed: boolean; + constructor(ptr: pointer, finalizer: pointer, managed?: boolean); + createHandle(): string | undefined; + makeNativeThunk(ptr: pointer, finalizer: pointer, handle: string | undefined): NativeThunk; + close(): void; + release(): pointer; + resetPeer(pointer: pointer): void; + use(body: (value: Finalizable) => R): R; +} +//# sourceMappingURL=Finalizable.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/Finalizable.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Finalizable.js new file mode 100644 index 000000000..21c45b5b0 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Finalizable.js @@ -0,0 +1,100 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Finalizable = exports.NativeThunk = void 0; +const Wrapper_1 = require("./Wrapper"); +const common_1 = require("#koalaui/common"); +const InteropNativeModule_1 = require("./InteropNativeModule"); +class NativeThunk { + constructor(obj, finalizer, name) { + this.finalizer = finalizer; + this.obj = obj; + this.name = name; + } + clean() { + if (!(0, Wrapper_1.isNullPtr)(this.obj)) { + this.destroyNative(this.obj, this.finalizer); + } + this.obj = Wrapper_1.nullptr; + } + destroyNative(ptr, finalizer) { + InteropNativeModule_1.InteropNativeModule._InvokeFinalizer(ptr, finalizer); + } +} +exports.NativeThunk = NativeThunk; +/** + * Class with the custom finalizer, usually used to release a native peer. + * Do not use directly, only via subclasses. + */ +class Finalizable extends Wrapper_1.Wrapper { + constructor(ptr, finalizer, managed = true) { + super(ptr); + this.cleaner = undefined; + this.finalizer = finalizer; + this.managed = managed; + const handle = this.createHandle(); + if (this.managed) { + // TODO: reenable exception. + if (this.ptr == Wrapper_1.nullptr) + return; // throw new Error("Can't have nullptr ptr ${}") + if (this.finalizer == Wrapper_1.nullptr) + throw new Error("Managed finalizer is 0"); + const thunk = this.makeNativeThunk(ptr, finalizer, handle); + (0, common_1.finalizerRegister)(this, thunk); + this.cleaner = thunk; + } + } + createHandle() { + return undefined; + } + makeNativeThunk(ptr, finalizer, handle) { + return new NativeThunk(ptr, finalizer, handle); + } + close() { + if ((0, Wrapper_1.isNullPtr)(this.ptr)) { + throw new Error(`Closing a closed object: ` + this.toString()); + } + else if (this.cleaner == null) { + throw new Error(`No thunk assigned to ` + this.toString()); + } + else { + (0, common_1.finalizerUnregister)(this); + this.cleaner.clean(); + this.cleaner = undefined; + this.ptr = Wrapper_1.nullptr; + } + } + release() { + (0, common_1.finalizerUnregister)(this); + if (this.cleaner) + this.cleaner.obj = Wrapper_1.nullptr; + let result = this.ptr; + this.ptr = Wrapper_1.nullptr; + return result; + } + resetPeer(pointer) { + if (this.managed) + throw new Error("Can only reset peer for an unmanaged object"); + this.ptr = pointer; + } + use(body) { + let result = body(this); + this.close(); + return result; + } +} +exports.Finalizable = Finalizable; +//# sourceMappingURL=Finalizable.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropNativeModule.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropNativeModule.d.ts new file mode 100644 index 000000000..75ea2a718 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropNativeModule.d.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/common"; +import { KPointer, KStringPtr, KUint8ArrayPtr } from "./InteropTypes"; +export declare class InteropNativeModule { + static _SetCallbackDispatcher(dispatcher: (id: int32, args: Uint8Array, length: int32) => int32): void; + static _CleanCallbackDispatcher(): void; + static _GetGroupedLog(index: int32): KPointer; + static _StartGroupedLog(index: int32): void; + static _StopGroupedLog(index: int32): void; + static _AppendGroupedLog(index: int32, message: string): void; + static _PrintGroupedLog(index: int32): void; + static _GetStringFinalizer(): KPointer; + static _InvokeFinalizer(ptr1: KPointer, ptr2: KPointer): void; + static _GetPtrVectorElement(ptr1: KPointer, arg: int32): KPointer; + static _StringLength(ptr1: KPointer): int32; + static _StringData(ptr1: KPointer, arr: KUint8ArrayPtr, i: int32): void; + static _StringMake(str1: KStringPtr): KPointer; + static _GetPtrVectorSize(ptr1: KPointer): int32; + static _ManagedStringWrite(str1: string, arr: Uint8Array, arg: int32): int32; + static _NativeLog(str1: string): void; + static _Utf8ToString(data: KUint8ArrayPtr, offset: int32, length: int32): string; + static _StdStringToString(cstring: KPointer): string; + static _CheckCallbackEvent(buffer: KUint8ArrayPtr, bufferLength: int32): int32; + static _HoldCallbackResource(resourceId: int32): void; + static _ReleaseCallbackResource(resourceId: int32): void; + static _CallCallback(callbackKind: int32, args: Uint8Array, argsSize: int32): void; + static _CallCallbackSync(callbackKind: int32, args: Uint8Array, argsSize: int32): void; + static _CallCallbackResourceHolder(holder: KPointer, resourceId: int32): void; + static _CallCallbackResourceReleaser(releaser: KPointer, resourceId: int32): void; + static _MaterializeBuffer(data: KPointer, length: int32, resourceId: int32, hold: KPointer, release: KPointer): ArrayBuffer; + static _GetNativeBufferPointer(data: ArrayBuffer): KPointer; + static _LoadVirtualMachine(arg0: int32, arg1: string, arg2: string): int32; + static _RunApplication(arg0: int32, arg1: int32): number; + static _StartApplication(appUrl: string, appParams: string): KPointer; + static _EmitEvent(eventType: int32, target: int32, arg0: int32, arg1: int32): void; + static _CallForeignVM(foreignContext: KPointer, kind: int32, args: Uint8Array, argsSize: int32): int32; +} +export declare function loadInteropNativeModule(): void; +//# sourceMappingURL=InteropNativeModule.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropNativeModule.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropNativeModule.js new file mode 100644 index 000000000..404c7f6c0 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropNativeModule.js @@ -0,0 +1,59 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.loadInteropNativeModule = exports.InteropNativeModule = void 0; +const loadLibraries_1 = require("./loadLibraries"); +class InteropNativeModule { + static _SetCallbackDispatcher(dispatcher) { throw "method not loaded"; } + static _CleanCallbackDispatcher() { throw "method not loaded"; } + static _GetGroupedLog(index) { throw "method not loaded"; } + static _StartGroupedLog(index) { throw "method not loaded"; } + static _StopGroupedLog(index) { throw "method not loaded"; } + static _AppendGroupedLog(index, message) { throw "method not loaded"; } + static _PrintGroupedLog(index) { throw "method not loaded"; } + static _GetStringFinalizer() { throw "method not loaded"; } + static _InvokeFinalizer(ptr1, ptr2) { throw "method not loaded"; } + static _GetPtrVectorElement(ptr1, arg) { throw "method not loaded"; } + static _StringLength(ptr1) { throw "method not loaded"; } + static _StringData(ptr1, arr, i) { throw "method not loaded"; } + static _StringMake(str1) { throw "method not loaded"; } + static _GetPtrVectorSize(ptr1) { throw "method not loaded"; } + static _ManagedStringWrite(str1, arr, arg) { throw "method not loaded"; } + static _NativeLog(str1) { throw "method not loaded"; } + static _Utf8ToString(data, offset, length) { throw "method not loaded"; } + static _StdStringToString(cstring) { throw "method not loaded"; } + static _CheckCallbackEvent(buffer, bufferLength) { throw "method not loaded"; } + static _HoldCallbackResource(resourceId) { throw "method not loaded"; } + static _ReleaseCallbackResource(resourceId) { throw "method not loaded"; } + static _CallCallback(callbackKind, args, argsSize) { throw "method not loaded"; } + static _CallCallbackSync(callbackKind, args, argsSize) { throw "method not loaded"; } + static _CallCallbackResourceHolder(holder, resourceId) { throw "method not loaded"; } + static _CallCallbackResourceReleaser(releaser, resourceId) { throw "method not loaded"; } + static _MaterializeBuffer(data, length, resourceId, hold, release) { throw "method not loaded"; } + static _GetNativeBufferPointer(data) { throw "method not loaded"; } + static _LoadVirtualMachine(arg0, arg1, arg2) { throw "method not loaded"; } + static _RunApplication(arg0, arg1) { throw "method not loaded"; } + static _StartApplication(appUrl, appParams) { throw "method not loaded"; } + static _EmitEvent(eventType, target, arg0, arg1) { throw "method not loaded"; } + static _CallForeignVM(foreignContext, kind, args, argsSize) { throw "method not loaded"; } +} +exports.InteropNativeModule = InteropNativeModule; +function loadInteropNativeModule() { + (0, loadLibraries_1.loadNativeModuleLibrary)("InteropNativeModule", InteropNativeModule); +} +exports.loadInteropNativeModule = loadInteropNativeModule; +//# sourceMappingURL=InteropNativeModule.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropOps.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropOps.d.ts new file mode 100644 index 000000000..2b1206036 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropOps.d.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/common"; +export type CallbackType = (args: Uint8Array, length: int32) => int32; +export declare function wrapCallback(callback: CallbackType, autoDisposable?: boolean): int32; +export declare function wrapSystemCallback(id: number, callback: CallbackType): int32; +export declare function disposeCallback(id: int32): void; +export declare function callCallback(id: int32, args: Uint8Array, length: int32): int32; +//# sourceMappingURL=InteropOps.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropOps.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropOps.js new file mode 100644 index 000000000..150decb9c --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropOps.js @@ -0,0 +1,75 @@ +"use strict"; +/* + * Copyright (c) 2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.callCallback = exports.disposeCallback = exports.wrapSystemCallback = exports.wrapCallback = void 0; +class CallbackRecord { + constructor(callback, autoDisposable) { + this.callback = callback; + this.autoDisposable = autoDisposable; + } +} +class CallbackRegistry { + constructor() { + this.callbacks = new Map(); + this.id = 1024; + this.callbacks.set(0, new CallbackRecord((args, length) => { + console.log(`Callback 0 called with args = ${args} and length = ${length}`); + throw new Error(`Null callback called`); + }, false)); + } + wrap(callback, autoDisposable) { + const id = this.id++; + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)); + return id; + } + wrapSystem(id, callback, autoDisposable) { + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)); + return id; + } + call(id, args, length) { + const record = this.callbacks.get(id); + if (!record) { + console.log(`Callback ${id} is not known`); + // throw new Error(`Disposed or unwrapped callback called (id = ${id})`) + return 0; // todo + } + if (record.autoDisposable) { + this.dispose(id); + } + return record.callback(args, length); + } + dispose(id) { + this.callbacks.delete(id); + } +} +CallbackRegistry.INSTANCE = new CallbackRegistry(); +function wrapCallback(callback, autoDisposable = true) { + return CallbackRegistry.INSTANCE.wrap(callback, autoDisposable); +} +exports.wrapCallback = wrapCallback; +function wrapSystemCallback(id, callback) { + return CallbackRegistry.INSTANCE.wrapSystem(id, callback, false); +} +exports.wrapSystemCallback = wrapSystemCallback; +function disposeCallback(id) { + CallbackRegistry.INSTANCE.dispose(id); +} +exports.disposeCallback = disposeCallback; +function callCallback(id, args, length) { + return CallbackRegistry.INSTANCE.call(id, args, length); +} +exports.callCallback = callCallback; +//# sourceMappingURL=InteropOps.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropTypes.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropTypes.d.ts new file mode 100644 index 000000000..2b012790e --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropTypes.d.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022-2025 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 { int32, int64, float32, float64 } from "#koalaui/common"; +export type KStringPtr = int32 | string | null; +export type KStringArrayPtr = int32 | Uint8Array | null; +export type KInt32ArrayPtr = int32 | Int32Array | null; +export type KFloat32ArrayPtr = int32 | Float32Array | null; +export type KUint8ArrayPtr = int32 | Uint8Array | null; +export type KInt = int32; +export type KUInt = int32; +export type KLong = int64; +export type KFloat = float32; +export type KDouble = float64; +export type KBoolean = int32; +export type KPointer = number | bigint; +export type pointer = KPointer; +export type KNativePointer = KPointer; +export type KInteropReturnBuffer = Uint8Array; +//# sourceMappingURL=InteropTypes.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropTypes.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropTypes.js new file mode 100644 index 000000000..41af5b8e8 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/InteropTypes.js @@ -0,0 +1,18 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ + +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=InteropTypes.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/MaterializedBase.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/MaterializedBase.d.ts new file mode 100644 index 000000000..beaa7d02c --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/MaterializedBase.d.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022-2025 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; +} +//# sourceMappingURL=MaterializedBase.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/MaterializedBase.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/MaterializedBase.js new file mode 100644 index 000000000..629c7d70e --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/MaterializedBase.js @@ -0,0 +1,17 @@ +"use strict"; +/* + * Copyright (c) 2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=MaterializedBase.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeBuffer.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeBuffer.d.ts new file mode 100644 index 000000000..8c309b51f --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeBuffer.d.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2025 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 { pointer } from './InteropTypes'; +import { int32, int64 } from '#koalaui/common'; +export declare class NativeBuffer extends ArrayBuffer { + data: pointer; + length: int64; + resourceId: int32; + hold: pointer; + release: pointer; + constructor(data: pointer, length: int64, resourceId: int32, hold: pointer, release: pointer); + static wrap(data: pointer, length: int64, resourceId: int32, hold: pointer, release: pointer): NativeBuffer; +} +//# sourceMappingURL=NativeBuffer.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeBuffer.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeBuffer.js new file mode 100644 index 000000000..96755df13 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeBuffer.js @@ -0,0 +1,38 @@ +"use strict"; +/* + * Copyright (c) 2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NativeBuffer = void 0; +// stub wrapper for KInteropBuffer +class NativeBuffer extends ArrayBuffer { + constructor(data, length, resourceId, hold, release) { + super(length); + this.data = 0; + this.length = 0; + this.resourceId = 0; + this.hold = 0; + this.release = 0; + this.data = data; + this.length = length; + this.resourceId = resourceId; + this.hold = hold; + this.release = release; + } + static wrap(data, length, resourceId, hold, release) { + return new NativeBuffer(data, length, resourceId, hold, release); + } +} +exports.NativeBuffer = NativeBuffer; +//# sourceMappingURL=NativeBuffer.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeString.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeString.d.ts new file mode 100644 index 000000000..e59b72f42 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeString.d.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022-2025 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"; +import { pointer } from "./InteropTypes"; +export declare class NativeString extends Finalizable { + constructor(ptr: pointer); + static Make(value: string): NativeString; + toString(): string; +} +//# sourceMappingURL=NativeString.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeString.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeString.js new file mode 100644 index 000000000..0bd0d1586 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/NativeString.js @@ -0,0 +1,32 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NativeString = void 0; +const Finalizable_1 = require("./Finalizable"); +const InteropNativeModule_1 = require("./InteropNativeModule"); +class NativeString extends Finalizable_1.Finalizable { + constructor(ptr) { + super(ptr, InteropNativeModule_1.InteropNativeModule._GetStringFinalizer()); + } + static Make(value) { + return new NativeString(InteropNativeModule_1.InteropNativeModule._StringMake(value)); + } + toString() { + return InteropNativeModule_1.InteropNativeModule._StdStringToString(this.ptr); + } +} +exports.NativeString = NativeString; +//# sourceMappingURL=NativeString.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/Platform.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Platform.d.ts new file mode 100644 index 000000000..078095680 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Platform.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/common"; +import { Wrapper } from "./Wrapper"; +import { KPointer } from "./InteropTypes"; +export declare abstract class NativeStringBase extends Wrapper { + constructor(ptr: KPointer); + protected abstract bytesLength(): int32; + protected abstract getData(data: Uint8Array): void; + toString(): string; + abstract close(): void; +} +export declare abstract class ArrayDecoder { + abstract getArraySize(blob: KPointer): int32; + abstract disposeArray(blob: KPointer): void; + abstract getArrayElement(blob: KPointer, index: int32): T; + decode(blob: KPointer): Array; +} +export interface CallbackRegistry { + registerCallback(callback: any, obj: any): KPointer; +} +export interface PlatformDefinedData { + nativeString(ptr: KPointer): NativeStringBase; + nativeStringArrayDecoder(): ArrayDecoder; + callbackRegistry(): CallbackRegistry | undefined; +} +export declare function providePlatformDefinedData(platformDataParam: PlatformDefinedData): void; +export declare function withStringResult(ptr: KPointer): string | undefined; +export declare function withStringArrayResult(ptr: KPointer): Array; +//# sourceMappingURL=Platform.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/Platform.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Platform.js new file mode 100644 index 000000000..adf11745b --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Platform.js @@ -0,0 +1,69 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.withStringArrayResult = exports.withStringResult = exports.providePlatformDefinedData = exports.ArrayDecoder = exports.NativeStringBase = void 0; +const Wrapper_1 = require("./Wrapper"); +const arrays_1 = require("#common/wrappers/arrays"); +const Callback_1 = require("#common/wrappers/Callback"); +class NativeStringBase extends Wrapper_1.Wrapper { + constructor(ptr) { + super(ptr); + } + toString() { + let length = this.bytesLength(); + let data = new Uint8Array(length); + this.getData(data); + return (0, arrays_1.decodeToString)(data); + } +} +exports.NativeStringBase = NativeStringBase; +class ArrayDecoder { + decode(blob) { + const size = this.getArraySize(blob); + const result = new Array(size); + for (let index = 0; index < size; index++) { + result[index] = this.getArrayElement(blob, index); + } + this.disposeArray(blob); + return result; + } +} +exports.ArrayDecoder = ArrayDecoder; +let platformData = undefined; +function providePlatformDefinedData(platformDataParam) { + platformData = platformDataParam; + let registry = platformDataParam.callbackRegistry(); + if (registry) + (0, Callback_1.setCallbackRegistry)(registry); +} +exports.providePlatformDefinedData = providePlatformDefinedData; +function withStringResult(ptr) { + if ((0, Wrapper_1.isNullPtr)(ptr)) + return undefined; + let managedString = platformData.nativeString(ptr); + let result = managedString === null || managedString === void 0 ? void 0 : managedString.toString(); + managedString === null || managedString === void 0 ? void 0 : managedString.close(); + return result; +} +exports.withStringResult = withStringResult; +function withStringArrayResult(ptr) { + if (ptr == Wrapper_1.nullptr) + return new Array(); + let managedStringArray = platformData.nativeStringArrayDecoder().decode(ptr); + return managedStringArray.map((nativeString) => nativeString.toString()); +} +exports.withStringArrayResult = withStringArrayResult; +//# sourceMappingURL=Platform.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/SerializerBase.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/SerializerBase.d.ts new file mode 100644 index 000000000..6dbd43280 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/SerializerBase.d.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2022-2025 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 { float32, int32, int64 } from "#koalaui/common"; +import { pointer, KPointer } from "./InteropTypes"; +import { ResourceId } from "../arkts/ResourceManager"; +/** + * Value representing possible JS runtime object type. + * Must be synced with "enum RuntimeType" in C++. + */ +export declare enum RuntimeType { + UNEXPECTED = -1, + NUMBER = 1, + STRING = 2, + OBJECT = 3, + BOOLEAN = 4, + UNDEFINED = 5, + BIGINT = 6, + FUNCTION = 7, + SYMBOL = 8, + MATERIALIZED = 9 +} +/** + * Value representing object type in serialized data. + * Must be synced with "enum Tags" in C++. + */ +export declare enum Tags { + UNDEFINED = 101, + INT32 = 102, + FLOAT32 = 103, + STRING = 104, + LENGTH = 105, + RESOURCE = 106, + OBJECT = 107 +} +export declare function runtimeType(value: any): int32; +export declare function isResource(value: unknown): boolean; +export declare function isInstanceOf(className: string, value: object | undefined): boolean; +export declare function registerCallback(value: object | undefined): int32; +export declare function registerMaterialized(value: object | undefined): number; +export interface CallbackResource { + resourceId: int32; + hold: pointer; + release: pointer; +} +export declare abstract class CustomSerializer { + protected supported: Array; + constructor(supported: Array); + supports(kind: string): boolean; + abstract serialize(serializer: SerializerBase, value: any, kind: string): void; + next: CustomSerializer | undefined; +} +export declare class SerializerBase { + private position; + private buffer; + private view; + private static customSerializers; + static registerCustomSerializer(serializer: CustomSerializer): void; + constructor(); + release(): void; + asArray(): Uint8Array; + length(): int32; + currentPosition(): int32; + private checkCapacity; + private heldResources; + holdAndWriteCallback(callback: object, hold?: KPointer, release?: KPointer, call?: KPointer, callSync?: KPointer): ResourceId; + holdAndWriteCallbackForPromiseVoid(hold?: KPointer, release?: KPointer, call?: KPointer, callSync?: number): [Promise, ResourceId]; + holdAndWriteCallbackForPromise(hold?: KPointer, release?: KPointer, call?: KPointer): [Promise, ResourceId]; + writeCallbackResource(resource: CallbackResource): void; + private releaseResources; + writeCustomObject(kind: string, value: any): void; + writeNumber(value: number | undefined): void; + writeInt8(value: int32): void; + writeInt32(value: int32): void; + writeInt64(value: int64): void; + writePointer(value: pointer): void; + writeFloat32(value: float32): void; + writeBoolean(value: boolean | undefined): void; + writeFunction(value: object | undefined): void; + writeString(value: string): void; + writeBuffer(buffer: ArrayBuffer): void; +} +export declare function unsafeCast(value: unknown): T; +//# sourceMappingURL=SerializerBase.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/SerializerBase.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/SerializerBase.js new file mode 100644 index 000000000..5af311bb5 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/SerializerBase.js @@ -0,0 +1,298 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ + + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.unsafeCast = exports.SerializerBase = exports.CustomSerializer = exports.registerMaterialized = exports.registerCallback = exports.isInstanceOf = exports.isResource = exports.runtimeType = exports.Tags = exports.RuntimeType = void 0; +const InteropOps_1 = require("./InteropOps"); +const InteropNativeModule_1 = require("./InteropNativeModule"); +const ResourceManager_1 = require("../arkts/ResourceManager"); +// imports required interfaces (now generation is disabled) +// import { Resource } from "@arkoala/arkui" +/** + * Value representing possible JS runtime object type. + * Must be synced with "enum RuntimeType" in C++. + */ +var RuntimeType; +(function (RuntimeType) { + RuntimeType[RuntimeType["UNEXPECTED"] = -1] = "UNEXPECTED"; + RuntimeType[RuntimeType["NUMBER"] = 1] = "NUMBER"; + RuntimeType[RuntimeType["STRING"] = 2] = "STRING"; + RuntimeType[RuntimeType["OBJECT"] = 3] = "OBJECT"; + RuntimeType[RuntimeType["BOOLEAN"] = 4] = "BOOLEAN"; + RuntimeType[RuntimeType["UNDEFINED"] = 5] = "UNDEFINED"; + RuntimeType[RuntimeType["BIGINT"] = 6] = "BIGINT"; + RuntimeType[RuntimeType["FUNCTION"] = 7] = "FUNCTION"; + RuntimeType[RuntimeType["SYMBOL"] = 8] = "SYMBOL"; + RuntimeType[RuntimeType["MATERIALIZED"] = 9] = "MATERIALIZED"; +})(RuntimeType = exports.RuntimeType || (exports.RuntimeType = {})); +/** + * Value representing object type in serialized data. + * Must be synced with "enum Tags" in C++. + */ +var Tags; +(function (Tags) { + Tags[Tags["UNDEFINED"] = 101] = "UNDEFINED"; + Tags[Tags["INT32"] = 102] = "INT32"; + Tags[Tags["FLOAT32"] = 103] = "FLOAT32"; + Tags[Tags["STRING"] = 104] = "STRING"; + Tags[Tags["LENGTH"] = 105] = "LENGTH"; + Tags[Tags["RESOURCE"] = 106] = "RESOURCE"; + Tags[Tags["OBJECT"] = 107] = "OBJECT"; +})(Tags = exports.Tags || (exports.Tags = {})); +function runtimeType(value) { + let type = typeof value; + if (type == "number") + return RuntimeType.NUMBER; + if (type == "string") + return RuntimeType.STRING; + if (type == "undefined") + return RuntimeType.UNDEFINED; + if (type == "object") + return RuntimeType.OBJECT; + if (type == "boolean") + return RuntimeType.BOOLEAN; + if (type == "bigint") + return RuntimeType.BIGINT; + if (type == "function") + return RuntimeType.FUNCTION; + if (type == "symbol") + return RuntimeType.SYMBOL; + throw new Error(`bug: ${value} is ${type}`); +} +exports.runtimeType = runtimeType; +function isResource(value) { + return value !== undefined + && typeof value === 'object' + && value !== null + && value.hasOwnProperty("bundleName") + && value.hasOwnProperty("moduleName"); +} +exports.isResource = isResource; +// Poor man's instanceof, fails on subclasses +function isInstanceOf(className, value) { + return (value === null || value === void 0 ? void 0 : value.constructor.name) === className; +} +exports.isInstanceOf = isInstanceOf; +function registerCallback(value) { + return (0, InteropOps_1.wrapCallback)((args, length) => { + // TBD: deserialize the callback arguments and call the callback + return 42; + }); +} +exports.registerCallback = registerCallback; +function registerMaterialized(value) { + // TODO: fix me! + return 42; +} +exports.registerMaterialized = registerMaterialized; +/* Serialization extension point */ +class CustomSerializer { + constructor(supported) { + this.supported = supported; + this.next = undefined; + } + supports(kind) { return this.supported.includes(kind); } +} +exports.CustomSerializer = CustomSerializer; +class SerializerBase { + static registerCustomSerializer(serializer) { + if (SerializerBase.customSerializers == undefined) { + SerializerBase.customSerializers = serializer; + } + else { + let current = SerializerBase.customSerializers; + while (current.next != undefined) { + current = current.next; + } + current.next = serializer; + } + } + constructor() { + this.position = 0; + this.heldResources = []; + this.buffer = new ArrayBuffer(96); + this.view = new DataView(this.buffer); + } + release() { + this.releaseResources(); + this.position = 0; + } + asArray() { + return new Uint8Array(this.buffer); + } + length() { + return this.position; + } + currentPosition() { return this.position; } + checkCapacity(value) { + if (value < 1) { + throw new Error(`${value} is less than 1`); + } + let buffSize = this.buffer.byteLength; + if (this.position > buffSize - value) { + const minSize = this.position + value; + const resizedSize = Math.max(minSize, Math.round(3 * buffSize / 2)); + let resizedBuffer = new ArrayBuffer(resizedSize); + // TODO: can we grow without new? + new Uint8Array(resizedBuffer).set(new Uint8Array(this.buffer)); + this.buffer = resizedBuffer; + this.view = new DataView(resizedBuffer); + } + } + holdAndWriteCallback(callback, hold = 0, release = 0, call = 0, callSync = 0) { + const resourceId = ResourceManager_1.ResourceHolder.instance().registerAndHold(callback); + this.heldResources.push(resourceId); + this.writeInt32(resourceId); + this.writePointer(hold); + this.writePointer(release); + this.writePointer(call); + this.writePointer(callSync); + return resourceId; + } + holdAndWriteCallbackForPromiseVoid(hold = 0, release = 0, call = 0, callSync = 0) { + let resourceId; + const promise = new Promise((resolve, reject) => { + const callback = (err) => { + if (err !== undefined) + reject(err); + else + resolve(); + }; + resourceId = this.holdAndWriteCallback(callback, hold, release, call, callSync); + }); + return [promise, resourceId]; + } + holdAndWriteCallbackForPromise(hold = 0, release = 0, call = 0) { + let resourceId; + const promise = new Promise((resolve, reject) => { + const callback = (value, err) => { + if (err !== undefined) + reject(err); + else + resolve(value); + }; + resourceId = this.holdAndWriteCallback(callback, hold, release, call); + }); + return [promise, resourceId]; + } + writeCallbackResource(resource) { + this.writeInt32(resource.resourceId); + this.writePointer(resource.hold); + this.writePointer(resource.release); + } + releaseResources() { + for (const resourceId of this.heldResources) + InteropNativeModule_1.InteropNativeModule._ReleaseCallbackResource(resourceId); + // todo think about effective array clearing/pushing + this.heldResources = []; + } + writeCustomObject(kind, value) { + let current = SerializerBase.customSerializers; + while (current) { + if (current.supports(kind)) { + current.serialize(this, value, kind); + return; + } + current = current.next; + } + console.log(`Unsupported custom serialization for ${kind}, write undefined`); + this.writeInt8(Tags.UNDEFINED); + } + writeNumber(value) { + this.checkCapacity(5); + if (value == undefined) { + this.view.setInt8(this.position, Tags.UNDEFINED); + this.position++; + return; + } + if (value == Math.round(value)) { + this.view.setInt8(this.position, Tags.INT32); + this.view.setInt32(this.position + 1, value, true); + this.position += 5; + return; + } + this.view.setInt8(this.position, Tags.FLOAT32); + this.view.setFloat32(this.position + 1, value, true); + this.position += 5; + } + writeInt8(value) { + this.checkCapacity(1); + this.view.setInt8(this.position, value); + this.position += 1; + } + writeInt32(value) { + this.checkCapacity(4); + this.view.setInt32(this.position, value, true); + this.position += 4; + } + writeInt64(value) { + this.checkCapacity(8); + this.view.setBigInt64(this.position, BigInt(value), true); + this.position += 8; + } + writePointer(value) { + this.checkCapacity(8); + this.view.setBigInt64(this.position, BigInt(value !== null && value !== void 0 ? value : 0), true); + this.position += 8; + } + writeFloat32(value) { + this.checkCapacity(4); + this.view.setFloat32(this.position, value, true); + this.position += 4; + } + writeBoolean(value) { + this.checkCapacity(1); + this.view.setInt8(this.position, value == undefined ? RuntimeType.UNDEFINED : +value); + this.position++; + } + writeFunction(value) { + this.writeInt32(registerCallback(value)); + } + writeString(value) { + this.checkCapacity(4 + value.length * 4); // length, data + let encodedLength = InteropNativeModule_1.InteropNativeModule._ManagedStringWrite(value, new Uint8Array(this.view.buffer, 0), this.position + 4); + this.view.setInt32(this.position, encodedLength, true); + this.position += encodedLength + 4; + } + writeBuffer(buffer) { + const resourceId = ResourceManager_1.ResourceHolder.instance().registerAndHold(buffer); + this.writeCallbackResource({ + resourceId, + hold: 0, + release: 0 + }); + const ptr = InteropNativeModule_1.InteropNativeModule._GetNativeBufferPointer(buffer); + this.writePointer(ptr); + this.writeInt64(buffer.byteLength); + } +} +exports.SerializerBase = SerializerBase; +SerializerBase.customSerializers = undefined; +class DateSerializer extends CustomSerializer { + constructor() { + super(["Date"]); + } + serialize(serializer, value, kind) { + serializer.writeString(value.toISOString()); + } +} +SerializerBase.registerCustomSerializer(new DateSerializer()); +function unsafeCast(value) { + return value; +} +exports.unsafeCast = unsafeCast; +//# sourceMappingURL=SerializerBase.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/Wrapper.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Wrapper.d.ts new file mode 100644 index 000000000..44c84a9f8 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Wrapper.d.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2025 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 { KPointer } from "./InteropTypes"; +export { isNullPtr, nullptr, ptrToBits, bitsToPtr, isSamePtr, ptrToString } from "#common/wrappers/Wrapper"; +/** + * An object holding reference to the native pointer. + */ +export declare class Wrapper { + ptr: KPointer; + constructor(ptr: KPointer); + toString(): string; +} +export declare function getPtr(value: Wrapper | undefined): KPointer; +export declare function ptrEqual(a: Wrapper | undefined, b: Wrapper | undefined): boolean; +//# sourceMappingURL=Wrapper.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/Wrapper.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Wrapper.js new file mode 100644 index 000000000..dfbdcd17e --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/Wrapper.js @@ -0,0 +1,54 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ptrEqual = exports.getPtr = exports.Wrapper = exports.ptrToString = exports.isSamePtr = exports.bitsToPtr = exports.ptrToBits = exports.nullptr = exports.isNullPtr = void 0; +const Wrapper_1 = require("#common/wrappers/Wrapper"); +const common_1 = require("#koalaui/common"); +var Wrapper_2 = require("#common/wrappers/Wrapper"); +Object.defineProperty(exports, "isNullPtr", { enumerable: true, get: function () { return Wrapper_2.isNullPtr; } }); +Object.defineProperty(exports, "nullptr", { enumerable: true, get: function () { return Wrapper_2.nullptr; } }); +Object.defineProperty(exports, "ptrToBits", { enumerable: true, get: function () { return Wrapper_2.ptrToBits; } }); +Object.defineProperty(exports, "bitsToPtr", { enumerable: true, get: function () { return Wrapper_2.bitsToPtr; } }); +Object.defineProperty(exports, "isSamePtr", { enumerable: true, get: function () { return Wrapper_2.isSamePtr; } }); +Object.defineProperty(exports, "ptrToString", { enumerable: true, get: function () { return Wrapper_2.ptrToString; } }); +/** + * An object holding reference to the native pointer. + */ +class Wrapper { + constructor(ptr) { + if (ptr == null) + throw new Error(`Init <${(0, common_1.className)(this)}> with null native peer`); + this.ptr = ptr; + } + toString() { + return `[native object <${(0, common_1.className)(this)}> at ${(0, Wrapper_1.ptrToString)(this.ptr)}]`; + } +} +exports.Wrapper = Wrapper; +function getPtr(value) { + var _a; + return (_a = value === null || value === void 0 ? void 0 : value.ptr) !== null && _a !== void 0 ? _a : Wrapper_1.nullptr; +} +exports.getPtr = getPtr; +function ptrEqual(a, b) { + if (a === b) + return true; + if (a == undefined || b == undefined) + return false; + return (0, Wrapper_1.isSamePtr)(a.ptr, b.ptr); +} +exports.ptrEqual = ptrEqual; +//# sourceMappingURL=Wrapper.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/arrays.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/arrays.d.ts new file mode 100644 index 000000000..e610b47da --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/arrays.d.ts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/common"; +export declare enum Access { + READ = 1, + WRITE = 2, + READWRITE = 3 +} +export declare function isRead(access: Access): number; +export declare function isWrite(access: Access): number; +export type Exec = (pointer: P) => R; +export type ExecWithLength = (pointer: P, length: int32) => R; +export type TypedArray = Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array; +export type PtrArray = Uint32Array | BigUint64Array; +//# sourceMappingURL=arrays.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/arrays.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/arrays.js new file mode 100644 index 000000000..783d697f1 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/arrays.js @@ -0,0 +1,32 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isWrite = exports.isRead = exports.Access = void 0; +var Access; +(function (Access) { + Access[Access["READ"] = 1] = "READ"; + Access[Access["WRITE"] = 2] = "WRITE"; + Access[Access["READWRITE"] = 3] = "READWRITE"; +})(Access = exports.Access || (exports.Access = {})); +function isRead(access) { + return access & Access.READ; +} +exports.isRead = isRead; +function isWrite(access) { + return access & Access.WRITE; +} +exports.isWrite = isWrite; +//# sourceMappingURL=arrays.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/buffer.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/buffer.d.ts new file mode 100644 index 000000000..09fa8065b --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/buffer.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2025 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 declare class KBuffer { + private readonly _buffer; + get buffer(): ArrayBuffer; + get length(): number; + constructor(length: number); + set(index: number, value: number): void; + get(index: number): number; +} +//# sourceMappingURL=buffer.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/buffer.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/buffer.js new file mode 100644 index 000000000..9a8111a81 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/buffer.js @@ -0,0 +1,38 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.KBuffer = void 0; +// todo can be removed if passing ArrayBuffer type through interop is possible +class KBuffer { + get buffer() { + return this._buffer; + } + get length() { + return this._buffer.length; + } + constructor(length) { + this._buffer = new Uint8Array(length); + } + set(index, value) { + this._buffer[index] = value; + } + get(index) { + return this._buffer[index]; + } +} +exports.KBuffer = KBuffer; +//# sourceMappingURL=buffer.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/index.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/index.d.ts new file mode 100644 index 000000000..b06ae1e32 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/index.d.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022-2025 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 { withFloat32Array, withFloat64Array, withInt16Array, withInt32Array, withInt8Array, withUint16Array, withUint32Array, withUint8Array, wasmHeap as wasmHeapArrayBuffer } from "#common/wrappers/arrays"; +export { registerCallback, setCallbackRegistry } from "#common/wrappers/Callback"; +export { Access, Exec } from "./arrays"; +export { Finalizable, NativeThunk } from "./Finalizable"; +export { nullable } from "./nullable"; +export { getPtr, isNullPtr, nullptr, ptrEqual, Wrapper, ptrToBits, bitsToPtr } from "./Wrapper"; +export { decodeToString, encodeToData, withString, withStringArray, withPtrArray, fromPtrArray, toPtrArray } from "#common/wrappers/arrays"; +export declare const withFloatArray: typeof withFloat32Array; +export declare const withByteArray: typeof withUint8Array; +export declare const withIntArray: typeof withInt32Array; +export declare const wasmHeap: typeof wasmHeapArrayBuffer; +export { withFloat32Array, withFloat64Array, withInt8Array, withInt16Array, withInt32Array, withUint8Array, withUint16Array, withUint32Array, }; +export * from "./Platform"; +export * from "./InteropTypes"; +export * from "./InteropOps"; +export * from "./NativeString"; +export * from "./buffer"; +export * from "../arkts/ResourceManager"; +export * from "./NativeBuffer"; +export { InteropNativeModule, loadInteropNativeModule } from "./InteropNativeModule"; +export { SerializerBase, RuntimeType, Tags, runtimeType, CallbackResource, unsafeCast, isResource, isInstanceOf } from "./SerializerBase"; +export { DeserializerBase } from "./DeserializerBase"; +export { loadNativeModuleLibrary, loadNativeLibrary, registerNativeModuleLibraryName } from "./loadLibraries"; +export * from "./MaterializedBase"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/index.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/index.js new file mode 100644 index 000000000..8067bd807 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/index.js @@ -0,0 +1,96 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.registerNativeModuleLibraryName = exports.loadNativeLibrary = exports.loadNativeModuleLibrary = exports.DeserializerBase = exports.isInstanceOf = exports.isResource = exports.unsafeCast = exports.runtimeType = exports.Tags = exports.RuntimeType = exports.SerializerBase = exports.loadInteropNativeModule = exports.InteropNativeModule = exports.withUint32Array = exports.withUint16Array = exports.withUint8Array = exports.withInt32Array = exports.withInt16Array = exports.withInt8Array = exports.withFloat64Array = exports.withFloat32Array = exports.wasmHeap = exports.withIntArray = exports.withByteArray = exports.withFloatArray = exports.toPtrArray = exports.fromPtrArray = exports.withPtrArray = exports.withStringArray = exports.withString = exports.encodeToData = exports.decodeToString = exports.bitsToPtr = exports.ptrToBits = exports.Wrapper = exports.ptrEqual = exports.nullptr = exports.isNullPtr = exports.getPtr = exports.nullable = exports.NativeThunk = exports.Finalizable = exports.Access = exports.setCallbackRegistry = exports.registerCallback = void 0; +const arrays_1 = require("#common/wrappers/arrays"); +Object.defineProperty(exports, "withFloat32Array", { enumerable: true, get: function () { return arrays_1.withFloat32Array; } }); +Object.defineProperty(exports, "withFloat64Array", { enumerable: true, get: function () { return arrays_1.withFloat64Array; } }); +Object.defineProperty(exports, "withInt16Array", { enumerable: true, get: function () { return arrays_1.withInt16Array; } }); +Object.defineProperty(exports, "withInt32Array", { enumerable: true, get: function () { return arrays_1.withInt32Array; } }); +Object.defineProperty(exports, "withInt8Array", { enumerable: true, get: function () { return arrays_1.withInt8Array; } }); +Object.defineProperty(exports, "withUint16Array", { enumerable: true, get: function () { return arrays_1.withUint16Array; } }); +Object.defineProperty(exports, "withUint32Array", { enumerable: true, get: function () { return arrays_1.withUint32Array; } }); +Object.defineProperty(exports, "withUint8Array", { enumerable: true, get: function () { return arrays_1.withUint8Array; } }); +var Callback_1 = require("#common/wrappers/Callback"); +Object.defineProperty(exports, "registerCallback", { enumerable: true, get: function () { return Callback_1.registerCallback; } }); +Object.defineProperty(exports, "setCallbackRegistry", { enumerable: true, get: function () { return Callback_1.setCallbackRegistry; } }); +var arrays_2 = require("./arrays"); +Object.defineProperty(exports, "Access", { enumerable: true, get: function () { return arrays_2.Access; } }); +var Finalizable_1 = require("./Finalizable"); +Object.defineProperty(exports, "Finalizable", { enumerable: true, get: function () { return Finalizable_1.Finalizable; } }); +Object.defineProperty(exports, "NativeThunk", { enumerable: true, get: function () { return Finalizable_1.NativeThunk; } }); +var nullable_1 = require("./nullable"); +Object.defineProperty(exports, "nullable", { enumerable: true, get: function () { return nullable_1.nullable; } }); +var Wrapper_1 = require("./Wrapper"); +Object.defineProperty(exports, "getPtr", { enumerable: true, get: function () { return Wrapper_1.getPtr; } }); +Object.defineProperty(exports, "isNullPtr", { enumerable: true, get: function () { return Wrapper_1.isNullPtr; } }); +Object.defineProperty(exports, "nullptr", { enumerable: true, get: function () { return Wrapper_1.nullptr; } }); +Object.defineProperty(exports, "ptrEqual", { enumerable: true, get: function () { return Wrapper_1.ptrEqual; } }); +Object.defineProperty(exports, "Wrapper", { enumerable: true, get: function () { return Wrapper_1.Wrapper; } }); +Object.defineProperty(exports, "ptrToBits", { enumerable: true, get: function () { return Wrapper_1.ptrToBits; } }); +Object.defineProperty(exports, "bitsToPtr", { enumerable: true, get: function () { return Wrapper_1.bitsToPtr; } }); +var arrays_3 = require("#common/wrappers/arrays"); +Object.defineProperty(exports, "decodeToString", { enumerable: true, get: function () { return arrays_3.decodeToString; } }); +Object.defineProperty(exports, "encodeToData", { enumerable: true, get: function () { return arrays_3.encodeToData; } }); +Object.defineProperty(exports, "withString", { enumerable: true, get: function () { return arrays_3.withString; } }); +Object.defineProperty(exports, "withStringArray", { enumerable: true, get: function () { return arrays_3.withStringArray; } }); +Object.defineProperty(exports, "withPtrArray", { enumerable: true, get: function () { return arrays_3.withPtrArray; } }); +Object.defineProperty(exports, "fromPtrArray", { enumerable: true, get: function () { return arrays_3.fromPtrArray; } }); +Object.defineProperty(exports, "toPtrArray", { enumerable: true, get: function () { return arrays_3.toPtrArray; } }); +exports.withFloatArray = arrays_1.withFloat32Array; +exports.withByteArray = arrays_1.withUint8Array; +exports.withIntArray = arrays_1.withInt32Array; +exports.wasmHeap = arrays_1.wasmHeap; +__exportStar(require("./Platform"), exports); +__exportStar(require("./InteropTypes"), exports); +__exportStar(require("./InteropOps"), exports); +__exportStar(require("./NativeString"), exports); +__exportStar(require("./buffer"), exports); +__exportStar(require("../arkts/ResourceManager"), exports); +__exportStar(require("./NativeBuffer"), exports); +var InteropNativeModule_1 = require("./InteropNativeModule"); +Object.defineProperty(exports, "InteropNativeModule", { enumerable: true, get: function () { return InteropNativeModule_1.InteropNativeModule; } }); +Object.defineProperty(exports, "loadInteropNativeModule", { enumerable: true, get: function () { return InteropNativeModule_1.loadInteropNativeModule; } }); +var SerializerBase_1 = require("./SerializerBase"); +Object.defineProperty(exports, "SerializerBase", { enumerable: true, get: function () { return SerializerBase_1.SerializerBase; } }); +Object.defineProperty(exports, "RuntimeType", { enumerable: true, get: function () { return SerializerBase_1.RuntimeType; } }); +Object.defineProperty(exports, "Tags", { enumerable: true, get: function () { return SerializerBase_1.Tags; } }); +Object.defineProperty(exports, "runtimeType", { enumerable: true, get: function () { return SerializerBase_1.runtimeType; } }); +Object.defineProperty(exports, "unsafeCast", { enumerable: true, get: function () { return SerializerBase_1.unsafeCast; } }); +Object.defineProperty(exports, "isResource", { enumerable: true, get: function () { return SerializerBase_1.isResource; } }); +Object.defineProperty(exports, "isInstanceOf", { enumerable: true, get: function () { return SerializerBase_1.isInstanceOf; } }); +var DeserializerBase_1 = require("./DeserializerBase"); +Object.defineProperty(exports, "DeserializerBase", { enumerable: true, get: function () { return DeserializerBase_1.DeserializerBase; } }); +var loadLibraries_1 = require("./loadLibraries"); +Object.defineProperty(exports, "loadNativeModuleLibrary", { enumerable: true, get: function () { return loadLibraries_1.loadNativeModuleLibrary; } }); +Object.defineProperty(exports, "loadNativeLibrary", { enumerable: true, get: function () { return loadLibraries_1.loadNativeLibrary; } }); +Object.defineProperty(exports, "registerNativeModuleLibraryName", { enumerable: true, get: function () { return loadLibraries_1.registerNativeModuleLibraryName; } }); +__exportStar(require("./MaterializedBase"), exports); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/loadLibraries.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/loadLibraries.d.ts new file mode 100644 index 000000000..1089c8bd4 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/loadLibraries.d.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2022-2025 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 declare function loadNativeLibrary(name: string): Record; +export declare function registerNativeModuleLibraryName(nativeModule: string, libraryName: string): void; +export declare function loadNativeModuleLibrary(moduleName: string, module?: object): void; +//# sourceMappingURL=loadLibraries.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/loadLibraries.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/loadLibraries.js new file mode 100644 index 000000000..5446b33c3 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/loadLibraries.js @@ -0,0 +1,45 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.loadNativeModuleLibrary = exports.registerNativeModuleLibraryName = exports.loadNativeLibrary = void 0; +const nativeModuleLibraries = new Map(); +function loadNativeLibrary(name) { + if (globalThis.requireNapi) + return globalThis.requireNapi(name, true); + else { + const suffixedName = name.endsWith(".node") ? name : `${name}.node`; + return require(suffixedName) + } +} +exports.loadNativeLibrary = loadNativeLibrary; +function registerNativeModuleLibraryName(nativeModule, libraryName) { + nativeModuleLibraries.set(nativeModule, libraryName); +} +exports.registerNativeModuleLibraryName = registerNativeModuleLibraryName; +function loadNativeModuleLibrary(moduleName, module) { + var _a; + if (!module) + throw new Error(" argument is required and optional only for compatibility with ArkTS"); + const library = loadNativeLibrary((_a = nativeModuleLibraries.get(moduleName)) !== null && _a !== void 0 ? _a : moduleName); + if (!library || !library[moduleName]) { + console.error(`Failed to load library for module ${moduleName}`); + return; + } + Object.assign(module, library[moduleName]); +} +exports.loadNativeModuleLibrary = loadNativeModuleLibrary; +//# sourceMappingURL=loadLibraries.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/nullable.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/interop/nullable.d.ts new file mode 100644 index 000000000..bf90c00ac --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/nullable.d.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022-2025 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 { KPointer } from "./InteropTypes"; +export declare function nullable(value: KPointer, body: (arg: KPointer) => T | undefined): T | undefined; +//# sourceMappingURL=nullable.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/interop/nullable.js b/koala-wrapper/koalaui/interop/dist/lib/src/interop/nullable.js new file mode 100644 index 000000000..13b7d505e --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/interop/nullable.js @@ -0,0 +1,28 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.nullable = void 0; +const Wrapper_1 = require("./Wrapper"); +function nullable(value, body) { + if ((0, Wrapper_1.isNullPtr)(value)) { + return undefined; + } + else { + return body(value); + } +} +exports.nullable = nullable; +//# sourceMappingURL=nullable.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Callback.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Callback.d.ts new file mode 100644 index 000000000..bef3cebce --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Callback.d.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022-2025 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 { KPointer } from "../../interop/InteropTypes"; +import { CallbackRegistry } from "../../interop/Platform"; +export declare function registerCallback(callback: any, obj?: any): KPointer; +export declare function setCallbackRegistry(registry: CallbackRegistry): void; +//# sourceMappingURL=Callback.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Callback.js b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Callback.js new file mode 100644 index 000000000..c30af143e --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Callback.js @@ -0,0 +1,27 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.setCallbackRegistry = exports.registerCallback = void 0; +function registerCallback(callback, obj = null) { + return theRegistry.registerCallback(callback, obj); +} +exports.registerCallback = registerCallback; +let theRegistry = undefined; +function setCallbackRegistry(registry) { + theRegistry = registry; +} +exports.setCallbackRegistry = setCallbackRegistry; +//# sourceMappingURL=Callback.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Wrapper.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Wrapper.d.ts new file mode 100644 index 000000000..6a35ba0bd --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Wrapper.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/common"; +import { KPointer } from "../../interop/InteropTypes"; +export declare const nullptr: bigint; +export declare function isNullPtr(value: KPointer): boolean; +export declare function ptrToString(ptr: KPointer): string; +export declare function isSamePtr(a: KPointer, b: KPointer): boolean; +export declare function ptrToBits(ptr: KPointer): Uint32Array | null; +export declare function bitsToPtr(array: Int32Array, offset: int32): KPointer; +//# sourceMappingURL=Wrapper.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Wrapper.js b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Wrapper.js new file mode 100644 index 000000000..dd3dd6116 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/Wrapper.js @@ -0,0 +1,46 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bitsToPtr = exports.ptrToBits = exports.isSamePtr = exports.ptrToString = exports.isNullPtr = exports.nullptr = void 0; +exports.nullptr = BigInt(0); +function isNullPtr(value) { + return value === exports.nullptr; +} +exports.isNullPtr = isNullPtr; +function ptrToString(ptr) { + return `0x${ptr.toString(16).padStart(8, "0")}`; +} +exports.ptrToString = ptrToString; +function isSamePtr(a, b) { + return (a === b); +} +exports.isSamePtr = isSamePtr; +// TODO rethink me +function ptrToBits(ptr) { + let result = new Uint32Array(2); + let ptrBigInt = ptr; + result[0] = Number(ptrBigInt & BigInt(0xFFFFFFFF)); + result[1] = Number((ptrBigInt >> BigInt(32)) & BigInt(0xFFFFFFFF)); + return result; +} +exports.ptrToBits = ptrToBits; +function bitsToPtr(array, offset) { + let ptrBigInt = BigInt(array[offset + 1]) & BigInt(0xFFFFFFFF); + ptrBigInt = (ptrBigInt << BigInt(32)) | (BigInt(array[offset]) & BigInt(0xFFFFFFFF)); + return ptrBigInt; +} +exports.bitsToPtr = bitsToPtr; +//# sourceMappingURL=Wrapper.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/arrays.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/arrays.d.ts new file mode 100644 index 000000000..c6a9d1171 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/arrays.d.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-2025 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 { Access, Exec, ExecWithLength, PtrArray } from "../../interop/arrays"; +import { Wrapper } from "../../interop/Wrapper"; +import { KPointer, KStringArrayPtr } from "../../interop"; +export declare function decodeToString(array: Uint8Array): string; +export declare function encodeToData(string: string): Uint8Array; +export declare function withString(data: string | undefined, exec: Exec): R; +export declare function withStringArray(strings: Array | undefined, exec: Exec): R; +export declare function withPtrArray(data: BigUint64Array, access: Access, exec: ExecWithLength): R; +export declare function toPtrArray(data: Array | undefined): BigUint64Array; +export declare function fromPtrArray(array: PtrArray, factory: (ptr: KPointer) => T): Array; +export declare function withUint8Array(data: Uint8Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withInt8Array(data: Int8Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withUint16Array(data: Uint16Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withInt16Array(data: Int16Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withUint32Array(data: Uint32Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withInt32Array(data: Int32Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withFloat32Array(data: Float32Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withFloat64Array(data: Float64Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function wasmHeap(): ArrayBuffer; +//# sourceMappingURL=arrays.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/arrays.js b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/arrays.js new file mode 100644 index 000000000..bf8bea46d --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/napi/wrappers/arrays.js @@ -0,0 +1,116 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.wasmHeap = exports.withFloat64Array = exports.withFloat32Array = exports.withInt32Array = exports.withUint32Array = exports.withInt16Array = exports.withUint16Array = exports.withInt8Array = exports.withUint8Array = exports.fromPtrArray = exports.toPtrArray = exports.withPtrArray = exports.withStringArray = exports.withString = exports.encodeToData = exports.decodeToString = void 0; +const common_1 = require("#koalaui/common"); +const Wrapper_1 = require("./Wrapper"); +const encoder = new common_1.CustomTextEncoder(); +const decoder = new common_1.CustomTextDecoder(); +function decodeToString(array) { + return decoder.decode(array); +} +exports.decodeToString = decodeToString; +function encodeToData(string) { + return encoder.encode(string, false); +} +exports.encodeToData = encodeToData; +function withString(data, exec) { + return exec(data === undefined ? null : data); +} +exports.withString = withString; +function withStringArray(strings, exec) { + if (strings === undefined || strings.length === 0) { + return exec(null); + } + let array = encoder.encodeArray(strings); + return exec(array); +} +exports.withStringArray = withStringArray; +function withArray(data, exec) { + var _a; + return exec(data !== null && data !== void 0 ? data : null, (_a = data === null || data === void 0 ? void 0 : data.length) !== null && _a !== void 0 ? _a : 0); +} +function withPtrArray(data, access, exec) { + var _a; + return exec(data !== null && data !== void 0 ? data : null, (_a = data === null || data === void 0 ? void 0 : data.length) !== null && _a !== void 0 ? _a : 0); // TODO rethink +} +exports.withPtrArray = withPtrArray; +function toPtrArray(data) { + if (data == undefined || data.length === 0) { + return new BigUint64Array(0); + } + const array = new BigUint64Array(data.length); + for (let i = 0; i < data.length; i++) { + let item = data[i]; + array[i] = item != undefined ? item.ptr : Wrapper_1.nullptr; + } + return array; +} +exports.toPtrArray = toPtrArray; +function fromPtrArray(array, factory) { + if (array.length === 0) { + return new Array(0); + } + const result = new Array(array.length); + for (let i = 0; i < array.length; i++) { + let ptr = array[i]; + if (ptr == Wrapper_1.nullptr) { + result[i] = undefined; + } + else { + result[i] = factory(ptr); + } + } + return result; +} +exports.fromPtrArray = fromPtrArray; +function withUint8Array(data, access, exec) { + return withArray(data, exec); +} +exports.withUint8Array = withUint8Array; +function withInt8Array(data, access, exec) { + return withArray(data, exec); +} +exports.withInt8Array = withInt8Array; +function withUint16Array(data, access, exec) { + return withArray(data, exec); +} +exports.withUint16Array = withUint16Array; +function withInt16Array(data, access, exec) { + return withArray(data, exec); +} +exports.withInt16Array = withInt16Array; +function withUint32Array(data, access, exec) { + return withArray(data, exec); +} +exports.withUint32Array = withUint32Array; +function withInt32Array(data, access, exec) { + return withArray(data, exec); +} +exports.withInt32Array = withInt32Array; +function withFloat32Array(data, access, exec) { + return withArray(data, exec); +} +exports.withFloat32Array = withFloat32Array; +function withFloat64Array(data, access, exec) { + return withArray(data, exec); +} +exports.withFloat64Array = withFloat64Array; +function wasmHeap() { + throw new Error("Unused"); +} +exports.wasmHeap = wasmHeap; +//# sourceMappingURL=arrays.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Callback.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Callback.d.ts new file mode 100644 index 000000000..558d0b4fd --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Callback.d.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022-2025 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 { KPointer } from "../../interop/InteropTypes"; +import { CallbackRegistry } from "../../interop/Platform"; +export declare function registerCallback(callback: any, obj?: any): KPointer; +export declare function setCallbackRegistry(_ignoredRegistry: CallbackRegistry): void; +//# sourceMappingURL=Callback.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Callback.js b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Callback.js new file mode 100644 index 000000000..42d551ac4 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Callback.js @@ -0,0 +1,81 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.setCallbackRegistry = exports.registerCallback = void 0; +class CallbackInfo { + constructor(callback, obj = null) { + this.cb = callback; + this.recv = obj; + } +} +const GLOBAL_SCOPE = new (_a = class CallbackScope { + constructor() { + this.nextId = 1; + this.callbackMap = new Map(); + this.callbackMap.set(CallbackScope.CB_NULL_ID, CallbackScope.CB_NULL); + } + addCallback(cb, obj) { + var _a; + let id = this.nextId++; + (_a = this.callbackMap) === null || _a === void 0 ? void 0 : _a.set(id, new CallbackInfo(cb, obj)); + return id; + } + getCallback(id) { + var _a; + return ((_a = this.callbackMap) === null || _a === void 0 ? void 0 : _a.get(id)) || CallbackScope.CB_UNDEFINED; + } + deleteCallback(id) { + var _a; + if (id > CallbackScope.CB_NULL_ID) { + (_a = this.callbackMap) === null || _a === void 0 ? void 0 : _a.delete(id); + } + } + release() { + this.callbackMap = null; + } + }, + _a.CB_NULL = new CallbackInfo(() => { throw new Error("attempted to call a callback at NULL"); }, null), + _a.CB_UNDEFINED = new CallbackInfo(() => { throw new Error("attempted to call an uninitialized callback"); }, null), + _a.CB_NULL_ID = 0, + _a); +function callCallback(callbackId) { + let CallbackInfo = GLOBAL_SCOPE.getCallback(callbackId); + try { + let cb = CallbackInfo.cb; + if (CallbackInfo.recv !== null) { + cb = cb.bind(CallbackInfo.recv); + } + return cb(); + } + catch (e) { + console.error(e); + } +} +function registerCallback(callback, obj = null) { + return GLOBAL_SCOPE.addCallback(callback, obj); +} +exports.registerCallback = registerCallback; +function releaseCallback(callbackId) { + return GLOBAL_SCOPE.deleteCallback(callbackId); +} +globalThis.callCallback = callCallback; +globalThis.releaseCallback = releaseCallback; +function setCallbackRegistry(_ignoredRegistry) { + // On WASM we don't need registry in current implementation. +} +exports.setCallbackRegistry = setCallbackRegistry; +//# sourceMappingURL=Callback.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Wrapper.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Wrapper.d.ts new file mode 100644 index 000000000..dc132570a --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Wrapper.d.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "#koalaui/common"; +import { KPointer } from "../../interop/InteropTypes"; +export declare const nullptr: number; +export declare function isNullPtr(value: KPointer): boolean; +export declare function ptrToString(ptr: KPointer): string; +export declare function isSamePtr(a: KPointer, b: KPointer): boolean; +export declare function ptrToBits(ptr: KPointer): Uint32Array; +export declare function bitsToPtr(array: Int32Array, offset: int32): KPointer; +//# sourceMappingURL=Wrapper.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Wrapper.js b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Wrapper.js new file mode 100644 index 000000000..b849ad662 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/Wrapper.js @@ -0,0 +1,44 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bitsToPtr = exports.ptrToBits = exports.isSamePtr = exports.ptrToString = exports.isNullPtr = exports.nullptr = void 0; +exports.nullptr = 0; +function isNullPtr(value) { + return (value == exports.nullptr); +} +exports.isNullPtr = isNullPtr; +function ptrToString(ptr) { + if (ptr === 0) + return "0x0"; + const hex = ptr.toString(16).padStart(8, "0"); + return `0x${hex}`; +} +exports.ptrToString = ptrToString; +function isSamePtr(a, b) { + return a === b; +} +exports.isSamePtr = isSamePtr; +function ptrToBits(ptr) { + let result = new Uint32Array(2); + result[0] = ptr; + return result; +} +exports.ptrToBits = ptrToBits; +function bitsToPtr(array, offset) { + return array[offset]; +} +exports.bitsToPtr = bitsToPtr; +//# sourceMappingURL=Wrapper.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/arrays.d.ts b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/arrays.d.ts new file mode 100644 index 000000000..e539c7462 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/arrays.d.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-2025 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 { KPointer } from "../../interop/InteropTypes"; +import { Wrapper } from "../../interop/Wrapper"; +import { Access, Exec, ExecWithLength } from "../../interop/arrays"; +export declare function decodeToString(array: Uint8Array): string; +export declare function encodeToData(string: string): Uint8Array; +export declare function withString(data: string | undefined, exec: Exec): R; +export declare function withStringArray(strings: Array | undefined, exec: Exec): R; +export declare function withPtrArray(data: Uint32Array, access: Access, exec: ExecWithLength): R; +export declare function toPtrArray(data: Array | undefined): Uint32Array; +export declare function fromPtrArray(array: Uint32Array, factory: (ptr: KPointer) => T): Array; +export declare function withUint8Array(data: Uint8Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withInt8Array(data: Int8Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withUint16Array(data: Uint16Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withInt16Array(data: Int16Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withUint32Array(data: Uint32Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withInt32Array(data: Int32Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withFloat32Array(data: Float32Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function withFloat64Array(data: Float64Array | undefined, access: Access, exec: ExecWithLength): T; +export declare function wasmHeap(): ArrayBuffer; +//# sourceMappingURL=arrays.d.ts.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/arrays.js b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/arrays.js new file mode 100644 index 000000000..9ee0f6369 --- /dev/null +++ b/koala-wrapper/koalaui/interop/dist/lib/src/wasm/wrappers/arrays.js @@ -0,0 +1,147 @@ +"use strict"; +/* + * Copyright (c) 2022-2025 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. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.wasmHeap = exports.withFloat64Array = exports.withFloat32Array = exports.withInt32Array = exports.withUint32Array = exports.withInt16Array = exports.withUint16Array = exports.withInt8Array = exports.withUint8Array = exports.fromPtrArray = exports.toPtrArray = exports.withPtrArray = exports.withStringArray = exports.withString = exports.encodeToData = exports.decodeToString = void 0; +const common_1 = require("#koalaui/common"); +const arrays_1 = require("../../interop/arrays"); +const encoder = new common_1.CustomTextEncoder(); +const decoder = new common_1.CustomTextDecoder(); +function decodeToString(array) { + return decoder.decode(array); +} +exports.decodeToString = decodeToString; +function encodeToData(string) { + return encoder.encode(string, false); +} +exports.encodeToData = encodeToData; +const nullptr = 0; +// with string as array of utf8 data headed by length +function withString(data, exec) { + if (data === undefined) + return exec(nullptr); + let array = encoder.encode(data, true); + return withUint8Array(array, arrays_1.Access.READ, exec); +} +exports.withString = withString; +function withStringArray(strings, exec) { + if (strings === undefined || strings.length === 0) { + return exec(nullptr); + } + let array = encoder.encodeArray(strings); + return withUint8Array(array, arrays_1.Access.READ, exec); +} +exports.withStringArray = withStringArray; +function withArray(data, access, exec, bytesPerElement, ctor) { + if (data === undefined || data.length === 0) { + return exec(nullptr, 0); + } + let ptr = _malloc(data.length * bytesPerElement); + let wasmArray = ctor(ptr, data.length); + if ((0, arrays_1.isRead)(access)) { + wasmArray.set(data); + } + let result = exec(ptr, data.length); + if ((0, arrays_1.isWrite)(access)) { + data.set(wasmArray); + } + _free(ptr); + return result; +} +function withPtrArray(data, access, exec) { + return withArray(data, access, exec, Uint32Array.BYTES_PER_ELEMENT, (ptr, length) => { + return new Uint32Array(_heaps.HEAPU8().buffer, ptr, length); + }); +} +exports.withPtrArray = withPtrArray; +function toPtrArray(data) { + var _a; + if (data === undefined || data.length === 0) { + return new Uint32Array(0); + } + const array = new Uint32Array(data.length); + for (let i = 0; i < data.length; i++) { + array[i] = (_a = data[i]) === null || _a === void 0 ? void 0 : _a.ptr; + } + return array; +} +exports.toPtrArray = toPtrArray; +function fromPtrArray(array, factory) { + const result = new Array(array.length); + for (let i = 0; i < array.length; i++) { + let v = array[i]; + if (v == 0) { + result[i] = undefined; + } + else { + result[i] = factory(v); + } + } + return result; +} +exports.fromPtrArray = fromPtrArray; +function withUint8Array(data, access, exec) { + return withArray(data, access, exec, Uint8Array.BYTES_PER_ELEMENT, (ptr, length) => { + return new Uint8Array(_heaps.HEAPU8().buffer, ptr, length); + }); +} +exports.withUint8Array = withUint8Array; +function withInt8Array(data, access, exec) { + return withArray(data, access, exec, Int8Array.BYTES_PER_ELEMENT, (ptr, length) => { + return new Int8Array(_heaps.HEAPU8().buffer, ptr, length); + }); +} +exports.withInt8Array = withInt8Array; +function withUint16Array(data, access, exec) { + return withArray(data, access, exec, Uint16Array.BYTES_PER_ELEMENT, (ptr, length) => { + return new Uint16Array(_heaps.HEAPU8().buffer, ptr, length); + }); +} +exports.withUint16Array = withUint16Array; +function withInt16Array(data, access, exec) { + return withArray(data, access, exec, Int16Array.BYTES_PER_ELEMENT, (ptr, length) => { + return new Int16Array(_heaps.HEAPU8().buffer, ptr, length); + }); +} +exports.withInt16Array = withInt16Array; +function withUint32Array(data, access, exec) { + return withArray(data, access, exec, Uint32Array.BYTES_PER_ELEMENT, (ptr, length) => { + return new Uint32Array(_heaps.HEAPU8().buffer, ptr, length); + }); +} +exports.withUint32Array = withUint32Array; +function withInt32Array(data, access, exec) { + return withArray(data, access, exec, Int32Array.BYTES_PER_ELEMENT, (ptr, length) => { + return new Int32Array(_heaps.HEAPU8().buffer, ptr, length); + }); +} +exports.withInt32Array = withInt32Array; +function withFloat32Array(data, access, exec) { + return withArray(data, access, exec, Float32Array.BYTES_PER_ELEMENT, (ptr, length) => { + return new Float32Array(_heaps.HEAPU8().buffer, ptr, length); + }); +} +exports.withFloat32Array = withFloat32Array; +function withFloat64Array(data, access, exec) { + return withArray(data, access, exec, Float64Array.BYTES_PER_ELEMENT, (ptr, length) => { + return new Float64Array(_heaps.HEAPU8().buffer, ptr, length); + }); +} +exports.withFloat64Array = withFloat64Array; +function wasmHeap() { + return _heaps.HEAP32().buffer; +} +exports.wasmHeap = wasmHeap; +//# sourceMappingURL=arrays.js.map \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/oh-package.json5 b/koala-wrapper/koalaui/interop/oh-package.json5 new file mode 100644 index 000000000..49ca1a9b2 --- /dev/null +++ b/koala-wrapper/koalaui/interop/oh-package.json5 @@ -0,0 +1,62 @@ +{ + "name": "@koalaui/interop", + "version": "1.4.1+devel", + "description": "", + "files": [ + "build/lib/src/**/*.js", + "build/lib/src/**/*.d.ts" + ], + "main": "./build/lib/src/interop/index.js", + "exports": { + ".": "./build/lib/src/interop/index.js", + "./*.js": "./build/lib/src/interop/*.js", + "./*": "./build/lib/src/interop/*.js" + }, + "imports": { + "#common/wrappers": { + "browser": "./build/lib/src/wasm/wrappers/index.js", + "node": "./build/lib/src/napi/wrappers/index.js" + }, + "#common/wrappers/*": { + "browser": "./build/lib/src/wasm/wrappers/*.js", + "node": "./build/lib/src/napi/wrappers/*.js" + } + }, + "types": "./index.d.ts", + "typesVersions": { + "*": { + "*": ["./build/lib/src/interop/*"] + } + }, + "scripts": { + "clean": "tsc -b . --clean && rimraf dist build types", + "ets-api": "node scripts/download-ets-api.mjs", + "compile": "tsc -b .", + "compile:ohos": "npm run ets-api && npm run compile", + "compile:all": "npm run compile:ohos", + "compile:arkts": "bash ../tools/panda/arkts/arktsc --arktsconfig arktsconfig.json", + "lint": "eslint src test components", + "test:wasm:coverage": "NODE_OPTIONS='--conditions browser --no-experimental-fetch' nyc mocha", + "test:wasm": "NODE_OPTIONS='--conditions browser --no-experimental-fetch' mocha", + "test:node:coverage": "nyc mocha", + "test:node": "mocha", + "test:coverage": "npm run test:node:coverage", + "test": "npm run test:node", + "watch": "tsc -b . --watch" + }, + "keywords": [], + "dependencies": { + "@koalaui/common": "../common" + }, + "devDependencies": { + "@types/chai": "^4.3.1", + "@types/mocha": "^9.1.0", + "@typescript-eslint/eslint-plugin": "^5.20.0", + "@typescript-eslint/parser": "^5.20.0", + "chai": "^4.3.6", + "eslint": "^8.13.0", + "eslint-plugin-unused-imports": "^2.0.0", + "mocha": "^9.2.2", + "source-map-support": "^0.5.21" + } +} diff --git a/koala-wrapper/koalaui/interop/src/arkts/DeserializerBase.sts b/koala-wrapper/koalaui/interop/src/arkts/DeserializerBase.sts new file mode 100644 index 000000000..13b585d03 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/DeserializerBase.sts @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2025 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 { float32, int32, int64, float32FromBits } from "@koalaui/common" +import { pointer, KUint8ArrayPtr } from "./InteropTypes" +import { KBuffer } from "./buffer" +import { NativeBuffer } from "./NativeBuffer" +import { InteropNativeModule } from "./InteropNativeModule" +import { Tags, CallbackResource } from "./SerializerBase"; + +export class DeserializerBase { + private position = 0 + private readonly buffer: KBuffer + private readonly length: int32 + private static customDeserializers: CustomDeserializer | undefined = new DateDeserializer() + + static registerCustomDeserializer(deserializer: CustomDeserializer) { + let current = DeserializerBase.customDeserializers + if (current == undefined) { + DeserializerBase.customDeserializers = deserializer + } else { + while (current!.next != undefined) { + current = current!.next + } + current!.next = deserializer + } + } + + constructor(buffer: KUint8ArrayPtr, length: int32) { + this.buffer = new KBuffer(buffer) + this.length = length + } + + static get( + factory: (args: Uint8Array, length: int32) => T, + args: Uint8Array, length: int32): T { + + // TBD: Use cache + return factory(args, length); + } + + asArray(): KUint8ArrayPtr { + return this.buffer.buffer + } + + currentPosition(): int32 { + return this.position + } + + resetCurrentPosition(): void { + this.position = 0 + } + + private checkCapacity(value: int32) { + if (value > this.length) { + throw new Error(`${value} is less than remaining buffer length`) + } + } + + readInt8(): int32 { + this.checkCapacity(1) + const value = this.buffer.get(this.position) + this.position += 1 + return value + } + + readInt32(): int32 { + this.checkCapacity(4) + let res: int32 = 0; + for (let i = 0; i < 4; i++) { + let byteVal = this.buffer.get(this.position + i) as int32; + byteVal &= 0xff + res = (res | byteVal << (8 * i)) as int32; + } + this.position += 4 + return res + } + + readPointer(): pointer { + this.checkCapacity(8) + let res: int64 = 0; + for (let i = 0; i < 8; i++) { + let byteVal = this.buffer.get(this.position + i) as int64; + byteVal &= 0xff + res = (res | byteVal << (8 * i)) as int64; + } + this.position += 8 + return res + } + + readInt64(): int64 { + this.checkCapacity(8) + let res: int64 = 0; + for (let i = 0; i < 8; i++) { + let byteVal = this.buffer.get(this.position + i) as int64; + byteVal &= 0xff + res = (res | byteVal << (8 * i)) as int64; + } + this.position += 8 + return res + } + + readFloat32(): float32 { + this.checkCapacity(4) + let res: int32 = 0; + for (let i = 0; i < 4; i++) { + let byteVal = this.buffer.get(this.position + i) as int32; + byteVal &= 0xff + res = (res | byteVal << (8 * i)) as int32; + } + this.position += 4 + return float32FromBits(res) + } + + readBoolean(): boolean { + this.checkCapacity(1) + const value = this.buffer.get(this.position) + this.position += 1 + return value == 1 + } + + readFunction(): int32 { + // TODO: not exactly correct. + const id = this.readInt32() + return id + } + + // readMaterialized(): object { + // const ptr = this.readPointer() + // return { ptr: ptr } + // } + + readCallbackResource(): CallbackResource { + return ({ + resourceId: this.readInt32(), + hold: this.readPointer(), + release: this.readPointer(), + } as CallbackResource) + } + + readString(): string { + const length = this.readInt32() + this.checkCapacity(length) + // read without null-terminated byte + const value = InteropNativeModule._Utf8ToString(this.buffer.buffer, this.position, length) + this.position += length + return value + } + + readCustomObject(kind: string): object { + let current = DeserializerBase.customDeserializers + while (current) { + if (current!.supports(kind)) { + return current!.deserialize(this, kind) + } + current = current!.next + } + // consume tag + const tag = this.readInt8() + throw Error(`${kind} is not supported`) + } + + readNumber(): number | undefined { + const tag = this.readInt8() + if (tag == Tags.UNDEFINED) { + return undefined + } else if (tag == Tags.INT32) { + return this.readInt32() + } else if (tag == Tags.FLOAT32) { + return this.readFloat32() + } else { + throw new Error(`Unknown number tag: ${tag}`) + } + } + + static lengthUnitFromInt(unit: int32): string { + let suffix: string + switch (unit) { + case 0: + suffix = "px" + break + case 1: + suffix = "vp" + break + case 3: + suffix = "%" + break + case 4: + suffix = "lpx" + break + default: + suffix = "" + } + return suffix + } + + readBuffer(): NativeBuffer { + /* not implemented */ + const resource = this.readCallbackResource() + const data = this.readPointer() + const length = this.readInt64() + return NativeBuffer.wrap(data, length, resource.resourceId, resource.hold, resource.release) + } + + readUint8ClampedArray(): Uint8ClampedArray { + throw new Error("Not implemented") + } +} + +export abstract class CustomDeserializer { + protected supported: string + protected constructor(supported_: string) { + this.supported = supported_ + } + + supports(kind: string): boolean { + return this.supported.includes(kind) + } + + abstract deserialize(serializer: DeserializerBase, kind: string): object + + next: CustomDeserializer | undefined = undefined +} + +class DateDeserializer extends CustomDeserializer { + constructor() { + super("Date") + } + + deserialize(serializer: DeserializerBase, kind: string): Date { + return new Date(serializer.readString()) + } +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/arkts/Finalizable.sts b/koala-wrapper/koalaui/interop/src/arkts/Finalizable.sts new file mode 100644 index 000000000..6ae3ac2d8 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/Finalizable.sts @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025 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 { finalizerRegister, finalizerUnregister, Thunk } from "@koalaui/common" +import { InteropNativeModule } from "./InteropNativeModule" +import { pointer, nullptr } from "./InteropTypes" + +class NativeThunk implements Thunk { + finalizer: pointer + obj: pointer + name: string|undefined + + constructor(obj: pointer, finalizer: pointer, name?: string) { + this.finalizer = finalizer + this.obj = obj + this.name = name + } + + clean() { + if (this.obj != nullptr) { + this.destroyNative(this.obj, this.finalizer) + } + this.obj = nullptr + } + + destroyNative(ptr: pointer, finalizer: pointer): void { + InteropNativeModule._InvokeFinalizer(ptr, finalizer) + } +} + +/** + * Class with the custom finalizer, usually used to release a native peer. + * Do not use directly, only via subclasses. + */ +export class Finalizable { + ptr: pointer + finalizer: pointer + cleaner: NativeThunk|undefined = undefined + managed: boolean + constructor(ptr: pointer, finalizer: pointer, managed: boolean = true) { + this.ptr = ptr + this.finalizer = finalizer + this.managed = managed + const handle = undefined + + if (this.managed) { + if (this.ptr == nullptr) throw new Error("Can't have nullptr ptr ${}") + if (this.finalizer == nullptr) throw new Error("Managed finalizer is 0") + + const thunk = new NativeThunk(ptr, finalizer, handle) + finalizerRegister(this, thunk) + this.cleaner = thunk + } + } + + close() { + if (this.ptr == nullptr) { + throw new Error(`Closing a closed object: ` + this.toString()) + } else if (this.cleaner == undefined) { + throw new Error(`No thunk assigned to ` + this.toString()) + } else { + finalizerUnregister(this) + this.cleaner!.clean() + this.cleaner = undefined + this.ptr = nullptr + } + } + + release(): pointer { + finalizerUnregister(this) + if (this.cleaner) + this.cleaner!.obj = nullptr + let result = this.ptr + this.ptr = nullptr + return result + } + + resetPeer(pointer: pointer) { + if (this.managed) throw new Error("Can only reset peer for an unmanaged object") + this.ptr = pointer + } + + use(body: (value: Finalizable) => R): R { + let result = body(this) + this.close() + return result + } +} diff --git a/koala-wrapper/koalaui/interop/src/arkts/InteropNativeModule.sts b/koala-wrapper/koalaui/interop/src/arkts/InteropNativeModule.sts new file mode 100644 index 000000000..d804174f6 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/InteropNativeModule.sts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/common"; +import { KPointer, KUint8ArrayPtr, KInt } from "./InteropTypes"; +import { callCallback } from "./callback" +import { loadNativeModuleLibrary } from "./loadLibraries" + +export class InteropNativeModule { + static { + loadNativeModuleLibrary("InteropNativeModule") + } + static callCallbackFromNative(id: KInt, args: KUint8ArrayPtr, length: KInt): KInt { + return callCallback(id, args, length) + } + native static _GetGroupedLog(index: int32): KPointer + native static _StartGroupedLog(index: int32): void + native static _StopGroupedLog(index: int32): void + native static _AppendGroupedLog(index: int32, message: string): void + native static _PrintGroupedLog(index: int32): void + native static _GetStringFinalizer(): KPointer + native static _InvokeFinalizer(ptr1: KPointer, ptr2: KPointer): void + native static _GetPtrVectorElement(ptr1: KPointer, arg: int32): KPointer + native static _StringLength(ptr1: KPointer): int32 + native static _StringData(ptr1: KPointer, arr: KUint8ArrayPtr, i: int32): void + native static _StringMake(str1: string): KPointer + native static _GetPtrVectorSize(ptr1: KPointer): int32 + native static _ManagedStringWrite(str1: string, arr: KUint8ArrayPtr, arg: int32): int32 + native static _NativeLog(str1: string): void + native static _Utf8ToString(data: KUint8ArrayPtr, offset: int32, length: int32): string + native static _StdStringToString(cstring: KPointer): string + native static _CheckCallbackEvent(buffer: KUint8ArrayPtr, bufferLength: int32): int32 + native static _HoldCallbackResource(resourceId: int32): void + native static _ReleaseCallbackResource(resourceId: int32): void + native static _CallCallback(callbackKind: int32, args: KUint8ArrayPtr, argsSize: int32): void + native static _CallCallbackSync(callbackKind: int32, args: KUint8ArrayPtr, argsSize: int32): void + native static _CallCallbackResourceHolder(holder: KPointer, resourceId: int32): void + native static _CallCallbackResourceReleaser(releaser: KPointer, resourceId: int32): void + native static _LoadVirtualMachine(arg0: int32, arg1: string, arg2: string): int32 + native static _RunApplication(arg0: int32, arg1: int32): boolean + native static _StartApplication(appUrl: string, appParams: string): KPointer + native static _EmitEvent(eventType: int32, target: int32, arg0: int32, arg1: int32): void + native static _CallForeignVM(context:KPointer, callback: int32, data: KUint8ArrayPtr, dataLength: int32): int32 + native static _RestartWith(page: string): void +} + diff --git a/koala-wrapper/koalaui/interop/src/arkts/InteropTypes.sts b/koala-wrapper/koalaui/interop/src/arkts/InteropTypes.sts new file mode 100644 index 000000000..adbf6e433 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/InteropTypes.sts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022-2025 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 type NodePointer = pointer // todo: move to NativeModule + +export type KStringPtr = string +export type KStringPtrArray = byte[] +export type KUint8ArrayPtr = byte[] +export type KInt32ArrayPtr = int[] +export type KFloat32ArrayPtr = float[] +export type KInt = int +export type KLong = long +export type KUInt = KInt +export type KBoolean = int +export type KFloat = float +export type KPointer = long // look once again +export type pointer = KPointer +export type KNativePointer = KPointer +export type KInteropReturnBuffer = byte[] + +export const nullptr: pointer = 0 + diff --git a/koala-wrapper/koalaui/interop/src/arkts/MaterializedBase.sts b/koala-wrapper/koalaui/interop/src/arkts/MaterializedBase.sts new file mode 100644 index 000000000..f0ea6ee4c --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/MaterializedBase.sts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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/koala-wrapper/koalaui/interop/src/arkts/NativeBuffer.sts b/koala-wrapper/koalaui/interop/src/arkts/NativeBuffer.sts new file mode 100644 index 000000000..3c7eb7afe --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/NativeBuffer.sts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 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 { pointer } from './InteropTypes' +import { int32, int64 } from '@koalaui/common' + +// stub wrapper for KInteropBuffer +export class NativeBuffer { + public data:pointer = 0 + public length: int64 = 0 + public resourceId: int32 = 0 + public hold:pointer = 0 + public release: pointer = 0 + + constructor(data:pointer, length: int64, resourceId: int32, hold:pointer, release: pointer) { + this.data = data + this.length = length + this.resourceId = resourceId + this.hold = hold + this.release = release + } + + static wrap(data:pointer, length: int64, resourceId: int32, hold:pointer, release: pointer): NativeBuffer { + return new NativeBuffer(data, length, resourceId, hold, release) + } +} diff --git a/koala-wrapper/koalaui/interop/src/arkts/ResourceManager.ts b/koala-wrapper/koalaui/interop/src/arkts/ResourceManager.ts new file mode 100644 index 000000000..985c81298 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/ResourceManager.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/common" + +export type ResourceId = int32 + +interface ResourceInfo { + resource: object + holdersCount: int32 +} + +export class ResourceHolder { + private static nextResourceId: ResourceId = 100 + private resources: Map = new Map() + private static _instance: ResourceHolder|undefined = undefined + static instance(): ResourceHolder { + if (ResourceHolder._instance == undefined) { + ResourceHolder._instance = new ResourceHolder() + } + return ResourceHolder._instance! + } + + public hold(resourceId: ResourceId) { + if (!this.resources.has(resourceId)) + throw new Error(`Resource ${resourceId} does not exists, can not hold`) + this.resources.get(resourceId)!.holdersCount++ + } + + public release(resourceId: ResourceId) { + if (!this.resources.has(resourceId)) + throw new Error(`Resource ${resourceId} does not exists, can not release`) + const resource = this.resources.get(resourceId)! + resource.holdersCount-- + if (resource.holdersCount <= 0) + this.resources.delete(resourceId) + } + + public registerAndHold(resource: object): ResourceId { + const resourceId = ResourceHolder.nextResourceId++ + this.resources.set(resourceId, { + resource: resource, + holdersCount: 1, + }) + return resourceId + } + + public get(resourceId: ResourceId): object { + if (!this.resources.has(resourceId)) + throw new Error(`Resource ${resourceId} does not exists`) + return this.resources.get(resourceId)!.resource + } + + public has(resourceId: ResourceId): boolean { + return this.resources.has(resourceId) + } +} diff --git a/koala-wrapper/koalaui/interop/src/arkts/SerializerBase.sts b/koala-wrapper/koalaui/interop/src/arkts/SerializerBase.sts new file mode 100644 index 000000000..764590c8d --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/SerializerBase.sts @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2025 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 { float32, float64, int8, int32, int64, int32BitsFromFloat } from "@koalaui/common" +import { pointer, KUint8ArrayPtr } from "./InteropTypes" +import { ResourceId, ResourceHolder } from "./ResourceManager" +import { KBuffer } from "./buffer" +import { NativeBuffer } from "./NativeBuffer" +import { InteropNativeModule } from "./InteropNativeModule" + +/** + * Value representing possible JS runtime object type. + * Must be synced with "enum RuntimeType" in C++. + */ +export class RuntimeType { + static UNEXPECTED = -1 + static NUMBER = 1 + static STRING = 2 + static OBJECT = 3 + static BOOLEAN = 4 + static UNDEFINED = 5 + static BIGINT = 6 + static FUNCTION = 7 + static SYMBOL = 8 + static MATERIALIZED = 9 +} + +/** + * Value representing object type in serialized data. + * Must be synced with "enum Tags" in C++. + */ +export class Tags { + static UNDEFINED = 101 + static INT32 = 102 + static FLOAT32 = 103 + static STRING = 104 + static LENGTH = 105 + static RESOURCE = 106 + static OBJECT = 107 +} + +export function runtimeType(value: Object|String|number|undefined|null): int32 { + let type = typeof value + if (type == "number") return RuntimeType.NUMBER + if (type == "string") return RuntimeType.STRING + if (type == "undefined") return RuntimeType.UNDEFINED + if (type == "object") return RuntimeType.OBJECT + if (type == "boolean") return RuntimeType.BOOLEAN + if (type == "bigint") return RuntimeType.BIGINT + if (type == "function") return RuntimeType.FUNCTION + if (type == "symbol") return RuntimeType.SYMBOL + + throw new Error(`bug: ${value} is ${type}`) +} + +export function registerCallback(value: object): int32 { + // TODO: fix me! + return 42 +} + +function registerMaterialized(value: Object): int32 { + // TODO: fix me! + return 42 +} + +export function isResource(value: Object|undefined): boolean { + // TODO: fix me! + return false +} + +export function isInstanceOf(className: string, value: Object|undefined): boolean { + // TODO: fix me! + return false +} + +export interface CallbackResource { + resourceId: int32 + hold: pointer + release: pointer +} + +/* Serialization extension point */ +export abstract class CustomSerializer { + protected supported: Array + constructor(supported: Array) { + this.supported = supported + } + supports(kind: string): boolean { return this.supported.includes(kind) } + abstract serialize(serializer: SerializerBase, value: object, kind: string): void + next: CustomSerializer | undefined = undefined +} + +class DateSerializer extends CustomSerializer { + constructor() { + super(Array.of("Date" as string)) + } + + serialize(serializer: SerializerBase, value: object, kind: string): void { + serializer.writeString((value as Date).toISOString()) + } +} +SerializerBase.registerCustomSerializer(new DateSerializer()) + +export class SerializerBase { + private position = 0 + private buffer: KBuffer + + private static customSerializers: CustomSerializer | undefined = new DateSerializer() + static registerCustomSerializer(serializer: CustomSerializer) { + if (SerializerBase.customSerializers == undefined) { + SerializerBase.customSerializers = serializer + } else { + let current = SerializerBase.customSerializers + while (current!.next != undefined) { + current = current!.next + } + current!.next = serializer + } + } + + resetCurrentPosition(): void { this.position = 0 } + + constructor() { + this.buffer = new KBuffer(96) + } + public release() { + this.releaseResources() + this.position = 0 + } + asArray(): KUint8ArrayPtr { + return this.buffer.buffer + } + length(): int32 { + return this.position + } + currentPosition(): int32 { return this.position } + private checkCapacity(value: int32) { + if (value < 1) { + throw new Error(`${value} is less than 1`) + } + let buffSize = this.buffer.length + if (this.position > buffSize - value) { + const minSize = this.position + value + const resizedSize = Math.max(minSize, Math.round(3 * buffSize / 2)) + let resizedBuffer = new KBuffer(resizedSize as int32) + for (let i = 0; i < this.buffer.length; i++) { + resizedBuffer.set(i, this.buffer.get(i)) + } + this.buffer = resizedBuffer + } + } + private heldResources: Array = new Array() + holdAndWriteCallback(callback: object, hold: pointer = 0, release: pointer = 0, call: pointer = 0, callSync: pointer = 0): ResourceId { + const resourceId = ResourceHolder.instance().registerAndHold(callback) + this.heldResources.push(resourceId) + this.writeInt32(resourceId) + this.writePointer(hold) + this.writePointer(release) + this.writePointer(call) + this.writePointer(callSync) + return resourceId + } + holdAndWriteCallbackForPromiseVoid(hold: pointer = 0, release: pointer = 0, call: pointer = 0): [Promise, ResourceId] { + let resourceId: ResourceId + const promise = new Promise((resolve: (value: PromiseLike) => void, reject: (err: Object|null|undefined) => void) => { + const callback = (err: string[]|undefined) => { + if (err !== undefined) + reject(err!) + else + resolve(Promise.resolve()) + } + resourceId = this.holdAndWriteCallback(callback, hold, release, call) + }) + return [promise, resourceId] + } + holdAndWriteCallbackForPromise(hold: pointer = 0, release: pointer = 0, call: pointer = 0): [Promise, ResourceId] { + let resourceId: ResourceId + const promise = new Promise((resolve: (value: T|PromiseLike) => void, reject: (err: Object|null|undefined) => void) => { + const callback = (value: T|undefined, err: string[]|undefined) => { + if (err !== undefined) + reject(err!) + else + resolve(value!) + } + resourceId = this.holdAndWriteCallback(callback, hold, release, call) + }) + return [promise, resourceId] + } + writeCallbackResource(resource: CallbackResource) { + this.writeInt32(resource.resourceId) + this.writePointer(resource.hold) + this.writePointer(resource.release) + } + writeResource(resource: object) { + const resourceId = ResourceHolder.instance().registerAndHold(resource) + this.heldResources.push(resourceId) + this.writeInt32(resourceId) + } + private releaseResources() { + for (const resourceId of this.heldResources) + InteropNativeModule._ReleaseCallbackResource(resourceId) + // todo think about effective array clearing/pushing + this.heldResources = new Array() + } + writeCustomObject(kind: string, value: object) { + let current = SerializerBase.customSerializers + while (current) { + if (current!.supports(kind)) { + current!.serialize(this, value, kind) + return + } + current = current!.next + } + // console.log(`Unsupported custom serialization for ${kind}, write undefined`) + this.writeInt8(Tags.UNDEFINED as int32) + } + writeFunction(value: Object) { + this.writeInt32(registerCallback(value)) + } + writeTag(tag: int32): void { + this.buffer.set(this.position, tag as int8) + this.position++ + } + writeNumber(value: number|undefined) { + this.checkCapacity(5) + if (value == undefined) { + this.writeTag(Tags.UNDEFINED) + this.position++ + return + } + if ((value as float64) == Math.round(value)) { + this.writeTag(Tags.INT32) + this.writeInt32(value as int32) + return + } else { + this.writeTag(Tags.FLOAT32) + this.writeFloat32(value as float32) + } + } + writeInt8(value: int32) { + this.checkCapacity(1) + this.buffer.set(this.position, value as int8) + this.position += 1 + } + private setInt32(position: int32, value: int32): void { + this.buffer.set(position + 0, ((value ) & 0xff) as int8) + this.buffer.set(position + 1, ((value >> 8) & 0xff) as int8) + this.buffer.set(position + 2, ((value >> 16) & 0xff) as int8) + this.buffer.set(position + 3, ((value >> 24) & 0xff) as int8) + } + writeInt32(value: int32) { + this.checkCapacity(4) + this.setInt32(this.position, value) + this.position += 4 + } + writeInt64(value: int64) { + this.checkCapacity(8) + this.buffer.set(this.position + 0, ((value ) & 0xff) as int8) + this.buffer.set(this.position + 1, ((value >> 8) & 0xff) as int8) + this.buffer.set(this.position + 2, ((value >> 16) & 0xff) as int8) + this.buffer.set(this.position + 3, ((value >> 24) & 0xff) as int8) + this.buffer.set(this.position + 4, ((value >> 32) & 0xff) as int8) + this.buffer.set(this.position + 5, ((value >> 40) & 0xff) as int8) + this.buffer.set(this.position + 6, ((value >> 48) & 0xff) as int8) + this.buffer.set(this.position + 7, ((value >> 56) & 0xff) as int8) + this.position += 8 + } + writeFloat32(value: float32) { + let bits = int32BitsFromFloat(value) + // TODO: this is wrong! + this.checkCapacity(4) + this.buffer.set(this.position + 0, ((bits ) & 0xff) as int8) + this.buffer.set(this.position + 1, ((bits >> 8) & 0xff) as int8) + this.buffer.set(this.position + 2, ((bits >> 16) & 0xff) as int8) + this.buffer.set(this.position + 3, ((bits >> 24) & 0xff) as int8) + this.position += 4 + } + writePointer(value: pointer) { + if (typeof value === "bigint") + // todo where it is possible to be called from? + throw new Error("Not implemented") + this.writeInt64(value) + } + writeBoolean(value: boolean|undefined) { + this.checkCapacity(1) + if (value == undefined) { + this.buffer.set(this.position, RuntimeType.UNDEFINED as int32 as int8) + } else { + this.buffer.set(this.position, (value ? 1 : 0) as int8) + } + this.position++ + } + writeMaterialized(value: Object) { + this.writePointer(registerMaterialized(value)) + } + writeString(value: string) { + this.checkCapacity((4 + value.length * 4 + 1) as int32) // length, data + let encodedLength = InteropNativeModule._ManagedStringWrite(value, this.asArray(), this.position + 4) + this.setInt32(this.position, encodedLength) + this.position += encodedLength + 4 + } + //TODO: Needs to be implemented + writeBuffer(value: NativeBuffer) { + this.writeCallbackResource({ + resourceId: value.resourceId, + hold: value.hold, + release: value.release + }) + this.writePointer(value.data) + this.writeInt64(value.length as int64) + } +} + diff --git a/koala-wrapper/koalaui/interop/src/arkts/buffer.sts b/koala-wrapper/koalaui/interop/src/arkts/buffer.sts new file mode 100644 index 000000000..d808bdc82 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/buffer.sts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022-2025 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 { int8 } from "@koalaui/common" + +export class KBuffer { + private readonly _buffer: byte[] + public get buffer(): byte[] { + return this._buffer + } + public get length(): int { + return this._buffer.length + } + + constructor(length: int) { + this._buffer = new byte[length] + } + + constructor(buffer: byte[]) { + this._buffer = buffer + } + + set(index: int, value: int8): void { + this._buffer[index] = value as byte + } + + get(index: int): byte { + return this._buffer[index] + } +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/arkts/callback.sts b/koala-wrapper/koalaui/interop/src/arkts/callback.sts new file mode 100644 index 000000000..06992e1ac --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/callback.sts @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2022-2025 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 { KUint8ArrayPtr } from "./InteropTypes" +import { int32 } from "@koalaui/common" + +export type CallbackType = (args: KUint8ArrayPtr, length: int32) => int32 + +class CallbackRecord { + public readonly callback: CallbackType + public readonly autoDisposable: boolean + + constructor( + callback: CallbackType, + autoDisposable: boolean + ) { + this.callback = callback + this.autoDisposable = autoDisposable + } +} + +class CallbackRegistry { + + static INSTANCE = new CallbackRegistry() + + private callbacks = new Map() + private id = 1024 + + constructor() { + this.callbacks.set(0, new CallbackRecord( + (args: KUint8ArrayPtr, length: int32): int32 => { + console.log(`Callback 0 called with args = ${args} and length = ${length}`) + throw new Error(`Null callback called`) + }, false) + ) + } + + wrap(callback: CallbackType, autoDisposable: boolean): int32 { + const id = this.id++ + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)) + return id + } + + wrapSystem(id: int32, callback: CallbackType, autoDisposable: boolean): int32 { + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)) + return id + } + + call(id: int32, args: KUint8ArrayPtr, length: int32): int32 { + const record = this.callbacks.get(id) + if (!record) { + console.log(`Callback ${id} is not known`) + throw new Error(`Disposed or unwrapped callback called (id = ${id})`) + } + if (record.autoDisposable) { + this.dispose(id) + } + return record.callback(args, length) + } + + dispose(id: int32) { + this.callbacks.delete(id) + } +} + +export function wrapCallback(callback: CallbackType, autoDisposable: boolean = true): int32 { + return CallbackRegistry.INSTANCE.wrap(callback, autoDisposable) +} + +export function wrapSystemCallback(id:int32, callback: CallbackType): int32 { + return CallbackRegistry.INSTANCE.wrapSystem(id, callback, false) +} + +export function disposeCallback(id: int32) { + CallbackRegistry.INSTANCE.dispose(id) +} + +export function callCallback(id: int32, args: KUint8ArrayPtr, length: int32): int32 { + return CallbackRegistry.INSTANCE.call(id, args, length) +} diff --git a/koala-wrapper/koalaui/interop/src/arkts/index.sts b/koala-wrapper/koalaui/interop/src/arkts/index.sts new file mode 100644 index 000000000..b57068080 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/index.sts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022-2025 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 * from "./InteropTypes" +export * from "./callback" +export * from "./buffer" +export * from "./ResourceManager" +export * from "./NativeBuffer" +export * from "./InteropNativeModule" +export * from "./SerializerBase" +export * from "./DeserializerBase" +export * from "./Finalizable" +export * from "./loadLibraries" +export * from "./MaterializedBase" diff --git a/koala-wrapper/koalaui/interop/src/arkts/loadLibraries.sts b/koala-wrapper/koalaui/interop/src/arkts/loadLibraries.sts new file mode 100644 index 000000000..1db028d2e --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/arkts/loadLibraries.sts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +const nativeModuleLibraries: Map = new Map() + +export function loadNativeLibrary(library: string) { + loadLibrary(library) +} + +export function registerNativeModuleLibraryName(nativeModule: string, libraryName: string) { + nativeModuleLibraries.set(nativeModule, libraryName) +} + +export function loadNativeModuleLibrary(nativeModule: string) { + loadLibrary(nativeModuleLibraries.get(nativeModule) ?? nativeModule) +} diff --git a/koala-wrapper/koalaui/interop/src/cangjie/DeserializerBase.cj b/koala-wrapper/koalaui/interop/src/cangjie/DeserializerBase.cj new file mode 100644 index 000000000..0e3e2d449 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cangjie/DeserializerBase.cj @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2025 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. + */ +package Interop + +import std.binary.* +import std.collection.* + +public class CallbackResource { + public var resourceId: Int32 + public var hold: pointer + public var release: pointer + init(resourceId: Int32, hold: pointer, release: pointer) { + this.resourceId = resourceId + this.hold = hold + this.release = release + } +} + +public open class DeserializerBase { + private var position = 0 + private var length = 96 + private var buffer: Array + + public init(buffer: Array, length: Int64) { + this.buffer = buffer + this.length = length + } + + public func asArray(position: Int64, length: Int64): ArrayList { + return ArrayList() + } + + public func currentPosition(): Int64 { + return this.position + } + + public func resetCurrentPosition(): Unit { + this.position = 0 + } + + private func checkCapacity(value: Int64) { + if (value > this.length) { + throw Exception("${value} is less than remaining buffer length") + } + } + + public func readInt8(): Int8 { + this.checkCapacity(1) + let res = Int8.readLittleEndian(this.buffer[this.position..this.position+1]) + this.position += 1 + return res + } + + public func readInt32(): Int32 { + this.checkCapacity(4) + let res = Int32.readLittleEndian(this.buffer[this.position..this.position+4]) + this.position += 4 + return res + } + + public func readInt64(): Int64 { + this.checkCapacity(8) + let res = Int64.readLittleEndian(this.buffer[this.position..this.position+8]) + this.position += 8 + return res + } + + public func readPointer(): KPointer { + this.checkCapacity(8) + let res = UInt64.readLittleEndian(this.buffer[this.position..this.position+8]) + this.position += 8 + return res + } + + public func readFloat32(): Float32 { + this.checkCapacity(4) + let res = Float32.readLittleEndian(this.buffer[this.position..this.position+4]) + this.position += 4 + return res + } + + public func readBoolean(): Bool { + let res = Bool.readLittleEndian(this.buffer[this.position..this.position+1]) + this.position += 1 + return res + } + + // readMaterialized(): object { + // const ptr = this.readPointer() + // return { ptr: ptr } + // } + + public func readString(): String { + let length = Int64(this.readInt32()) + this.checkCapacity(length) + // read without null-terminated byte + let value = InteropNativeModule._Utf8ToString(this.buffer.toArray(), Int32(this.position), Int32(length)) + this.position += length + return value + } + + public func readCustomObject(kind: String): Object{ + throw Exception("readCustomObject") + } + + public func readNumber(): Float64 { + let tag = this.readInt8() + if (tag == Tag.UNDEFINED.value) { + throw Exception("Read number can't return undefined.") + } else if (tag == Tag.INT32.value) { + return Float64(this.readInt32()) + } else if (tag == Tag.FLOAT32.value) { + return Float64(this.readFloat32()) + } else { + throw Exception("Unknown number tag: ${tag}") + } + } + + public func readCallbackResource(): CallbackResource { + return CallbackResource(this.readInt32(), this.readPointer(), this.readPointer()) + } +} diff --git a/koala-wrapper/koalaui/interop/src/cangjie/Finalizable.cj b/koala-wrapper/koalaui/interop/src/cangjie/Finalizable.cj new file mode 100644 index 000000000..b5ac709d4 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cangjie/Finalizable.cj @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 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. + */ +package Interop + +public open class Finalizable { + public var ptr: KPointer + public var finalizer: KPointer + + public Finalizable(ptr: KPointer, finalizer: KPointer) { + this.ptr = ptr + this.finalizer = finalizer + } +} + +public abstract class MaterializedBase { + public var peer: Option = Option.None + + public func getPeer(): ?Finalizable { + return this.peer + } +} diff --git a/koala-wrapper/koalaui/interop/src/cangjie/InteropNativeModule.cj b/koala-wrapper/koalaui/interop/src/cangjie/InteropNativeModule.cj new file mode 100644 index 000000000..5d4617498 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cangjie/InteropNativeModule.cj @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2024-2025 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. + */ + +package Interop + +import std.collection.* + +foreign { + func CheckCallbackEvent(buffer: CPointer, bufferLength: Int32): Int32 + + func GetGroupedLog(index: Int32): UInt64 + func StartGroupedLog(index: Int32): Unit + func StopGroupedLog(index: Int32): Unit + func AppendGroupedLog(index: Int32, message: CString): Unit + func PrintGroupedLog(index: Int32): Unit + func GetStringFinalizer(): UInt64 + func InvokeFinalizer(ptr1: UInt64, ptr2: UInt64): Unit + func GetPtrVectorElement(ptr1: UInt64, arg: Int32): UInt64 + func StringLength(ptr1: UInt64): Int32 + func StringData(ptr1: UInt64, arr: CPointer, i: Int32): Unit + func StringMake(str1: CString): UInt64 + func GetPtrVectorSize(ptr1: UInt64): Int32 + func ManagedStringWrite(str1: CString, arr: CPointer, arg: Int32): Int32 + func NativeLog(str1: CString): Unit + func Utf8ToString(data: CPointer, offset: Int32, length: Int32): CString + func StdStringToString(cstring: UInt64): CString + func CallCallback(callbackKind: Int32, args: CPointer, argsSize: Int32): Unit + func CallCallbackSync(callbackKind: Int32, args: CPointer, argsSize: Int32): Unit + func CallCallbackResourceHolder(holder: UInt64, resourceId: Int32): Unit + func CallCallbackResourceReleaser(releaser: UInt64, resourceId: Int32): Unit + func LoadVirtualMachine(arg0: Int32, arg1: CString, arg2: CString): Int32 + func RunApplication(arg0: Int32, arg1: Int32): Bool + func StartApplication(appUrl: CString, appParams: CString): UInt64 + func EmitEvent(eventType: Int32, target: Int32, arg0: Int32, arg1: Int32): Unit +} + +public open class InteropNativeModule { + public static func _CheckCallbackEvent(buffer: Array, bufferLength: Int32): Int32 { + unsafe { + let handle_0 = acquireArrayRawData(buffer) + let result = CheckCallbackEvent(handle_0.pointer, bufferLength) + releaseArrayRawData(handle_0); + return result + } + } + public static func _GetGroupedLog(index: Int32): UInt64 { + unsafe { + let result = GetGroupedLog(index) + return result + } + } + public static func _StartGroupedLog(index: Int32): Unit { + unsafe { + StartGroupedLog(index) + } + } + public static func _StopGroupedLog(index: Int32): Unit { + unsafe { + StopGroupedLog(index) + } + } + public static func _AppendGroupedLog(index: Int32, message: String): Unit { + unsafe { + let message = LibC.mallocCString(message) + AppendGroupedLog(index, message) + LibC.free(message) + } + } + public static func _PrintGroupedLog(index: Int32): Unit { + unsafe { + PrintGroupedLog(index) + } + } + public static func _GetStringFinalizer(): UInt64 { + unsafe { + let result = GetStringFinalizer() + return result + } + } + public static func _InvokeFinalizer(ptr1: UInt64, ptr2: UInt64): Unit { + unsafe { + InvokeFinalizer(ptr1, ptr2) + } + } + public static func _GetPtrVectorElement(ptr1: UInt64, arg: Int32): UInt64 { + unsafe { + let result = GetPtrVectorElement(ptr1, arg) + return result + } + } + public static func _StringLength(ptr1: UInt64): Int32 { + unsafe { + let result = StringLength(ptr1) + return result + } + } + public static func _StringData(ptr1: UInt64, arr: ArrayList, i: Int32): Unit { + unsafe { + let handle_1 = acquireArrayRawData(arr.toArray()) + StringData(ptr1, handle_1.pointer, i) + releaseArrayRawData(handle_1) + } + } + public static func _StringMake(str1: String): UInt64 { + unsafe { + let str1 = LibC.mallocCString(str1) + let result = StringMake(str1) + LibC.free(str1) + return result + } + } + public static func _GetPtrVectorSize(ptr1: UInt64): Int32 { + unsafe { + let result = GetPtrVectorSize(ptr1) + return result + } + } + public static func _ManagedStringWrite(str1: String, arr: ArrayList, arg: Int32): Int32 { + unsafe { + let str1 = LibC.mallocCString(str1) + let handle_1 = acquireArrayRawData(arr.toArray()) + let result = ManagedStringWrite(str1, handle_1.pointer, arg) + LibC.free(str1) + releaseArrayRawData(handle_1) + return result + } + } + public static func _NativeLog(str1: String): Unit { + unsafe { + let str1 = LibC.mallocCString(str1) + NativeLog(str1) + LibC.free(str1) + } + } + public static func _Utf8ToString(data: Array, offset: Int32, length: Int32): String { + unsafe { + let handle_0 = acquireArrayRawData(data) + let result = Utf8ToString(handle_0.pointer, offset, length) + releaseArrayRawData(handle_0) + return result.toString() + } + } + public static func _StdStringToString(cstring: UInt64): String { + unsafe { + let result = StdStringToString(cstring) + return result.toString() + } + } + public static func _CallCallback(callbackKind: Int32, args: ArrayList, argsSize: Int32): Unit { + unsafe { + let handle_1 = acquireArrayRawData(args.toArray()) + CallCallback(callbackKind, handle_1.pointer, argsSize) + releaseArrayRawData(handle_1) + } + } + public static func _CallCallbackSync(callbackKind: Int32, args: ArrayList, argsSize: Int32): Unit { + unsafe { + let handle_1 = acquireArrayRawData(args.toArray()) + CallCallbackSync(callbackKind, handle_1.pointer, argsSize) + releaseArrayRawData(handle_1) + } + } + public static func _CallCallbackResourceHolder(holder: UInt64, resourceId: Int32): Unit { + unsafe { + CallCallbackResourceHolder(holder, resourceId) + } + } + public static func _CallCallbackResourceReleaser(releaser: UInt64, resourceId: Int32): Unit { + unsafe { + CallCallbackResourceReleaser(releaser, resourceId) + } + } + public static func _LoadVirtualMachine(arg0: Int32, arg1: String, arg2: String): Int32 { + unsafe { + let arg1 = LibC.mallocCString(arg1) + let arg2 = LibC.mallocCString(arg2) + let result = LoadVirtualMachine(arg0, arg1, arg2) + LibC.free(arg1) + LibC.free(arg1) + return result + } + } + public static func _RunApplication(arg0: Int32, arg1: Int32): Bool { + unsafe { + let result = RunApplication(arg0, arg1) + return result + } + } + public static func _StartApplication(appUrl: String, appParams: String): UInt64 { + unsafe { + let appUrl = LibC.mallocCString(appUrl) + let appParams = LibC.mallocCString(appParams) + let result = StartApplication(appUrl, appParams) + LibC.free(appUrl) + LibC.free(appUrl) + return result + } + } + public static func _EmitEvent(eventType: Int32, target: Int32, arg0: Int32, arg1: Int32): Unit { + unsafe { + EmitEvent(eventType, target, arg0, arg1) + } + } + public static func _StringData(ptr: KPointer, data: Array, arg2: Int32): Unit { + unsafe { + let handle_1 = acquireArrayRawData(data) + StringData(ptr, handle_1.pointer, arg2) + releaseArrayRawData(handle_1) + } + } +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cangjie/InteropTypes.cj b/koala-wrapper/koalaui/interop/src/cangjie/InteropTypes.cj new file mode 100644 index 000000000..2e2895609 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cangjie/InteropTypes.cj @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 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. + */ +package Interop + +import std.collection.* + +public type KPointer = UInt64 +public type KFloat = Float32 +public type pointer = KPointer +public type KInt = Int32 +public type KStringPtr = String +public type ArrayBuffer = ArrayList \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cangjie/ResourceManager.cj b/koala-wrapper/koalaui/interop/src/cangjie/ResourceManager.cj new file mode 100644 index 000000000..61d207889 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cangjie/ResourceManager.cj @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022-2025 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. + */ +package Interop + +import std.binary.* +import std.math.* +import std.collection.* + +public type ResourceId = Int32 + +class ResourceInfo { + public var resource: Any + public var holdersCount: Int32 + init(resource: Any, holdersCount: Int32 ) { + this.resource = resource + this.holdersCount = holdersCount + } +} + +public class ResourceHolder { + private static var nextResourceId: ResourceId = 100 + private var resources: HashMap = HashMap() + private static var _instance: ?ResourceHolder = Option.None + public static func instance(): ResourceHolder { + ResourceHolder._instance = match (ResourceHolder._instance) { + case Some(resourceHolder) => resourceHolder + case _ => ResourceHolder() + } + if (let Some(rh) <- ResourceHolder._instance) { + return rh + } else { + throw Exception() + } + } + public func hold(resourceId: ResourceId) { + match(this.resources.get(resourceId)) { + case Some(resource) => resource.holdersCount++ + case _ => throw Exception("Resource ${resourceId} does not exists, can not hold") + } + } + + public func release(resourceId: ResourceId) { + let resource = match (this.resources.get(resourceId)) { + case Some(resource) => resource + case _ => throw Exception("Resource ${resourceId} does not exists, can not hold") + } + resource.holdersCount-- + if (resource.holdersCount <= 0) { + this.resources.remove(resourceId) + } + } + + public func registerAndHold(resource: Any): ResourceId { + ResourceHolder.nextResourceId += 1 + let resourceId = ResourceHolder.nextResourceId + this.resources.add(resourceId, ResourceInfo(resource, resourceId)) + return resourceId + } + + public func get(resourceId: ResourceId): Any { + match(this.resources.get(resourceId)) { + case Some(resource) => return resource.resource + case _ => throw Exception("Resource ${resourceId} does not exists") + } + } +} diff --git a/koala-wrapper/koalaui/interop/src/cangjie/SerializerBase.cj b/koala-wrapper/koalaui/interop/src/cangjie/SerializerBase.cj new file mode 100644 index 000000000..526e566d6 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cangjie/SerializerBase.cj @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2025 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. + */ + +package Interop + +import std.binary.* +import std.math.* +import std.reflect.* +import std.collection.* + +public enum RuntimeType { + |UNEXPECTED + |NUMBER + |STRING + |OBJECT + |BOOLEAN + |UNDEFINED + |BIGINT + |FUNCTION + |SYMBOL + |MATERIALIZED + public prop ordinal: Int32 { + get() { + match (this) { + case UNEXPECTED => -1 + case NUMBER => 1 + case STRING => 2 + case OBJECT => 3 + case BOOLEAN => 4 + case UNDEFINED => 5 + case BIGINT => 6 + case FUNCTION => 7 + case SYMBOL => 8 + case MATERIALIZED => 9 + } + } + } +} + + +/* Serialization extension point */ +public abstract class CustomSerializer { + public var supported: Array + init(supported: Array) { + this.supported = supported + } + public func supports(kind: String): Bool { return this.supported.contains(kind) } + public func serialize(serializer: SerializerBase, value: Object, kind: String): Unit {} + var next: ?CustomSerializer = Option.None +} + +public open class SerializerBase { + protected var isHolding: Bool = false + private var position: Int64 = 0 + private var buffer: ArrayList = ArrayList() + + private static var customSerializers: ?CustomSerializer = Option.None + static func registerCustomSerializer(serializer: CustomSerializer) { + //TODO + } + + public init() { + this.buffer = ArrayList(Array(96, repeat: UInt8(0))) + } + public open func release() { + this.isHolding = false + // todo handle release resources + this.position = 0 + } + public func asArray(): ArrayList { + return this.buffer + } + public func length(): Int32 { + return Int32(this.position) + } + public func currentPosition(): Int64 { return this.position } + private func checkCapacity(value: Int64) { + if (value < 1) { + throw Exception("${value} is less than 1") + } + var buffSize = this.buffer.size + if (this.position > buffSize - value) { + let minSize = this.position + value + let resizedSize = max(minSize, Int64(round(3.0 * Float64(buffSize) / 2.0))) + var resizedBuffer = ArrayList(this.buffer) + while (resizedBuffer.size < resizedSize) { + resizedBuffer.add(0) + } + this.buffer = resizedBuffer + } + } + public func writeCustomObject(kind: String, value: Any): Unit { + var current = SerializerBase.customSerializers + // TODO + println("Unsupported custom serialization for ${kind}, write undefined") + this.writeInt8(Tag.UNDEFINED.value) + } + private var heldResources: ArrayList = ArrayList() + public func holdAndWriteCallback(callback: Any): ResourceId { + let resourceId = ResourceHolder.instance().registerAndHold(callback) + this.heldResources.add(resourceId) + this.writeInt32(resourceId) + this.writePointer(0) + this.writePointer(0) + this.writePointer(0) + this.writePointer(0) + return resourceId + } + public func holdAndWriteCallback(callback: Any, hold: KPointer, release: KPointer, call: KPointer, callSync: KPointer): ResourceId { + let resourceId = ResourceHolder.instance().registerAndHold(callback) + this.heldResources.add(resourceId) + this.writeInt32(resourceId) + this.writePointer(hold) + this.writePointer(release) + this.writePointer(call) + this.writePointer(callSync) + return resourceId + } + public func writeFunction(value: Any): Unit { + // TODO + } + private func setBytes(position: Int64, value: T): Unit where T <: LittleEndianOrder{ + var arr = Array(100, repeat: 0) + let n = value.writeLittleEndian(arr) + this.checkCapacity(n) + for (i in 0..n) { + this.buffer[this.position + i] = arr[i] + } + this.position += n + } + public func writeTag(tag: Int32): Unit { + this.setBytes(this.position, tag) + } + public func writeNumber(value: ?Float32): Unit { + if (let Some(value) <- value) { + if(value == Float32(Int32(value))) { + this.writeNumber(Int32(value)) + } else { + this.setBytes(this.position, Tag.FLOAT32.value) + this.setBytes(this.position, value) + } + } + else { + this.buffer[Int64(this.position)] = UInt8(RuntimeType.UNDEFINED.ordinal) + this.position++ + } + } + public func writeNumber(value: ?Float64): Unit { + if (let Some(value) <- value) { + if(value == Float64(Int32(value))) { + this.writeNumber(Int32(value)) + } else { + this.setBytes(this.position, Tag.FLOAT32.value) + this.setBytes(this.position, Float32(value)) + } + } + else { + this.buffer[Int64(this.position)] = UInt8(RuntimeType.UNDEFINED.ordinal) + this.position++ + } + } + public func writeNumber(value: ?Int32): Unit { + if (let Some(value) <- value) { + this.setBytes(this.position, Tag.INT32.value) + this.setBytes(this.position, value) + } + else { + this.buffer[Int64(this.position)] = UInt8(RuntimeType.UNDEFINED.ordinal) + this.position++ + } + } + public func writeNumber(value: ?Int64): Unit { + if (let Some(value) <- value) { + this.setBytes(this.position, Tag.INT32.value) + this.setBytes(this.position, Int32(value)) + } + else { + this.buffer[Int64(this.position)] = UInt8(RuntimeType.UNDEFINED.ordinal) + this.position++ + } + } + public func writeInt8(value: Int8): Unit { + this.setBytes(this.position, value) + } + public func writeInt8(value: Int32): Unit { + this.setBytes(this.position, Int8(value)) + } + public func writeInt32(value: Int32): Unit { + this.setBytes(this.position, Int32(value)) + } + public func writeInt64(value: Int64): Unit { + this.setBytes(this.position, Int64(value)) + } + public func writeFloat32(value: Float32): Unit { + this.setBytes(this.position, value) + } + public func writePointer(ptr: UInt64): Unit { + this.setBytes(this.position, ptr) + } + public func writeBoolean(value: ?Bool): Unit { + this.checkCapacity(1) + if(let Some(value) <- value) { + this.setBytes(this.position, value) + } + else { + this.buffer[Int64(this.position)] = UInt8(RuntimeType.UNDEFINED.ordinal) + this.position++ + } + } + public func writeMaterialized(value: Object): Unit { + // TODO + } + public func writeCallbackResource(resource: CallbackResource) { + this.writeInt32(resource.resourceId) + this.writePointer(resource.hold) + this.writePointer(resource.release) + } + public func writeString(value: String): Unit { + this.checkCapacity(4 + value.size * 4 + 1) // length, data + this.writeInt32(Int32(value.size + 1)) + for (i in 0..value.size) { + this.setBytes(this.position, value[i]) + } + this.writeInt8(Int8(0)) + } + public func writeBuffer(buffer: Array) { + let resourceId = ResourceHolder.instance().registerAndHold(buffer) + this.writeCallbackResource(CallbackResource(resourceId, 0, 0)) + unsafe { + let ptr = acquireArrayRawData(buffer).pointer + this.writePointer(UInt64(ptr.toUIntNative())) + this.writeInt64(buffer.size) + } + } +} + +public open class DateCustomSerializer <: CustomSerializer { + public DateCustomSerializer() { + super(["Date"]) + } + public func serialize(serializer: SerializerBase, value: Ark_CustomObject, kind: String): Unit { + serializer.writeString("{}") + } +} + +public open class Ark_CustomObject { + init() { + SerializerBase.registerCustomSerializer(DateCustomSerializer()) + } +} diff --git a/koala-wrapper/koalaui/interop/src/cangjie/Tag.cj b/koala-wrapper/koalaui/interop/src/cangjie/Tag.cj new file mode 100644 index 000000000..621a1fd57 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cangjie/Tag.cj @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 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. + */ +package Interop + +public open class Tag { + public static var UNDEFINED: Tag = Tag(101) + public static var INT32: Tag = Tag(102) + public static var FLOAT32: Tag = Tag(103) + public static var STRING: Tag = Tag(104) + public static var LENGTH: Tag = Tag(105) + public static var RESOURCE: Tag = Tag(106) + public static var OBJECT: Tag = Tag(107) + public var value: Int8 + Tag (arg0: Int8) { + value = arg0 + } +} diff --git a/koala-wrapper/koalaui/interop/src/cangjie/cjpm.toml b/koala-wrapper/koalaui/interop/src/cangjie/cjpm.toml new file mode 100644 index 000000000..d29229886 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cangjie/cjpm.toml @@ -0,0 +1,12 @@ +[dependencies] +[package] + cjc-version = "0.56.4" + compile-option = "" + description = "config file for cj build" + link-option = "" + name = "Interop" + output-type = "static" + src-dir = "." + target-dir = "./build/cj" + version = "1.0.0" + package-configuration = {} diff --git a/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h new file mode 100644 index 000000000..e09c40524 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h @@ -0,0 +1,650 @@ +/* + * Copyright (c) 2025 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 _DESERIALIZER_BASE_H_ +#define _DESERIALIZER_BASE_H_ + +#include +#include +#include +#include +#include +#include + +#include "interop-types.h" +#include "interop-logging.h" + +void holdManagedCallbackResource(InteropInt32); +void releaseManagedCallbackResource(InteropInt32); + +#ifdef __arm__ +#define KOALA_NO_UNALIGNED_ACCESS 1 +#endif + +inline const char *tagName(InteropTag tag) +{ + switch (tag) + { + case InteropTag::INTEROP_TAG_UNDEFINED: + return "UNDEFINED"; + case InteropTag::INTEROP_TAG_INT32: + return "INT32"; + case InteropTag::INTEROP_TAG_FLOAT32: + return "FLOAT32"; + case InteropTag::INTEROP_TAG_LENGTH: + return "LENGTH"; + case InteropTag::INTEROP_TAG_RESOURCE: + return "RESOURCE"; + case InteropTag::INTEROP_TAG_STRING: + return "STRING"; + case InteropTag::INTEROP_TAG_OBJECT: + return "OBJECT"; + } + INTEROP_FATAL("Fatal error"); +} + +inline const char *tagNameExact(InteropTag tag) +{ + switch (tag) + { + case InteropTag::INTEROP_TAG_UNDEFINED: + return "INTEROP_TAG_UNDEFINED"; + case InteropTag::INTEROP_TAG_INT32: + return "INTEROP_TAG_INT32"; + case InteropTag::INTEROP_TAG_FLOAT32: + return "INTEROP_TAG_FLOAT32"; + case InteropTag::INTEROP_TAG_LENGTH: + return "INTEROP_TAG_LENGTH"; + case InteropTag::INTEROP_TAG_RESOURCE: + return "INTEROP_TAG_RESOURCE"; + case InteropTag::INTEROP_TAG_STRING: + return "INTEROP_TAG_STRING"; + case InteropTag::INTEROP_TAG_OBJECT: + return "INTEROP_TAG_OBJECT"; + } + INTEROP_FATAL("Fatal error"); +} + +inline InteropFunction makeArkFunctionFromId(InteropInt32 id) { + InteropFunction result; + result.id = id; + return result; +} + +inline const char *getUnitName(int value) +{ + switch (value) + { + case 0: + return "px"; + case 1: + return "vp"; + case 2: + return "fp"; + case 3: + return "%"; + case 4: + return "lpx"; + default: + return ""; + } +} + +inline void parseDimension(const InteropString &string, InteropLength *result) +{ + char *suffixPtr = nullptr; + float value = std::strtof(string.chars, &suffixPtr); + + if (!suffixPtr || suffixPtr == string.chars) + { + // not a numeric value + result->unit = -1; + return; + } + result->value = value; + if (suffixPtr[0] == '\0' || (suffixPtr[0] == 'v' && suffixPtr[1] == 'p')) + { + result->unit = 1; + } + else if (suffixPtr[0] == '%') + { + result->unit = 3; + } + else if (suffixPtr[0] == 'p' && suffixPtr[1] == 'x') + { + result->unit = 0; + } + else if (suffixPtr[0] == 'l' && suffixPtr[1] == 'p' && suffixPtr[2] == 'x') + { + result->unit = 4; + } + else if (suffixPtr[0] == 'f' && suffixPtr[1] == 'p') + { + result->unit = 2; + } + else + { + result->unit = -1; + } +} + +template +inline void convertor(T value) = delete; + +// TODO: restore full printing! +template +inline void WriteToString(std::string *result, T value) = delete; + +template <> +inline void WriteToString(std::string *result, const InteropEmpty &value) +{ + result->append("{"); + result->append(".dummy=" + std::to_string(value.dummy)); + result->append("}"); +} + +struct Error +{ + std::string message; + Error(const std::string &message) : message(message) {} +}; + +template <> +inline void WriteToString(std::string *result, InteropTag value) +{ + result->append(".tag="); + result->append(tagName(value)); +} + +template <> +inline void WriteToString(std::string *result, InteropNativePointer value) +{ + result->append("0x" + std::to_string((uint64_t)value)); +} + +template <> +inline void WriteToString(std::string *result, InteropNodeHandle value) +{ + result->append("0x" + std::to_string((uint64_t)value)); +} + +template <> +inline void WriteToString(std::string *result, InteropFunction value) +{ + result->append("{"); + result->append(".id=" + std::to_string(value.id)); + result->append("}"); +} + +template <> +inline void WriteToString(std::string *result, const InteropFunction* value) +{ + result->append("{"); + result->append(".id=" + std::to_string(value->id)); + result->append("}"); +} + +template <> +inline void WriteToString(std::string *result, const InteropMaterialized *value) +{ + char hex[20]; + std::snprintf(hex, sizeof(hex), "0x%llx", (long long)value->ptr); + result->append("\""); + result->append("Materialized "); + result->append(hex); + result->append("\""); +} + +// TODO: generate! +template<> +inline void WriteToString(std::string *result, const InteropCallbackResource *value) +{ + result->append("{"); + result->append(".resourceId=" + std::to_string(value->resourceId)); + result->append(", .hold=0"); + result->append(", .release=0"); + result->append("}"); +} + +class DeserializerBase; + +template <> +inline void WriteToString(std::string *result, InteropUndefined value) +{ + result->append("{}"); +} +template <> +inline void WriteToString(std::string *result, const InteropUndefined *value) +{ + result->append("{}"); +} +template <> +inline void WriteToString(std::string *result, InteropVoid value) +{ + result->append("{}"); +} +template <> +inline void WriteToString(std::string *result, const InteropVoid *value) +{ + result->append("{}"); +} +template <> +inline void WriteToString(std::string *result, const InteropCustomObject *value) +{ + if (strcmp(value->kind, "NativeErrorFunction") == 0) + { + result->append("() => {} /* TBD: Function*/"); + return; + } + result->append("{"); + result->append(".kind=\""); + result->append(value->kind); + result->append("\"}"); +} + +struct CustomDeserializer +{ + virtual ~CustomDeserializer() {} + virtual bool supports(const std::string &kind) { return false; } + virtual InteropCustomObject deserialize(DeserializerBase *deserializer, const std::string &kind) + { + InteropCustomObject result; + strcpy(result.kind, "error"); + return result; + } + CustomDeserializer *next = nullptr; +}; + +class DeserializerBase +{ +protected: + uint8_t *data; + int32_t length; + int32_t position; + std::vector toClean; + + static CustomDeserializer *customDeserializers; + +public: + DeserializerBase(uint8_t *data, int32_t length) + : data(data), length(length), position(0) {} + + ~DeserializerBase() + { + for (auto data : toClean) + { + free(data); + } + } + + static void registerCustomDeserializer(CustomDeserializer *deserializer) + { + if (DeserializerBase::customDeserializers == nullptr) + { + DeserializerBase::customDeserializers = deserializer; + } + else + { + auto *current = DeserializerBase::customDeserializers; + while (current->next != nullptr) + current = current->next; + current->next = deserializer; + } + } + + template + void resizeArray(T *array, int32_t length) + { + void *value = nullptr; + if (length > 0) + { + value = malloc(length * sizeof(E)); + memset(value, 0, length * sizeof(E)); + toClean.push_back(value); + } + array->length = length; + array->array = reinterpret_cast(value); + } + + template + void resizeMap(T *map, int32_t length) + { + void *keys = nullptr; + void *values = nullptr; + if (length > 0) + { + keys = malloc(length * sizeof(K)); + memset(keys, 0, length * sizeof(K)); + toClean.push_back(keys); + + values = malloc(length * sizeof(V)); + memset(values, 0, length * sizeof(V)); + toClean.push_back(values); + } + map->size = length; + map->keys = reinterpret_cast(keys); + map->values = reinterpret_cast(values); + } + + int32_t currentPosition() const { return this->position; } + + void check(int32_t count) + { + if (position + count > length) { + fprintf(stderr, "Incorrect serialized data, check for %d, buffer %d position %d\n", count, length, position); + assert(false); + abort(); + } + } + + InteropCustomObject readCustomObject(std::string kind) + { + auto *current = DeserializerBase::customDeserializers; + while (current) + { + if (current->supports(kind)) + return current->deserialize(this, kind); + current = current->next; + } + LOGE("Unsupported custom deserialization for %s\n", kind.c_str()); + auto tag = readTag(); + if (tag == INTEROP_TAG_UNDEFINED) LOGE("Undefined interop tag"); + // Skip undefined tag!. + InteropCustomObject result; + strcpy(result.kind, "Error"); + strcat(result.kind, kind.c_str()); + return result; + } + + InteropCallbackResource readCallbackResource() { + InteropCallbackResource result = {}; + result.resourceId = readInt32(); + result.hold = reinterpret_cast(readPointerOrDefault(reinterpret_cast(holdManagedCallbackResource))); + result.release = reinterpret_cast(readPointerOrDefault(reinterpret_cast(releaseManagedCallbackResource))); + return result; + } + + int8_t readInt8() + { + check(1); + int8_t value = *(data + position); + position += 1; + return value; + } + InteropTag readTag() + { + return (InteropTag)readInt8(); + } + InteropBoolean readBoolean() + { + check(1); + int8_t value = *(data + position); + position += 1; + return value; + } + InteropInt32 readInt32() + { + check(4); +#ifdef KOALA_NO_UNALIGNED_ACCESS + InteropInt32 value; + memcpy(&value, data + position, 4); +#else + auto value = *(InteropInt32 *)(data + position); +#endif + position += 4; + return value; + } + InteropInt64 readInt64() + { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + InteropInt64 value; + memcpy(&value, data + position, 4); +#else + auto value = *(InteropInt64 *)(data + position); +#endif + position += 8; + return value; + } + InteropUInt64 readUInt64() + { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + InteropInt64 value; + memcpy(&value, data + position, 4); +#else + auto value = *(InteropUInt64 *)(data + position); +#endif + position += 8; + return value; + } + InteropFloat32 readFloat32() + { + check(4); +#ifdef KOALA_NO_UNALIGNED_ACCESS + InteropFloat32 value; + memcpy(&value, data + position, 4); +#else + auto value = *(InteropFloat32 *)(data + position); +#endif + position += 4; + return value; + } + InteropNativePointer readPointer() + { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + int64_t value = 0; + memcpy(&value, data + position, 8); +#else + int64_t value = *(int64_t *)(data + position); +#endif + position += 8; + return reinterpret_cast(value); + } + InteropNativePointer readPointerOrDefault(InteropNativePointer defaultValue) + { + const InteropNativePointer value = this->readPointer(); + return value ? value : defaultValue; + } + InteropNumber readNumber() + { + check(5); + InteropNumber result; + result.tag = readTag(); + if (result.tag == InteropTag::INTEROP_TAG_INT32) + { + result.i32 = readInt32(); + } + else if (result.tag == InteropTag::INTEROP_TAG_FLOAT32) + { + result.f32 = readFloat32(); + } + else + { + INTEROP_FATAL("Fatal error"); + } + return result; + } + InteropBuffer readBuffer() + { + InteropCallbackResource resource = readCallbackResource(); + InteropNativePointer data = readPointer(); + InteropInt64 length = readInt64(); + return InteropBuffer { resource, (void*)data, length }; + } + + // TODO: produce them with prefix in generator. + InteropLength readLength() + { + InteropLength result = {}; + result.unit = 1; + result.type = readInt8(); + switch (result.type) + { + case INTEROP_RUNTIME_OBJECT: + { + result.resource = readInt32(); + break; + } + case INTEROP_RUNTIME_STRING: + { + InteropString string = readString(); + parseDimension(string, &result); + break; + } + case INTEROP_RUNTIME_NUMBER: + { + result.value = readFloat32(); + break; + } + default: + { + INTEROP_FATAL("Fatal error"); + } + } + return result; + } + + InteropString readString() + { + InteropString result; + InteropInt32 length = readInt32(); + check(length); + // We refer to string data in-place. + result.chars = (const char *)(data + position); + result.length = length - 1; + this->position += length; + return result; + } + + InteropFunction readFunction() + { + InteropFunction result; + result.id = readInt32(); + return result; + } + + InteropMaterialized readMaterialized() + { + InteropMaterialized result; + result.ptr = readPointer(); + return result; + } + + InteropUndefined readUndefined() + { + return InteropUndefined(); + } +}; +template <> +inline void WriteToString(std::string *result, InteropBoolean value) +{ + result->append(value ? "true" : "false"); +} +template <> +inline void WriteToString(std::string *result, InteropInt32 value) +{ + result->append(std::to_string(value)); +} +template <> +inline void WriteToString(std::string *result, const InteropInt32* value) +{ + result->append(std::to_string(*value)); +} +template <> +inline void WriteToString(std::string *result, InteropInt64 value) +{ + result->append(std::to_string(value)); +} +template <> +inline void WriteToString(std::string *result, InteropUInt32 value) +{ + result->append(std::to_string(value)); +} +template <> +inline void WriteToString(std::string *result, InteropFloat32 value) +{ +#if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 130300L)) + // to_chars() is not available on older macOS. + char buf[20]; + snprintf(buf, sizeof buf, "%f", value); + result->append(buf); +#else + std::string storage; + storage.resize(20); + // We use to_chars() to avoid locale issues. + auto rc = std::to_chars(storage.data(), storage.data() + storage.size(), value); + storage.resize(rc.ptr - storage.data()); + result->append(storage); +#endif +} +template <> +inline void WriteToString(std::string* result, const InteropBuffer* value) { + result->append("{.data=nullptr, .length="); + result->append(std::to_string(value->length)); + result->append("}"); +} +template <> +inline void WriteToString(std::string* result, InteropBuffer value) { + result->append("{.data=nullptr, .length="); + result->append(std::to_string(value.length)); + result->append("}"); +} +template <> +inline void WriteToString(std::string *result, const InteropString *value) +{ + result->append("{"); + if (value->chars) { + result->append(".chars=\""); + result->append(value->chars); + result->append("\""); + } else { + result->append(".chars=\"\""); + } + result->append(", .length="); + WriteToString(result, value->length); + result->append("}"); +} + +template <> +inline void WriteToString(std::string *result, const InteropNumber *value) +{ + result->append("{.tag=" + std::to_string(value->tag) + ", "); + + if (value->tag == INTEROP_TAG_FLOAT32) + { + std::string valueString; + result->append(".f32="); + WriteToString(result, value->f32); + } else { + result->append(".i32=" + std::to_string(value->i32)); + } + + result->append("}"); +} + +template <> +inline void WriteToString(std::string *result, const InteropLength *value) +{ + result->append("{"); + result->append(".type=" + std::to_string(value->type)); + result->append(", .value="); + WriteToString(result, value->value); + result->append(", .unit=" + std::to_string(value->unit)); + result->append(", .resource=" + std::to_string(value->resource)); + result->append("}"); +} + +#endif // _DESERIALIZER_BASE_H_ diff --git a/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h new file mode 100644 index 000000000..f6cce0fae --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2025 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 _SERIALIZER_BASE_H +#define _SERIALIZER_BASE_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "callback-resource.h" +#include "interop-types.h" +#include "koala-types.h" + +#ifdef __arm__ +#define KOALA_NO_UNALIGNED_ACCESS 1 +#endif + +template +inline InteropRuntimeType runtimeType(const T& value) = delete; + +template <> +inline InteropRuntimeType runtimeType(const InteropCustomObject& value) { + return INTEROP_RUNTIME_OBJECT; +} + +template <> +inline InteropRuntimeType runtimeType(const InteropMaterialized& value) { + return INTEROP_RUNTIME_OBJECT; +} + +static const std::size_t buffer_size = 1024 * 1024; // 1 MB +static std::size_t offset = 0; +alignas(std::max_align_t) static char buffer[buffer_size]; + +template +T* allocArray(const std::array& ref) { + std::size_t space = sizeof(buffer) - offset; + void* ptr = buffer + offset; + void* aligned_ptr = std::align(alignof(T), sizeof(T) * size, ptr, space); + assert(aligned_ptr != nullptr && "Insufficient space or alignment failed!"); + offset = (char*)aligned_ptr + sizeof(T) * size - buffer; + T* array = reinterpret_cast(aligned_ptr); + for (size_t i = 0; i < size; ++i) { + new (&array[i]) T(ref[i]); + } + return array; +} + +class SerializerBase { +private: + uint8_t* data; + uint32_t dataLength; + uint32_t position; + bool ownData; + CallbackResourceHolder* resourceHolder; + void resize(uint32_t newLength) { + assert(ownData); + assert(newLength > dataLength); + auto* newData = reinterpret_cast(malloc(newLength)); + memcpy(newData, data, position); + free(data); + data = newData; + } +public: + SerializerBase(CallbackResourceHolder* resourceHolder = nullptr): + position(0), ownData(true), resourceHolder(resourceHolder) { + this->dataLength = 256; + this->data = reinterpret_cast(malloc(this->dataLength)); + } + + SerializerBase(uint8_t* data, uint32_t dataLength, CallbackResourceHolder* resourceHolder = nullptr): + data(data), dataLength(dataLength), position(0), ownData(false), resourceHolder(resourceHolder) { + } + + virtual ~SerializerBase() { + if (ownData) { + free(data); + } + } + + SerializerBase(const SerializerBase&) = delete; + SerializerBase& operator=(const SerializerBase&) = delete; + + void* release() { + ownData = false; + return data; + } + int length() { + return position; + } + + inline void check(int more) { + if (position + more > dataLength) { + if (ownData) { + resize(dataLength * 3 / 2 + 2); + } else { + fprintf(stderr, "Buffer overrun: %d > %d\n", position + more, dataLength); + assert(false); + } + } + } + + void writeInt8(InteropInt8 value) { + check(1); + *((InteropInt8*)(data + position)) = value; + position += 1; + } + + void writeInt32(InteropInt32 value) { + check(4); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value, 4); +#else + *((InteropInt32*)(data + position)) = value; +#endif + position += 4; + } + + void writeInt64(InteropInt64 value) { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value, 8); +#else + *((InteropInt64*)(data + position)) = value; +#endif + position += 8; + } + + void writeUInt64(InteropUInt64 value) { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value, 8); +#else + *((InteropUInt64*)(data + position)) = value; +#endif + position += 8; + } + + void writeFloat32(InteropFloat32 value) { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value, 4); +#else + *((InteropFloat32*)(data + position)) = value; +#endif + position += 4; + } + + void writePointer(InteropNativePointer value) { + check(8); +#ifdef KOALA_NO_UNALIGNED_ACCESS + memcpy(data + position, &value, 8); +#else + *((int64_t*)(data + position)) = reinterpret_cast(value); +#endif + position += 8; + } + + void writeFunction(InteropFunction value) { + // TODO: ignored, remove! + writeInt32(0x666); + } + + void writeNumber(InteropNumber value) { + writeInt8(value.tag); + if (value.tag == InteropTag::INTEROP_TAG_INT32) { + writeInt32(value.i32); + } else if (value.tag == InteropTag::INTEROP_TAG_FLOAT32) { + writeFloat32(value.f32); + } else { + INTEROP_FATAL("Unknown tag number"); + } + } + + void writeString(InteropString value) { + writeInt32(value.length + 1); + check(value.length + 1); + strcpy((char*)(data + position), value.chars); + position += value.length + 1; + } + + void writeBoolean(InteropBoolean value) { + writeInt8(value); + } + + void writeLength(InteropLength value) { + InteropRuntimeType tag = (InteropRuntimeType) value.type; + writeInt8(tag); + switch (tag) { + case INTEROP_RUNTIME_NUMBER: + writeFloat32(value.value); + break; + case INTEROP_RUNTIME_OBJECT: + writeInt32(value.resource); + break; + case INTEROP_RUNTIME_STRING: { + char buf[64]; + std::string suffix; + switch (value.unit) { + case 0: suffix = "px"; break; + case 1: suffix = "vp"; break; + case 2: suffix = "fp"; break; + case 3: suffix = "%"; break; + case 4: suffix = "lpx"; break; + } + snprintf(buf, 64, "%.8f%s", value.value, suffix.c_str()); + InteropString str = { buf, (InteropInt32) strlen(buf) }; + writeString(str); + break; + } + default: + break; + } + } + + void writeCallbackResource(const InteropCallbackResource resource) { + writeInt32(resource.resourceId); + writePointer(reinterpret_cast(resource.hold)); + writePointer(reinterpret_cast(resource.release)); + if (this->resourceHolder != nullptr) { + this->resourceHolder->holdCallbackResource(&resource); + } + } + + void writeCustomObject(std::string type, InteropCustomObject value) { + // TODO implement + } + + void writeBuffer(InteropBuffer buffer) { + writeCallbackResource(buffer.resource); + writePointer((void*)buffer.data); + writeInt64(buffer.length); + } + + KInteropReturnBuffer toReturnBuffer() { + if (this->ownData) { + KInteropReturnBuffer buffer {this->length(), this->release(), [](KNativePointer data, KInt length) { free(data); }}; + // TODO fix memory issues + return buffer; + } else { + return {this->length(), this->data, nullptr}; + } + } +}; + +#endif // _SERIALIZER_BASE_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/ani/ani.h b/koala-wrapper/koalaui/interop/src/cpp/ani/ani.h new file mode 100644 index 000000000..3adbe2416 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/ani/ani.h @@ -0,0 +1,9062 @@ +/** + * Copyright (c) 2025 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 __ANI_H__ +#define __ANI_H__ +// NOLINTBEGIN + +#ifdef __cplusplus +#include +#include +#include +#else +#include +#include +#include +#endif + +#define ANI_VERSION_1 1 + +#define ANI_FALSE 0 +#define ANI_TRUE 1 + +typedef size_t ani_size; + +// Primitive types: +typedef uint8_t ani_boolean; +typedef uint32_t ani_char; +typedef int8_t ani_byte; +typedef int16_t ani_short; +typedef int32_t ani_int; +typedef int64_t ani_long; +typedef float ani_float; +typedef double ani_double; + +// Reference types: +#ifdef __cplusplus +class __ani_ref {}; +class __ani_module : public __ani_ref {}; +class __ani_namespace : public __ani_ref {}; +class __ani_object : public __ani_ref {}; +class __ani_fn_object : public __ani_object {}; +class __ani_enum_value : public __ani_object {}; +class __ani_error : public __ani_object {}; +class __ani_promise : public __ani_object {}; +class __ani_tuple_value : public __ani_object {}; +class __ani_type : public __ani_object {}; +class __ani_arraybuffer : public __ani_object {}; +class __ani_string : public __ani_object {}; +class __ani_stringliteral : public __ani_string {}; +class __ani_class : public __ani_type {}; +class __ani_enum : public __ani_type {}; +class __ani_tuple : public __ani_type {}; +class __ani_fixedarray : public __ani_object {}; +class __ani_fixedarray_boolean : public __ani_fixedarray {}; +class __ani_fixedarray_char : public __ani_fixedarray {}; +class __ani_fixedarray_byte : public __ani_fixedarray {}; +class __ani_fixedarray_short : public __ani_fixedarray {}; +class __ani_fixedarray_int : public __ani_fixedarray {}; +class __ani_fixedarray_long : public __ani_fixedarray {}; +class __ani_fixedarray_float : public __ani_fixedarray {}; +class __ani_fixedarray_double : public __ani_fixedarray {}; +class __ani_fixedarray_ref : public __ani_fixedarray {}; +typedef __ani_ref *ani_ref; +typedef __ani_module *ani_module; +typedef __ani_namespace *ani_namespace; +typedef __ani_object *ani_object; +typedef __ani_fn_object *ani_fn_object; +typedef __ani_enum_value *ani_enum_value; +typedef __ani_error *ani_error; +typedef __ani_promise *ani_promise; +typedef __ani_tuple_value *ani_tuple_value; +typedef __ani_type *ani_type; +typedef __ani_arraybuffer *ani_arraybuffer; +typedef __ani_string *ani_string; +typedef __ani_stringliteral *ani_stringliteral; +typedef __ani_class *ani_class; +typedef __ani_enum *ani_enum; +typedef __ani_tuple *ani_tuple; +typedef __ani_fixedarray *ani_fixedarray; +typedef __ani_fixedarray_boolean *ani_fixedarray_boolean; +typedef __ani_fixedarray_char *ani_fixedarray_char; +typedef __ani_fixedarray_byte *ani_fixedarray_byte; +typedef __ani_fixedarray_short *ani_fixedarray_short; +typedef __ani_fixedarray_int *ani_fixedarray_int; +typedef __ani_fixedarray_long *ani_fixedarray_long; +typedef __ani_fixedarray_float *ani_fixedarray_float; +typedef __ani_fixedarray_double *ani_fixedarray_double; +typedef __ani_fixedarray_ref *ani_fixedarray_ref; +#else // __cplusplus +struct __ani_ref; +typedef struct __ani_ref *ani_ref; +typedef ani_ref ani_module; +typedef ani_ref ani_namespace; +typedef ani_ref ani_object; +typedef ani_object ani_fn_object; +typedef ani_object ani_enum_value; +typedef ani_object ani_error; +typedef ani_object ani_promise; +typedef ani_object ani_tuple_value; +typedef ani_object ani_type; +typedef ani_object ani_arraybuffer; +typedef ani_object ani_string; +typedef ani_string ani_stringliteral; +typedef ani_type ani_class; +typedef ani_type ani_enum; +typedef ani_type ani_tuple; +typedef ani_object ani_fixedarray; +typedef ani_fixedarray ani_fixedarray_boolean; +typedef ani_fixedarray ani_fixedarray_char; +typedef ani_fixedarray ani_fixedarray_byte; +typedef ani_fixedarray ani_fixedarray_short; +typedef ani_fixedarray ani_fixedarray_int; +typedef ani_fixedarray ani_fixedarray_long; +typedef ani_fixedarray ani_fixedarray_float; +typedef ani_fixedarray ani_fixedarray_double; +typedef ani_fixedarray ani_fixedarray_ref; +#endif // __cplusplus + +struct __ani_gref; +typedef struct __ani_gref *ani_gref; + +struct __ani_wref; +typedef struct __ani_wref *ani_wref; + +struct __ani_variable; +typedef struct __ani_variable *ani_variable; + +struct __ani_function; +typedef struct __ani_function *ani_function; + +struct __ani_field; +typedef struct __ani_field *ani_field; + +struct __ani_static_field; +typedef struct __ani_satic_field *ani_static_field; + +struct __ani_property; +typedef struct __ani_property *ani_property; + +struct __ani_method; +typedef struct __ani_method *ani_method; + +struct __ani_static_method; +typedef struct __ani_static_method *ani_static_method; + +struct __ani_cls_slot; +typedef struct __ani_cls_slot *ani_cls_slot; + +typedef void (*ani_finalizer)(void *data, void *hint); + +typedef enum { + ANI_KIND_BOOLEAN, + ANI_KIND_CHAR, + ANI_KIND_BYTE, + ANI_KIND_SHORT, + ANI_KIND_INT, + ANI_KIND_LONG, + ANI_KIND_FLOAT, + ANI_KIND_DOUBLE, + ANI_KIND_REF, +} ani_kind; + +typedef union { + ani_boolean z; + ani_char c; + ani_byte b; + ani_short s; + ani_int i; + ani_long l; + ani_float f; + ani_double d; + ani_ref r; +} ani_value; + +typedef struct { + const char *name; + const char *signature; + const void *pointer; +} ani_native_function; + +#ifdef __cplusplus +typedef struct __ani_vm ani_vm; +typedef struct __ani_env ani_env; +#else +typedef const struct __ani_vm_api *ani_vm; +typedef const struct __ani_interaction_api *ani_env; +#endif + +typedef enum { + ANI_OK, + ANI_ERROR, + ANI_INVALID_ARGS, + ANI_INVALID_TYPE, + ANI_INVALID_DESCRIPTOR, + ANI_PENDING_ERROR, + ANI_NOT_FOUND, + ANI_ALREADY_BINDED, + ANI_OUT_OF_REF, + ANI_OUT_OF_MEMORY, + ANI_OUT_OF_RANGE, + ANI_BUFFER_TO_SMALL, + // NOTE: Add necessary status codes +} ani_status; + +struct __ani_vm_api { + void *reserved0; + void *reserved1; + void *reserved2; + void *reserved3; + + ani_status (*DestroyVM)(ani_vm *vm); + ani_status (*GetEnv)(ani_vm *vm, uint32_t version, ani_env **result); + ani_status (*AttachThread)(ani_vm *vm, void *params, ani_env **result); + ani_status (*DetachThread)(ani_vm *vm); +}; + +typedef struct { + const char *option; + void *option_data; +} ani_vm_option; + +#define ANI_EXPORT __attribute__((visibility("default"))) + +#ifdef __cplusplus +extern "C" { +#endif + +ANI_EXPORT ani_status ANI_CreateVM(uint32_t version, size_t nr_options, const ani_vm_option *options, ani_vm **result); +ANI_EXPORT ani_status ANI_GetCreatedVMs(ani_vm **vms_buffer, ani_size vms_buffer_length, ani_size *result); + +// Prototypes of exported functions for a shared library. +ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result); +ANI_EXPORT ani_status ANI_Destructor(ani_vm *vm); + +#ifdef __cplusplus +} +#endif + +struct __ani_interaction_api { + void *reserved0; + void *reserved1; + void *reserved2; + void *reserved3; + + /** + * @brief Retrieves the version information. + * + * This function retrieves the version information and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to a variable where the version information will be stored. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetVersion)(ani_env *env, uint32_t *result); + + /** + * @brief Retrieves the Virtual Machine (VM) instance. + * + * This function retrieves the VM instance and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to the VM instance to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetVM)(ani_env *env, ani_vm **result); + + /** + * @brief Checks if a reference is an object. + * + * This function determines whether the specified reference represents an object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the boolean result (true if the reference is an object, false otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsObject)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a functional object. + * + * This function determines whether the specified reference represents a functional object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the boolean result (true if the reference is a functional object, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFunctionalObject)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is an enum. + * + * This function determines whether the specified reference represents an enum. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the boolean result (true if the reference is an enum, false otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsEnum)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a tuple. + * + * This function determines whether the specified reference represents a tuple. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the boolean result (true if the reference is a tuple, false otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsTuple)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a string. + * + * This function determines whether the specified reference represents a string. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the boolean result (true if the reference is a string, false otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsString)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a string literal. + * + * This function determines whether the specified reference represents a string literal. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the boolean result (true if the reference is a string literal, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsStringLiteral)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array. + * + * This function determines whether the specified reference represents a fixed array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the boolean result (true if the reference is a fixed array, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array of booleans. + * + * This function determines whether the specified reference represents a fixed array of booleans. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the boolean result (true if the reference is a fixed array of booleans, + * false otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray_Boolean)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array of chars. + * + * This function determines whether the specified reference represents a fixed array of chars. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the char result (true if the reference is a fixed array of chars, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray_Char)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array of bytes. + * + * This function determines whether the specified reference represents a fixed array of bytes. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the byte result (true if the reference is a fixed array of bytes, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray_Byte)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array of shorts. + * + * This function determines whether the specified reference represents a fixed array of shorts. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the short result (true if the reference is a fixed array of shorts, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray_Short)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array of integers. + * + * This function determines whether the specified reference represents a fixed array of integers. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the integer result (true if the reference is a fixed array of integers, + * false otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray_Int)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array of longs. + * + * This function determines whether the specified reference represents a fixed array of longs. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the long result (true if the reference is a fixed array of longs, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray_Long)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array of floats. + * + * This function determines whether the specified reference represents a fixed array of floats. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the float result (true if the reference is a fixed array of floats, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray_Float)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array of doubles. + * + * This function determines whether the specified reference represents a fixed array of doubles. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the double result (true if the reference is a fixed array of doubles, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray_Double)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is a fixed array of references. + * + * This function determines whether the specified reference represents a fixed array of references. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to store the boolean result (true if the reference is a fixed array of references, + * false otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsFixedArray_Ref)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Creates a new object of a specified class using a constructor method. + * + * This function creates a new object of the given class and calls the specified constructor method with variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class of the object to create. + * @param[in] method The constructor method to invoke. + * @param[in] ... Variadic arguments to pass to the constructor method. + * @param[out] result A pointer to store the object return value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_New)(ani_env *env, ani_class cls, ani_method method, ani_object *result, ...); + + /** + * @brief Creates a new object of a specified class using a constructor method (array-based). + * + * This function creates a new object of the given class and calls the specified constructor method with arguments + * provided in an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class of the object to create. + * @param[in] method The constructor method to invoke. + * @param[in] args An array of arguments to pass to the constructor method. + * @param[out] result A pointer to store the object return value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_New_A)(ani_env *env, ani_class cls, ani_method method, ani_object *result, + const ani_value *args); + + /** + * @brief Creates a new object of a specified class using a constructor method (variadic arguments). + * + * This function creates a new object of the given class and calls the specified constructor method with a `va_list` + * of arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class of the object to create. + * @param[in] method The constructor method to invoke. + * @param[in] args A `va_list` of arguments to pass to the constructor method. + * @param[out] result A pointer to store the object return value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_New_V)(ani_env *env, ani_class cls, ani_method method, ani_object *result, va_list args); + + /** + * @brief Retrieves the type of a given object. + * + * This function retrieves the type of the specified object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object whose type is to be retrieved. + * @param[out] result A pointer to store the retrieved type. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetType)(ani_env *env, ani_object object, ani_type *result); + + /** + * @brief Checks if an object is an instance of a specified type. + * + * This function checks whether the given object is an instance of the specified type. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object to check. + * @param[in] type The type to compare against. + * @param[out] result A pointer to store the boolean result (true if the object is an instance of the type, false + * otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_InstanceOf)(ani_env *env, ani_object object, ani_type type, ani_boolean *result); + + /** + * @brief Checks if two objects are the same. + * + * This function compares two objects to determine if they refer to the same instance. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object1 The first object to compare. + * @param[in] object2 The second object to compare. + * @param[out] result A pointer to store the boolean result (true if the objects are the same, false otherwise). + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_IsSame)(ani_env *env, ani_object object1, ani_object object2, ani_boolean *result); + + /** + * @brief Retrieves the superclass of a specified type. + * + * This function retrieves the superclass of a given type and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] type The type for which to retrieve the superclass. + * @param[out] result A pointer to the superclass to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Type_GetSuperClass)(ani_env *env, ani_type type, ani_class *result); + + /** + * @brief Determines if one type is assignable from another. + * + * This function checks if a type is assignable from another and stores the result in the output parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] from_type The source type. + * @param[in] to_type The target type. + * @param[out] result A pointer to a boolean indicating assignability. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Type_IsAssignableFrom)(ani_env *env, ani_type from_type, ani_type to_type, ani_boolean *result); + + /** + * @brief Finds a module by its descriptor. + * + * This function locates a module based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module_descriptor The descriptor of the module to find. + * @param[out] result A pointer to the module to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindModule)(ani_env *env, const char *module_descriptor, ani_module *result); + + /** + * @brief Finds a namespace by its descriptor. + * + * This function locates a namespace based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] namespace_descriptor The descriptor of the namespace to find. + * @param[out] result A pointer to the namespace to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindNamespace)(ani_env *env, const char *namespace_descriptor, ani_namespace *result); + + /** + * @brief Finds a class by its descriptor. + * + * This function locates a class based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] class_descriptor The descriptor of the class to find. + * @param[out] result A pointer to the class to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindClass)(ani_env *env, const char *class_descriptor, ani_class *result); + + /** + * @brief Finds an enum by its descriptor. + * + * This function locates an enum based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_descriptor The descriptor of the enum to find. + * @param[out] result A pointer to the enum to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindEnum)(ani_env *env, const char *enum_descriptor, ani_enum *result); + + /** + * @brief Finds a tuple by its descriptor. + * + * This function locates a tuple based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_descriptor The descriptor of the tuple to find. + * @param[out] result A pointer to the tuple to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindTuple)(ani_env *env, const char *tuple_descriptor, ani_tuple *result); + + /** + * @brief Finds a function by its descriptor. + * + * This function locates a function based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] function_descriptor The descriptor of the function to find. + * @param[out] result A pointer to the function to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindFunction)(ani_env *env, const char *function_descriptor, ani_function *result); + + /** + * @brief Finds a variable by its descriptor. + * + * This function locates a variable based on its descriptor and stores it in the result parameter. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable_descriptor The descriptor of the variable to find. + * @param[out] result A pointer to the variable to be populated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FindVariable)(ani_env *env, const char *variable_descriptor, ani_variable *result); + + /** + * @brief Finds a namespace within a module by its descriptor. + * + * This function locates a namespace within the specified module based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] namespace_descriptor The descriptor of the namespace to find. + * @param[out] result A pointer to the namespace object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindNamespace)(ani_env *env, ani_module module, const char *namespace_descriptor, + ani_namespace *result); + + /** + * @brief Finds a class within a module by its descriptor. + * + * This function locates a class within the specified module based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] class_descriptor The descriptor of the class to find. + * @param[out] result A pointer to the class object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindClass)(ani_env *env, ani_module module, const char *class_descriptor, ani_class *result); + + /** + * @brief Finds an enum within a module by its descriptor. + * + * This function locates an enum within the specified module based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] enum_descriptor The descriptor of the enum to find. + * @param[out] result A pointer to the enum object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindEnum)(ani_env *env, ani_module module, const char *enum_descriptor, ani_enum *result); + + /** + * @brief Finds a function within a module by its name and signature. + * + * This function locates a function within the specified module based on its name and signature. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] name The name of the function to retrieve. + * @param[in] signature The signature of the function to retrieve. + * @param[out] result A pointer to the function object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindFunction)(ani_env *env, ani_module module, const char *name, const char *signature, + ani_function *result); + + /** + * @brief Finds a variable within a module by its descriptor. + * + * This function locates a variable within the specified module based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to search within. + * @param[in] variable_descriptor The descriptor of the variable to find. + * @param[out] result A pointer to the variable object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_FindVariable)(ani_env *env, ani_module module, const char *variable_descriptor, + ani_variable *result); + + /** + * @brief Finds a namespace within another namespace by its descriptor. + * + * This function locates a namespace within the specified parent namespace based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The parent namespace to search within. + * @param[in] namespace_descriptor The descriptor of the namespace to find. + * @param[out] result A pointer to the namespace object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindNamespace)(ani_env *env, ani_namespace ns, const char *namespace_descriptor, + ani_namespace *result); + + /** + * @brief Finds a class within a namespace by its descriptor. + * + * This function locates a class within the specified namespace based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to search within. + * @param[in] class_descriptor The descriptor of the class to find. + * @param[out] result A pointer to the class object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindClass)(ani_env *env, ani_namespace ns, const char *class_descriptor, ani_class *result); + + /** + * @brief Finds an enum within a namespace by its descriptor. + * + * This function locates an enum within the specified namespace based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to search within. + * @param[in] enum_descriptor The descriptor of the enum to find. + * @param[out] result A pointer to the enum object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindEnum)(ani_env *env, ani_namespace ns, const char *enum_descriptor, ani_enum *result); + + /** + * @brief Finds a function within a namespace by its name and signature. + * + * This function locates a function within the specified namespace based on its name and signature. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to search within. + * @param[in] name The name of the function to retrieve. + * @param[in] signature The signature of the function to retrieve. + * @param[out] result A pointer to the function object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindFunction)(ani_env *env, ani_namespace ns, const char *name, const char *signature, + ani_function *result); + + /** + * @brief Finds a variable within a namespace by its descriptor. + * + * This function locates a variable within the specified namespace based on its descriptor. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to search within. + * @param[in] variable_descriptor The descriptor of the variable to find. + * @param[out] result A pointer to the variable object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_FindVariable)(ani_env *env, ani_namespace ns, const char *variable_descriptor, + ani_variable *result); + + /** + * @brief Binds native functions to a module. + * + * This function binds an array of native functions to the specified module. + * + * @param[in] env A pointer to the environment structure. + * @param[in] module The module to which the native functions will be bound. + * @param[in] functions A pointer to an array of native functions to bind. + * @param[in] nr_functions The number of native functions in the array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Module_BindNativeFunctions)(ani_env *env, ani_module module, const ani_native_function *functions, + ani_size nr_functions); + + /** + * @brief Binds native functions to a namespace. + * + * This function binds an array of native functions to the specified namespace. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ns The namespace to which the native functions will be bound. + * @param[in] functions A pointer to an array of native functions to bind. + * @param[in] nr_functions The number of native functions in the array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Namespace_BindNativeFunctions)(ani_env *env, ani_namespace ns, const ani_native_function *functions, + ani_size nr_functions); + + /** + * @brief Binds native methods to a class. + * + * This function binds an array of native methods to the specified class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to which the native methods will be bound. + * @param[in] methods A pointer to an array of native methods to bind. + * @param[in] nr_methods The number of native methods in the array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_BindNativeMethods)(ani_env *env, ani_class cls, const ani_native_function *methods, + ani_size nr_methods); + + /** + * @brief Deletes a local reference. + * + * This function deletes a specified local reference to free up resources. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to be deleted. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_Delete)(ani_env *env, ani_ref ref); + + /** + * @brief Ensures enough local references are available. + * + * This function checks and ensures that the specified number of local references can be created. + * + * @param[in] env A pointer to the environment structure. + * @param[in] nr_refs The number of local references to ensure availability for. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnsureEnoughReferences)(ani_env *env, ani_size nr_refs); + + /** + * @brief Creates a new local scope for references. + * + * This function creates a local scope for references with a specified capacity. + * + * @param[in] env A pointer to the environment structure. + * @param[in] nr_refs The maximum number of references that can be created in this scope. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CreateLocalScope)(ani_env *env, ani_size nr_refs); + + /** + * @brief Destroys the current local scope. + * + * This function destroys the current local scope and frees all references within it. + * + * @param[in] env A pointer to the environment structure. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*DestroyLocalScope)(ani_env *env); + + /** + * @brief Creates a new escape local scope. + * + * This function creates a local scope for references with escape functionality, allowing objects to escape this + * scope. + * + * @param[in] env A pointer to the environment structure. + * @param[in] nr_refs The maximum number of references that can be created in this scope. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CreateEscapeLocalScope)(ani_env *env, ani_size nr_refs); + + /** + * @brief Destroys the current escape local scope. + * + * This function destroys the current escape local scope and allows escaping references to be retrieved. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to be escaped from the current scope. + * @param[out] result A pointer to the resulting reference that has escaped the scope. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*DestroyEscapeLocalScope)(ani_env *env, ani_ref ref, ani_ref *result); + + /** + * @brief Throws an error. + * + * This function throws the specified error in the current environment. + * + * @param[in] env A pointer to the environment structure. + * @param[in] err The error to throw. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*ThrowError)(ani_env *env, ani_error err); + + /** + * @brief Checks if there are unhandled errors. + * + * This function determines if there are unhandled errors in the current environment. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to a boolean indicating if unhandled errors exist. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*ExistUnhandledError)(ani_env *env, ani_boolean *result); + + /** + * @brief Retrieves the current unhandled error. + * + * This function fetches the unhandled error in the environment. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to store the unhandled error. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetUnhandledError)(ani_env *env, ani_error *result); + + /** + * @brief Resets the current error state. + * + * This function clears the error state in the current environment. + * + * @param[in] env A pointer to the environment structure. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*ResetError)(ani_env *env); + + /** + * @brief Provides a description of the current error. + * + * This function prints the stack trace or other debug information for the current error. + * + * @param[in] env A pointer to the environment structure. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*DescribeError)(ani_env *env); // NOTE: Print stacktrace for debugging? + + /** + * @brief Aborts execution with a message. + * + * This function terminates execution with the specified error message. + * + * @param[in] env A pointer to the environment structure. + * @param[in] message The error message to display on termination. + * @return Does not return; the process terminates. + */ + ani_status (*Abort)(ani_env *env, const char *message); + + /** + * @brief Retrieves a null reference. + * + * This function provides a null reference in the specified result. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to store the null reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetNull)(ani_env *env, ani_ref *result); + + /** + * @brief Retrieves an undefined reference. + * + * This function provides an undefined reference in the specified result. + * + * @param[in] env A pointer to the environment structure. + * @param[out] result A pointer to store the undefined reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GetUndefined)(ani_env *env, ani_ref *result); + + /** + * @brief Checks if a reference is null. + * + * This function determines if the specified reference is null. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to a boolean indicating if the reference is null. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsNull)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is undefined. + * + * This function determines if the specified reference is undefined. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to a boolean indicating if the reference is undefined. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsUndefined)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Checks if a reference is nullish value (null or undefined). + * + * This function determines if the specified reference is either null or undefined. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The reference to check. + * @param[out] result A pointer to a boolean indicating if the reference is nullish value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_IsNullishValue)(ani_env *env, ani_ref ref, ani_boolean *result); + + /** + * @brief Compares two references for equality. + * + * This function checks if two references are equal. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref0 The first reference to compare. + * @param[in] ref1 The second reference to compare. + * @param[out] result A pointer to a boolean indicating if the references are equal. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_Equals)(ani_env *env, ani_ref ref0, ani_ref ref1, ani_boolean *result); + + /** + * @brief Compares two references for strict equality. + * + * This function checks if two references are strictly equal. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref0 The first reference to compare. + * @param[in] ref1 The second reference to compare. + * @param[out] result A pointer to a boolean indicating if the references are strictly equal. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reference_StrictEquals)(ani_env *env, ani_ref ref0, ani_ref ref1, ani_boolean *result); + + /** + * @brief Creates a new UTF-16 string. + * + * This function creates a new string from the provided UTF-16 encoded data. + * + * @param[in] env A pointer to the environment structure. + * @param[in] utf16_string A pointer to the UTF-16 encoded string data. + * @param[in] utf16_size The size of the UTF-16 string in code units. + * @param[out] result A pointer to store the created string. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_NewUTF16)(ani_env *env, const uint16_t *utf16_string, ani_size utf16_size, ani_string *result); + + /** + * @brief Retrieves the size of a UTF-16 string. + * + * This function retrieves the size (in code units) of the specified UTF-16 string. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The UTF-16 string to measure. + * @param[out] result A pointer to store the size of the string. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF16Size)(ani_env *env, ani_string string, ani_size *result); + + /** + * @brief Retrieves the UTF-16 encoded data of a string. + * + * This function copies the UTF-16 encoded data of the string into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string to retrieve data from. + * @param[out] utf16_buffer A buffer to store the UTF-16 encoded data. + * @param[in] utf16_buffer_size The size of the buffer in code units. + * @param[out] result A pointer to store the number of code units written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF16)(ani_env *env, ani_string string, uint16_t *utf16_buffer, ani_size utf16_buffer_size, + ani_size *result); + + /** + * @brief Retrieves a substring of a UTF-16 string. + * + * This function copies a portion of the UTF-16 string into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string to retrieve data from. + * @param[in] substr_offset The starting offset of the substring. + * @param[in] substr_size The size of the substring in code units. + * @param[out] utf16_buffer A buffer to store the substring. + * @param[in] utf16_buffer_size The size of the buffer in code units. + * @param[out] result A pointer to store the number of code units written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF16SubString)(ani_env *env, ani_string string, ani_size substr_offset, + ani_size substr_size, uint16_t *utf16_buffer, ani_size utf16_buffer_size, + ani_size *result); + + /** + * @brief Creates a new UTF-8 string. + * + * This function creates a new string from the provided UTF-8 encoded data. + * + * @param[in] env A pointer to the environment structure. + * @param[in] utf8_string A pointer to the UTF-8 encoded string data. + * @param[in] utf8_size The size of the UTF-8 string in bytes. + * @param[out] result A pointer to store the created string. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_NewUTF8)(ani_env *env, const char *utf8_string, ani_size utf8_size, ani_string *result); + + /** + * @brief Retrieves the size of a UTF-8 string. + * + * This function retrieves the size (in bytes) of the specified UTF-8 string. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The UTF-8 string to measure. + * @param[out] result A pointer to store the size of the string. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF8Size)(ani_env *env, ani_string string, ani_size *result); + + /** + * @brief Retrieves the UTF-8 encoded data of a string. + * + * This function copies the UTF-8 encoded data of the string into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string to retrieve data from. + * @param[out] utf8_buffer A buffer to store the UTF-8 encoded data. + * @param[in] utf8_buffer_size The size of the buffer in bytes. + * @param[out] result A pointer to store the number of bytes written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF8)(ani_env *env, ani_string string, char *utf8_buffer, ani_size utf8_buffer_size, + ani_size *result); + + /** + * @brief Retrieves a substring of a UTF-8 string. + * + * This function copies a portion of the UTF-8 string into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string to retrieve data from. + * @param[in] substr_offset The starting offset of the substring. + * @param[in] substr_size The size of the substring in bytes. + * @param[out] utf8_buffer A buffer to store the substring. + * @param[in] utf8_buffer_size The size of the buffer in bytes. + * @param[out] result A pointer to store the number of bytes written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetUTF8SubString)(ani_env *env, ani_string string, ani_size substr_offset, ani_size substr_size, + char *utf8_buffer, ani_size utf8_buffer_size, ani_size *result); + + /** + * @brief Retrieves critical information about a string. + * + * This function retrieves the type and data of a string for critical operations. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string to analyze. + * @param[out] result_string_type A pointer to store the type of the string (e.g., UTF-16 or UTF-8). + * @param[out] result_data A pointer to the raw string data. + * @param[out] result_size A pointer to the size of the string data. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_GetCritical)(ani_env *env, ani_string string, uint32_t *result_string_type, + const void **result_data, + ani_size *result_size); // result_string_type - string type utf16/utf8, etc? + + /** + * @brief Releases critical string data. + * + * This function releases the raw string data retrieved using `String_GetCritical`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string whose data was retrieved. + * @param[in] data A pointer to the raw data to release. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*String_ReleaseCritical)(ani_env *env, ani_string string, const void *data); + + /** + * @brief Creates a new UTF-16 string literal. + * + * This function creates a new string literal from the provided UTF-16 encoded data. + * + * @param[in] env A pointer to the environment structure. + * @param[in] utf16_string A pointer to the UTF-16 encoded string data. + * @param[in] utf16_size The size of the UTF-16 string in code units. + * @param[out] result A pointer to store the created string literal. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_NewUTF16)(ani_env *env, const uint16_t *utf16_string, ani_size utf16_size, + ani_stringliteral *result); + + /** + * @brief Retrieves the size of a UTF-16 string literal. + * + * This function retrieves the size (in code units) of the specified UTF-16 string literal. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The UTF-16 string literal to measure. + * @param[out] result A pointer to store the size of the string literal. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_GetUTF16Size)(ani_env *env, ani_stringliteral string, ani_size *result); + + /** + * @brief Retrieves the UTF-16 encoded data of a string literal. + * + * This function copies the UTF-16 encoded data of the string literal into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string literal to retrieve data from. + * @param[out] utf16_buffer A buffer to store the UTF-16 encoded data. + * @param[in] utf16_buffer_size The size of the buffer in code units. + * @param[out] result A pointer to store the number of code units written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_GetUTF16)(ani_env *env, ani_stringliteral string, uint16_t *utf16_buffer, + ani_size utf16_buffer_size, ani_size *result); + + /** + * @brief Retrieves a substring of a UTF-16 string literal. + * + * This function copies a portion of the UTF-16 string literal into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string literal to retrieve data from. + * @param[in] substr_offset The starting offset of the substring. + * @param[in] substr_size The size of the substring in code units. + * @param[out] utf16_buffer A buffer to store the substring. + * @param[in] utf16_buffer_size The size of the buffer in code units. + * @param[out] result A pointer to store the number of code units written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_GetUTF16SubString)(ani_env *env, ani_stringliteral string, ani_size substr_offset, + ani_size substr_size, uint16_t *utf16_buffer, + ani_size utf16_buffer_size, ani_size *result); + + /** + * @brief Creates a new UTF-8 string literal. + * + * This function creates a new string literal from the provided UTF-8 encoded data. + * + * @param[in] env A pointer to the environment structure. + * @param[in] utf8_string A pointer to the UTF-8 encoded string data. + * @param[in] size The size of the UTF-8 string in bytes. + * @param[out] result A pointer to store the created string literal. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_NewUTF8)(ani_env *env, const char *utf8_string, ani_size size, + ani_stringliteral *result); + + /** + * @brief Retrieves the size of a UTF-8 string literal. + * + * This function retrieves the size (in bytes) of the specified UTF-8 string literal. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The UTF-8 string literal to measure. + * @param[out] result A pointer to store the size of the string literal. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_GetUTF8Size)(ani_env *env, ani_stringliteral string, ani_size *result); + + /** + * @brief Retrieves the UTF-8 encoded data of a string literal. + * + * This function copies the UTF-8 encoded data of the string literal into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string literal to retrieve data from. + * @param[out] utf8_buffer A buffer to store the UTF-8 encoded data. + * @param[in] utf8_buffer_size The size of the buffer in bytes. + * @param[out] result A pointer to store the number of bytes written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_GetUTF8)(ani_env *env, ani_stringliteral string, char *utf8_buffer, + ani_size utf8_buffer_size, ani_size *result); + + /** + * @brief Retrieves a substring of a UTF-8 string literal. + * + * This function copies a portion of the UTF-8 string literal into the provided buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string literal to retrieve data from. + * @param[in] substr_offset The starting offset of the substring. + * @param[in] substr_size The size of the substring in bytes. + * @param[out] utf8_buffer A buffer to store the substring. + * @param[in] utf8_buffer_size The size of the buffer in bytes. + * @param[out] result A pointer to store the number of bytes written. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_GetUTF8SubString)(ani_env *env, ani_stringliteral string, ani_size substr_offset, + ani_size substr_size, char *utf8_buffer, ani_size utf8_buffer_size, + ani_size *result); + + /** + * @brief Retrieves critical information about a string literal. + * + * This function retrieves the type and data of a string literal for critical operations. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string literal to analyze. + * @param[out] result_string_type A pointer to store the type of the string literal (e.g., UTF-16 or UTF-8). + * @param[out] result_data A pointer to the raw string literal data. + * @param[out] result_size A pointer to the size of the string literal data. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_GetCritical)( + ani_env *env, ani_stringliteral string, uint32_t *result_string_type, const void **result_data, + ani_size *result_size); // result_string_type - string type utf16/utf8, etc? + + /** + * @brief Releases critical string literal data. + * + * This function releases the raw string literal data retrieved using `StringLiteral_GetCritical`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] string The string literal whose data was retrieved. + * @param[in] data A pointer to the raw data to release. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*StringLiteral_ReleaseCritical)(ani_env *env, ani_stringliteral string, const void *data); + + /** + * @brief Retrieves the length of a fixed array. + * + * This function retrieves the length of the specified fixed array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array whose length is to be retrieved. + * @param[out] result A pointer to store the length of the array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_GetLength)(ani_env *env, ani_fixedarray array, ani_size *result); + + /** + * @brief Creates a new fixed array of booleans. + * + * This function creates a new fixed array of the specified length for boolean values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created fixed array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Boolean)(ani_env *env, ani_size length, ani_fixedarray_boolean *result); + + /** + * @brief Creates a new fixed array of characters. + * + * This function creates a new fixed array of the specified length for character values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created fixed array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Char)(ani_env *env, ani_size length, ani_fixedarray_char *result); + + /** + * @brief Creates a new fixed array of bytes. + * + * This function creates a new fixed array of the specified length for byte values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created fixed array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Byte)(ani_env *env, ani_size length, ani_fixedarray_byte *result); + + /** + * @brief Creates a new fixed array of shorts. + * + * This function creates a new fixed array of the specified length for short integer values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created fixed array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Short)(ani_env *env, ani_size length, ani_fixedarray_short *result); + + /** + * @brief Creates a new fixed array of integers. + * + * This function creates a new fixed array of the specified length for integer values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created fixed array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Int)(ani_env *env, ani_size length, ani_fixedarray_int *result); + + /** + * @brief Creates a new fixed array of long integers. + * + * This function creates a new fixed array of the specified length for long integer values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created fixed array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Long)(ani_env *env, ani_size length, ani_fixedarray_long *result); + + /** + * @brief Creates a new fixed array of floats. + * + * This function creates a new fixed array of the specified length for float values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created fixed array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Float)(ani_env *env, ani_size length, ani_fixedarray_float *result); + + /** + * @brief Creates a new fixed array of doubles. + * + * This function creates a new fixed array of the specified length for double values. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[out] result A pointer to store the created fixed array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Double)(ani_env *env, ani_size length, ani_fixedarray_double *result); + + /** + * @brief Retrieves a region of boolean values from a fixed array. + * + * This function retrieves a portion of the specified boolean fixed array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved boolean values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_GetRegion_Boolean)(ani_env *env, ani_fixedarray_boolean array, ani_size offset, + ani_size length, ani_boolean *native_buffer); + + /** + * @brief Retrieves a region of character values from a fixed array. + * + * This function retrieves a portion of the specified character fixed array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved character values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_GetRegion_Char)(ani_env *env, ani_fixedarray_char array, ani_size offset, ani_size length, + ani_char *native_buffer); + + /** + * @brief Retrieves a region of byte values from a fixed array. + * + * This function retrieves a portion of the specified byte fixed array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved byte values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_GetRegion_Byte)(ani_env *env, ani_fixedarray_byte array, ani_size offset, ani_size length, + ani_byte *native_buffer); + + /** + * @brief Retrieves a region of short values from a fixed array. + * + * This function retrieves a portion of the specified short fixed array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved short values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_GetRegion_Short)(ani_env *env, ani_fixedarray_short array, ani_size offset, ani_size length, + ani_short *native_buffer); + + /** + * @brief Retrieves a region of integer values from a fixed array. + * + * This function retrieves a portion of the specified integer fixed array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved integer values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_GetRegion_Int)(ani_env *env, ani_fixedarray_int array, ani_size offset, ani_size length, + ani_int *native_buffer); + + /** + * @brief Retrieves a region of long integer values from a fixed array. + * + * This function retrieves a portion of the specified long integer fixed array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved long integer values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_GetRegion_Long)(ani_env *env, ani_fixedarray_long array, ani_size offset, ani_size length, + ani_long *native_buffer); + + /** + * @brief Retrieves a region of float values from a fixed array. + * + * This function retrieves a portion of the specified float fixed array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved float values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_GetRegion_Float)(ani_env *env, ani_fixedarray_float array, ani_size offset, ani_size length, + ani_float *native_buffer); + + /** + * @brief Retrieves a region of double values from a fixed array. + * + * This function retrieves a portion of the specified double fixed array into a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to retrieve values from. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to retrieve. + * @param[out] native_buffer A buffer to store the retrieved double values. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_GetRegion_Double)(ani_env *env, ani_fixedarray_double array, ani_size offset, + ani_size length, ani_double *native_buffer); + + /** + * @brief Sets a region of boolean values in a fixed array. + * + * This function sets a portion of the specified boolean fixed array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the boolean values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_SetRegion_Boolean)(ani_env *env, ani_fixedarray_boolean array, ani_size offset, + ani_size length, const ani_boolean *native_buffer); + + /** + * @brief Sets a region of character values in a fixed array. + * + * This function sets a portion of the specified character fixed array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the character values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_SetRegion_Char)(ani_env *env, ani_fixedarray_char array, ani_size offset, ani_size length, + const ani_char *native_buffer); + + /** + * @brief Sets a region of byte values in a fixed array. + * + * This function sets a portion of the specified byte fixed array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the byte values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_SetRegion_Byte)(ani_env *env, ani_fixedarray_byte array, ani_size offset, ani_size length, + const ani_byte *native_buffer); + + /** + * @brief Sets a region of short values in a fixed array. + * + * This function sets a portion of the specified short fixed array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the short values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_SetRegion_Short)(ani_env *env, ani_fixedarray_short array, ani_size offset, ani_size length, + const ani_short *native_buffer); + + /** + * @brief Sets a region of integer values in a fixed array. + * + * This function sets a portion of the specified integer fixed array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the integer values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_SetRegion_Int)(ani_env *env, ani_fixedarray_int array, ani_size offset, ani_size length, + const ani_int *native_buffer); + + /** + * @brief Sets a region of long integer values in a fixed array. + * + * This function sets a portion of the specified long integer fixed array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the long integer values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_SetRegion_Long)(ani_env *env, ani_fixedarray_long array, ani_size offset, ani_size length, + const ani_long *native_buffer); + + /** + * @brief Sets a region of float values in a fixed array. + * + * This function sets a portion of the specified float fixed array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the float values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_SetRegion_Float)(ani_env *env, ani_fixedarray_float array, ani_size offset, ani_size length, + const ani_float *native_buffer); + + /** + * @brief Sets a region of double values in a fixed array. + * + * This function sets a portion of the specified double fixed array using a native buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array to set values in. + * @param[in] offset The starting offset of the region. + * @param[in] length The number of elements to set. + * @param[in] native_buffer A buffer containing the double values to set. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_SetRegion_Double)(ani_env *env, ani_fixedarray_double array, ani_size offset, + ani_size length, const ani_double *native_buffer); + + /** + * @brief Pins a fixed array in memory. + * + * This function pins a fixed array of primitive types in memory to ensure it is not moved by the garbage collector. + * + * @param[in] env A pointer to the environment structure. + * @param[in] primitive_array The fixed array to pin. + * @param[out] result A pointer to store the memory address of the pinned array. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_Pin)(ani_env *env, ani_fixedarray primitive_array, void **result); + + /** + * @brief Unpins a fixed array in memory. + * + * This function unpins a previously pinned fixed array, allowing it to be moved by the garbage collector. + * + * @param[in] env A pointer to the environment structure. + * @param[in] primitive_array The fixed array to unpin. + * @param[in] data A pointer to the pinned memory that was previously retrieved. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_Unpin)(ani_env *env, ani_fixedarray primitive_array, void *data); + + /** + * @brief Creates a new fixed array of references. + * + * This function creates a new fixed array of references, optionally initializing it with an array of references. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array to be created. + * @param[in] initial_array An optional array of references to initialize the fixed array. Can be null. + * @param[out] result A pointer to store the created fixed array of references. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_New_Ref)(ani_env *env, ani_size length, ani_ref *initial_array, ani_fixedarray_ref *result); + + /** + * @brief Sets a reference at a specific index in a fixed array. + * + * This function sets the value of a reference at the specified index in the fixed array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array of references to modify. + * @param[in] index The index at which to set the reference. + * @param[in] ref The reference to set at the specified index. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_Set_Ref)(ani_env *env, ani_fixedarray_ref array, ani_size index, ani_ref ref); + + /** + * @brief Retrieves a reference from a specific index in a fixed array. + * + * This function retrieves the value of a reference at the specified index in the fixed array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] array The fixed array of references to query. + * @param[in] index The index from which to retrieve the reference. + * @param[out] result A pointer to store the retrieved reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FixedArray_Get_Ref)(ani_env *env, ani_fixedarray_ref array, ani_size index, ani_ref *result); + + /** + * @brief Retrieves an enum value by its name. + * + * This function retrieves an enum value associated with the specified name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enm The enum to search within. + * @param[in] name The name of the enum value to retrieve. + * @param[out] result A pointer to store the retrieved enum value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Enum_GetEnumValueByName)(ani_env *env, ani_enum enm, const char *name, ani_enum_value *result); + + /** + * @brief Retrieves an enum value by its index. + * + * This function retrieves an enum value located at the specified index. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enm The enum to search within. + * @param[in] index The index of the enum value to retrieve. + * @param[out] result A pointer to store the retrieved enum value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Enum_GetEnumValueByIndex)(ani_env *env, ani_enum enm, ani_size index, ani_enum_value *result); + + /** + * @brief Retrieves the enum associated with an enum value. + * + * This function retrieves the enum to which the specified enum value belongs. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_value The enum value whose associated enum is to be retrieved. + * @param[out] result A pointer to store the retrieved enum. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnumValue_GetEnum)(ani_env *env, ani_enum_value enum_value, ani_enum *result); + + /** + * @brief Retrieves the underlying value of an enum value. + * + * This function retrieves the object representing the value of the specified enum value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_value The enum value whose underlying value is to be retrieved. + * @param[out] result A pointer to store the retrieved object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnumValue_GetValue)(ani_env *env, ani_enum_value enum_value, ani_object *result); + + /** + * @brief Retrieves the name of an enum value. + * + * This function retrieves the name associated with the specified enum value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_value The enum value whose name is to be retrieved. + * @param[out] result A pointer to store the retrieved name. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnumValue_GetName)(ani_env *env, ani_enum_value enum_value, ani_string *result); + + /** + * @brief Retrieves the index of an enum value. + * + * This function retrieves the index of the specified enum value within its enum. + * + * @param[in] env A pointer to the environment structure. + * @param[in] enum_value The enum value whose index is to be retrieved. + * @param[out] result A pointer to store the retrieved index. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*EnumValue_GetIndex)(ani_env *env, ani_enum_value enum_value, ani_size *result); + + /** + * @brief Invokes a functional object. + * + * This function invokes a functional object (e.g., a function or callable object) with the specified arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The functional object to invoke. + * @param[in] argc The number of arguments being passed to the functional object. + * @param[in] argv A pointer to an array of references representing the arguments. Can be null if `argc` is 0. + * @param[out] result A pointer to store the result of the invocation. Can be null if the functional object does not + * return a value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*FunctionalObject_Call)(ani_env *env, ani_fn_object fn, ani_size argc, ani_ref *argv, ani_ref *result); + + /** + * @brief Sets a boolean value to a variable. + * + * This function assigns a boolean value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The boolean value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Boolean)(ani_env *env, ani_variable variable, ani_boolean value); + + /** + * @brief Sets a character value to a variable. + * + * This function assigns a character value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The character value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Char)(ani_env *env, ani_variable variable, ani_char value); + + /** + * @brief Sets a byte value to a variable. + * + * This function assigns a byte value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The byte value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Byte)(ani_env *env, ani_variable variable, ani_byte value); + + /** + * @brief Sets a short value to a variable. + * + * This function assigns a short integer value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The short integer value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Short)(ani_env *env, ani_variable variable, ani_short value); + + /** + * @brief Sets an integer value to a variable. + * + * This function assigns an integer value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The integer value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Int)(ani_env *env, ani_variable variable, ani_int value); + + /** + * @brief Sets a long value to a variable. + * + * This function assigns a long integer value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The long integer value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Long)(ani_env *env, ani_variable variable, ani_long value); + + /** + * @brief Sets a float value to a variable. + * + * This function assigns a float value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The float value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Float)(ani_env *env, ani_variable variable, ani_float value); + + /** + * @brief Sets a double value to a variable. + * + * This function assigns a double value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The double value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Double)(ani_env *env, ani_variable variable, ani_double value); + + /** + * @brief Sets a reference value to a variable. + * + * This function assigns a reference value to the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to modify. + * @param[in] value The reference value to assign to the variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_SetValue_Ref)(ani_env *env, ani_variable variable, ani_ref value); + + /** + * @brief Retrieves a boolean value from a variable. + * + * This function fetches a boolean value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Boolean)(ani_env *env, ani_variable variable, ani_boolean *result); + + /** + * @brief Retrieves a character value from a variable. + * + * This function fetches a character value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved character value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Char)(ani_env *env, ani_variable variable, ani_char *result); + + /** + * @brief Retrieves a byte value from a variable. + * + * This function fetches a byte value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Byte)(ani_env *env, ani_variable variable, ani_byte *result); + + /** + * @brief Retrieves a short value from a variable. + * + * This function fetches a short integer value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved short integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Short)(ani_env *env, ani_variable variable, ani_short *result); + + /** + * @brief Retrieves an integer value from a variable. + * + * This function fetches an integer value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Int)(ani_env *env, ani_variable variable, ani_int *result); + + /** + * @brief Retrieves a long value from a variable. + * + * This function fetches a long integer value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved long integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Long)(ani_env *env, ani_variable variable, ani_long *result); + + /** + * @brief Retrieves a float value from a variable. + * + * This function fetches a float value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Float)(ani_env *env, ani_variable variable, ani_float *result); + + /** + * @brief Retrieves a double value from a variable. + * + * This function fetches a double value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Double)(ani_env *env, ani_variable variable, ani_double *result); + + /** + * @brief Retrieves a reference value from a variable. + * + * This function fetches a reference value from the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to query. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Variable_GetValue_Ref)(ani_env *env, ani_variable variable, ani_ref *result); + + /** + * @brief Calls a function and retrieves a boolean result. + * + * This function calls the specified function with variadic arguments and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Boolean)(ani_env *env, ani_function fn, ani_boolean *result, ...); + + /** + * @brief Calls a function and retrieves a boolean result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Boolean_A)(ani_env *env, ani_function fn, ani_boolean *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a boolean result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Boolean_V)(ani_env *env, ani_function fn, ani_boolean *result, va_list args); + + /** + * @brief Calls a function and retrieves a character result. + * + * This function calls the specified function with variadic arguments and retrieves a character result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the character result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Char)(ani_env *env, ani_function fn, ani_char *result, ...); + + /** + * @brief Calls a function and retrieves a character result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a character result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the character result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Char_A)(ani_env *env, ani_function fn, ani_char *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a character result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a character + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the character result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Char_V)(ani_env *env, ani_function fn, ani_char *result, va_list args); + + /** + * @brief Calls a function and retrieves a byte result. + * + * This function calls the specified function with variadic arguments and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the byte result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Byte)(ani_env *env, ani_function fn, ani_byte *result, ...); + + /** + * @brief Calls a function and retrieves a byte result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Byte_A)(ani_env *env, ani_function fn, ani_byte *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a byte result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Byte_V)(ani_env *env, ani_function fn, ani_byte *result, va_list args); + + /** + * @brief Calls a function and retrieves a short result. + * + * This function calls the specified function with variadic arguments and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the short result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Short)(ani_env *env, ani_function fn, ani_short *result, ...); + + /** + * @brief Calls a function and retrieves a short result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the short result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Short_A)(ani_env *env, ani_function fn, ani_short *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a short result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the short result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Short_V)(ani_env *env, ani_function fn, ani_short *result, va_list args); + + /** + * @brief Calls a function and retrieves an integer result. + * + * This function calls the specified function with variadic arguments and retrieves an integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the integer result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Int)(ani_env *env, ani_function fn, ani_int *result, ...); + + /** + * @brief Calls a function and retrieves an integer result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves an integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Int_A)(ani_env *env, ani_function fn, ani_int *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves an integer result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves an integer + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Int_V)(ani_env *env, ani_function fn, ani_int *result, va_list args); + + /** + * @brief Calls a function and retrieves a long result. + * + * This function calls the specified function with variadic arguments and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the long result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Long)(ani_env *env, ani_function fn, ani_long *result, ...); + + /** + * @brief Calls a function and retrieves a long result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the long result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Long_A)(ani_env *env, ani_function fn, ani_long *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a long result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the long result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Long_V)(ani_env *env, ani_function fn, ani_long *result, va_list args); + + /** + * @brief Calls a function and retrieves a float result. + * + * This function calls the specified function with variadic arguments and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the float result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Float)(ani_env *env, ani_function fn, ani_float *result, ...); + + /** + * @brief Calls a function and retrieves a float result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the float result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Float_A)(ani_env *env, ani_function fn, ani_float *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a float result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the float result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Float_V)(ani_env *env, ani_function fn, ani_float *result, va_list args); + + /** + * @brief Calls a function and retrieves a double result. + * + * This function calls the specified function with variadic arguments and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the double result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Double)(ani_env *env, ani_function fn, ani_double *result, ...); + + /** + * @brief Calls a function and retrieves a double result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the double result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Double_A)(ani_env *env, ani_function fn, ani_double *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a double result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the double result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Double_V)(ani_env *env, ani_function fn, ani_double *result, va_list args); + + /** + * @brief Calls a function and retrieves a reference result. + * + * This function calls the specified function with variadic arguments and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the reference result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Ref)(ani_env *env, ani_function fn, ani_ref *result, ...); + + /** + * @brief Calls a function and retrieves a reference result (array-based). + * + * This function calls the specified function with arguments provided in an array and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Ref_A)(ani_env *env, ani_function fn, ani_ref *result, const ani_value *args); + + /** + * @brief Calls a function and retrieves a reference result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and retrieves a reference + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Ref_V)(ani_env *env, ani_function fn, ani_ref *result, va_list args); + + /** + * @brief Calls a function without returning a result. + * + * This function calls the specified function with variadic arguments and does not return a result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Void)(ani_env *env, ani_function fn, ...); + + /** + * @brief Calls a function without returning a result (array-based). + * + * This function calls the specified function with arguments provided in an array and does not return a result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[in] args A pointer to an array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Void_A)(ani_env *env, ani_function fn, const ani_value *args); + + /** + * @brief Calls a function without returning a result (variadic arguments). + * + * This function calls the specified function with arguments provided in a `va_list` and does not return a result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The function to call. + * @param[in] args A `va_list` containing the arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Function_Call_Void_V)(ani_env *env, ani_function fn, va_list args); + + /** + * @brief Retrieves the partial class representation. + * + * This function retrieves the partial class representation of the specified class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[out] result A pointer to store the partial class representation. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetPartial)(ani_env *env, ani_class cls, ani_class *result); + + /** + * @brief Retrieves the required class representation. + * + * This function retrieves the required class representation of the specified class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[out] result A pointer to store the required class representation. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetRequired)(ani_env *env, ani_class cls, ani_class *result); + + /** + * @brief Retrieves a field from the class. + * + * This function retrieves the specified field by name from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the field to retrieve. + * @param[out] result A pointer to store the retrieved field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetField)(ani_env *env, ani_class cls, const char *name, ani_field *result); + + /** + * @brief Retrieves a static field from the class. + * + * This function retrieves the specified static field by name from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved static field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField)(ani_env *env, ani_class cls, const char *name, ani_static_field *result); + + /** + * @brief Retrieves a method from the class. + * + * This function retrieves the specified method by name and signature from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the method to retrieve. + * @param[in] signature The signature of the method to retrieve. + * @param[out] result A pointer to store the retrieved method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetMethod)(ani_env *env, ani_class cls, const char *name, const char *signature, + ani_method *result); + + /** + * @brief Retrieves a static method from the class. + * + * This function retrieves the specified static method by name and signature from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the static method to retrieve. + * @param[in] signature The signature of the static method to retrieve. + * @param[out] result A pointer to store the retrieved static method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticMethod)(ani_env *env, ani_class cls, const char *name, const char *signature, + ani_static_method *result); + + /** + * @brief Retrieves a property from the class. + * + * This function retrieves the specified property by name from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the property to retrieve. + * @param[out] result A pointer to store the retrieved property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetProperty)(ani_env *env, ani_class cls, const char *name, ani_property *result); + + /** + * @brief Retrieves the setter method of a property from the class. + * + * This function retrieves the setter method for the specified property by name from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the property whose setter is to be retrieved. + * @param[out] result A pointer to store the retrieved setter method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetSetter)(ani_env *env, ani_class cls, const char *name, ani_method *result); + + /** + * @brief Retrieves the getter method of a property from the class. + * + * This function retrieves the getter method for the specified property by name from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] name The name of the property whose getter is to be retrieved. + * @param[out] result A pointer to store the retrieved getter method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetGetter)(ani_env *env, ani_class cls, const char *name, ani_method *result); + + /** + * @brief Retrieves the indexable getter method from the class. + * + * This function retrieves the indexable getter method for the specified signature from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] signature The signature of the indexable getter to retrieve. + * @param[out] result A pointer to store the retrieved indexable getter method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetIndexableGetter)(ani_env *env, ani_class cls, const char *signature, ani_method *result); + + /** + * @brief Retrieves the indexable setter method from the class. + * + * This function retrieves the indexable setter method for the specified signature from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[in] signature The signature of the indexable setter to retrieve. + * @param[out] result A pointer to store the retrieved indexable setter method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetIndexableSetter)(ani_env *env, ani_class cls, const char *signature, ani_method *result); + + /** + * @brief Retrieves the iterator method from the class. + * + * This function retrieves the iterator method from the specified class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class to query. + * @param[out] result A pointer to store the retrieved iterator method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetIterator)(ani_env *env, ani_class cls, ani_method *result); + + /** + * @brief Retrieves a boolean value from a static field of a class. + * + * This function retrieves the boolean value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Boolean)(ani_env *env, ani_class cls, ani_static_field field, + ani_boolean *result); + + /** + * @brief Retrieves a character value from a static field of a class. + * + * This function retrieves the character value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved character value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Char)(ani_env *env, ani_class cls, ani_static_field field, ani_char *result); + + /** + * @brief Retrieves a byte value from a static field of a class. + * + * This function retrieves the byte value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Byte)(ani_env *env, ani_class cls, ani_static_field field, ani_byte *result); + + /** + * @brief Retrieves a short value from a static field of a class. + * + * This function retrieves the short value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Short)(ani_env *env, ani_class cls, ani_static_field field, ani_short *result); + + /** + * @brief Retrieves an integer value from a static field of a class. + * + * This function retrieves the integer value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Int)(ani_env *env, ani_class cls, ani_static_field field, ani_int *result); + + /** + * @brief Retrieves a long value from a static field of a class. + * + * This function retrieves the long value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Long)(ani_env *env, ani_class cls, ani_static_field field, ani_long *result); + + /** + * @brief Retrieves a float value from a static field of a class. + * + * This function retrieves the float value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Float)(ani_env *env, ani_class cls, ani_static_field field, ani_float *result); + + /** + * @brief Retrieves a double value from a static field of a class. + * + * This function retrieves the double value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Double)(ani_env *env, ani_class cls, ani_static_field field, ani_double *result); + + /** + * @brief Retrieves a reference value from a static field of a class. + * + * This function retrieves the reference value of the specified static field from the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to retrieve. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticField_Ref)(ani_env *env, ani_class cls, ani_static_field field, ani_ref *result); + + /** + * @brief Sets a boolean value to a static field of a class. + * + * This function assigns a boolean value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The boolean value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Boolean)(ani_env *env, ani_class cls, ani_static_field field, ani_boolean value); + + /** + * @brief Sets a character value to a static field of a class. + * + * This function assigns a character value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The character value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Char)(ani_env *env, ani_class cls, ani_static_field field, ani_char value); + + /** + * @brief Sets a byte value to a static field of a class. + * + * This function assigns a byte value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The byte value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Byte)(ani_env *env, ani_class cls, ani_static_field field, ani_byte value); + + /** + * @brief Sets a short value to a static field of a class. + * + * This function assigns a short value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The short value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Short)(ani_env *env, ani_class cls, ani_static_field field, ani_short value); + + /** + * @brief Sets an integer value to a static field of a class. + * + * This function assigns an integer value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The integer value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Int)(ani_env *env, ani_class cls, ani_static_field field, ani_int value); + + /** + * @brief Sets a long value to a static field of a class. + * + * This function assigns a long value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The long value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Long)(ani_env *env, ani_class cls, ani_static_field field, ani_long value); + + /** + * @brief Sets a float value to a static field of a class. + * + * This function assigns a float value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The float value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Float)(ani_env *env, ani_class cls, ani_static_field field, ani_float value); + + /** + * @brief Sets a double value to a static field of a class. + * + * This function assigns a double value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The double value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Double)(ani_env *env, ani_class cls, ani_static_field field, ani_double value); + + /** + * @brief Sets a reference value to a static field of a class. + * + * This function assigns a reference value to the specified static field of the given class. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to modify. + * @param[in] value The reference value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticField_Ref)(ani_env *env, ani_class cls, ani_static_field field, ani_ref value); + + /** + * @brief Retrieves a boolean value from a static field of a class by its name. + * + * This function retrieves the boolean value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Boolean)(ani_env *env, ani_class cls, const char *name, + ani_boolean *result); + + /** + * @brief Retrieves a character value from a static field of a class by its name. + * + * This function retrieves the character value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved character value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Char)(ani_env *env, ani_class cls, const char *name, ani_char *result); + + /** + * @brief Retrieves a byte value from a static field of a class by its name. + * + * This function retrieves the byte value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Byte)(ani_env *env, ani_class cls, const char *name, ani_byte *result); + + /** + * @brief Retrieves a short value from a static field of a class by its name. + * + * This function retrieves the short value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Short)(ani_env *env, ani_class cls, const char *name, ani_short *result); + + /** + * @brief Retrieves an integer value from a static field of a class by its name. + * + * This function retrieves the integer value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Int)(ani_env *env, ani_class cls, const char *name, ani_int *result); + + /** + * @brief Retrieves a long value from a static field of a class by its name. + * + * This function retrieves the long value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Long)(ani_env *env, ani_class cls, const char *name, ani_long *result); + + /** + * @brief Retrieves a float value from a static field of a class by its name. + * + * This function retrieves the float value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Float)(ani_env *env, ani_class cls, const char *name, ani_float *result); + + /** + * @brief Retrieves a double value from a static field of a class by its name. + * + * This function retrieves the double value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Double)(ani_env *env, ani_class cls, const char *name, ani_double *result); + + /** + * @brief Retrieves a reference value from a static field of a class by its name. + * + * This function retrieves the reference value of the specified static field from the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to retrieve. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_GetStaticFieldByName_Ref)(ani_env *env, ani_class cls, const char *name, ani_ref *result); + + /** + * @brief Sets a boolean value to a static field of a class by its name. + * + * This function assigns a boolean value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The boolean value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Boolean)(ani_env *env, ani_class cls, const char *name, ani_boolean value); + + /** + * @brief Sets a character value to a static field of a class by its name. + * + * This function assigns a character value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The character value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Char)(ani_env *env, ani_class cls, const char *name, ani_char value); + + /** + * @brief Sets a byte value to a static field of a class by its name. + * + * This function assigns a byte value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The byte value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Byte)(ani_env *env, ani_class cls, const char *name, ani_byte value); + + /** + * @brief Sets a short value to a static field of a class by its name. + * + * This function assigns a short value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The short value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Short)(ani_env *env, ani_class cls, const char *name, ani_short value); + + /** + * @brief Sets an integer value to a static field of a class by its name. + * + * This function assigns an integer value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The integer value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Int)(ani_env *env, ani_class cls, const char *name, ani_int value); + + /** + * @brief Sets a long value to a static field of a class by its name. + * + * This function assigns a long value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The long value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Long)(ani_env *env, ani_class cls, const char *name, ani_long value); + + /** + * @brief Sets a float value to a static field of a class by its name. + * + * This function assigns a float value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The float value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Float)(ani_env *env, ani_class cls, const char *name, ani_float value); + + /** + * @brief Sets a double value to a static field of a class by its name. + * + * This function assigns a double value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The double value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Double)(ani_env *env, ani_class cls, const char *name, ani_double value); + + /** + * @brief Sets a reference value to a static field of a class by its name. + * + * This function assigns a reference value to the specified static field of the given class by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] name The name of the static field to modify. + * @param[in] value The reference value to assign. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_SetStaticFieldByName_Ref)(ani_env *env, ani_class cls, const char *name, ani_ref value); + + /** + * @brief Calls a static method with a boolean return type. + * + * This function calls the specified static method of a class and retrieves a boolean result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Boolean)(ani_env *env, ani_class cls, ani_static_method method, + ani_boolean *result, ...); + + /** + * @brief Calls a static method with a boolean return type (array-based). + * + * This function calls the specified static method of a class and retrieves a boolean result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Boolean_A)(ani_env *env, ani_class cls, ani_static_method method, + ani_boolean *result, const ani_value *args); + + /** + * @brief Calls a static method with a boolean return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a boolean result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Boolean_V)(ani_env *env, ani_class cls, ani_static_method method, + ani_boolean *result, va_list args); + + /** + * @brief Calls a static method with a character return type. + * + * This function calls the specified static method of a class and retrieves a character result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the character result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Char)(ani_env *env, ani_class cls, ani_static_method method, ani_char *result, + ...); + + /** + * @brief Calls a static method with a character return type (array-based). + * + * This function calls the specified static method of a class and retrieves a character result using arguments from + * an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the character result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Char_A)(ani_env *env, ani_class cls, ani_static_method method, ani_char *result, + const ani_value *args); + + /** + * @brief Calls a static method with a character return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a character result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the character result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Char_V)(ani_env *env, ani_class cls, ani_static_method method, ani_char *result, + va_list args); + + /** + * @brief Calls a static method with a byte return type. + * + * This function calls the specified static method of a class and retrieves a byte result using variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Byte)(ani_env *env, ani_class cls, ani_static_method method, ani_byte *result, + ...); + + /** + * @brief Calls a static method with a byte return type (array-based). + * + * This function calls the specified static method of a class and retrieves a byte result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Byte_A)(ani_env *env, ani_class cls, ani_static_method method, ani_byte *result, + const ani_value *args); + + /** + * @brief Calls a static method with a byte return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a byte result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Byte_V)(ani_env *env, ani_class cls, ani_static_method method, ani_byte *result, + va_list args); + + /** + * @brief Calls a static method with a short return type. + * + * This function calls the specified static method of a class and retrieves a short result using variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Short)(ani_env *env, ani_class cls, ani_static_method method, ani_short *result, + ...); + + /** + * @brief Calls a static method with a short return type (array-based). + * + * This function calls the specified static method of a class and retrieves a short result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Short_A)(ani_env *env, ani_class cls, ani_static_method method, + ani_short *result, const ani_value *args); + + /** + * @brief Calls a static method with a short return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a short result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Short_V)(ani_env *env, ani_class cls, ani_static_method method, + ani_short *result, va_list args); + + /** + * @brief Calls a static method with an integer return type. + * + * This function calls the specified static method of a class and retrieves an integer result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Int)(ani_env *env, ani_class cls, ani_static_method method, ani_int *result, + ...); + + /** + * @brief Calls a static method with an integer return type (array-based). + * + * This function calls the specified static method of a class and retrieves an integer result using arguments from + * an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Int_A)(ani_env *env, ani_class cls, ani_static_method method, ani_int *result, + const ani_value *args); + + /** + * @brief Calls a static method with an integer return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves an integer result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Int_V)(ani_env *env, ani_class cls, ani_static_method method, ani_int *result, + va_list args); + + /** + * @brief Calls a static method with a long return type. + * + * This function calls the specified static method of a class and retrieves a long result using variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Long)(ani_env *env, ani_class cls, ani_static_method method, ani_long *result, + ...); + + /** + * @brief Calls a static method with a long return type (array-based). + * + * This function calls the specified static method of a class and retrieves a long result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Long_A)(ani_env *env, ani_class cls, ani_static_method method, ani_long *result, + const ani_value *args); + + /** + * @brief Calls a static method with a long return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a long result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Long_V)(ani_env *env, ani_class cls, ani_static_method method, ani_long *result, + va_list args); + + /** + * @brief Calls a static method with a float return type. + * + * This function calls the specified static method of a class and retrieves a float result using variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Float)(ani_env *env, ani_class cls, ani_static_method method, ani_float *result, + ...); + + /** + * @brief Calls a static method with a float return type (array-based). + * + * This function calls the specified static method of a class and retrieves a float result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Float_A)(ani_env *env, ani_class cls, ani_static_method method, + ani_float *result, const ani_value *args); + + /** + * @brief Calls a static method with a float return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a float result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Float_V)(ani_env *env, ani_class cls, ani_static_method method, + ani_float *result, va_list args); + + /** + * @brief Calls a static method with a double return type. + * + * This function calls the specified static method of a class and retrieves a double result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Double)(ani_env *env, ani_class cls, ani_static_method method, + ani_double *result, ...); + + /** + * @brief Calls a static method with a double return type (array-based). + * + * This function calls the specified static method of a class and retrieves a double result using arguments from an + * array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Double_A)(ani_env *env, ani_class cls, ani_static_method method, + ani_double *result, const ani_value *args); + + /** + * @brief Calls a static method with a double return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a double result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Double_V)(ani_env *env, ani_class cls, ani_static_method method, + ani_double *result, va_list args); + + /** + * @brief Calls a static method with a reference return type. + * + * This function calls the specified static method of a class and retrieves a reference result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Ref)(ani_env *env, ani_class cls, ani_static_method method, ani_ref *result, + ...); + + /** + * @brief Calls a static method with a reference return type (array-based). + * + * This function calls the specified static method of a class and retrieves a reference result using arguments from + * an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Ref_A)(ani_env *env, ani_class cls, ani_static_method method, ani_ref *result, + const ani_value *args); + + /** + * @brief Calls a static method with a reference return type (variadic arguments). + * + * This function calls the specified static method of a class and retrieves a reference result using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Ref_V)(ani_env *env, ani_class cls, ani_static_method method, ani_ref *result, + va_list args); + + /** + * @brief Calls a static method with no return value. + * + * This function calls the specified static method of a class using variadic arguments. The method does not return a + * value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Void)(ani_env *env, ani_class cls, ani_static_method method, ...); + + /** + * @brief Calls a static method with no return value (array-based). + * + * This function calls the specified static method of a class using arguments from an array. The method does not + * return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Void_A)(ani_env *env, ani_class cls, ani_static_method method, + const ani_value *args); + + /** + * @brief Calls a static method with no return value (variadic arguments). + * + * This function calls the specified static method of a class using a `va_list`. The method does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to call. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethod_Void_V)(ani_env *env, ani_class cls, ani_static_method method, va_list args); + + /** + * @brief Calls a static method by name with a boolean return type. + * + * This function calls the specified static method of a class by its name and retrieves a boolean result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Boolean)(ani_env *env, ani_class cls, const char *name, + ani_boolean *result, ...); + + /** + * @brief Calls a static method by name with a boolean return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a boolean result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Boolean_A)(ani_env *env, ani_class cls, const char *name, + ani_boolean *result, const ani_value *args); + + /** + * @brief Calls a static method by name with a boolean return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a boolean result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the boolean result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Boolean_V)(ani_env *env, ani_class cls, const char *name, + ani_boolean *result, va_list args); + + /** + * @brief Calls a static method by name with a char return type. + * + * This function calls the specified static method of a class by its name and retrieves a char result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the char result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Char)(ani_env *env, ani_class cls, const char *name, ani_char *result, + ...); + + /** + * @brief Calls a static method by name with a char return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a char result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the char result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Char_A)(ani_env *env, ani_class cls, const char *name, ani_char *result, + const ani_value *args); + + /** + * @brief Calls a static method by name with a char return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a char result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the char result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Char_V)(ani_env *env, ani_class cls, const char *name, ani_char *result, + va_list args); + + /** + * @brief Calls a static method by name with a byte return type. + * + * This function calls the specified static method of a class by its name and retrieves a byte result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Byte)(ani_env *env, ani_class cls, const char *name, ani_byte *result, + ...); + + /** + * @brief Calls a static method by name with a byte return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a byte result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Byte_A)(ani_env *env, ani_class cls, const char *name, ani_byte *result, + const ani_value *args); + + /** + * @brief Calls a static method by name with a byte return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a byte result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the byte result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Byte_V)(ani_env *env, ani_class cls, const char *name, ani_byte *result, + va_list args); + + /** + * @brief Calls a static method by name with a short return type. + * + * This function calls the specified static method of a class by its name and retrieves a short result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Short)(ani_env *env, ani_class cls, const char *name, ani_short *result, + ...); + + /** + * @brief Calls a static method by name with a short return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a short result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Short_A)(ani_env *env, ani_class cls, const char *name, ani_short *result, + const ani_value *args); + + /** + * @brief Calls a static method by name with a short return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a short result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the short result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Short_V)(ani_env *env, ani_class cls, const char *name, ani_short *result, + va_list args); + + /** + * @brief Calls a static method by name with a integer return type. + * + * This function calls the specified static method of a class by its name and retrieves a integer result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Int)(ani_env *env, ani_class cls, const char *name, ani_int *result, ...); + + /** + * @brief Calls a static method by name with a integer return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a integer result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Int_A)(ani_env *env, ani_class cls, const char *name, ani_int *result, + const ani_value *args); + + /** + * @brief Calls a static method by name with a integer return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a integer result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the integer result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Int_V)(ani_env *env, ani_class cls, const char *name, ani_int *result, + va_list args); + + /** + * @brief Calls a static method by name with a long return type. + * + * This function calls the specified static method of a class by its name and retrieves a long result using variadic + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Long)(ani_env *env, ani_class cls, const char *name, ani_long *result, + ...); + + /** + * @brief Calls a static method by name with a long return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a long result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Long_A)(ani_env *env, ani_class cls, const char *name, ani_long *result, + const ani_value *args); + + /** + * @brief Calls a static method by name with a long return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a long result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the long result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Long_V)(ani_env *env, ani_class cls, const char *name, ani_long *result, + va_list args); + + /** + * @brief Calls a static method by name with a float return type. + * + * This function calls the specified static method of a class by its name and retrieves a float result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Float)(ani_env *env, ani_class cls, const char *name, ani_float *result, + ...); + + /** + * @brief Calls a static method by name with a float return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a float result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Float_A)(ani_env *env, ani_class cls, const char *name, ani_float *result, + const ani_value *args); + + /** + * @brief Calls a static method by name with a float return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a float result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the float result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Float_V)(ani_env *env, ani_class cls, const char *name, ani_float *result, + va_list args); + + /** + * @brief Calls a static method by name with a double return type. + * + * This function calls the specified static method of a class by its name and retrieves a double result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Double)(ani_env *env, ani_class cls, const char *name, ani_double *result, + ...); + + /** + * @brief Calls a static method by name with a double return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a double result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Double_A)(ani_env *env, ani_class cls, const char *name, + ani_double *result, const ani_value *args); + + /** + * @brief Calls a static method by name with a double return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a double result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the double result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Double_V)(ani_env *env, ani_class cls, const char *name, + ani_double *result, va_list args); + + /** + * @brief Calls a static method by name with a reference return type. + * + * This function calls the specified static method of a class by its name and retrieves a reference result using + * variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Ref)(ani_env *env, ani_class cls, const char *name, ani_ref *result, ...); + + /** + * @brief Calls a static method by name with a reference return type (array-based). + * + * This function calls the specified static method of a class by its name and retrieves a reference result using + * arguments from an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Ref_A)(ani_env *env, ani_class cls, const char *name, ani_ref *result, + const ani_value *args); + + /** + * @brief Calls a static method by name with a reference return type (variadic arguments). + * + * This function calls the specified static method of a class by its name and retrieves a reference result using a + * `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[out] result A pointer to store the reference result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Ref_V)(ani_env *env, ani_class cls, const char *name, ani_ref *result, + va_list args); + + /** + * @brief Calls a static method by name with no return value. + * + * This function calls the specified static method of a class by its name using variadic arguments. The method does + * not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Void)(ani_env *env, ani_class cls, const char *name, ...); + + /** + * @brief Calls a static method by name with no return value (array-based). + * + * This function calls the specified static method of a class by its name using arguments from an array. The method + * does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Void_A)(ani_env *env, ani_class cls, const char *name, + const ani_value *args); + + /** + * @brief Calls a static method by name with no return value (variadic arguments). + * + * This function calls the specified static method of a class by its name using a `va_list`. The method does not + * return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] name The name of the static method to call. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Class_CallStaticMethodByName_Void_V)(ani_env *env, ani_class cls, const char *name, va_list args); + + /** + * @brief Retrieves a boolean value from a field of an object. + * + * This function retrieves the boolean value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the boolean value from. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Boolean)(ani_env *env, ani_object object, ani_field field, ani_boolean *result); + + /** + * @brief Retrieves a char value from a field of an object. + * + * This function retrieves the char value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the char value from. + * @param[out] result A pointer to store the retrieved char value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Char)(ani_env *env, ani_object object, ani_field field, ani_char *result); + + /** + * @brief Retrieves a byte value from a field of an object. + * + * This function retrieves the byte value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the byte value from. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Byte)(ani_env *env, ani_object object, ani_field field, ani_byte *result); + + /** + * @brief Retrieves a short value from a field of an object. + * + * This function retrieves the short value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the short value from. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Short)(ani_env *env, ani_object object, ani_field field, ani_short *result); + + /** + * @brief Retrieves a integer value from a field of an object. + * + * This function retrieves the integer value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the integer value from. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Int)(ani_env *env, ani_object object, ani_field field, ani_int *result); + + /** + * @brief Retrieves a long value from a field of an object. + * + * This function retrieves the long value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the long value from. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Long)(ani_env *env, ani_object object, ani_field field, ani_long *result); + + /** + * @brief Retrieves a float value from a field of an object. + * + * This function retrieves the float value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the float value from. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Float)(ani_env *env, ani_object object, ani_field field, ani_float *result); + + /** + * @brief Retrieves a double value from a field of an object. + * + * This function retrieves the double value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the double value from. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Double)(ani_env *env, ani_object object, ani_field field, ani_double *result); + + /** + * @brief Retrieves a reference value from a field of an object. + * + * This function retrieves the reference value of the specified field from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to retrieve the reference value from. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetField_Ref)(ani_env *env, ani_object object, ani_field field, ani_ref *result); + + /** + * @brief Sets a boolean value to a field of an object. + * + * This function assigns a boolean value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the boolean value to. + * @param[in] value The boolean value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Boolean)(ani_env *env, ani_object object, ani_field field, ani_boolean value); + + /** + * @brief Sets a char value to a field of an object. + * + * This function assigns a char value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the char value to. + * @param[in] value The char value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Char)(ani_env *env, ani_object object, ani_field field, ani_char value); + + /** + * @brief Sets a byte value to a field of an object. + * + * This function assigns a byte value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the byte value to. + * @param[in] value The byte value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Byte)(ani_env *env, ani_object object, ani_field field, ani_byte value); + + /** + * @brief Sets a short value to a field of an object. + * + * This function assigns a short value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the short value to. + * @param[in] value The short value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Short)(ani_env *env, ani_object object, ani_field field, ani_short value); + + /** + * @brief Sets a integer value to a field of an object. + * + * This function assigns a integer value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the integer value to. + * @param[in] value The integer value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Int)(ani_env *env, ani_object object, ani_field field, ani_int value); + + /** + * @brief Sets a long value to a field of an object. + * + * This function assigns a long value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the long value to. + * @param[in] value The long value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Long)(ani_env *env, ani_object object, ani_field field, ani_long value); + + /** + * @brief Sets a float value to a field of an object. + * + * This function assigns a float value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the float value to. + * @param[in] value The float value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Float)(ani_env *env, ani_object object, ani_field field, ani_float value); + + /** + * @brief Sets a double value to a field of an object. + * + * This function assigns a double value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the double value to. + * @param[in] value The double value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Double)(ani_env *env, ani_object object, ani_field field, ani_double value); + + /** + * @brief Sets a reference value to a field of an object. + * + * This function assigns a reference value to the specified field of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] field The field to set the reference value to. + * @param[in] value The reference value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetField_Ref)(ani_env *env, ani_object object, ani_field field, ani_ref value); + + /** + * @brief Retrieves a boolean value from a field of an object by its name. + * + * This function retrieves the boolean value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the boolean value from. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Boolean)(ani_env *env, ani_object object, const char *name, ani_boolean *result); + + /** + * @brief Retrieves a char value from a field of an object by its name. + * + * This function retrieves the char value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the char value from. + * @param[out] result A pointer to store the retrieved char value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Char)(ani_env *env, ani_object object, const char *name, ani_char *result); + + /** + * @brief Retrieves a byte value from a field of an object by its name. + * + * This function retrieves the byte value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the byte value from. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Byte)(ani_env *env, ani_object object, const char *name, ani_byte *result); + + /** + * @brief Retrieves a short value from a field of an object by its name. + * + * This function retrieves the short value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the short value from. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Short)(ani_env *env, ani_object object, const char *name, ani_short *result); + + /** + * @brief Retrieves a integer value from a field of an object by its name. + * + * This function retrieves the integer value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the integer value from. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Int)(ani_env *env, ani_object object, const char *name, ani_int *result); + + /** + * @brief Retrieves a long value from a field of an object by its name. + * + * This function retrieves the long value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the long value from. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Long)(ani_env *env, ani_object object, const char *name, ani_long *result); + + /** + * @brief Retrieves a float value from a field of an object by its name. + * + * This function retrieves the float value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the float value from. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Float)(ani_env *env, ani_object object, const char *name, ani_float *result); + + /** + * @brief Retrieves a double value from a field of an object by its name. + * + * This function retrieves the double value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the double value from. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Double)(ani_env *env, ani_object object, const char *name, ani_double *result); + + /** + * @brief Retrieves a reference value from a field of an object by its name. + * + * This function retrieves the reference value of the specified field from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to retrieve the reference value from. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetFieldByName_Ref)(ani_env *env, ani_object object, const char *name, ani_ref *result); + + /** + * @brief Sets a boolean value to a field of an object by its name. + * + * This function assigns a boolean value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the boolean value to. + * @param[in] value The boolean value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Boolean)(ani_env *env, ani_object object, const char *name, ani_boolean value); + + /** + * @brief Sets a char value to a field of an object by its name. + * + * This function assigns a char value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the char value to. + * @param[in] value The char value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Char)(ani_env *env, ani_object object, const char *name, ani_char value); + + /** + * @brief Sets a byte value to a field of an object by its name. + * + * This function assigns a byte value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the byte value to. + * @param[in] value The byte value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Byte)(ani_env *env, ani_object object, const char *name, ani_byte value); + + /** + * @brief Sets a short value to a field of an object by its name. + * + * This function assigns a short value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the short value to. + * @param[in] value The short value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Short)(ani_env *env, ani_object object, const char *name, ani_short value); + + /** + * @brief Sets a integer value to a field of an object by its name. + * + * This function assigns a integer value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the integer value to. + * @param[in] value The integer value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Int)(ani_env *env, ani_object object, const char *name, ani_int value); + + /** + * @brief Sets a long value to a field of an object by its name. + * + * This function assigns a long value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the long value to. + * @param[in] value The long value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Long)(ani_env *env, ani_object object, const char *name, ani_long value); + + /** + * @brief Sets a float value to a field of an object by its name. + * + * This function assigns a float value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the float value to. + * @param[in] value The float value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Float)(ani_env *env, ani_object object, const char *name, ani_float value); + + /** + * @brief Sets a double value to a field of an object by its name. + * + * This function assigns a double value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the double value to. + * @param[in] value The double value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Double)(ani_env *env, ani_object object, const char *name, ani_double value); + + /** + * @brief Sets a reference value to a field of an object by its name. + * + * This function assigns a reference value to the specified field of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the field. + * @param[in] name The name of the field to set the reference value to. + * @param[in] value The reference value to assign to the field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetFieldByName_Ref)(ani_env *env, ani_object object, const char *name, ani_ref value); + + /** + * @brief Retrieves a boolean value from a property of an object. + * + * This function retrieves the boolean value of the specified property from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to retrieve the boolean value from. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetProperty_Boolean)(ani_env *env, ani_object object, ani_property property, + ani_boolean *result); + + /** + * @brief Retrieves a char value from a property of an object. + * + * This function retrieves the char value of the specified property from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to retrieve the char value from. + * @param[out] result A pointer to store the retrieved char value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetProperty_Char)(ani_env *env, ani_object object, ani_property property, ani_char *result); + + /** + * @brief Retrieves a byte value from a property of an object. + * + * This function retrieves the byte value of the specified property from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to retrieve the byte value from. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetProperty_Byte)(ani_env *env, ani_object object, ani_property property, ani_byte *result); + + /** + * @brief Retrieves a short value from a property of an object. + * + * This function retrieves the short value of the specified property from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to retrieve the short value from. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetProperty_Short)(ani_env *env, ani_object object, ani_property property, ani_short *result); + + /** + * @brief Retrieves a integer value from a property of an object. + * + * This function retrieves the integer value of the specified property from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to retrieve the integer value from. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetProperty_Int)(ani_env *env, ani_object object, ani_property property, ani_int *result); + + /** + * @brief Retrieves a long value from a property of an object. + * + * This function retrieves the long value of the specified property from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to retrieve the long value from. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetProperty_Long)(ani_env *env, ani_object object, ani_property property, ani_long *result); + + /** + * @brief Retrieves a float value from a property of an object. + * + * This function retrieves the float value of the specified property from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to retrieve the float value from. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetProperty_Float)(ani_env *env, ani_object object, ani_property property, ani_float *result); + + /** + * @brief Retrieves a double value from a property of an object. + * + * This function retrieves the double value of the specified property from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to retrieve the double value from. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetProperty_Double)(ani_env *env, ani_object object, ani_property property, ani_double *result); + + /** + * @brief Retrieves a reference value from a property of an object. + * + * This function retrieves the reference value of the specified property from the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to retrieve the reference value from. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetProperty_Ref)(ani_env *env, ani_object object, ani_property property, ani_ref *result); + + /** + * @brief Sets a boolean value to a property of an object. + * + * This function assigns a boolean value to the specified property of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to set the boolean value to. + * @param[in] value The boolean value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetProperty_Boolean)(ani_env *env, ani_object object, ani_property property, ani_boolean value); + + /** + * @brief Sets a char value to a property of an object. + * + * This function assigns a char value to the specified property of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to set the char value to. + * @param[in] value The char value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetProperty_Char)(ani_env *env, ani_object object, ani_property property, ani_char value); + + /** + * @brief Sets a byte value to a property of an object. + * + * This function assigns a byte value to the specified property of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to set the byte value to. + * @param[in] value The byte value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetProperty_Byte)(ani_env *env, ani_object object, ani_property property, ani_byte value); + + /** + * @brief Sets a short value to a property of an object. + * + * This function assigns a short value to the specified property of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to set the short value to. + * @param[in] value The short value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetProperty_Short)(ani_env *env, ani_object object, ani_property property, ani_short value); + + /** + * @brief Sets a integer value to a property of an object. + * + * This function assigns a integer value to the specified property of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to set the integer value to. + * @param[in] value The integer value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetProperty_Int)(ani_env *env, ani_object object, ani_property property, ani_int value); + + /** + * @brief Sets a long value to a property of an object. + * + * This function assigns a long value to the specified property of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to set the long value to. + * @param[in] value The long value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetProperty_Long)(ani_env *env, ani_object object, ani_property property, ani_long value); + + /** + * @brief Sets a float value to a property of an object. + * + * This function assigns a float value to the specified property of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to set the float value to. + * @param[in] value The float value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetProperty_Float)(ani_env *env, ani_object object, ani_property property, ani_float value); + + /** + * @brief Sets a double value to a property of an object. + * + * This function assigns a double value to the specified property of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to set the double value to. + * @param[in] value The double value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetProperty_Double)(ani_env *env, ani_object object, ani_property property, ani_double value); + + /** + * @brief Sets a reference value to a property of an object. + * + * This function assigns a reference value to the specified property of the given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] property The property to set the reference value to. + * @param[in] value The reference value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetProperty_Ref)(ani_env *env, ani_object object, ani_property property, ani_ref value); + + /** + * @brief Retrieves a boolean value from a property of an object by its name. + * + * This function retrieves the boolean value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the boolean value from. + * @param[out] result A pointer to store the retrieved boolean value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Boolean)(ani_env *env, ani_object object, const char *name, + ani_boolean *result); + + /** + * @brief Retrieves a char value from a property of an object by its name. + * + * This function retrieves the char value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the char value from. + * @param[out] result A pointer to store the retrieved char value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Char)(ani_env *env, ani_object object, const char *name, ani_char *result); + + /** + * @brief Retrieves a byte value from a property of an object by its name. + * + * This function retrieves the byte value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the byte value from. + * @param[out] result A pointer to store the retrieved byte value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Byte)(ani_env *env, ani_object object, const char *name, ani_byte *result); + + /** + * @brief Retrieves a short value from a property of an object by its name. + * + * This function retrieves the short value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the short value from. + * @param[out] result A pointer to store the retrieved short value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Short)(ani_env *env, ani_object object, const char *name, ani_short *result); + + /** + * @brief Retrieves a integer value from a property of an object by its name. + * + * This function retrieves the integer value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the integer value from. + * @param[out] result A pointer to store the retrieved integer value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Int)(ani_env *env, ani_object object, const char *name, ani_int *result); + + /** + * @brief Retrieves a long value from a property of an object by its name. + * + * This function retrieves the long value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the long value from. + * @param[out] result A pointer to store the retrieved long value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Long)(ani_env *env, ani_object object, const char *name, ani_long *result); + + /** + * @brief Retrieves a float value from a property of an object by its name. + * + * This function retrieves the float value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the float value from. + * @param[out] result A pointer to store the retrieved float value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Float)(ani_env *env, ani_object object, const char *name, ani_float *result); + + /** + * @brief Retrieves a double value from a property of an object by its name. + * + * This function retrieves the double value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the double value from. + * @param[out] result A pointer to store the retrieved double value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Double)(ani_env *env, ani_object object, const char *name, + ani_double *result); + + /** + * @brief Retrieves a reference value from a property of an object by its name. + * + * This function retrieves the reference value of the specified property from the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to retrieve the reference value from. + * @param[out] result A pointer to store the retrieved reference value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_GetPropertyByName_Ref)(ani_env *env, ani_object object, const char *name, ani_ref *result); + + /** + * @brief Sets a boolean value to a property of an object by its name. + * + * This function assigns a boolean value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the boolean value to. + * @param[in] value The boolean value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Boolean)(ani_env *env, ani_object object, const char *name, + ani_boolean value); + + /** + * @brief Sets a char value to a property of an object by its name. + * + * This function assigns a char value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the char value to. + * @param[in] value The char value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Char)(ani_env *env, ani_object object, const char *name, ani_char value); + + /** + * @brief Sets a byte value to a property of an object by its name. + * + * This function assigns a byte value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the byte value to. + * @param[in] value The byte value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Byte)(ani_env *env, ani_object object, const char *name, ani_byte value); + + /** + * @brief Sets a short value to a property of an object by its name. + * + * This function assigns a short value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the short value to. + * @param[in] value The short value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Short)(ani_env *env, ani_object object, const char *name, ani_short value); + + /** + * @brief Sets a integer value to a property of an object by its name. + * + * This function assigns a integer value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the integer value to. + * @param[in] value The integer value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Int)(ani_env *env, ani_object object, const char *name, ani_int value); + + /** + * @brief Sets a long value to a property of an object by its name. + * + * This function assigns a long value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the long value to. + * @param[in] value The long value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Long)(ani_env *env, ani_object object, const char *name, ani_long value); + + /** + * @brief Sets a float value to a property of an object by its name. + * + * This function assigns a float value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the float value to. + * @param[in] value The float value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Float)(ani_env *env, ani_object object, const char *name, ani_float value); + + /** + * @brief Sets a double value to a property of an object by its name. + * + * This function assigns a double value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the double value to. + * @param[in] value The double value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Double)(ani_env *env, ani_object object, const char *name, ani_double value); + + /** + * @brief Sets a reference value to a property of an object by its name. + * + * This function assigns a reference value to the specified property of the given object by its name. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object containing the property. + * @param[in] name The name of the property to set the reference value to. + * @param[in] value The reference value to assign to the property. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_SetPropertyByName_Ref)(ani_env *env, ani_object object, const char *name, ani_ref value); + + /** + * @brief Calls a method on an object and retrieves a boolean return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Boolean)(ani_env *env, ani_object object, ani_method method, ani_boolean *result, + ...); + + /** + * @brief Calls a method on an object and retrieves a boolean return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a + * boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Boolean_A)(ani_env *env, ani_object object, ani_method method, ani_boolean *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a boolean return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Boolean_V)(ani_env *env, ani_object object, ani_method method, ani_boolean *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a char return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Char)(ani_env *env, ani_object object, ani_method method, ani_char *result, ...); + + /** + * @brief Calls a method on an object and retrieves a char return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a char + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Char_A)(ani_env *env, ani_object object, ani_method method, ani_char *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a char return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Char_V)(ani_env *env, ani_object object, ani_method method, ani_char *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a byte return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Byte)(ani_env *env, ani_object object, ani_method method, ani_byte *result, ...); + + /** + * @brief Calls a method on an object and retrieves a byte return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a byte + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Byte_A)(ani_env *env, ani_object object, ani_method method, ani_byte *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a byte return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Byte_V)(ani_env *env, ani_object object, ani_method method, ani_byte *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a short return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Short)(ani_env *env, ani_object object, ani_method method, ani_short *result, ...); + + /** + * @brief Calls a method on an object and retrieves a short return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a short + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Short_A)(ani_env *env, ani_object object, ani_method method, ani_short *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a short return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Short_V)(ani_env *env, ani_object object, ani_method method, ani_short *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a integer return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Int)(ani_env *env, ani_object object, ani_method method, ani_int *result, ...); + + /** + * @brief Calls a method on an object and retrieves a integer return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a + * integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Int_A)(ani_env *env, ani_object object, ani_method method, ani_int *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a integer return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Int_V)(ani_env *env, ani_object object, ani_method method, ani_int *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a long return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Long)(ani_env *env, ani_object object, ani_method method, ani_long *result, ...); + + /** + * @brief Calls a method on an object and retrieves a long return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a long + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Long_A)(ani_env *env, ani_object object, ani_method method, ani_long *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a long return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Long_V)(ani_env *env, ani_object object, ani_method method, ani_long *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a float return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Float)(ani_env *env, ani_object object, ani_method method, ani_float *result, ...); + + /** + * @brief Calls a method on an object and retrieves a float return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a float + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Float_A)(ani_env *env, ani_object object, ani_method method, ani_float *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a float return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Float_V)(ani_env *env, ani_object object, ani_method method, ani_float *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a double return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Double)(ani_env *env, ani_object object, ani_method method, ani_double *result, ...); + + /** + * @brief Calls a method on an object and retrieves a double return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a double + * result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Double_A)(ani_env *env, ani_object object, ani_method method, ani_double *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a double return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Double_V)(ani_env *env, ani_object object, ani_method method, ani_double *result, + va_list args); + + /** + * @brief Calls a method on an object and retrieves a reference return value. + * + * This function calls the specified method of an object using variadic arguments and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Ref)(ani_env *env, ani_object object, ani_method method, ani_ref *result, ...); + + /** + * @brief Calls a method on an object and retrieves a reference return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array and retrieves a + * reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Ref_A)(ani_env *env, ani_object object, ani_method method, ani_ref *result, + const ani_value *args); + + /** + * @brief Calls a method on an object and retrieves a reference return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list` and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Ref_V)(ani_env *env, ani_object object, ani_method method, ani_ref *result, + va_list args); + + /** + * @brief Calls a method on an object with no return value. + * + * This function calls the specified method of an object using variadic arguments. The method does not return a + * value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Void)(ani_env *env, ani_object object, ani_method method, ...); + + /** + * @brief Calls a method on an object with no return value (array-based). + * + * This function calls the specified method of an object using arguments provided in an array. The method does not + * return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Void_A)(ani_env *env, ani_object object, ani_method method, const ani_value *args); + + /** + * @brief Calls a method on an object with no return value (variadic arguments). + * + * This function calls the specified method of an object using a `va_list`. The method does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] method The method to call. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethod_Void_V)(ani_env *env, ani_object object, ani_method method, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a boolean return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Boolean)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_boolean *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a boolean return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Boolean_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_boolean *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a boolean return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * boolean result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the boolean return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Boolean_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_boolean *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a char return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Char)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_char *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a char return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Char_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_char *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a char return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * char result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the char return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Char_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_char *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a byte return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Byte)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_byte *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a byte return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Byte_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_byte *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a byte return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * byte result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the byte return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Byte_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_byte *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a short return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Short)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_short *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a short return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Short_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_short *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a short return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * short result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the short return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Short_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_short *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a integer return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Int)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_int *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a integer return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Int_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_int *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a integer return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * integer result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the integer return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Int_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_int *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a long return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Long)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_long *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a long return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Long_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_long *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a long return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * long result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the long return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Long_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_long *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a float return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Float)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_float *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a float return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Float_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_float *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a float return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * float result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the float return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Float_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_float *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a double return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Double)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_double *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a double return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Double_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_double *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a double return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * double result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the double return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Double_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_double *result, va_list args); + + /** + * @brief Calls a method by name on an object and retrieves a reference return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments and + * retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Ref)(ani_env *env, ani_object object, const char *name, const char *signature, + ani_ref *result, ...); + + /** + * @brief Calls a method by name on an object and retrieves a reference return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array and retrieves a reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Ref_A)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_ref *result, const ani_value *args); + + /** + * @brief Calls a method by name on an object and retrieves a reference return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list` and retrieves a + * reference result. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[out] result A pointer to store the reference return value. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Ref_V)(ani_env *env, ani_object object, const char *name, + const char *signature, ani_ref *result, va_list args); + + /** + * @brief Calls a method by name on an object with no return value. + * + * This function calls the specified method by its name and signature on an object using variadic arguments. The + * method does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Void)(ani_env *env, ani_object object, const char *name, const char *signature, + ...); + + /** + * @brief Calls a method by name on an object with no return value (array-based). + * + * This function calls the specified method by its name and signature on an object using arguments provided in an + * array. The method does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Void_A)(ani_env *env, ani_object object, const char *name, + const char *signature, const ani_value *args); + + /** + * @brief Calls a method by name on an object with no return value (variadic arguments). + * + * This function calls the specified method by its name and signature on an object using a `va_list`. The method + * does not return a value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] object The object on which the method is to be called. + * @param[in] name The name of the method to call. + * @param[in] signature The signature of the method to call. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Object_CallMethodByName_Void_V)(ani_env *env, ani_object object, const char *name, + const char *signature, va_list args); + + /** + * @brief Creates a new tuple value. + * + * This function creates a new value for the specified tuple using variadic arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple The tuple for which to create a new value. + * @param[out] result A pointer to store the new tuple value. + * @param[in] ... Variadic arguments to initialize the tuple value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Tuple_NewTupleValue)(ani_env *env, ani_tuple tuple, ani_tuple_value *result, ...); + + /** + * @brief Creates a new tuple value (array-based). + * + * This function creates a new value for the specified tuple using arguments provided in an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple The tuple for which to create a new value. + * @param[out] result A pointer to store the new tuple value. + * @param[in] args An array of arguments to initialize the tuple value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Tuple_NewTupleValue_A)(ani_env *env, ani_tuple tuple, ani_tuple_value *result, const ani_value *args); + + /** + * @brief Creates a new tuple value (variadic arguments). + * + * This function creates a new value for the specified tuple using a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple The tuple for which to create a new value. + * @param[out] result A pointer to store the new tuple value. + * @param[in] args A `va_list` of arguments to initialize the tuple value. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Tuple_NewTupleValue_V)(ani_env *env, ani_tuple tuple, ani_tuple_value *result, va_list args); + + /** + * @brief Retrieves the number of items in a tuple. + * + * This function retrieves the total number of items in the specified tuple. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple The tuple whose number of items is to be retrieved. + * @param[out] result A pointer to store the number of items. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Tuple_GetNumberOfItems)(ani_env *env, ani_tuple tuple, ani_size *result); + + /** + * @brief Retrieves the kind of an item in a tuple. + * + * This function retrieves the kind of the item at the specified index in the tuple. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple The tuple containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the kind of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Tuple_GetItemKind)(ani_env *env, ani_tuple tuple, ani_size index, ani_kind *result); + + /** + * @brief Retrieves the type of an item in a tuple. + * + * This function retrieves the type of the item at the specified index in the tuple. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple The tuple containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the type of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Tuple_GetItemType)(ani_env *env, ani_tuple tuple, ani_size index, ani_type *result); + + /** + * @brief Retrieves the tuple associated with a tuple value. + * + * This function retrieves the tuple that corresponds to the specified tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] value The tuple value to query. + * @param[out] result A pointer to store the associated tuple. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetTuple)(ani_env *env, ani_tuple_value value, ani_tuple *result); + + /** + * @brief Retrieves a boolean item from a tuple value. + * + * This function retrieves the boolean value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the boolean value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Boolean)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_boolean *result); + + /** + * @brief Retrieves a char item from a tuple value. + * + * This function retrieves the char value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the char value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Char)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_char *result); + + /** + * @brief Retrieves a byte item from a tuple value. + * + * This function retrieves the byte value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the byte value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Byte)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_byte *result); + + /** + * @brief Retrieves a short item from a tuple value. + * + * This function retrieves the short value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the short value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Short)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_short *result); + + /** + * @brief Retrieves a integer item from a tuple value. + * + * This function retrieves the integer value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the integer value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Int)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_int *result); + + /** + * @brief Retrieves a long item from a tuple value. + * + * This function retrieves the long value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the long value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Long)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_long *result); + + /** + * @brief Retrieves a float item from a tuple value. + * + * This function retrieves the float value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the float value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Float)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_float *result); + + /** + * @brief Retrieves a double item from a tuple value. + * + * This function retrieves the double value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the double value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Double)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_double *result); + + /** + * @brief Retrieves a reference item from a tuple value. + * + * This function retrieves the reference value of the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[out] result A pointer to store the reference value of the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_GetItem_Ref)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_ref *result); + + /** + * @brief Sets a boolean value to an item in a tuple value. + * + * This function assigns a boolean value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The boolean value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Boolean)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_boolean value); + + /** + * @brief Sets a char value to an item in a tuple value. + * + * This function assigns a char value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The char value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Char)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_char value); + + /** + * @brief Sets a byte value to an item in a tuple value. + * + * This function assigns a byte value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The byte value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Byte)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_byte value); + + /** + * @brief Sets a short value to an item in a tuple value. + * + * This function assigns a short value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The short value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Short)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_short value); + + /** + * @brief Sets a integer value to an item in a tuple value. + * + * This function assigns a integer value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The integer value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Int)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_int value); + + /** + * @brief Sets a long value to an item in a tuple value. + * + * This function assigns a long value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The long value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Long)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_long value); + + /** + * @brief Sets a float value to an item in a tuple value. + * + * This function assigns a float value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The float value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Float)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_float value); + + /** + * @brief Sets a double value to an item in a tuple value. + * + * This function assigns a double value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The double value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Double)(ani_env *env, ani_tuple_value tuple_value, ani_size index, + ani_double value); + + /** + * @brief Sets a reference value to an item in a tuple value. + * + * This function assigns a reference value to the item at the specified index in the tuple value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] tuple_value The tuple value containing the item. + * @param[in] index The index of the item. + * @param[in] value The reference value to assign to the item. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*TupleValue_SetItem_Ref)(ani_env *env, ani_tuple_value tuple_value, ani_size index, ani_ref value); + + /** + * @brief Creates a global reference. + * + * This function creates a global reference from a local reference. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The local reference to convert to a global reference. + * @param[out] result A pointer to store the created global reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GlobalReference_Create)(ani_env *env, ani_ref ref, ani_gref *result); + + /** + * @brief Deletes a global reference. + * + * This function deletes the specified global reference, releasing all associated resources. + * + * @param[in] env A pointer to the environment structure. + * @param[in] gref The global reference to delete. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*GlobalReference_Delete)(ani_env *env, ani_gref gref); + + /** + * @brief Creates a weak reference. + * + * This function creates a weak reference from a local reference. + * + * @param[in] env A pointer to the environment structure. + * @param[in] ref The local reference to convert to a weak reference. + * @param[out] result A pointer to store the created weak reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*WeakReference_Create)(ani_env *env, ani_ref ref, ani_wref *result); + + /** + * @brief Deletes a weak reference. + * + * This function deletes the specified weak reference, releasing all associated resources. + * + * @param[in] env A pointer to the environment structure. + * @param[in] wref The weak reference to delete. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*WeakReference_Delete)(ani_env *env, ani_wref wref); + + /** + * @brief Retrieves the local reference associated with a weak reference. + * + * This function retrieves the local reference that corresponds to the specified weak reference. + * + * @param[in] env A pointer to the environment structure. + * @param[in] wref The weak reference to query. + * @param[out] result A pointer to store the retrieved local reference. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*WeakReference_GetReference)(ani_env *env, ani_wref wref, ani_ref *result); + + /** + * @brief Creates a new array buffer. + * + * This function creates a new array buffer with the specified length and returns a pointer to the allocated data. + * + * @param[in] env A pointer to the environment structure. + * @param[in] length The length of the array buffer in bytes. + * @param[out] data_result A pointer to store the allocated data of the array buffer. + * @param[out] arraybuffer_result A pointer to store the created array buffer object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CreateArrayBuffer)(ani_env *env, size_t length, void **data_result, + ani_arraybuffer *arraybuffer_result); + + /** + * @brief Creates a new array buffer using external data. + * + * This function creates an array buffer that uses external data. The provided finalizer will be called when the + * array buffer is no longer needed. + * + * @param[in] env A pointer to the environment structure. + * @param[in] external_data A pointer to the external data to be used by the array buffer. + * @param[in] length The length of the external data in bytes. + * @param[in] finalizer A callback function to be called when the array buffer is finalized. + * @param[in] hint A user-defined hint to be passed to the finalizer. + * @param[out] result A pointer to store the created array buffer object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CreateArrayBufferExternal)(ani_env *env, void *external_data, size_t length, ani_finalizer finalizer, + void *hint, ani_arraybuffer *result); + + /** + * @brief Retrieves information about an array buffer. + * + * This function retrieves the data pointer and length of the specified array buffer. + * + * @param[in] env A pointer to the environment structure. + * @param[in] arraybuffer The array buffer to query. + * @param[out] data_result A pointer to store the data of the array buffer. + * @param[out] length_result A pointer to store the length of the array buffer in bytes. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*ArrayBuffer_GetInfo)(ani_env *env, ani_arraybuffer arraybuffer, void **data_result, + size_t *length_result); + + /** + * @brief Converts an object to a method. + * + * This function extracts the method information from a given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] method The object representing the method. + * @param[out] result A pointer to store the extracted method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_FromMethod)(ani_env *env, ani_object method, ani_method *result); + + /** + * @brief Converts a method to an object. + * + * This function creates an object representing the specified method. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the method. + * @param[in] method The method to convert. + * @param[out] result A pointer to store the created object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_ToMethod)(ani_env *env, ani_class cls, ani_method method, ani_object *result); + + /** + * @brief Converts an object to a field. + * + * This function extracts the field information from a given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] field The object representing the field. + * @param[out] result A pointer to store the extracted field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_FromField)(ani_env *env, ani_object field, ani_field *result); + + /** + * @brief Converts a field to an object. + * + * This function creates an object representing the specified field. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the field. + * @param[in] field The field to convert. + * @param[out] result A pointer to store the created object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_ToField)(ani_env *env, ani_class cls, ani_field field, ani_object *result); + + /** + * @brief Converts an object to a static method. + * + * This function extracts the static method information from a given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] method The object representing the static method. + * @param[out] result A pointer to store the extracted static method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_FromStaticMethod)(ani_env *env, ani_object method, ani_static_method *result); + + /** + * @brief Converts a static method to an object. + * + * This function creates an object representing the specified static method. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static method. + * @param[in] method The static method to convert. + * @param[out] result A pointer to store the created object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_ToStaticMethod)(ani_env *env, ani_class cls, ani_static_method method, ani_object *result); + + /** + * @brief Converts an object to a static field. + * + * This function extracts the static field information from a given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] field The object representing the static field. + * @param[out] result A pointer to store the extracted static field. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_FromStaticField)(ani_env *env, ani_object field, ani_static_field *result); + + /** + * @brief Converts a static field to an object. + * + * This function creates an object representing the specified static field. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class containing the static field. + * @param[in] field The static field to convert. + * @param[out] result A pointer to store the created object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_ToStaticField)(ani_env *env, ani_class cls, ani_static_field field, ani_object *result); + + /** + * @brief Converts an object to a function. + * + * This function extracts the function information from a given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] function The object representing the function. + * @param[out] result A pointer to store the extracted function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_FromFunction)(ani_env *env, ani_object function, ani_function *result); + + /** + * @brief Converts a function to an object. + * + * This function creates an object representing the specified function. + * + * @param[in] env A pointer to the environment structure. + * @param[in] function The function to convert. + * @param[out] result A pointer to store the created object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_ToFunction)(ani_env *env, ani_function function, ani_object *result); + + /** + * @brief Converts an object to a variable. + * + * This function extracts the variable information from a given object. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The object representing the variable. + * @param[out] result A pointer to store the extracted variable. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_FromVariable)(ani_env *env, ani_object variable, ani_variable *result); + + /** + * @brief Converts a variable to an object. + * + * This function creates an object representing the specified variable. + * + * @param[in] env A pointer to the environment structure. + * @param[in] variable The variable to convert. + * @param[out] result A pointer to store the created object. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Reflection_ToVariable)(ani_env *env, ani_variable variable, ani_object *result); + + /** + * @brief Registers a new coroutine-local storage slot. + * + * This function registers a new coroutine-local storage (CLS) slot with an optional initial data, finalizer, and + * hint. + * + * @param[in] env A pointer to the environment structure. + * @param[in] initial_data A pointer to the initial data to associate with the slot. Can be null. + * @param[in] finalizer A callback function to finalize and clean up the data when it is no longer needed. + * @param[in] hint A user-defined pointer that is passed to the finalizer. Can be null. + * @param[out] result A pointer to store the created CLS slot. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CLS_Register)(ani_env *env, void *initial_data, ani_finalizer finalizer, void *hint, + ani_cls_slot *result); + + /** + * @brief Unregisters a coroutine-local storage slot. + * + * This function unregisters a previously registered CLS slot, releasing its resources. + * + * @param[in] env A pointer to the environment structure. + * @param[in] slot The CLS slot to unregister. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CLS_Unregister)(ani_env *env, ani_cls_slot slot); + + /** + * @brief Sets data for a CLS slot. + * + * This function associates the specified data with the given CLS slot. + * + * @param[in] env A pointer to the environment structure. + * @param[in] slot The CLS slot to set data for. + * @param[in] data A pointer to the data to associate with the slot. Can be null. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CLS_SetData)(ani_env *env, ani_cls_slot slot, void *data); + + /** + * @brief Retrieves data from a CLS slot. + * + * This function retrieves the data associated with the given CLS slot. + * + * @param[in] env A pointer to the environment structure. + * @param[in] slot The CLS slot to retrieve data from. + * @param[out] result A pointer to store the retrieved data. Can be null if no data is associated. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*CLS_GetData)(ani_env *env, ani_cls_slot slot, void **result); + + /** + * @brief Launches a coroutine using a functional object. + * + * This function starts a coroutine that executes the specified functional object with the given arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] fn The functional object to execute. + * @param[in] argc The number of arguments to pass to the functional object. + * @param[in] argv An array of arguments to pass to the functional object. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchFunctionalObject)(ani_env *env, ani_fn_object fn, ani_size argc, ani_ref *argv, + ani_promise *result); + + /** + * @brief Launches a coroutine using a function with variadic arguments. + * + * This function starts a coroutine that executes the specified function with the given arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] function The function to execute. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @param[in] ... Variadic arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchFunction)(ani_env *env, ani_function function, ani_promise *result, ...); + + /** + * @brief Launches a coroutine using a function with array-based arguments. + * + * This function starts a coroutine that executes the specified function using arguments provided in an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] function The function to execute. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @param[in] args An array of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchFunction_A)(ani_env *env, ani_function function, ani_promise *result, + const ani_value *args); + + /** + * @brief Launches a coroutine using a function with variadic arguments in a `va_list`. + * + * This function starts a coroutine that executes the specified function using arguments provided in a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] function The function to execute. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @param[in] args A `va_list` of arguments to pass to the function. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchFunction_V)(ani_env *env, ani_function function, ani_promise *result, va_list args); + + /** + * @brief Launches a coroutine using an object method with variadic arguments. + * + * This function starts a coroutine that executes the specified method on the given object with the provided + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] self The object on which the method is to be executed. + * @param[in] function The method to execute. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @param[in] ... Variadic arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchMethod)(ani_env *env, ani_object self, ani_function function, ani_promise *result, + ...); + + /** + * @brief Launches a coroutine using an object method with array-based arguments. + * + * This function starts a coroutine that executes the specified method on the given object using arguments provided + * in an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] self The object on which the method is to be executed. + * @param[in] function The method to execute. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @param[in] args An array of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchMethod_A)(ani_env *env, ani_object self, ani_function function, ani_promise *result, + const ani_value *args); + + /** + * @brief Launches a coroutine using an object method with variadic arguments in a `va_list`. + * + * This function starts a coroutine that executes the specified method on the given object using arguments provided + * in a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] self The object on which the method is to be executed. + * @param[in] function The method to execute. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @param[in] args A `va_list` of arguments to pass to the method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchMethod_V)(ani_env *env, ani_object self, ani_function function, ani_promise *result, + va_list args); + + /** + * @brief Launches a coroutine using a static method with variadic arguments. + * + * This function starts a coroutine that executes the specified static method on the given class with the provided + * arguments. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class on which the static method is to be executed. + * @param[in] function The static method to execute. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @param[in] ... Variadic arguments to pass to the static method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchStaticMethod)(ani_env *env, ani_class cls, ani_function function, ani_promise *result, + ...); + + /** + * @brief Launches a coroutine using a static method with array-based arguments. + * + * This function starts a coroutine that executes the specified static method on the given class using arguments + * provided in an array. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class on which the static method is to be executed. + * @param[in] function The static method to execute. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @param[in] args An array of arguments to pass to the static method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchStaticMethod_A)(ani_env *env, ani_class cls, ani_function function, + ani_promise *result, const ani_value *args); + + /** + * @brief Launches a coroutine using a static method with variadic arguments in a `va_list`. + * + * This function starts a coroutine that executes the specified static method on the given class using arguments + * provided in a `va_list`. + * + * @param[in] env A pointer to the environment structure. + * @param[in] cls The class on which the static method is to be executed. + * @param[in] function The static method to execute. + * @param[out] result A pointer to store the promise representing the coroutine's result. + * @param[in] args A `va_list` of arguments to pass to the static method. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_LaunchStaticMethod_V)(ani_env *env, ani_class cls, ani_function function, + ani_promise *result, va_list args); + + /** + * @brief Awaits the completion of a promise and retrieves a boolean result. + * + * This function waits for the specified promise to complete and retrieves its result as a boolean value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] promise The promise to await. + * @param[out] value A pointer to store the boolean result of the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_Await_Boolean)(ani_env *env, ani_promise promise, ani_boolean value); + + /** + * @brief Awaits the completion of a promise and retrieves a char result. + * + * This function waits for the specified promise to complete and retrieves its result as a char value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] promise The promise to await. + * @param[out] value A pointer to store the char result of the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_Await_Char)(ani_env *env, ani_promise promise, ani_char value); + + /** + * @brief Awaits the completion of a promise and retrieves a byte result. + * + * This function waits for the specified promise to complete and retrieves its result as a byte value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] promise The promise to await. + * @param[out] value A pointer to store the byte result of the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_Await_Byte)(ani_env *env, ani_promise promise, ani_byte value); + + /** + * @brief Awaits the completion of a promise and retrieves a short result. + * + * This function waits for the specified promise to complete and retrieves its result as a short value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] promise The promise to await. + * @param[out] value A pointer to store the short result of the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_Await_Short)(ani_env *env, ani_promise promise, ani_short value); + + /** + * @brief Awaits the completion of a promise and retrieves a integer result. + * + * This function waits for the specified promise to complete and retrieves its result as a integer value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] promise The promise to await. + * @param[out] value A pointer to store the integer result of the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_Await_Int)(ani_env *env, ani_promise promise, ani_int value); + + /** + * @brief Awaits the completion of a promise and retrieves a long result. + * + * This function waits for the specified promise to complete and retrieves its result as a long value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] promise The promise to await. + * @param[out] value A pointer to store the long result of the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_Await_Long)(ani_env *env, ani_promise promise, ani_long value); + + /** + * @brief Awaits the completion of a promise and retrieves a float result. + * + * This function waits for the specified promise to complete and retrieves its result as a float value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] promise The promise to await. + * @param[out] value A pointer to store the float result of the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_Await_Float)(ani_env *env, ani_promise promise, ani_float value); + + /** + * @brief Awaits the completion of a promise and retrieves a double result. + * + * This function waits for the specified promise to complete and retrieves its result as a double value. + * + * @param[in] env A pointer to the environment structure. + * @param[in] promise The promise to await. + * @param[out] value A pointer to store the double result of the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_Await_Double)(ani_env *env, ani_promise promise, ani_double value); + + /** + * @brief Awaits the completion of a promise and retrieves a reference result. + * + * This function waits for the specified promise to complete and retrieves its result as a reference. + * + * @param[in] env A pointer to the environment structure. + * @param[in] promise The promise to await. + * @param[out] value A pointer to store the reference result of the promise. + * @return Returns a status code of type `ani_status` indicating success or failure. + */ + ani_status (*Coroutine_Await_Ref)(ani_env *env, ani_promise promise, ani_ref value); +}; + +// C++ API +struct __ani_vm { + const struct __ani_vm_api *c_api; + +#ifdef __cplusplus + ani_status DestroyVM() + { + return c_api->DestroyVM(this); + } + ani_status GetEnv(uint32_t version, ani_env **result) + { + return c_api->GetEnv(this, version, result); + } + ani_status AttachThread(void *params, ani_env **result) + { + return c_api->AttachThread(this, params, result); + } + ani_status DetachThread() + { + return c_api->DetachThread(this); + } +#endif // __cplusplus +}; + +struct __ani_env { + const struct __ani_interaction_api *c_api; + +#ifdef __cplusplus + ani_status GetVersion(uint32_t *result) + { + return c_api->GetVersion(this, result); + } + ani_status GetVM(ani_vm **result) + { + return c_api->GetVM(this, result); + } + ani_status Reference_IsObject(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsObject(this, ref, result); + } + ani_status Reference_IsFunctionalObject(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFunctionalObject(this, ref, result); + } + ani_status Reference_IsEnum(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsEnum(this, ref, result); + } + ani_status Reference_IsTuple(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsTuple(this, ref, result); + } + ani_status Reference_IsString(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsString(this, ref, result); + } + ani_status Reference_IsStringLiteral(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsStringLiteral(this, ref, result); + } + ani_status Reference_IsFixedArray(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray(this, ref, result); + } + ani_status Reference_IsFixedArray_Boolean(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray_Boolean(this, ref, result); + } + ani_status Reference_IsFixedArray_Char(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray_Char(this, ref, result); + } + ani_status Reference_IsFixedArray_Byte(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray_Byte(this, ref, result); + } + ani_status Reference_IsFixedArray_Short(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray_Short(this, ref, result); + } + ani_status Reference_IsFixedArray_Int(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray_Int(this, ref, result); + } + ani_status Reference_IsFixedArray_Long(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray_Long(this, ref, result); + } + ani_status Reference_IsFixedArray_Float(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray_Float(this, ref, result); + } + ani_status Reference_IsFixedArray_Double(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray_Double(this, ref, result); + } + ani_status Reference_IsFixedArray_Ref(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsFixedArray_Ref(this, ref, result); + } + ani_status Object_New(ani_class cls, ani_method method, ani_object *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_New_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Object_New_A(ani_class cls, ani_method method, ani_object *result, const ani_value *args) + { + return c_api->Object_New_A(this, cls, method, result, args); + } + ani_status Object_New_V(ani_class cls, ani_method method, ani_object *result, va_list args) + { + return c_api->Object_New_V(this, cls, method, result, args); + } + ani_status Object_GetType(ani_object object, ani_type *result) + { + return c_api->Object_GetType(this, object, result); + } + ani_status Object_InstanceOf(ani_object object, ani_type type, ani_boolean *result) + { + return c_api->Object_InstanceOf(this, object, type, result); + } + ani_status Object_IsSame(ani_object object1, ani_object object2, ani_boolean *result) + { + return c_api->Object_IsSame(this, object1, object2, result); + } + ani_status Type_GetSuperClass(ani_type type, ani_class *result) + { + return c_api->Type_GetSuperClass(this, type, result); + } + ani_status Type_IsAssignableFrom(ani_type from_type, ani_type to_type, ani_boolean *result) + { + return c_api->Type_IsAssignableFrom(this, from_type, to_type, result); + } + ani_status FindModule(const char *module_descriptor, ani_module *result) + { + return c_api->FindModule(this, module_descriptor, result); + } + ani_status FindNamespace(const char *namespace_descriptor, ani_namespace *result) + { + return c_api->FindNamespace(this, namespace_descriptor, result); + } + ani_status FindClass(const char *class_descriptor, ani_class *result) + { + return c_api->FindClass(this, class_descriptor, result); + } + ani_status FindEnum(const char *enum_descriptor, ani_enum *result) + { + return c_api->FindEnum(this, enum_descriptor, result); + } + ani_status FindTuple(const char *tuple_descriptor, ani_tuple *result) + { + return c_api->FindTuple(this, tuple_descriptor, result); + } + ani_status FindFunction(const char *function_descriptor, ani_function *result) + { + return c_api->FindFunction(this, function_descriptor, result); + } + ani_status FindVariable(const char *variable_descriptor, ani_variable *result) + { + return c_api->FindVariable(this, variable_descriptor, result); + } + ani_status Module_FindNamespace(ani_module module, const char *namespace_descriptor, ani_namespace *result) + { + return c_api->Module_FindNamespace(this, module, namespace_descriptor, result); + } + ani_status Module_FindClass(ani_module module, const char *class_descriptor, ani_class *result) + { + return c_api->Module_FindClass(this, module, class_descriptor, result); + } + ani_status Module_FindEnum(ani_module module, const char *enum_descriptor, ani_enum *result) + { + return c_api->Module_FindEnum(this, module, enum_descriptor, result); + } + ani_status Module_FindFunction(ani_module module, const char *name, const char *signature, ani_function *result) + { + return c_api->Module_FindFunction(this, module, name, signature, result); + } + ani_status Module_FindVariable(ani_module module, const char *variable_descriptor, ani_variable *result) + { + return c_api->Module_FindVariable(this, module, variable_descriptor, result); + } + ani_status Namespace_FindNamespace(ani_namespace ns, const char *namespace_descriptor, ani_namespace *result) + { + return c_api->Namespace_FindNamespace(this, ns, namespace_descriptor, result); + } + ani_status Namespace_FindClass(ani_namespace ns, const char *class_descriptor, ani_class *result) + { + return c_api->Namespace_FindClass(this, ns, class_descriptor, result); + } + ani_status Namespace_FindEnum(ani_namespace ns, const char *enum_descriptor, ani_enum *result) + { + return c_api->Namespace_FindEnum(this, ns, enum_descriptor, result); + } + ani_status Namespace_FindFunction(ani_namespace ns, const char *name, const char *signature, ani_function *result) + { + return c_api->Namespace_FindFunction(this, ns, name, signature, result); + } + ani_status Namespace_FindVariable(ani_namespace ns, const char *variable_descriptor, ani_variable *result) + { + return c_api->Namespace_FindVariable(this, ns, variable_descriptor, result); + } + ani_status Module_BindNativeFunctions(ani_module module, const ani_native_function *functions, + ani_size nr_functions) + { + return c_api->Module_BindNativeFunctions(this, module, functions, nr_functions); + } + ani_status Namespace_BindNativeFunctions(ani_namespace ns, const ani_native_function *functions, + ani_size nr_functions) + { + return c_api->Namespace_BindNativeFunctions(this, ns, functions, nr_functions); + } + ani_status Class_BindNativeMethods(ani_class cls, const ani_native_function *methods, ani_size nr_methods) + { + return c_api->Class_BindNativeMethods(this, cls, methods, nr_methods); + } + ani_status Reference_Delete(ani_ref ref) + { + return c_api->Reference_Delete(this, ref); + } + ani_status EnsureEnoughReferences(ani_size nr_refs) + { + return c_api->EnsureEnoughReferences(this, nr_refs); + } + ani_status CreateLocalScope(ani_size nr_refs) + { + return c_api->CreateLocalScope(this, nr_refs); + } + ani_status DestroyLocalScope() + { + return c_api->DestroyLocalScope(this); + } + ani_status CreateEscapeLocalScope(ani_size nr_refs) + { + return c_api->CreateEscapeLocalScope(this, nr_refs); + } + ani_status DestroyEscapeLocalScope(ani_ref ref, ani_ref *result) + { + return c_api->DestroyEscapeLocalScope(this, ref, result); + } + ani_status ThrowError(ani_error err) + { + return c_api->ThrowError(this, err); + } + ani_status ExistUnhandledError(ani_boolean *result) + { + return c_api->ExistUnhandledError(this, result); + } + ani_status GetUnhandledError(ani_error *result) + { + return c_api->GetUnhandledError(this, result); + } + ani_status ResetError() + { + return c_api->ResetError(this); + } + ani_status DescribeError() + { + return c_api->DescribeError(this); + } + ani_status Abort(const char *message) + { + return c_api->Abort(this, message); + } + ani_status GetNull(ani_ref *result) + { + return c_api->GetNull(this, result); + } + ani_status GetUndefined(ani_ref *result) + { + return c_api->GetUndefined(this, result); + } + ani_status Reference_IsNull(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsNull(this, ref, result); + } + ani_status Reference_IsUndefined(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsUndefined(this, ref, result); + } + ani_status Reference_IsNullishValue(ani_ref ref, ani_boolean *result) + { + return c_api->Reference_IsNullishValue(this, ref, result); + } + ani_status Reference_Equals(ani_ref ref0, ani_ref ref1, ani_boolean *result) + { + return c_api->Reference_Equals(this, ref0, ref1, result); + } + ani_status Reference_StrictEquals(ani_ref ref0, ani_ref ref1, ani_boolean *result) + { + return c_api->Reference_StrictEquals(this, ref0, ref1, result); + } + ani_status String_NewUTF16(const uint16_t *utf16_string, ani_size utf16_size, ani_string *result) + { + return c_api->String_NewUTF16(this, utf16_string, utf16_size, result); + } + ani_status String_GetUTF16Size(ani_string string, ani_size *result) + { + return c_api->String_GetUTF16Size(this, string, result); + } + ani_status String_GetUTF16(ani_string string, uint16_t *utf16_buffer, ani_size utf16_buffer_size, ani_size *result) + { + return c_api->String_GetUTF16(this, string, utf16_buffer, utf16_buffer_size, result); + } + ani_status String_GetUTF16SubString(ani_string string, ani_size substr_offset, ani_size substr_size, + uint16_t *utf16_buffer, ani_size utf16_buffer_size, ani_size *result) + { + return c_api->String_GetUTF16SubString(this, string, substr_offset, substr_size, utf16_buffer, + utf16_buffer_size, result); + } + ani_status String_NewUTF8(const char *utf8_string, ani_size utf8_size, ani_string *result) + { + return c_api->String_NewUTF8(this, utf8_string, utf8_size, result); + } + ani_status String_GetUTF8Size(ani_string string, ani_size *result) + { + return c_api->String_GetUTF8Size(this, string, result); + } + ani_status String_GetUTF8(ani_string string, char *utf8_buffer, ani_size utf8_buffer_size, ani_size *result) + { + return c_api->String_GetUTF8(this, string, utf8_buffer, utf8_buffer_size, result); + } + ani_status String_GetUTF8SubString(ani_string string, ani_size substr_offset, ani_size substr_size, + char *utf8_buffer, ani_size utf8_buffer_size, ani_size *result) + { + return c_api->String_GetUTF8SubString(this, string, substr_offset, substr_size, utf8_buffer, utf8_buffer_size, + result); + } + ani_status String_GetCritical(ani_string string, uint32_t *result_string_type, const void **result_data, + ani_size *result_size) // result_string_type - string type utf16/utf8, etc + { + return c_api->String_GetCritical(this, string, result_string_type, result_data, result_size); + } + ani_status String_ReleaseCritical(ani_string string, const void *data) + { + return c_api->String_ReleaseCritical(this, string, data); + } + ani_status StringLiteral_NewUTF16(const uint16_t *utf16_string, ani_size utf16_size, ani_stringliteral *result) + { + return c_api->StringLiteral_NewUTF16(this, utf16_string, utf16_size, result); + } + ani_status StringLiteral_GetUTF16Size(ani_stringliteral string, ani_size *result) + { + return c_api->StringLiteral_GetUTF16Size(this, string, result); + } + ani_status StringLiteral_GetUTF16(ani_stringliteral string, uint16_t *utf16_buffer, ani_size utf16_buffer_size, + ani_size *result) + { + return c_api->StringLiteral_GetUTF16(this, string, utf16_buffer, utf16_buffer_size, result); + } + ani_status StringLiteral_GetUTF16SubString(ani_stringliteral string, ani_size substr_offset, ani_size substr_size, + uint16_t *utf16_buffer, ani_size utf16_buffer_size, ani_size *result) + { + return c_api->StringLiteral_GetUTF16SubString(this, string, substr_offset, substr_size, utf16_buffer, + utf16_buffer_size, result); + } + ani_status StringLiteral_NewUTF8(const char *utf8_string, ani_size utf8_size, ani_stringliteral *result) + { + return c_api->StringLiteral_NewUTF8(this, utf8_string, utf8_size, result); + } + ani_status StringLiteral_GetUTF8Size(ani_stringliteral string, ani_size *result) + { + return c_api->StringLiteral_GetUTF8Size(this, string, result); + } + ani_status StringLiteral_GetUTF8(ani_stringliteral string, char *utf8_buffer, ani_size utf8_buffer_size, + ani_size *result) + { + return c_api->StringLiteral_GetUTF8(this, string, utf8_buffer, utf8_buffer_size, result); + } + ani_status StringLiteral_GetUTF8SubString(ani_stringliteral string, ani_size substr_offset, ani_size substr_size, + char *utf8_buffer, ani_size utf8_buffer_size, ani_size *result) + { + return c_api->StringLiteral_GetUTF8SubString(this, string, substr_offset, substr_size, utf8_buffer, + utf8_buffer_size, result); + } + ani_status StringLiteral_GetCritical(ani_stringliteral string, uint32_t *result_string_type, + const void **result_data, + ani_size *result_size) // result_string_type - string type utf16/utf8, etc + { + return c_api->StringLiteral_GetCritical(this, string, result_string_type, result_data, result_size); + } + ani_status StringLiteral_ReleaseCritical(ani_stringliteral string, const void *data) + { + return c_api->StringLiteral_ReleaseCritical(this, string, data); + } + ani_status FixedArray_GetLength(ani_fixedarray array, ani_size *result) + { + return c_api->FixedArray_GetLength(this, array, result); + } + ani_status FixedArray_New_Boolean(ani_size length, ani_fixedarray_boolean *result) + { + return c_api->FixedArray_New_Boolean(this, length, result); + } + ani_status FixedArray_New_Char(ani_size length, ani_fixedarray_char *result) + { + return c_api->FixedArray_New_Char(this, length, result); + } + ani_status FixedArray_New_Byte(ani_size length, ani_fixedarray_byte *result) + { + return c_api->FixedArray_New_Byte(this, length, result); + } + ani_status FixedArray_New_Short(ani_size length, ani_fixedarray_short *result) + { + return c_api->FixedArray_New_Short(this, length, result); + } + ani_status FixedArray_New_Int(ani_size length, ani_fixedarray_int *result) + { + return c_api->FixedArray_New_Int(this, length, result); + } + ani_status FixedArray_New_Long(ani_size length, ani_fixedarray_long *result) + { + return c_api->FixedArray_New_Long(this, length, result); + } + ani_status FixedArray_New_Float(ani_size length, ani_fixedarray_float *result) + { + return c_api->FixedArray_New_Float(this, length, result); + } + ani_status FixedArray_New_Double(ani_size length, ani_fixedarray_double *result) + { + return c_api->FixedArray_New_Double(this, length, result); + } + ani_status FixedArray_GetRegion_Boolean(ani_fixedarray_boolean array, ani_size offset, ani_size length, + ani_boolean *native_buffer) + { + return c_api->FixedArray_GetRegion_Boolean(this, array, offset, length, native_buffer); + } + ani_status FixedArray_GetRegion_Char(ani_fixedarray_char array, ani_size offset, ani_size length, + ani_char *native_buffer) + { + return c_api->FixedArray_GetRegion_Char(this, array, offset, length, native_buffer); + } + ani_status FixedArray_GetRegion_Byte(ani_fixedarray_byte array, ani_size offset, ani_size length, + ani_byte *native_buffer) + { + return c_api->FixedArray_GetRegion_Byte(this, array, offset, length, native_buffer); + } + ani_status FixedArray_GetRegion_Short(ani_fixedarray_short array, ani_size offset, ani_size length, + ani_short *native_buffer) + { + return c_api->FixedArray_GetRegion_Short(this, array, offset, length, native_buffer); + } + ani_status FixedArray_GetRegion_Int(ani_fixedarray_int array, ani_size offset, ani_size length, + ani_int *native_buffer) + { + return c_api->FixedArray_GetRegion_Int(this, array, offset, length, native_buffer); + } + ani_status FixedArray_GetRegion_Long(ani_fixedarray_long array, ani_size offset, ani_size length, + ani_long *native_buffer) + { + return c_api->FixedArray_GetRegion_Long(this, array, offset, length, native_buffer); + } + ani_status FixedArray_GetRegion_Float(ani_fixedarray_float array, ani_size offset, ani_size length, + ani_float *native_buffer) + { + return c_api->FixedArray_GetRegion_Float(this, array, offset, length, native_buffer); + } + ani_status FixedArray_GetRegion_Double(ani_fixedarray_double array, ani_size offset, ani_size length, + ani_double *native_buffer) + { + return c_api->FixedArray_GetRegion_Double(this, array, offset, length, native_buffer); + } + ani_status FixedArray_SetRegion_Boolean(ani_fixedarray_boolean array, ani_size offset, ani_size length, + const ani_boolean *native_buffer) + { + return c_api->FixedArray_SetRegion_Boolean(this, array, offset, length, native_buffer); + } + ani_status FixedArray_SetRegion_Char(ani_fixedarray_char array, ani_size offset, ani_size length, + const ani_char *native_buffer) + { + return c_api->FixedArray_SetRegion_Char(this, array, offset, length, native_buffer); + } + ani_status FixedArray_SetRegion_Byte(ani_fixedarray_byte array, ani_size offset, ani_size length, + const ani_byte *native_buffer) + { + return c_api->FixedArray_SetRegion_Byte(this, array, offset, length, native_buffer); + } + ani_status FixedArray_SetRegion_Short(ani_fixedarray_short array, ani_size offset, ani_size length, + const ani_short *native_buffer) + { + return c_api->FixedArray_SetRegion_Short(this, array, offset, length, native_buffer); + } + ani_status FixedArray_SetRegion_Int(ani_fixedarray_int array, ani_size offset, ani_size length, + const ani_int *native_buffer) + { + return c_api->FixedArray_SetRegion_Int(this, array, offset, length, native_buffer); + } + ani_status FixedArray_SetRegion_Long(ani_fixedarray_long array, ani_size offset, ani_size length, + const ani_long *native_buffer) + { + return c_api->FixedArray_SetRegion_Long(this, array, offset, length, native_buffer); + } + ani_status FixedArray_SetRegion_Float(ani_fixedarray_float array, ani_size offset, ani_size length, + const ani_float *native_buffer) + { + return c_api->FixedArray_SetRegion_Float(this, array, offset, length, native_buffer); + } + ani_status FixedArray_SetRegion_Double(ani_fixedarray_double array, ani_size offset, ani_size length, + const ani_double *native_buffer) + { + return c_api->FixedArray_SetRegion_Double(this, array, offset, length, native_buffer); + } + ani_status FixedArray_Pin(ani_fixedarray primitive_array, void **result) + { + return c_api->FixedArray_Pin(this, primitive_array, result); + } + ani_status FixedArray_Unpin(ani_fixedarray primitive_array, void *data) + { + return c_api->FixedArray_Unpin(this, primitive_array, data); + } + ani_status FixedArray_New_Ref(ani_size length, ani_ref *initial_array, ani_fixedarray_ref *result) + { + return c_api->FixedArray_New_Ref(this, length, initial_array, result); + } + ani_status FixedArray_Set_Ref(ani_fixedarray_ref array, ani_size index, ani_ref ref) + { + return c_api->FixedArray_Set_Ref(this, array, index, ref); + } + ani_status FixedArray_Get_Ref(ani_fixedarray_ref array, ani_size index, ani_ref *result) + { + return c_api->FixedArray_Get_Ref(this, array, index, result); + } + ani_status Enum_GetEnumValueByName(ani_enum enm, const char *name, ani_enum_value *result) + { + return c_api->Enum_GetEnumValueByName(this, enm, name, result); + } + ani_status Enum_GetEnumValueByIndex(ani_enum enm, ani_size index, ani_enum_value *result) + { + return c_api->Enum_GetEnumValueByIndex(this, enm, index, result); + } + ani_status EnumValue_GetEnum(ani_enum_value enum_value, ani_enum *result) + { + return c_api->EnumValue_GetEnum(this, enum_value, result); + } + ani_status EnumValue_GetValue(ani_enum_value enum_value, ani_object *result) + { + return c_api->EnumValue_GetValue(this, enum_value, result); + } + ani_status EnumValue_GetName(ani_enum_value enum_value, ani_string *result) + { + return c_api->EnumValue_GetName(this, enum_value, result); + } + ani_status EnumValue_GetIndex(ani_enum_value enum_value, ani_size *result) + { + return c_api->EnumValue_GetIndex(this, enum_value, result); + } + ani_status FunctionalObject_Call(ani_fn_object fn, ani_size argc, ani_ref *argv, ani_ref *result) + { + return c_api->FunctionalObject_Call(this, fn, argc, argv, result); + } + ani_status Variable_SetValue_Boolean(ani_variable variable, ani_boolean value) + { + return c_api->Variable_SetValue_Boolean(this, variable, value); + } + ani_status Variable_SetValue_Char(ani_variable variable, ani_char value) + { + return c_api->Variable_SetValue_Char(this, variable, value); + } + ani_status Variable_SetValue_Byte(ani_variable variable, ani_byte value) + { + return c_api->Variable_SetValue_Byte(this, variable, value); + } + ani_status Variable_SetValue_Short(ani_variable variable, ani_short value) + { + return c_api->Variable_SetValue_Short(this, variable, value); + } + ani_status Variable_SetValue_Int(ani_variable variable, ani_int value) + { + return c_api->Variable_SetValue_Int(this, variable, value); + } + ani_status Variable_SetValue_Long(ani_variable variable, ani_long value) + { + return c_api->Variable_SetValue_Long(this, variable, value); + } + ani_status Variable_SetValue_Float(ani_variable variable, ani_float value) + { + return c_api->Variable_SetValue_Float(this, variable, value); + } + ani_status Variable_SetValue_Double(ani_variable variable, ani_double value) + { + return c_api->Variable_SetValue_Double(this, variable, value); + } + ani_status Variable_SetValue_Ref(ani_variable variable, ani_ref value) + { + return c_api->Variable_SetValue_Ref(this, variable, value); + } + ani_status Variable_GetValue_Boolean(ani_variable variable, ani_boolean *result) + { + return c_api->Variable_GetValue_Boolean(this, variable, result); + } + ani_status Variable_GetValue_Char(ani_variable variable, ani_char *result) + { + return c_api->Variable_GetValue_Char(this, variable, result); + } + ani_status Variable_GetValue_Byte(ani_variable variable, ani_byte *result) + { + return c_api->Variable_GetValue_Byte(this, variable, result); + } + ani_status Variable_GetValue_Short(ani_variable variable, ani_short *result) + { + return c_api->Variable_GetValue_Short(this, variable, result); + } + ani_status Variable_GetValue_Int(ani_variable variable, ani_int *result) + { + return c_api->Variable_GetValue_Int(this, variable, result); + } + ani_status Variable_GetValue_Long(ani_variable variable, ani_long *result) + { + return c_api->Variable_GetValue_Long(this, variable, result); + } + ani_status Variable_GetValue_Float(ani_variable variable, ani_float *result) + { + return c_api->Variable_GetValue_Float(this, variable, result); + } + ani_status Variable_GetValue_Double(ani_variable variable, ani_double *result) + { + return c_api->Variable_GetValue_Double(this, variable, result); + } + ani_status Variable_GetValue_Ref(ani_variable variable, ani_ref *result) + { + return c_api->Variable_GetValue_Ref(this, variable, result); + } + ani_status Function_Call_Boolean(ani_function fn, ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Boolean_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Boolean_A(ani_function fn, ani_boolean *result, const ani_value *args) + { + return c_api->Function_Call_Boolean_A(this, fn, result, args); + } + ani_status Function_Call_Boolean_V(ani_function fn, ani_boolean *result, va_list args) + { + return c_api->Function_Call_Boolean_V(this, fn, result, args); + } + ani_status Function_Call_Char(ani_function fn, ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Char_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Char_A(ani_function fn, ani_char *result, const ani_value *args) + { + return c_api->Function_Call_Char_A(this, fn, result, args); + } + ani_status Function_Call_Char_V(ani_function fn, ani_char *result, va_list args) + { + return c_api->Function_Call_Char_V(this, fn, result, args); + } + ani_status Function_Call_Byte(ani_function fn, ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Byte_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Byte_A(ani_function fn, ani_byte *result, const ani_value *args) + { + return c_api->Function_Call_Byte_A(this, fn, result, args); + } + ani_status Function_Call_Byte_V(ani_function fn, ani_byte *result, va_list args) + { + return c_api->Function_Call_Byte_V(this, fn, result, args); + } + ani_status Function_Call_Short(ani_function fn, ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Short_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Short_A(ani_function fn, ani_short *result, const ani_value *args) + { + return c_api->Function_Call_Short_A(this, fn, result, args); + } + ani_status Function_Call_Short_V(ani_function fn, ani_short *result, va_list args) + { + return c_api->Function_Call_Short_V(this, fn, result, args); + } + ani_status Function_Call_Int(ani_function fn, ani_int *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Int_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Int_A(ani_function fn, ani_int *result, const ani_value *args) + { + return c_api->Function_Call_Int_A(this, fn, result, args); + } + ani_status Function_Call_Int_V(ani_function fn, ani_int *result, va_list args) + { + return c_api->Function_Call_Int_V(this, fn, result, args); + } + ani_status Function_Call_Long(ani_function fn, ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Long_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Long_A(ani_function fn, ani_long *result, const ani_value *args) + { + return c_api->Function_Call_Long_A(this, fn, result, args); + } + ani_status Function_Call_Long_V(ani_function fn, ani_long *result, va_list args) + { + return c_api->Function_Call_Long_V(this, fn, result, args); + } + ani_status Function_Call_Float(ani_function fn, ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Float_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Float_A(ani_function fn, ani_float *result, const ani_value *args) + { + return c_api->Function_Call_Float_A(this, fn, result, args); + } + ani_status Function_Call_Float_V(ani_function fn, ani_float *result, va_list args) + { + return c_api->Function_Call_Float_V(this, fn, result, args); + } + ani_status Function_Call_Double(ani_function fn, ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Double_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Double_A(ani_function fn, ani_double *result, const ani_value *args) + { + return c_api->Function_Call_Double_A(this, fn, result, args); + } + ani_status Function_Call_Double_V(ani_function fn, ani_double *result, va_list args) + { + return c_api->Function_Call_Double_V(this, fn, result, args); + } + ani_status Function_Call_Ref(ani_function fn, ani_ref *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Function_Call_Ref_V(this, fn, result, args); + va_end(args); + return status; + } + ani_status Function_Call_Ref_A(ani_function fn, ani_ref *result, const ani_value *args) + { + return c_api->Function_Call_Ref_A(this, fn, result, args); + } + ani_status Function_Call_Ref_V(ani_function fn, ani_ref *result, va_list args) + { + return c_api->Function_Call_Ref_V(this, fn, result, args); + } + ani_status Function_Call_Void(ani_function fn, ...) + { + va_list args; + va_start(args, fn); + ani_status status = c_api->Function_Call_Void_V(this, fn, args); + va_end(args); + return status; + } + ani_status Function_Call_Void_A(ani_function fn, const ani_value *args) + { + return c_api->Function_Call_Void_A(this, fn, args); + } + ani_status Function_Call_Void_V(ani_function fn, va_list args) + { + return c_api->Function_Call_Void_V(this, fn, args); + } + ani_status Class_GetPartial(ani_class cls, ani_class *result) + { + return c_api->Class_GetPartial(this, cls, result); + } + ani_status Class_GetRequired(ani_class cls, ani_class *result) + { + return c_api->Class_GetRequired(this, cls, result); + } + ani_status Class_GetField(ani_class cls, const char *name, ani_field *result) + { + return c_api->Class_GetField(this, cls, name, result); + } + ani_status Class_GetStaticField(ani_class cls, const char *name, ani_static_field *result) + { + return c_api->Class_GetStaticField(this, cls, name, result); + } + ani_status Class_GetMethod(ani_class cls, const char *name, const char *signature, ani_method *result) + { + return c_api->Class_GetMethod(this, cls, name, signature, result); + } + ani_status Class_GetStaticMethod(ani_class cls, const char *name, const char *signature, ani_static_method *result) + { + return c_api->Class_GetStaticMethod(this, cls, name, signature, result); + } + ani_status Class_GetProperty(ani_class cls, const char *name, ani_property *result) + { + return c_api->Class_GetProperty(this, cls, name, result); + } + ani_status Class_GetSetter(ani_class cls, const char *name, ani_method *result) + { + return c_api->Class_GetSetter(this, cls, name, result); + } + ani_status Class_GetGetter(ani_class cls, const char *name, ani_method *result) + { + return c_api->Class_GetGetter(this, cls, name, result); + } + ani_status Class_GetIndexableGetter(ani_class cls, const char *signature, ani_method *result) + { + return c_api->Class_GetIndexableGetter(this, cls, signature, result); + } + ani_status Class_GetIndexableSetter(ani_class cls, const char *signature, ani_method *result) + { + return c_api->Class_GetIndexableSetter(this, cls, signature, result); + } + ani_status Class_GetIterator(ani_class cls, ani_method *result) + { + return c_api->Class_GetIterator(this, cls, result); + } + ani_status Class_GetStaticField_Boolean(ani_class cls, ani_static_field field, ani_boolean *result) + { + return c_api->Class_GetStaticField_Boolean(this, cls, field, result); + } + ani_status Class_GetStaticField_Char(ani_class cls, ani_static_field field, ani_char *result) + { + return c_api->Class_GetStaticField_Char(this, cls, field, result); + } + ani_status Class_GetStaticField_Byte(ani_class cls, ani_static_field field, ani_byte *result) + { + return c_api->Class_GetStaticField_Byte(this, cls, field, result); + } + ani_status Class_GetStaticField_Short(ani_class cls, ani_static_field field, ani_short *result) + { + return c_api->Class_GetStaticField_Short(this, cls, field, result); + } + ani_status Class_GetStaticField_Int(ani_class cls, ani_static_field field, ani_int *result) + { + return c_api->Class_GetStaticField_Int(this, cls, field, result); + } + ani_status Class_GetStaticField_Long(ani_class cls, ani_static_field field, ani_long *result) + { + return c_api->Class_GetStaticField_Long(this, cls, field, result); + } + ani_status Class_GetStaticField_Float(ani_class cls, ani_static_field field, ani_float *result) + { + return c_api->Class_GetStaticField_Float(this, cls, field, result); + } + ani_status Class_GetStaticField_Double(ani_class cls, ani_static_field field, ani_double *result) + { + return c_api->Class_GetStaticField_Double(this, cls, field, result); + } + ani_status Class_GetStaticField_Ref(ani_class cls, ani_static_field field, ani_ref *result) + { + return c_api->Class_GetStaticField_Ref(this, cls, field, result); + } + ani_status Class_SetStaticField_Boolean(ani_class cls, ani_static_field field, ani_boolean value) + { + return c_api->Class_SetStaticField_Boolean(this, cls, field, value); + } + ani_status Class_SetStaticField_Char(ani_class cls, ani_static_field field, ani_char value) + { + return c_api->Class_SetStaticField_Char(this, cls, field, value); + } + ani_status Class_SetStaticField_Byte(ani_class cls, ani_static_field field, ani_byte value) + { + return c_api->Class_SetStaticField_Byte(this, cls, field, value); + } + ani_status Class_SetStaticField_Short(ani_class cls, ani_static_field field, ani_short value) + { + return c_api->Class_SetStaticField_Short(this, cls, field, value); + } + ani_status Class_SetStaticField_Int(ani_class cls, ani_static_field field, ani_int value) + { + return c_api->Class_SetStaticField_Int(this, cls, field, value); + } + ani_status Class_SetStaticField_Long(ani_class cls, ani_static_field field, ani_long value) + { + return c_api->Class_SetStaticField_Long(this, cls, field, value); + } + ani_status Class_SetStaticField_Float(ani_class cls, ani_static_field field, ani_float value) + { + return c_api->Class_SetStaticField_Float(this, cls, field, value); + } + ani_status Class_SetStaticField_Double(ani_class cls, ani_static_field field, ani_double value) + { + return c_api->Class_SetStaticField_Double(this, cls, field, value); + } + ani_status Class_SetStaticField_Ref(ani_class cls, ani_static_field field, ani_ref value) + { + return c_api->Class_SetStaticField_Ref(this, cls, field, value); + } + ani_status Class_GetStaticFieldByName_Boolean(ani_class cls, const char *name, ani_boolean *result) + { + return c_api->Class_GetStaticFieldByName_Boolean(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Char(ani_class cls, const char *name, ani_char *result) + { + return c_api->Class_GetStaticFieldByName_Char(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Byte(ani_class cls, const char *name, ani_byte *result) + { + return c_api->Class_GetStaticFieldByName_Byte(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Short(ani_class cls, const char *name, ani_short *result) + { + return c_api->Class_GetStaticFieldByName_Short(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Int(ani_class cls, const char *name, ani_int *result) + { + return c_api->Class_GetStaticFieldByName_Int(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Long(ani_class cls, const char *name, ani_long *result) + { + return c_api->Class_GetStaticFieldByName_Long(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Float(ani_class cls, const char *name, ani_float *result) + { + return c_api->Class_GetStaticFieldByName_Float(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Double(ani_class cls, const char *name, ani_double *result) + { + return c_api->Class_GetStaticFieldByName_Double(this, cls, name, result); + } + ani_status Class_GetStaticFieldByName_Ref(ani_class cls, const char *name, ani_ref *result) + { + return c_api->Class_GetStaticFieldByName_Ref(this, cls, name, result); + } + ani_status Class_SetStaticFieldByName_Boolean(ani_class cls, const char *name, ani_boolean value) + { + return c_api->Class_SetStaticFieldByName_Boolean(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Char(ani_class cls, const char *name, ani_char value) + { + return c_api->Class_SetStaticFieldByName_Char(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Byte(ani_class cls, const char *name, ani_byte value) + { + return c_api->Class_SetStaticFieldByName_Byte(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Short(ani_class cls, const char *name, ani_short value) + { + return c_api->Class_SetStaticFieldByName_Short(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Int(ani_class cls, const char *name, ani_int value) + { + return c_api->Class_SetStaticFieldByName_Int(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Long(ani_class cls, const char *name, ani_long value) + { + return c_api->Class_SetStaticFieldByName_Long(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Float(ani_class cls, const char *name, ani_float value) + { + return c_api->Class_SetStaticFieldByName_Float(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Double(ani_class cls, const char *name, ani_double value) + { + return c_api->Class_SetStaticFieldByName_Double(this, cls, name, value); + } + ani_status Class_SetStaticFieldByName_Ref(ani_class cls, const char *name, ani_ref value) + { + return c_api->Class_SetStaticFieldByName_Ref(this, cls, name, value); + } + ani_status Class_CallStaticMethod_Boolean(ani_class cls, ani_static_method method, ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Boolean_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Boolean_A(ani_class cls, ani_static_method method, ani_boolean *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Boolean_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Boolean_V(ani_class cls, ani_static_method method, ani_boolean *result, + va_list args) + { + return c_api->Class_CallStaticMethod_Boolean_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Char(ani_class cls, ani_static_method method, ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Char_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Char_A(ani_class cls, ani_static_method method, ani_char *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Char_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Char_V(ani_class cls, ani_static_method method, ani_char *result, va_list args) + { + return c_api->Class_CallStaticMethod_Char_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Byte(ani_class cls, ani_static_method method, ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Byte_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Byte_A(ani_class cls, ani_static_method method, ani_byte *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Byte_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Byte_V(ani_class cls, ani_static_method method, ani_byte *result, va_list args) + { + return c_api->Class_CallStaticMethod_Byte_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Short(ani_class cls, ani_static_method method, ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Short_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Short_A(ani_class cls, ani_static_method method, ani_short *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Short_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Short_V(ani_class cls, ani_static_method method, ani_short *result, va_list args) + { + return c_api->Class_CallStaticMethod_Short_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Int(ani_class cls, ani_static_method method, ani_int *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Int_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Int_A(ani_class cls, ani_static_method method, ani_int *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Int_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Int_V(ani_class cls, ani_static_method method, ani_int *result, va_list args) + { + return c_api->Class_CallStaticMethod_Int_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Long(ani_class cls, ani_static_method method, ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Long_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Long_A(ani_class cls, ani_static_method method, ani_long *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Long_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Long_V(ani_class cls, ani_static_method method, ani_long *result, va_list args) + { + return c_api->Class_CallStaticMethod_Long_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Float(ani_class cls, ani_static_method method, ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Float_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Float_A(ani_class cls, ani_static_method method, ani_float *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Float_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Float_V(ani_class cls, ani_static_method method, ani_float *result, va_list args) + { + return c_api->Class_CallStaticMethod_Float_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Double(ani_class cls, ani_static_method method, ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Double_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Double_A(ani_class cls, ani_static_method method, ani_double *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Double_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Double_V(ani_class cls, ani_static_method method, ani_double *result, + va_list args) + { + return c_api->Class_CallStaticMethod_Double_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Ref(ani_class cls, ani_static_method method, ani_ref *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethod_Ref_V(this, cls, method, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Ref_A(ani_class cls, ani_static_method method, ani_ref *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethod_Ref_A(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Ref_V(ani_class cls, ani_static_method method, ani_ref *result, va_list args) + { + return c_api->Class_CallStaticMethod_Ref_V(this, cls, method, result, args); + } + ani_status Class_CallStaticMethod_Void(ani_class cls, ani_static_method method, ...) + { + va_list args; + va_start(args, method); + ani_status status = c_api->Class_CallStaticMethod_Void_V(this, cls, method, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethod_Void_A(ani_class cls, ani_static_method method, const ani_value *args) + { + return c_api->Class_CallStaticMethod_Void_A(this, cls, method, args); + } + ani_status Class_CallStaticMethod_Void_V(ani_class cls, ani_static_method method, va_list args) + { + return c_api->Class_CallStaticMethod_Void_V(this, cls, method, args); + } + ani_status Class_CallStaticMethodByName_Boolean(ani_class cls, const char *name, ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Boolean_V(this, cls, name, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Boolean_A(ani_class cls, const char *name, ani_boolean *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Boolean_A(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Boolean_V(ani_class cls, const char *name, ani_boolean *result, + va_list args) + { + return c_api->Class_CallStaticMethodByName_Boolean_V(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Char(ani_class cls, const char *name, ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Char_V(this, cls, name, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Char_A(ani_class cls, const char *name, ani_char *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Char_A(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Char_V(ani_class cls, const char *name, ani_char *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Char_V(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Byte(ani_class cls, const char *name, ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Byte_V(this, cls, name, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Byte_A(ani_class cls, const char *name, ani_byte *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Byte_A(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Byte_V(ani_class cls, const char *name, ani_byte *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Byte_V(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Short(ani_class cls, const char *name, ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Short_V(this, cls, name, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Short_A(ani_class cls, const char *name, ani_short *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Short_A(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Short_V(ani_class cls, const char *name, ani_short *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Short_V(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Int(ani_class cls, const char *name, ani_int *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Int_V(this, cls, name, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Int_A(ani_class cls, const char *name, ani_int *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Int_A(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Int_V(ani_class cls, const char *name, ani_int *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Int_V(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Long(ani_class cls, const char *name, ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Long_V(this, cls, name, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Long_A(ani_class cls, const char *name, ani_long *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Long_A(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Long_V(ani_class cls, const char *name, ani_long *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Long_V(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Float(ani_class cls, const char *name, ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Float_V(this, cls, name, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Float_A(ani_class cls, const char *name, ani_float *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Float_A(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Float_V(ani_class cls, const char *name, ani_float *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Float_V(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Double(ani_class cls, const char *name, ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Double_V(this, cls, name, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Double_A(ani_class cls, const char *name, ani_double *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Double_A(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Double_V(ani_class cls, const char *name, ani_double *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Double_V(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Ref(ani_class cls, const char *name, ani_ref *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Class_CallStaticMethodByName_Ref_V(this, cls, name, result, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Ref_A(ani_class cls, const char *name, ani_ref *result, + const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Ref_A(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Ref_V(ani_class cls, const char *name, ani_ref *result, va_list args) + { + return c_api->Class_CallStaticMethodByName_Ref_V(this, cls, name, result, args); + } + ani_status Class_CallStaticMethodByName_Void(ani_class cls, const char *name, ...) + { + va_list args; + va_start(args, name); + ani_status status = c_api->Class_CallStaticMethodByName_Void_V(this, cls, name, args); + va_end(args); + return status; + } + ani_status Class_CallStaticMethodByName_Void_A(ani_class cls, const char *name, const ani_value *args) + { + return c_api->Class_CallStaticMethodByName_Void_A(this, cls, name, args); + } + ani_status Class_CallStaticMethodByName_Void_V(ani_class cls, const char *name, va_list args) + { + return c_api->Class_CallStaticMethodByName_Void_V(this, cls, name, args); + } + ani_status Object_GetField_Boolean(ani_object object, ani_field field, ani_boolean *result) + { + return c_api->Object_GetField_Boolean(this, object, field, result); + } + ani_status Object_GetField_Char(ani_object object, ani_field field, ani_char *result) + { + return c_api->Object_GetField_Char(this, object, field, result); + } + ani_status Object_GetField_Byte(ani_object object, ani_field field, ani_byte *result) + { + return c_api->Object_GetField_Byte(this, object, field, result); + } + ani_status Object_GetField_Short(ani_object object, ani_field field, ani_short *result) + { + return c_api->Object_GetField_Short(this, object, field, result); + } + ani_status Object_GetField_Int(ani_object object, ani_field field, ani_int *result) + { + return c_api->Object_GetField_Int(this, object, field, result); + } + ani_status Object_GetField_Long(ani_object object, ani_field field, ani_long *result) + { + return c_api->Object_GetField_Long(this, object, field, result); + } + ani_status Object_GetField_Float(ani_object object, ani_field field, ani_float *result) + { + return c_api->Object_GetField_Float(this, object, field, result); + } + ani_status Object_GetField_Double(ani_object object, ani_field field, ani_double *result) + { + return c_api->Object_GetField_Double(this, object, field, result); + } + ani_status Object_GetField_Ref(ani_object object, ani_field field, ani_ref *result) + { + return c_api->Object_GetField_Ref(this, object, field, result); + } + ani_status Object_SetField_Boolean(ani_object object, ani_field field, ani_boolean value) + { + return c_api->Object_SetField_Boolean(this, object, field, value); + } + ani_status Object_SetField_Char(ani_object object, ani_field field, ani_char value) + { + return c_api->Object_SetField_Char(this, object, field, value); + } + ani_status Object_SetField_Byte(ani_object object, ani_field field, ani_byte value) + { + return c_api->Object_SetField_Byte(this, object, field, value); + } + ani_status Object_SetField_Short(ani_object object, ani_field field, ani_short value) + { + return c_api->Object_SetField_Short(this, object, field, value); + } + ani_status Object_SetField_Int(ani_object object, ani_field field, ani_int value) + { + return c_api->Object_SetField_Int(this, object, field, value); + } + ani_status Object_SetField_Long(ani_object object, ani_field field, ani_long value) + { + return c_api->Object_SetField_Long(this, object, field, value); + } + ani_status Object_SetField_Float(ani_object object, ani_field field, ani_float value) + { + return c_api->Object_SetField_Float(this, object, field, value); + } + ani_status Object_SetField_Double(ani_object object, ani_field field, ani_double value) + { + return c_api->Object_SetField_Double(this, object, field, value); + } + ani_status Object_SetField_Ref(ani_object object, ani_field field, ani_ref value) + { + return c_api->Object_SetField_Ref(this, object, field, value); + } + ani_status Object_GetFieldByName_Boolean(ani_object object, const char *name, ani_boolean *result) + { + return c_api->Object_GetFieldByName_Boolean(this, object, name, result); + } + ani_status Object_GetFieldByName_Char(ani_object object, const char *name, ani_char *result) + { + return c_api->Object_GetFieldByName_Char(this, object, name, result); + } + ani_status Object_GetFieldByName_Byte(ani_object object, const char *name, ani_byte *result) + { + return c_api->Object_GetFieldByName_Byte(this, object, name, result); + } + ani_status Object_GetFieldByName_Short(ani_object object, const char *name, ani_short *result) + { + return c_api->Object_GetFieldByName_Short(this, object, name, result); + } + ani_status Object_GetFieldByName_Int(ani_object object, const char *name, ani_int *result) + { + return c_api->Object_GetFieldByName_Int(this, object, name, result); + } + ani_status Object_GetFieldByName_Long(ani_object object, const char *name, ani_long *result) + { + return c_api->Object_GetFieldByName_Long(this, object, name, result); + } + ani_status Object_GetFieldByName_Float(ani_object object, const char *name, ani_float *result) + { + return c_api->Object_GetFieldByName_Float(this, object, name, result); + } + ani_status Object_GetFieldByName_Double(ani_object object, const char *name, ani_double *result) + { + return c_api->Object_GetFieldByName_Double(this, object, name, result); + } + ani_status Object_GetFieldByName_Ref(ani_object object, const char *name, ani_ref *result) + { + return c_api->Object_GetFieldByName_Ref(this, object, name, result); + } + ani_status Object_SetFieldByName_Boolean(ani_object object, const char *name, ani_boolean value) + { + return c_api->Object_SetFieldByName_Boolean(this, object, name, value); + } + ani_status Object_SetFieldByName_Char(ani_object object, const char *name, ani_char value) + { + return c_api->Object_SetFieldByName_Char(this, object, name, value); + } + ani_status Object_SetFieldByName_Byte(ani_object object, const char *name, ani_byte value) + { + return c_api->Object_SetFieldByName_Byte(this, object, name, value); + } + ani_status Object_SetFieldByName_Short(ani_object object, const char *name, ani_short value) + { + return c_api->Object_SetFieldByName_Short(this, object, name, value); + } + ani_status Object_SetFieldByName_Int(ani_object object, const char *name, ani_int value) + { + return c_api->Object_SetFieldByName_Int(this, object, name, value); + } + ani_status Object_SetFieldByName_Long(ani_object object, const char *name, ani_long value) + { + return c_api->Object_SetFieldByName_Long(this, object, name, value); + } + ani_status Object_SetFieldByName_Float(ani_object object, const char *name, ani_float value) + { + return c_api->Object_SetFieldByName_Float(this, object, name, value); + } + ani_status Object_SetFieldByName_Double(ani_object object, const char *name, ani_double value) + { + return c_api->Object_SetFieldByName_Double(this, object, name, value); + } + ani_status Object_SetFieldByName_Ref(ani_object object, const char *name, ani_ref value) + { + return c_api->Object_SetFieldByName_Ref(this, object, name, value); + } + ani_status Object_GetProperty_Boolean(ani_object object, ani_property property, ani_boolean *result) + { + return c_api->Object_GetProperty_Boolean(this, object, property, result); + } + ani_status Object_GetProperty_Char(ani_object object, ani_property property, ani_char *result) + { + return c_api->Object_GetProperty_Char(this, object, property, result); + } + ani_status Object_GetProperty_Byte(ani_object object, ani_property property, ani_byte *result) + { + return c_api->Object_GetProperty_Byte(this, object, property, result); + } + ani_status Object_GetProperty_Short(ani_object object, ani_property property, ani_short *result) + { + return c_api->Object_GetProperty_Short(this, object, property, result); + } + ani_status Object_GetProperty_Int(ani_object object, ani_property property, ani_int *result) + { + return c_api->Object_GetProperty_Int(this, object, property, result); + } + ani_status Object_GetProperty_Long(ani_object object, ani_property property, ani_long *result) + { + return c_api->Object_GetProperty_Long(this, object, property, result); + } + ani_status Object_GetProperty_Float(ani_object object, ani_property property, ani_float *result) + { + return c_api->Object_GetProperty_Float(this, object, property, result); + } + ani_status Object_GetProperty_Double(ani_object object, ani_property property, ani_double *result) + { + return c_api->Object_GetProperty_Double(this, object, property, result); + } + ani_status Object_GetProperty_Ref(ani_object object, ani_property property, ani_ref *result) + { + return c_api->Object_GetProperty_Ref(this, object, property, result); + } + ani_status Object_SetProperty_Boolean(ani_object object, ani_property property, ani_boolean value) + { + return c_api->Object_SetProperty_Boolean(this, object, property, value); + } + ani_status Object_SetProperty_Char(ani_object object, ani_property property, ani_char value) + { + return c_api->Object_SetProperty_Char(this, object, property, value); + } + ani_status Object_SetProperty_Byte(ani_object object, ani_property property, ani_byte value) + { + return c_api->Object_SetProperty_Byte(this, object, property, value); + } + ani_status Object_SetProperty_Short(ani_object object, ani_property property, ani_short value) + { + return c_api->Object_SetProperty_Byte(this, object, property, value); + } + ani_status Object_SetProperty_Int(ani_object object, ani_property property, ani_int value) + { + return c_api->Object_SetProperty_Int(this, object, property, value); + } + ani_status Object_SetProperty_Long(ani_object object, ani_property property, ani_long value) + { + return c_api->Object_SetProperty_Long(this, object, property, value); + } + ani_status Object_SetProperty_Float(ani_object object, ani_property property, ani_float value) + { + return c_api->Object_SetProperty_Float(this, object, property, value); + } + ani_status Object_SetProperty_Double(ani_object object, ani_property property, ani_double value) + { + return c_api->Object_SetProperty_Double(this, object, property, value); + } + ani_status Object_SetProperty_Ref(ani_object object, ani_property property, ani_ref value) + { + return c_api->Object_SetProperty_Ref(this, object, property, value); + } + ani_status Object_GetPropertyByName_Boolean(ani_object object, const char *name, ani_boolean *result) + { + return c_api->Object_GetPropertyByName_Boolean(this, object, name, result); + } + ani_status Object_GetPropertyByName_Char(ani_object object, const char *name, ani_char *result) + { + return c_api->Object_GetPropertyByName_Char(this, object, name, result); + } + ani_status Object_GetPropertyByName_Byte(ani_object object, const char *name, ani_byte *result) + { + return c_api->Object_GetPropertyByName_Byte(this, object, name, result); + } + ani_status Object_GetPropertyByName_Short(ani_object object, const char *name, ani_short *result) + { + return c_api->Object_GetPropertyByName_Short(this, object, name, result); + } + ani_status Object_GetPropertyByName_Int(ani_object object, const char *name, ani_int *result) + { + return c_api->Object_GetPropertyByName_Int(this, object, name, result); + } + ani_status Object_GetPropertyByName_Long(ani_object object, const char *name, ani_long *result) + { + return c_api->Object_GetPropertyByName_Long(this, object, name, result); + } + ani_status Object_GetPropertyByName_Float(ani_object object, const char *name, ani_float *result) + { + return c_api->Object_GetPropertyByName_Float(this, object, name, result); + } + ani_status Object_GetPropertyByName_Double(ani_object object, const char *name, ani_double *result) + { + return c_api->Object_GetPropertyByName_Double(this, object, name, result); + } + ani_status Object_GetPropertyByName_Ref(ani_object object, const char *name, ani_ref *result) + { + return c_api->Object_GetPropertyByName_Ref(this, object, name, result); + } + ani_status Object_SetPropertyByName_Boolean(ani_object object, const char *name, ani_boolean value) + { + return c_api->Object_SetPropertyByName_Boolean(this, object, name, value); + } + ani_status Object_SetPropertyByName_Char(ani_object object, const char *name, ani_char value) + { + return c_api->Object_SetPropertyByName_Char(this, object, name, value); + } + ani_status Object_SetPropertyByName_Byte(ani_object object, const char *name, ani_byte value) + { + return c_api->Object_SetPropertyByName_Byte(this, object, name, value); + } + ani_status Object_SetPropertyByName_Short(ani_object object, const char *name, ani_short value) + { + return c_api->Object_SetPropertyByName_Short(this, object, name, value); + } + ani_status Object_SetPropertyByName_Int(ani_object object, const char *name, ani_int value) + { + return c_api->Object_SetPropertyByName_Int(this, object, name, value); + } + ani_status Object_SetPropertyByName_Long(ani_object object, const char *name, ani_long value) + { + return c_api->Object_SetPropertyByName_Long(this, object, name, value); + } + ani_status Object_SetPropertyByName_Float(ani_object object, const char *name, ani_float value) + { + return c_api->Object_SetPropertyByName_Float(this, object, name, value); + } + ani_status Object_SetPropertyByName_Double(ani_object object, const char *name, ani_double value) + { + return c_api->Object_SetPropertyByName_Double(this, object, name, value); + } + ani_status Object_SetPropertyByName_Ref(ani_object object, const char *name, ani_ref value) + { + return c_api->Object_SetPropertyByName_Ref(this, object, name, value); + } + ani_status Object_CallMethod_Boolean(ani_object object, ani_method method, ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Boolean_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Boolean_A(ani_object object, ani_method method, ani_boolean *result, + const ani_value *args) + { + return c_api->Object_CallMethod_Boolean_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Boolean_V(ani_object object, ani_method method, ani_boolean *result, va_list args) + { + return c_api->Object_CallMethod_Boolean_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Char(ani_object object, ani_method method, ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Char_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Char_A(ani_object object, ani_method method, ani_char *result, const ani_value *args) + { + return c_api->Object_CallMethod_Char_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Char_V(ani_object object, ani_method method, ani_char *result, va_list args) + { + return c_api->Object_CallMethod_Char_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Byte(ani_object object, ani_method method, ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Byte_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Byte_A(ani_object object, ani_method method, ani_byte *result, const ani_value *args) + { + return c_api->Object_CallMethod_Byte_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Byte_V(ani_object object, ani_method method, ani_byte *result, va_list args) + { + return c_api->Object_CallMethod_Byte_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Short(ani_object object, ani_method method, ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Short_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Short_A(ani_object object, ani_method method, ani_short *result, const ani_value *args) + { + return c_api->Object_CallMethod_Short_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Short_V(ani_object object, ani_method method, ani_short *result, va_list args) + { + return c_api->Object_CallMethod_Short_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Int(ani_object object, ani_method method, ani_int *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Int_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Int_A(ani_object object, ani_method method, ani_int *result, const ani_value *args) + { + return c_api->Object_CallMethod_Int_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Int_V(ani_object object, ani_method method, ani_int *result, va_list args) + { + return c_api->Object_CallMethod_Int_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Long(ani_object object, ani_method method, ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Long_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Long_A(ani_object object, ani_method method, ani_long *result, const ani_value *args) + { + return c_api->Object_CallMethod_Long_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Long_V(ani_object object, ani_method method, ani_long *result, va_list args) + { + return c_api->Object_CallMethod_Long_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Float(ani_object object, ani_method method, ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Float_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Float_A(ani_object object, ani_method method, ani_float *result, const ani_value *args) + { + return c_api->Object_CallMethod_Float_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Float_V(ani_object object, ani_method method, ani_float *result, va_list args) + { + return c_api->Object_CallMethod_Float_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Double(ani_object object, ani_method method, ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Double_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Double_A(ani_object object, ani_method method, ani_double *result, + const ani_value *args) + { + return c_api->Object_CallMethod_Double_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Double_V(ani_object object, ani_method method, ani_double *result, va_list args) + { + return c_api->Object_CallMethod_Double_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Ref(ani_object object, ani_method method, ani_ref *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethod_Ref_V(this, object, method, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Ref_A(ani_object object, ani_method method, ani_ref *result, const ani_value *args) + { + return c_api->Object_CallMethod_Ref_A(this, object, method, result, args); + } + ani_status Object_CallMethod_Ref_V(ani_object object, ani_method method, ani_ref *result, va_list args) + { + return c_api->Object_CallMethod_Ref_V(this, object, method, result, args); + } + ani_status Object_CallMethod_Void(ani_object object, ani_method method, ...) + { + va_list args; + va_start(args, method); + ani_status status = c_api->Object_CallMethod_Void_V(this, object, method, args); + va_end(args); + return status; + } + ani_status Object_CallMethod_Void_A(ani_object object, ani_method method, const ani_value *args) + { + return c_api->Object_CallMethod_Void_A(this, object, method, args); + } + ani_status Object_CallMethod_Void_V(ani_object object, ani_method method, va_list args) + { + return c_api->Object_CallMethod_Void_V(this, object, method, args); + } + ani_status Object_CallMethodByName_Boolean(ani_object object, const char *name, const char *signature, + ani_boolean *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Boolean_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Boolean_A(ani_object object, const char *name, const char *signature, + ani_boolean *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Boolean_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Boolean_V(ani_object object, const char *name, const char *signature, + ani_boolean *result, va_list args) + { + return c_api->Object_CallMethodByName_Boolean_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Char(ani_object object, const char *name, const char *signature, + ani_char *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Char_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Char_A(ani_object object, const char *name, const char *signature, + ani_char *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Char_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Char_V(ani_object object, const char *name, const char *signature, + ani_char *result, va_list args) + { + return c_api->Object_CallMethodByName_Char_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Byte(ani_object object, const char *name, const char *signature, + ani_byte *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Byte_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Byte_A(ani_object object, const char *name, const char *signature, + ani_byte *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Byte_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Byte_V(ani_object object, const char *name, const char *signature, + ani_byte *result, va_list args) + { + return c_api->Object_CallMethodByName_Byte_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Short(ani_object object, const char *name, const char *signature, + ani_short *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Short_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Short_A(ani_object object, const char *name, const char *signature, + ani_short *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Short_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Short_V(ani_object object, const char *name, const char *signature, + ani_short *result, va_list args) + { + return c_api->Object_CallMethodByName_Short_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Int(ani_object object, const char *name, const char *signature, ani_int *result, + ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Int_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Int_A(ani_object object, const char *name, const char *signature, + ani_int *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Int_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Int_V(ani_object object, const char *name, const char *signature, + ani_int *result, va_list args) + { + return c_api->Object_CallMethodByName_Int_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Long(ani_object object, const char *name, const char *signature, + ani_long *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Long_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Long_A(ani_object object, const char *name, const char *signature, + ani_long *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Long_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Long_V(ani_object object, const char *name, const char *signature, + ani_long *result, va_list args) + { + return c_api->Object_CallMethodByName_Long_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Float(ani_object object, const char *name, const char *signature, + ani_float *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Float_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Float_A(ani_object object, const char *name, const char *signature, + ani_float *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Float_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Float_V(ani_object object, const char *name, const char *signature, + ani_float *result, va_list args) + { + return c_api->Object_CallMethodByName_Float_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Double(ani_object object, const char *name, const char *signature, + ani_double *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Double_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Double_A(ani_object object, const char *name, const char *signature, + ani_double *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Double_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Double_V(ani_object object, const char *name, const char *signature, + ani_double *result, va_list args) + { + return c_api->Object_CallMethodByName_Double_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Ref(ani_object object, const char *name, const char *signature, ani_ref *result, + ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Object_CallMethodByName_Ref_V(this, object, name, signature, result, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Ref_A(ani_object object, const char *name, const char *signature, + ani_ref *result, const ani_value *args) + { + return c_api->Object_CallMethodByName_Ref_A(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Ref_V(ani_object object, const char *name, const char *signature, + ani_ref *result, va_list args) + { + return c_api->Object_CallMethodByName_Ref_V(this, object, name, signature, result, args); + } + ani_status Object_CallMethodByName_Void(ani_object object, const char *name, const char *signature, ...) + { + va_list args; + va_start(args, signature); + ani_status status = c_api->Object_CallMethodByName_Void_V(this, object, name, signature, args); + va_end(args); + return status; + } + ani_status Object_CallMethodByName_Void_A(ani_object object, const char *name, const char *signature, + const ani_value *args) + { + return c_api->Object_CallMethodByName_Void_A(this, object, name, signature, args); + } + ani_status Object_CallMethodByName_Void_V(ani_object object, const char *name, const char *signature, va_list args) + { + return c_api->Object_CallMethodByName_Void_V(this, object, name, signature, args); + } + ani_status Tuple_NewTupleValue(ani_tuple tuple, ani_tuple_value *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Tuple_NewTupleValue_V(this, tuple, result, args); + va_end(args); + return status; + } + ani_status Tuple_NewTupleValue_A(ani_tuple tuple, ani_tuple_value *result, const ani_value *args) + { + return c_api->Tuple_NewTupleValue_A(this, tuple, result, args); + } + ani_status Tuple_NewTupleValue_V(ani_tuple tuple, ani_tuple_value *result, va_list args) + { + return c_api->Tuple_NewTupleValue_V(this, tuple, result, args); + } + ani_status Tuple_GetNumberOfItems(ani_tuple tuple, ani_size *result) + { + return c_api->Tuple_GetNumberOfItems(this, tuple, result); + } + ani_status Tuple_GetItemKind(ani_tuple tuple, ani_size index, ani_kind *result) + { + return c_api->Tuple_GetItemKind(this, tuple, index, result); + } + ani_status Tuple_GetItemType(ani_tuple tuple, ani_size index, ani_type *result) + { + return c_api->Tuple_GetItemType(this, tuple, index, result); + } + ani_status TupleValue_GetTuple(ani_tuple_value value, ani_tuple *result) + { + return c_api->TupleValue_GetTuple(this, value, result); + } + ani_status TupleValue_GetItem_Boolean(ani_tuple_value tuple_value, ani_size index, ani_boolean *result) + { + return c_api->TupleValue_GetItem_Boolean(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Char(ani_tuple_value tuple_value, ani_size index, ani_char *result) + { + return c_api->TupleValue_GetItem_Char(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Byte(ani_tuple_value tuple_value, ani_size index, ani_byte *result) + { + return c_api->TupleValue_GetItem_Byte(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Short(ani_tuple_value tuple_value, ani_size index, ani_short *result) + { + return c_api->TupleValue_GetItem_Short(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Int(ani_tuple_value tuple_value, ani_size index, ani_int *result) + { + return c_api->TupleValue_GetItem_Int(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Long(ani_tuple_value tuple_value, ani_size index, ani_long *result) + { + return c_api->TupleValue_GetItem_Long(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Float(ani_tuple_value tuple_value, ani_size index, ani_float *result) + { + return c_api->TupleValue_GetItem_Float(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Double(ani_tuple_value tuple_value, ani_size index, ani_double *result) + { + return c_api->TupleValue_GetItem_Double(this, tuple_value, index, result); + } + ani_status TupleValue_GetItem_Ref(ani_tuple_value tuple_value, ani_size index, ani_ref *result) + { + return c_api->TupleValue_GetItem_Ref(this, tuple_value, index, result); + } + ani_status TupleValue_SetItem_Boolean(ani_tuple_value tuple_value, ani_size index, ani_boolean value) + { + return c_api->TupleValue_SetItem_Boolean(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Char(ani_tuple_value tuple_value, ani_size index, ani_char value) + { + return c_api->TupleValue_SetItem_Char(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Byte(ani_tuple_value tuple_value, ani_size index, ani_byte value) + { + return c_api->TupleValue_SetItem_Byte(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Short(ani_tuple_value tuple_value, ani_size index, ani_short value) + { + return c_api->TupleValue_SetItem_Short(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Int(ani_tuple_value tuple_value, ani_size index, ani_int value) + { + return c_api->TupleValue_SetItem_Int(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Long(ani_tuple_value tuple_value, ani_size index, ani_long value) + { + return c_api->TupleValue_SetItem_Long(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Float(ani_tuple_value tuple_value, ani_size index, ani_float value) + { + return c_api->TupleValue_SetItem_Float(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Double(ani_tuple_value tuple_value, ani_size index, ani_double value) + { + return c_api->TupleValue_SetItem_Double(this, tuple_value, index, value); + } + ani_status TupleValue_SetItem_Ref(ani_tuple_value tuple_value, ani_size index, ani_ref value) + { + return c_api->TupleValue_SetItem_Ref(this, tuple_value, index, value); + } + ani_status GlobalReference_Create(ani_ref ref, ani_gref *result) + { + return c_api->GlobalReference_Create(this, ref, result); + } + ani_status GlobalReference_Delete(ani_gref ref) + { + return c_api->GlobalReference_Delete(this, ref); + } + ani_status WeakReference_Create(ani_ref ref, ani_wref *result) + { + return c_api->WeakReference_Create(this, ref, result); + } + ani_status WeakReference_Delete(ani_wref wref) + { + return c_api->WeakReference_Delete(this, wref); + } + ani_status WeakReference_GetReference(ani_wref wref, ani_ref *result) + { + return c_api->WeakReference_GetReference(this, wref, result); + } + ani_status CreateArrayBuffer(size_t length, void **data_result, ani_arraybuffer *arraybuffer_result) + { + return c_api->CreateArrayBuffer(this, length, data_result, arraybuffer_result); + } + ani_status CreateArrayBufferExternal(void *external_data, size_t length, ani_finalizer finalizer, void *hint, + ani_arraybuffer *result) + { + return c_api->CreateArrayBufferExternal(this, external_data, length, finalizer, hint, result); + } + ani_status ArrayBuffer_GetInfo(ani_arraybuffer arraybuffer, void **data_result, size_t *length_result) + { + return c_api->ArrayBuffer_GetInfo(this, arraybuffer, data_result, length_result); + } + ani_status Reflection_FromMethod(ani_object method, ani_method *result) + { + return c_api->Reflection_FromMethod(this, method, result); + } + ani_status Reflection_ToMethod(ani_class cls, ani_method method, ani_object *result) + { + return c_api->Reflection_ToMethod(this, cls, method, result); + } + ani_status Reflection_FromField(ani_object field, ani_field *result) + { + return c_api->Reflection_FromField(this, field, result); + } + ani_status Reflection_ToField(ani_class cls, ani_field field, ani_object *result) + { + return c_api->Reflection_ToField(this, cls, field, result); + } + ani_status Reflection_FromStaticMethod(ani_object method, ani_static_method *result) + { + return c_api->Reflection_FromStaticMethod(this, method, result); + } + ani_status Reflection_ToStaticMethod(ani_class cls, ani_static_method method, ani_object *result) + { + return c_api->Reflection_ToStaticMethod(this, cls, method, result); + } + ani_status Reflection_FromStaticField(ani_object field, ani_static_field *result) + { + return c_api->Reflection_FromStaticField(this, field, result); + } + ani_status Reflection_ToStaticField(ani_class cls, ani_static_field field, ani_object *result) + { + return c_api->Reflection_ToStaticField(this, cls, field, result); + } + ani_status Reflection_FromFunction(ani_object function, ani_function *result) + { + return c_api->Reflection_FromFunction(this, function, result); + } + ani_status Reflection_ToFunction(ani_function function, ani_object *result) + { + return c_api->Reflection_ToFunction(this, function, result); + } + ani_status Reflection_FromVariable(ani_object variable, ani_variable *result) + { + return c_api->Reflection_FromVariable(this, variable, result); + } + ani_status Reflection_ToVariable(ani_variable variable, ani_object *result) + { + return c_api->Reflection_ToVariable(this, variable, result); + } + ani_status CLS_Register(void *initial_data, ani_finalizer finalizer, void *hint, ani_cls_slot *result) + { + return c_api->CLS_Register(this, initial_data, finalizer, hint, result); + } + ani_status CLS_Unregister(ani_cls_slot slot) + { + return c_api->CLS_Unregister(this, slot); + } + ani_status CLS_SetData(ani_cls_slot slot, void *data) + { + return c_api->CLS_SetData(this, slot, data); + } + ani_status CLS_GetData(ani_cls_slot slot, void **result) + { + return c_api->CLS_GetData(this, slot, result); + } + ani_status Coroutine_LaunchFunctionalObject(ani_fn_object fn, ani_size argc, ani_ref *argv, ani_promise *result) + { + return c_api->Coroutine_LaunchFunctionalObject(this, fn, argc, argv, result); + } + ani_status Coroutine_LaunchFunction(ani_function function, ani_promise *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Coroutine_LaunchFunction_V(this, function, result, args); + va_end(args); + return status; + } + ani_status Coroutine_LaunchFunction_A(ani_function function, ani_promise *result, const ani_value *args) + { + return c_api->Coroutine_LaunchFunction_A(this, function, result, args); + } + ani_status Coroutine_LaunchFunction_V(ani_function function, ani_promise *result, va_list args) + { + return c_api->Coroutine_LaunchFunction_V(this, function, result, args); + } + ani_status Coroutine_LaunchMethod(ani_object self, ani_function function, ani_promise *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Coroutine_LaunchMethod_V(this, self, function, result, args); + va_end(args); + return status; + } + ani_status Coroutine_LaunchMethod_A(ani_object self, ani_function function, ani_promise *result, + const ani_value *args) + { + return c_api->Coroutine_LaunchMethod_A(this, self, function, result, args); + } + ani_status Coroutine_LaunchMethod_V(ani_object self, ani_function function, ani_promise *result, va_list args) + { + return c_api->Coroutine_LaunchMethod_V(this, self, function, result, args); + } + ani_status Coroutine_LaunchStaticMethod(ani_class cls, ani_function function, ani_promise *result, ...) + { + va_list args; + va_start(args, result); + ani_status status = c_api->Coroutine_LaunchStaticMethod_V(this, cls, function, result, args); + va_end(args); + return status; + } + ani_status Coroutine_LaunchStaticMethod_A(ani_class cls, ani_function function, ani_promise *result, + const ani_value *args) + { + return c_api->Coroutine_LaunchStaticMethod_A(this, cls, function, result, args); + } + ani_status Coroutine_LaunchStaticMethod_V(ani_class cls, ani_function function, ani_promise *result, va_list args) + { + return c_api->Coroutine_LaunchStaticMethod_V(this, cls, function, result, args); + } + ani_status Coroutine_Await_Boolean(ani_promise promise, ani_boolean value) + { + return c_api->Coroutine_Await_Boolean(this, promise, value); + } + ani_status Coroutine_Await_Char(ani_promise promise, ani_char value) + { + return c_api->Coroutine_Await_Char(this, promise, value); + } + ani_status Coroutine_Await_Byte(ani_promise promise, ani_byte value) + { + return c_api->Coroutine_Await_Byte(this, promise, value); + } + ani_status Coroutine_Await_Short(ani_promise promise, ani_short value) + { + return c_api->Coroutine_Await_Short(this, promise, value); + } + ani_status Coroutine_Await_Int(ani_promise promise, ani_int value) + { + return c_api->Coroutine_Await_Int(this, promise, value); + } + ani_status Coroutine_Await_Long(ani_promise promise, ani_long value) + { + return c_api->Coroutine_Await_Long(this, promise, value); + } + ani_status Coroutine_Await_Float(ani_promise promise, ani_float value) + { + return c_api->Coroutine_Await_Float(this, promise, value); + } + ani_status Coroutine_Await_Double(ani_promise promise, ani_double value) + { + return c_api->Coroutine_Await_Double(this, promise, value); + } + ani_status Coroutine_Await_Ref(ani_promise promise, ani_ref value) + { + return c_api->Coroutine_Await_Ref(this, promise, value); + } +#endif // __cplusplus +}; + +// NOLINTEND +#endif // __ANI_H__ diff --git a/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.cc b/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.cc new file mode 100644 index 000000000..f41a2f5bf --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.cc @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2022-2025 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 +#include "convertors-ani.h" +#include "signatures.h" +#include "interop-logging.h" +#include "interop-types.h" + +static const char* callCallbackFromNative = "callCallbackFromNative"; +static const char* callCallbackFromNativeSig = "I[BI:I"; + +static const char* FAST_NATIVE_PREFIX = "#F$"; + +const bool registerByOne = true; + +static bool registerNatives(ani_env *env, const ani_class clazz, const std::vector> impls) { + std::vector methods; + methods.reserve(impls.size()); + bool result = true; + for (const auto &[name, type, func, flag] : impls) { + ani_native_function method; + method.name = name.c_str(); + method.pointer = func; + method.signature = (flag & ANI_SLOW_NATIVE_FLAG) == 0 ? FAST_NATIVE_PREFIX : nullptr; + if (registerByOne) { + result &= env->Class_BindNativeMethods(clazz, &method, 1) == ANI_OK; + ani_boolean isError = false; + env->ExistUnhandledError(&isError); + if (isError) { + //env->ErrorDescribe(); + env->ResetError(); + } + } + else { + methods.push_back(method); + } + } + if (!registerByOne) { + result = env->Class_BindNativeMethods(clazz, methods.data(), static_cast(methods.size())) == ANI_OK; + } + return registerByOne ? true : result; +} + +bool registerAllModules(ani_env *env) { + auto moduleNames = AniExports::getInstance()->getModules(); + + for (auto it = moduleNames.begin(); it != moduleNames.end(); ++it) { + std::string classpath = AniExports::getInstance()->getClasspath(*it); + ani_class nativeModule = nullptr; + env->FindClass(classpath.c_str(), &nativeModule); + if (nativeModule == nullptr) { + LOGE("Cannot find managed class %s", classpath.c_str()); + continue; + } + if (!registerNatives(env, nativeModule, AniExports::getInstance()->getMethods(*it))) { + return false; + } + } + + return true; +} + +#if 0 +extern "C" ETS_EXPORT ets_int ETS_CALL EtsNapiOnLoad(ets_env *env) { + if (!registerAllModules(env)) { + LOGE("Failed to register ets modules"); + return ETS_ERR; + } + auto interopClasspath = AniExports::getInstance()->getClasspath("InteropNativeModule"); + auto interopClass = env->FindClass(interopClasspath.c_str()); + if (interopClass == nullptr) { + LOGE("Can not find InteropNativeModule classpath to set callback dispatcher"); + return ETS_ERR; + } + if (!setKoalaEtsNapiCallbackDispatcher(env, interopClass, callCallbackFromNative, callCallbackFromNativeSig)) { + LOGE("Failed to set koala ets callback dispatcher"); + return ETS_ERR; + } + return ETS_NAPI_VERSION_1_0; +} +#endif + +AniExports* AniExports::getInstance() { + static AniExports *instance = nullptr; + if (instance == nullptr) { + instance = new AniExports(); + } + return instance; +} + +std::vector AniExports::getModules() { + std::vector result; + for (auto it = implementations.begin(); it != implementations.end(); ++it) { + result.push_back(it->first); + } + return result; +} + +const std::vector>& AniExports::getMethods(const std::string& module) { + auto it = implementations.find(module); + if (it == implementations.end()) { + LOGE("Module %s is not registered", module.c_str()); + } + return it->second; +} + +void AniExports::addMethod(const char* module, const char *name, const char *type, void *impl, int flags) { + auto it = implementations.find(module); + if (it == implementations.end()) { + it = implementations.insert(std::make_pair(module, std::vector>())).first; + } + it->second.push_back(std::make_tuple(name, convertType(name, type), impl, flags)); +} + +void AniExports::setClasspath(const char* module, const char *classpath) { + auto it = classpaths.find(module); + if (it == classpaths.end()) { + classpaths.insert(std::make_pair(module, classpath)); + } else { + LOGE("Classpath for module %s was redefined", module); + } +} + +static std::map g_defaultClasspaths = { + {"InteropNativeModule", "@koalaui/interop/InteropNativeModule/InteropNativeModule"}, + // todo leave just InteropNativeModule, define others via KOALA_ETS_INTEROP_MODULE_CLASSPATH + {"TestNativeModule", "@koalaui/arkts-arkui/generated/arkts/TestNativeModule/TestNativeModule"}, + {"ArkUINativeModule", "@koalaui/arkts-arkui/generated/arkts/ArkUINativeModule/ArkUINativeModule"}, + {"ArkUIGeneratedNativeModule", "@koalaui/arkts-arkui/generated/arkts/ArkUIGeneratedNativeModule/ArkUIGeneratedNativeModule"}, +}; +const std::string& AniExports::getClasspath(const std::string& module) { + auto it = classpaths.find(module); + if (it != classpaths.end()) { + return it->second; + } + auto defaultClasspath = g_defaultClasspaths.find(module); + if (defaultClasspath != g_defaultClasspaths.end()) { + return defaultClasspath->second; + } + INTEROP_FATAL("Classpath for module %s was not registered", module.c_str()); +} diff --git a/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.h b/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.h new file mode 100644 index 000000000..3be74d311 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.h @@ -0,0 +1,1378 @@ +/* + * Copyright (c) 2022-2025 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 KOALA_ANI +#define KOALA_ANI + +#include +#include +#include +#include +#include +#include +#include + +#include "ani.h" +#include "koala-types.h" + +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(ani_env* env, InteropType value) { return value; } + static InteropType convertTo(ani_env* env, T value) { return value; } + static void release(ani_env* env, InteropType value, T converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_string; + static KStringPtr convertFrom(ani_env* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + KStringPtr result; + // Notice that we use UTF length for buffer size, but counter is expressed in number of Unicode chars. + ani_size lengthUtf8 = 0; + env->String_GetUTF8Size(value, &lengthUtf8); + result.resize(lengthUtf8); + ani_size lengthUtf16 = 0; + env->String_GetUTF16Size(value, &lengthUtf16); + ani_size count; + env->String_GetUTF8SubString(value, 0, lengthUtf16, result.data(), result.length(), &count); + return result; + } + static InteropType convertTo(ani_env* env, const KStringPtr& value) { + ani_string result; + env->String_NewUTF8(value.c_str(), value.length(), &result); + return result; + } + static void release(ani_env* env, InteropType value, const KStringPtr& converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_long; + static KNativePointer convertFrom(ani_env* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(ani_env* env, KNativePointer value) { + return reinterpret_cast(value); + } + static void release(ani_env* env, InteropType value, KNativePointer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_fixedarray_int; + static KInt* convertFrom(ani_env* env, InteropType value) { + if (!value) return nullptr; + ani_size length = 0; + env->FixedArray_GetLength(value, &length); + KInt* result = new KInt[length]; + env->FixedArray_GetRegion_Int(value, 0, length, result); + return result; + } + static InteropType convertTo(ani_env* env, KInt* value) = delete; + static void release(ani_env* env, InteropType value, KInt* converted) { + if (converted) delete [] converted; + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_fixedarray_float; + static KFloat* convertFrom(ani_env* env, InteropType value) { + if (!value) return nullptr; + ani_size length = 0; + env->FixedArray_GetLength(value, &length); + KFloat* result = new KFloat[length]; + env->FixedArray_GetRegion_Float(value, 0, length, result); + return result; + } + static InteropType convertTo(ani_env* env, KFloat* value) = delete; + static void release(ani_env* env, InteropType value, KFloat* converted) { + if (converted) delete [] converted; + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_fixedarray_byte; + static KByte* convertFrom(ani_env* env, InteropType value) { + if (!value) return nullptr; + ani_size length = 0; + env->FixedArray_GetLength(value, &length); + KByte* result = new KByte[length]; + env->FixedArray_GetRegion_Byte(value, 0, length, (ani_byte*)result); + return result; + } + static InteropType convertTo(ani_env* env, KByte* value) = delete; + static void release(ani_env* env, InteropType value, KByte* converted) { + if (converted) delete [] converted; + } +}; + +template <> struct InteropTypeConverter { + using InteropType = ani_double; + static KInteropNumber convertFrom(ani_env *env, InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(ani_env *env, KInteropNumber value) { + return value.asDouble(); + } + static void release(ani_env *env, InteropType value, + KInteropNumber converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ani_ref; + static KLength convertFrom(ani_env* env, InteropType value) { + // TODO: implement me + return KLength( { 0, 0, 0, 0}); + } + static InteropType convertTo(ani_env* env, KLength value) = delete; + static void release(ani_env* env, InteropType value, const KLength& converted) {} +}; + +template +inline typename InteropTypeConverter::InteropType makeResult(ani_env* env, Type value) { + return InteropTypeConverter::convertTo(env, value); +} + +template +inline Type getArgument(ani_env* env, typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(env, arg); +} + +template +inline void releaseArgument(ani_env* env, typename InteropTypeConverter::InteropType arg, Type& data) { + InteropTypeConverter::release(env, arg, data); +} + +#define ANI_SLOW_NATIVE_FLAG 1 + +class AniExports { + std::unordered_map>> implementations; + std::unordered_map classpaths; + +public: + static AniExports* getInstance(); + + std::vector getModules(); + void addMethod(const char* module, const char* name, const char* type, void* impl, int flags); + const std::vector>& getMethods(const std::string& module); + + void setClasspath(const char* module, const char* classpath); + const std::string& getClasspath(const std::string& module); +}; + +#define KOALA_QUOTE0(x) #x +#define KOALA_QUOTE(x) KOALA_QUOTE0(x) + +#ifdef _MSC_VER +#define MAKE_ANI_EXPORT(module, name, type, flag) \ + static void __init_##name() { \ + AniExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Ani_##name), flag); \ + } \ + namespace { \ + struct __Init_##name { \ + __Init_##name() { __init_##name(); } \ + } __Init_##name##_v; \ + } +#define KOALA_ANI_INTEROP_MODULE_CLASSPATH(module, classpath) \ + static void __init_classpath_##module() { \ + AniExports::getInstance()->setClasspath(KOALA_QUOTE(module), classpath); \ + } \ + namespace { \ + struct __Init_classpath_##module { \ + __Init_classpath_##module() { __init_classpath_##module(); } \ + } __Init_classpath_##module##_v; \ + } +#else +#define MAKE_ANI_EXPORT(module, name, type, flag) \ + __attribute__((constructor)) \ + static void __init_ets_##name() { \ + AniExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Ani_##name), flag); \ + } +#define KOALA_ANI_INTEROP_MODULE_CLASSPATH(module, classpath) \ + __attribute__((constructor)) \ + static void __init_ani_classpath_##module() { \ + AniExports::getInstance()->setClasspath(KOALA_QUOTE(module), classpath); \ + } +#endif + +#define KOALA_INTEROP_0(name, Ret) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(env, impl_##name()); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, 0) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + auto rv = makeResult(env, impl_##name(p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, 0) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + auto rv = makeResult(env, impl_##name(p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ +InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + return rv; \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + return rv; \ + } \ + MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V0(name) \ + void Ani_##name(ani_env *env) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void", 0) + +#define KOALA_INTEROP_V1(name, P0) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + impl_##name(p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0, 0) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + impl_##name(p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + impl_##name(p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + impl_##name(p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V15(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13, \ + InteropTypeConverter::InteropType _p14) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + P14 p14 = getArgument(env, _p14); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + releaseArgument(env, _p14, p14); \ +} \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13 "|" #P14, 0) + +#define KOALA_INTEROP_CTX_0(name, Ret) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx)); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_5(name, Ret, P0, P1, P2, P3, P4) \ + InteropTypeConverter::InteropType Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3 \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V0(name) \ + void Ani_##name(ani_env *env, ani_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void", ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V1(name, P0) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3, ANI_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ + void Ani_##name(ani_env *env, ani_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + } \ +MAKE_ANI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, ANI_SLOW_NATIVE_FLAG) + +bool setKoalaEtsNapiCallbackDispatcher( + ani_env* ani_env, + ani_class clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +); +void getKoalaEtsNapiCallbackDispatcher(ani_class* clazz, ani_method* method); + +#if 0 +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ + ani_class clazz = nullptr; \ + ani_method method = nullptr; \ + getKoalaEtsNapiCallbackDispatcher(&clazz, &method); \ + ani_env* ani_env = reinterpret_cast(vmContext); \ + ani_env->PushLocalFrame(1); \ + ani_fixedarray_byte args_ets = ani_env->NewByteArray(length); \ + ani_env->SetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ + ani_env->CallStaticIntMethod(clazz, method, id, args_ets, length); \ + ani_env->GetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ + ani_env->PopLocalFrame(nullptr); \ +} + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + ani_class clazz = nullptr; \ + ani_method method = nullptr; \ + getKoalaEtsNapiCallbackDispatcher(&clazz, &method); \ + ani_env* ani_env = reinterpret_cast(venv); \ + ani_env->PushLocalFrame(1); \ + ani_fixedarray_byte args_ets = ani_env->NewByteArray(length); \ + ani_env->SetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ + int32_t rv = ani_env->CallStaticIntMethod(clazz, method, id, args_ets, length); \ + ani_env->GetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ + ani_env->PopLocalFrame(nullptr); \ + return rv; \ +} + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + ani_env* env = reinterpret_cast(vmContext); \ + env->ThrowError(object); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + ani_env* env = reinterpret_cast(vmContext); \ + const static ani_class errorClass = env->FindClass("std/core/Error"); \ + env->ThrowErrorNew(errorClass, message); \ + } while (0) +#else + +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) { return 0; } +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) { return; } +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) { return 0; } +#define KOALA_INTEROP_THROW(vmContext, object, ...) { return __VA_ARGS__; } +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) { return __VA_ARGS__; } +#endif + +#endif // KOALA_ETS_NAPI diff --git a/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc new file mode 100644 index 000000000..d7851e405 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2025 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. + */ + +#define KOALA_INTEROP_MODULE InteropNativeModule +#include "common-interop.h" +#include "interop-types.h" +#include "callback-resource.h" +#include +#include + + +static bool needReleaseFront = false; +static std::deque callbackEventsQueue; +static std::deque callbackCallSubqueue; +static std::deque callbackResourceSubqueue; + +void enqueueCallback(const CallbackBuffer* event) { + callbackEventsQueue.push_back(Event_CallCallback); + callbackCallSubqueue.push_back(*event); +} + +void holdManagedCallbackResource(InteropInt32 resourceId) { + callbackEventsQueue.push_back(Event_HoldManagedResource); + callbackResourceSubqueue.push_back(resourceId); +} + +void releaseManagedCallbackResource(InteropInt32 resourceId) { + callbackEventsQueue.push_back(Event_ReleaseManagedResource); + callbackResourceSubqueue.push_back(resourceId); +} + +KInt impl_CheckCallbackEvent(KByte* result, KInt size) { + if (needReleaseFront) + { + switch (callbackEventsQueue.front()) + { + case Event_CallCallback: + callbackCallSubqueue.front().resourceHolder.release(); + callbackCallSubqueue.pop_front(); + break; + case Event_HoldManagedResource: + case Event_ReleaseManagedResource: + callbackResourceSubqueue.pop_front(); + break; + default: + INTEROP_FATAL("Unknown event kind"); + } + callbackEventsQueue.pop_front(); + needReleaseFront = false; + } + if (callbackEventsQueue.empty()) { + return 0; + } + const CallbackEventKind frontEventKind = callbackEventsQueue.front(); + memcpy(result, &frontEventKind, 4); + switch (frontEventKind) + { + case Event_CallCallback: + memcpy(result + 4, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); + break; + case Event_HoldManagedResource: + case Event_ReleaseManagedResource: { + const InteropInt32 resourceId = callbackResourceSubqueue.front(); + memcpy(result + 4, &resourceId, 4); + break; + } + default: + INTEROP_FATAL("Unknown event kind"); + } + needReleaseFront = true; + return 1; +} +KOALA_INTEROP_2(CheckCallbackEvent, KInt, KByte*, KInt) + +void impl_ReleaseCallbackResource(InteropInt32 resourceId) { + releaseManagedCallbackResource(resourceId); +} +KOALA_INTEROP_V1(ReleaseCallbackResource, KInt) + +void impl_HoldCallbackResource(InteropInt32 resourceId) { + holdManagedCallbackResource(resourceId); +} +KOALA_INTEROP_V1(HoldCallbackResource, KInt) diff --git a/koala-wrapper/koalaui/interop/src/cpp/callback-resource.h b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.h new file mode 100644 index 000000000..451e4a3db --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 _INTEROP_CALLBACK_RESOURCE_H +#define _INTEROP_CALLBACK_RESOURCE_H + +#include +#include "interop-types.h" + + +class CallbackResourceHolder { +private: + std::vector heldResources; +public: + void holdCallbackResource(const InteropCallbackResource* resource) { + resource->hold(resource->resourceId); + this->heldResources.push_back(*resource); + } + void release() { + for (auto resource : this->heldResources) { + resource.release(resource.resourceId); + } + this->heldResources.clear(); + } +}; + +struct CallbackBuffer { + InteropInt32 kind; + uint8_t buffer[60 * 4]; + CallbackResourceHolder resourceHolder; +}; + +enum CallbackEventKind { + Event_CallCallback = 0, + Event_HoldManagedResource = 1, + Event_ReleaseManagedResource = 2, +}; + +void enqueueCallback(const CallbackBuffer* event); +void holdManagedCallbackResource(InteropInt32 resourceId); +void releaseManagedCallbackResource(InteropInt32 resourceId); + +#endif diff --git a/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.cc b/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.cc new file mode 100644 index 000000000..0a26aa8d9 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.cc @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2022-2025 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. + */ \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.h b/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.h new file mode 100644 index 000000000..17949006b --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.h @@ -0,0 +1,875 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include "koala-types.h" + +#define KOALA_INTEROP_EXPORT extern "C" + +#define MAKE_CJ_EXPORT(name, type, flag) \ + __attribute__((constructor)) \ + static void __init_ets_##name() { \ + CJExports::getInstance()->addImpl("_"#name, type, reinterpret_cast(Ark_##name), flag); \ + } + +class CJExports { + std::vector> implementations; + +public: + static CJExports* getInstance(); + + void addImpl(const char* name, const char* type, void* impl); + const std::vector>& getImpls() { + return implementations; + } +}; + +template +struct InteropTypeConverter { + using InteropType = T; + static inline T convertFrom(InteropType value) { return value; } + static inline InteropType convertTo(T value) { return value; } +}; + +template +inline T getArgument(typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(arg); +} + +template +inline typename InteropTypeConverter::InteropType makeResult(T value) { + return InteropTypeConverter::convertTo(value); +} + +template<> +struct InteropTypeConverter { + using InteropType = KDouble; + static inline KInteropNumber convertFrom(InteropType value) { + return KInteropNumber::fromDouble(value); + } + static inline InteropType convertTo(KInteropNumber value) { + return value.asDouble(); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = char*; + static KStringPtr convertFrom(InteropType value) { + return KStringPtr(value); + } + static InteropType convertTo(const KStringPtr& value) { + return value.data(); + } +}; + +// TODO: Rewrite all others to typed convertors. + +#define KOALA_INTEROP_0(name, Ret) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name() { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(impl_##name()); \ +} +// MAKE_CJ_EXPORT(name, #Ret, 0) + +#define KOALA_INTEROP_1(name, Ret, P0) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name(InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + return makeResult(impl_##name(p0)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0, 0) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + return makeResult(impl_##name(p0, p1)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + return makeResult(impl_##name(p0, p1, p2)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + return makeResult(impl_##name(p0, p1, p2, p3)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + P13 p13 = getArgument(_p13); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ +} +// MAKE_CJ_EXPORT(name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V0(name) \ +KOALA_INTEROP_EXPORT void name() { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + return; \ +} + +#define KOALA_INTEROP_V1(name, P0) \ +KOALA_INTEROP_EXPORT void name(typename InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + impl_##name(p0); \ + return; \ +} + +#define KOALA_INTEROP_V2(name, P0, P1) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + impl_##name(p0, p1); \ + return; \ +} + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + impl_##name(p0, p1, p2); \ + return; \ +} + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + impl_##name(p0, p1, p2, p3); \ + return; \ +} + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + return; \ +} + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + return; \ +} + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + return; \ +} + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + return; \ +} + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + return; \ +} + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + return; \ +} + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + return; \ +} + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + return; \ +} + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11, \ + typename InteropTypeConverter::InteropType _p12 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + return; \ +} + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11, \ + typename InteropTypeConverter::InteropType _p12, \ + typename InteropTypeConverter::InteropType _p13 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + P13 p13 = getArgument(_p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + return; \ +} + +#define KOALA_INTEROP_CTX_0(name, Ret) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name() { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx)); \ +} + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name(InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx, p0)); \ +} + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx, p0, p1)); \ +} + + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx, p0, p1, p2)); \ +} + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT InteropTypeConverter::InteropType name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + KVMContext ctx = (KVMContext)0; \ + return makeResult(impl_##name(ctx, p0, p1, p2, p3)); \ +} + + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + int32_t rv = 0; \ + return rv; \ +} +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ +} + + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + + +#define KOALA_INTEROP_CTX_V1(name, P0) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0) {\ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + impl_##name(nullptr, p0); \ +} + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + impl_##name(nullptr, p0, p1); \ +} + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + impl_##name(nullptr, p0, p1, p2); \ +} + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + impl_##name(nullptr, p0, p1, p2, p3); \ +} + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + impl_##name(nullptr, p0, p1, p2, p3, p4); \ +} + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + /* TODO: implement*/ assert(false); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + /* TODO: implement*/ assert(false); \ + return __VA_ARGS__; \ + } while (0) diff --git a/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc b/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc new file mode 100644 index 000000000..ec6572c6d --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc @@ -0,0 +1,469 @@ +/* + * Copyright (c) 2022-2025 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 +#include +#include + +#ifdef KOALA_INTEROP_MODULE +#undef KOALA_INTEROP_MODULE +#endif + +#define KOALA_INTEROP_MODULE InteropNativeModule +#include "common-interop.h" +#include "interop-logging.h" +#include "dynamic-loader.h" + + +#if KOALA_INTEROP_PROFILER +#include "profiler.h" + +InteropProfiler* InteropProfiler::_instance = nullptr; + +#endif + +using std::string; + +#ifdef KOALA_NAPI +// Callback dispatcher MOVED to convertors-napi.cc. +// Let's keep platform-specific parts of the code together + +typedef void (*hold_t)(KInt); + +KInteropBuffer impl_MaterializeBuffer(KNativePointer data, KLong length, KInt resourceId, KNativePointer holdPtr, KNativePointer releasePtr) { + auto hold = reinterpret_cast(holdPtr); + auto release = reinterpret_cast(releasePtr); + hold(resourceId); + return KInteropBuffer { length, data, resourceId, release }; +} +KOALA_INTEROP_5(MaterializeBuffer, KInteropBuffer, KNativePointer, KLong, KInt, KNativePointer, KNativePointer) + +KNativePointer impl_GetNativeBufferPointer(KInteropBuffer buffer) { + return buffer.data; +} +KOALA_INTEROP_1(GetNativeBufferPointer, KNativePointer, KInteropBuffer) + +#endif + +#ifdef KOALA_ETS_NAPI +#include "etsapi.h" + +static struct { + ets_class clazz = nullptr; + ets_method method = nullptr; +} g_koalaEtsNapiCallbackDispatcher; + +bool setKoalaEtsNapiCallbackDispatcher( + EtsEnv* etsEnv, + ets_class clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +) { + g_koalaEtsNapiCallbackDispatcher.clazz = clazz; + etsEnv->NewGlobalRef(clazz); + ets_method method = etsEnv->GetStaticp_method( + clazz, dispatcherMethodName, dispactherMethodSig + ); + if (method == nullptr) { + return false; + } + g_koalaEtsNapiCallbackDispatcher.method = method; + return true; +} + +void getKoalaEtsNapiCallbackDispatcher(ets_class* clazz, ets_method* method) { + *clazz = g_koalaEtsNapiCallbackDispatcher.clazz; + *method = g_koalaEtsNapiCallbackDispatcher.method; +} +#endif + +#ifdef KOALA_JNI +#include "jni.h" +static struct { + jclass clazz = nullptr; + jmethodID method = nullptr; +} g_koalaJniCallbackDispatcher; + +bool setKoalaJniCallbackDispatcher( + JNIEnv* jniEnv, + jclass clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +) { + g_koalaJniCallbackDispatcher.clazz = clazz; + jniEnv->NewGlobalRef(clazz); + jmethodID method = jniEnv->GetStaticMethodID( + clazz, dispatcherMethodName, dispactherMethodSig + ); + if (method == nullptr) { + return false; + } + g_koalaJniCallbackDispatcher.method = method; + return true; +} + +void getKoalaJniCallbackDispatcher(jclass* clazz, jmethodID* method) { + *clazz = g_koalaJniCallbackDispatcher.clazz; + *method = g_koalaJniCallbackDispatcher.method; +} +#endif + +KInt impl_StringLength(KNativePointer ptr) { + string* s = reinterpret_cast(ptr); + return s->length(); +} +KOALA_INTEROP_1(StringLength, KInt, KNativePointer) + +void impl_StringData(KNativePointer ptr, KByte* bytes, KUInt size) { + string* s = reinterpret_cast(ptr); + if (s) memcpy(bytes, s->c_str(), size); +} +KOALA_INTEROP_V3(StringData, KNativePointer, KByte*, KUInt) + + +#ifdef KOALA_JNI +// For Java only yet. +KInteropBuffer impl_StringDataBytes(KVMContext vmContext, KNativePointer ptr) { + string* s = reinterpret_cast(ptr); + KInteropBuffer result = { (int32_t)s->length(), (void*)s->c_str()}; + return result; +} +KOALA_INTEROP_CTX_1(StringDataBytes, KInteropBuffer, KNativePointer) +#endif + +KNativePointer impl_StringMake(const KStringPtr& str) { + return new string(str.c_str()); +} +KOALA_INTEROP_1(StringMake, KNativePointer, KStringPtr) + +// For slow runtimes w/o fast encoders. +KInt impl_ManagedStringWrite(const KStringPtr& string, KByte* buffer, KInt offset) { + memcpy(buffer + offset, string.c_str(), string.length() + 1); + return string.length() + 1; +} +KOALA_INTEROP_3(ManagedStringWrite, KInt, KStringPtr, KByte*, KInt) + +void stringFinalizer(string* ptr) { + delete ptr; +} +KNativePointer impl_GetStringFinalizer() { + return fnPtr(stringFinalizer); +} +KOALA_INTEROP_0(GetStringFinalizer, KNativePointer) + +void impl_InvokeFinalizer(KNativePointer obj, KNativePointer finalizer) { + auto finalizer_f = reinterpret_cast(finalizer); + finalizer_f(obj); +} +KOALA_INTEROP_V2(InvokeFinalizer, KNativePointer, KNativePointer) + +KInt impl_GetPtrVectorSize(KNativePointer ptr) { + return reinterpret_cast*>(ptr)->size(); +} +KOALA_INTEROP_1(GetPtrVectorSize, KInt, KNativePointer) + +KNativePointer impl_GetPtrVectorElement(KNativePointer ptr, KInt index) { + auto vector = reinterpret_cast*>(ptr); + auto element = vector->at(index); + return nativePtr(element); +} +KOALA_INTEROP_2(GetPtrVectorElement, KNativePointer, KNativePointer, KInt) + +inline KUInt unpackUInt(const KByte* bytes) { + return (bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24)); +} + +std::vector makeStringVector(KStringArray strArray) { + if (strArray == nullptr) { + return std::vector(0); + } + KUInt arraySize = unpackUInt(strArray); + std::vector res(arraySize); + size_t offset = sizeof(KUInt); + for (KUInt i = 0; i < arraySize; ++i) { + int len = unpackUInt(strArray + offset); + res[i].assign((const char*)(strArray + offset + sizeof(KUInt)), len); + offset += len + sizeof(KUInt); + } + return res; +} + +std::vector makeStringVector(KNativePointerArray arr, KInt length) { + if (arr == nullptr) { + return std::vector(0); + } else { + std::vector res(length); + char** strings = reinterpret_cast(arr); + for (KInt i = 0; i < length; ++i) { + const char* str = reinterpret_cast(strings[i]); + res[i].assign(str); + } + return res; + } +} + +KNativePointer impl_GetGroupedLog(KInt index) { + return new std::string(GetDefaultLogger()->getGroupedLog(index)); +} +KOALA_INTEROP_1(GetGroupedLog, KNativePointer, KInt) + +void impl_StartGroupedLog(KInt index) { + GetDefaultLogger()->startGroupedLog(index); +} +KOALA_INTEROP_V1(StartGroupedLog, KInt) + +void impl_StopGroupedLog(KInt index) { + GetDefaultLogger()->stopGroupedLog(index); +} +KOALA_INTEROP_V1(StopGroupedLog, KInt) + +void impl_AppendGroupedLog(KInt index, const KStringPtr& message) { + if (GetDefaultLogger()->needGroupedLog(index)) + GetDefaultLogger()->appendGroupedLog(index, message.c_str()); +} +KOALA_INTEROP_V2(AppendGroupedLog, KInt, KStringPtr) + +void impl_PrintGroupedLog(KInt index) { +#ifdef KOALA_OHOS + LOGI("%" LOG_PUBLIC "s", GetDefaultLogger()->getGroupedLog(index)); +#else + fprintf(stdout, "%s\n", GetDefaultLogger()->getGroupedLog(index)); + fflush(stdout); +#endif +} +KOALA_INTEROP_V1(PrintGroupedLog, KInt) + +int32_t callCallback(KVMContext context, int32_t methodId, uint8_t* argsData, int32_t argsLength) { +#if KOALA_USE_NODE_VM || KOALA_USE_HZ_VM || KOALA_USE_PANDA_VM || KOALA_USE_JAVA_VM || KOALA_CJ + KOALA_INTEROP_CALL_INT(context, methodId, argsLength, argsData); +#else + return 0; +#endif +} + +struct ForeignVMContext { + KVMContext vmContext; + int32_t (*callSync)(KVMContext vmContext, int32_t callback, uint8_t* data, int32_t length); +}; +typedef KInt (*LoadVirtualMachine_t)(KInt vmKind, const char* classPath, const char* libraryPath, const struct ForeignVMContext* foreignVM); +typedef KNativePointer (*StartApplication_t)(const char* appUrl, const char* appParams); +typedef KBoolean (*RunApplication_t)(const KInt arg0, const KInt arg1); +typedef const char* (*EmitEvent_t)(const KInt type, const KInt target, const KInt arg0, const KInt arg1); +typedef void (*RestartWith_t)(const char* page); + +void* getImpl(const char* path, const char* name) { + static void* lib = nullptr; + if (!lib && name) { + auto name = +#ifndef KOALA_OHOS // dlopen on OHOS doesn't like paths + std::string(path) + "/" + +#endif + libName("vmloader"); + lib = loadLibrary(name); + if (!lib) { + fprintf(stderr, "Ensure vmloader library %s was built\n", name.c_str()); + } + } + return findSymbol(lib, name); +} + +KInt impl_LoadVirtualMachine(KVMContext vmContext, KInt vmKind, const KStringPtr& classPath, const KStringPtr& libraryPath) { + const char* envClassPath = std::getenv("PANDA_CLASS_PATH"); + if (envClassPath) { + LOGI("CLASS PATH updated from env var PANDA_CLASS_PATH, %" LOG_PUBLIC "s", envClassPath); + } + const char* appClassPath = envClassPath ? envClassPath : classPath.c_str(); + const char* nativeLibPath = envClassPath ? envClassPath : libraryPath.c_str(); + + static LoadVirtualMachine_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nativeLibPath, "LoadVirtualMachine")); + if (!impl) KOALA_INTEROP_THROW_STRING(vmContext, "Cannot load VM", -1); + const ForeignVMContext foreignVM = { + vmContext, &callCallback + }; + return impl(vmKind, appClassPath, nativeLibPath, &foreignVM); +} +KOALA_INTEROP_CTX_3(LoadVirtualMachine, KInt, KInt, KStringPtr, KStringPtr) + +KNativePointer impl_StartApplication(const KStringPtr& appUrl, const KStringPtr& appParams) { + static StartApplication_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nullptr, "StartApplication")); + return impl(appUrl.c_str(), appParams.c_str()); +} +KOALA_INTEROP_2(StartApplication, KNativePointer, KStringPtr, KStringPtr) + +KBoolean impl_RunApplication(const KInt arg0, const KInt arg1) { + static RunApplication_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nullptr, "RunApplication")); + return impl(arg0, arg1); +} +KOALA_INTEROP_2(RunApplication, KBoolean, KInt, KInt) + +KStringPtr impl_EmitEvent(KVMContext vmContext, KInt type, KInt target, KInt arg0, KInt arg1) { + static EmitEvent_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nullptr, "EmitEvent")); + const char* out = impl(type, target, arg0, arg1); + auto size = std::string(out).size(); + KStringPtr result(out, size, true); + return result; +} +KOALA_INTEROP_CTX_4(EmitEvent, KStringPtr, KInt, KInt, KInt, KInt) + +void impl_RestartWith(const KStringPtr& page) { + static RestartWith_t impl = nullptr; + if (!impl) impl = reinterpret_cast(getImpl(nullptr, "RestartWith")); + impl(page.c_str()); +} +KOALA_INTEROP_V1(RestartWith, KStringPtr) + +static Callback_Caller_t g_callbackCaller = nullptr; +void setCallbackCaller(Callback_Caller_t callbackCaller) { + g_callbackCaller = callbackCaller; +} + +void impl_CallCallback(KInt callbackKind, KByte* args, KInt argsSize) { + if (g_callbackCaller) { + g_callbackCaller(callbackKind, args, argsSize); + } +} +KOALA_INTEROP_V3(CallCallback, KInt, KByte*, KInt) + +static Callback_Caller_Sync_t g_callbackCallerSync = nullptr; +void setCallbackCallerSync(Callback_Caller_Sync_t callbackCallerSync) { + g_callbackCallerSync = callbackCallerSync; +} + +void impl_CallCallbackSync(KVMContext vmContext, KInt callbackKind, KByte* args, KInt argsSize) { + if (g_callbackCallerSync) { + g_callbackCallerSync(vmContext, callbackKind, args, argsSize); + } +} +KOALA_INTEROP_CTX_V3(CallCallbackSync, KInt, KByte*, KInt) + +void impl_CallCallbackResourceHolder(KNativePointer holder, KInt resourceId) { + reinterpret_cast(holder)(resourceId); +} +KOALA_INTEROP_V2(CallCallbackResourceHolder, KNativePointer, KInt) + +void impl_CallCallbackResourceReleaser(KNativePointer releaser, KInt resourceId) { + reinterpret_cast(releaser)(resourceId); +} +KOALA_INTEROP_V2(CallCallbackResourceReleaser, KNativePointer, KInt) + +KInt impl_CallForeignVM(KNativePointer foreignContextRaw, KInt function, KByte* data, KInt length) { + const ForeignVMContext* foreignContext = (const ForeignVMContext*)foreignContextRaw; + // TODO: set actuall callbacks caller/holder/releaser. + /* + *(int64_t*)(data + 8) = impl_CallCallbackSync; + *(int64_t*)(data + 16) = 0; + *(int64_t*)(data + 24) = 0; */ + return foreignContext->callSync(foreignContext->vmContext, function, data, length); +} +KOALA_INTEROP_4(CallForeignVM, KInt, KNativePointer, KInt, KByte*, KInt) + + +#define __QUOTE(x) #x +#define QUOTE(x) __QUOTE(x) + +void impl_NativeLog(const KStringPtr& str) { +#ifdef KOALA_OHOS + LOGI("%{public}s: %{public}s", QUOTE(INTEROP_LIBRARY_NAME), str.c_str()); +#else + fprintf(stdout, "%s: %s\n", QUOTE(INTEROP_LIBRARY_NAME), str.c_str()); + fflush(stdout); +#endif +} +KOALA_INTEROP_V1(NativeLog, KStringPtr) + + + +void resolveDeferred(KVMDeferred* deferred, uint8_t* argsData, int32_t argsLength) { +#ifdef KOALA_NAPI + auto status = napi_call_threadsafe_function((napi_threadsafe_function)deferred->handler, deferred, napi_tsfn_nonblocking); + if (status != napi_ok) LOGE("cannot call thread-safe function; status=%d", status); + napi_release_threadsafe_function((napi_threadsafe_function)deferred->handler, napi_tsfn_release); +#endif +} + +void rejectDeferred(KVMDeferred* deferred, const char* message) { +#ifdef KOALA_NAPI + napi_release_threadsafe_function((napi_threadsafe_function)deferred->handler, napi_tsfn_release); + delete deferred; +#endif +} + +#ifdef KOALA_NAPI +void resolveDeferredImpl(napi_env env, napi_value js_callback, KVMDeferred* deferred, void* data) { + napi_value undefined = nullptr; + napi_get_undefined(env, &undefined); + auto status = napi_resolve_deferred(env, (napi_deferred)deferred->context, undefined); + if (status != napi_ok) LOGE("cannot resolve deferred; status=%d", status); + delete deferred; +} +#endif + +KVMDeferred* CreateDeferred(KVMContext vmContext, KVMObjectHandle* promiseHandle) { + KVMDeferred* deferred = new KVMDeferred(); + deferred->resolve = resolveDeferred; + deferred->reject = rejectDeferred; +#ifdef KOALA_NAPI + // TODO: move to interop! + napi_env env = (napi_env)vmContext; + napi_value promise; + napi_value resourceName; + napi_create_string_utf8(env, "Async", 5, &resourceName); + auto status = napi_create_promise(env, (napi_deferred*)&deferred->context, &promise); + if (status != napi_ok) LOGE("cannot make a promise; status=%d", status); + status = napi_create_threadsafe_function(env, + nullptr, + nullptr, + resourceName, + 0, + 1, + nullptr, + nullptr, + deferred, + (napi_threadsafe_function_call_js)resolveDeferredImpl, + (napi_threadsafe_function*)&deferred->handler); + if (status != napi_ok) LOGE("cannot make threadsafe function; status=%d", status); + *promiseHandle = (KVMObjectHandle)promise; +#endif + return deferred; +} + +#if defined(KOALA_ETS_NAPI) || defined(KOALA_NAPI) || defined(KOALA_JNI) || defined(KOALA_CJ) +// Allocate, so CTX versions. +KStringPtr impl_Utf8ToString(KVMContext vmContext, KByte* data, KInt offset, KInt length) { + KStringPtr result((const char*)(data + offset), length, false); + return result; +} +KOALA_INTEROP_CTX_3(Utf8ToString, KStringPtr, KByte*, KInt, KInt) + +KStringPtr impl_StdStringToString(KVMContext vmContext, KNativePointer stringPtr) { + std::string* string = reinterpret_cast(stringPtr); + KStringPtr result(string->c_str(), string->size(), false); + return result; +} +KOALA_INTEROP_CTX_1(StdStringToString, KStringPtr, KNativePointer) +#endif + +#if defined(KOALA_JNI) || defined(KOALA_NAPI) || defined(KOALA_CJ) +KInteropReturnBuffer impl_RawReturnData(KVMContext vmContext, KInt v1, KInt v2) { + void* data = new int8_t[v1]; + memset(data, v2, v1); + KInteropReturnBuffer buffer = { v1, data, [](KNativePointer ptr, KInt) { delete[] (int8_t*)ptr; }}; + return buffer; +} +KOALA_INTEROP_CTX_2(RawReturnData, KInteropReturnBuffer, KInt, KInt) +#endif diff --git a/koala-wrapper/koalaui/interop/src/cpp/common-interop.h b/koala-wrapper/koalaui/interop/src/cpp/common-interop.h new file mode 100644 index 000000000..abc8ebfd0 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/common-interop.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2022-2025 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 COMMON_INTEROP_BASE_H +#define COMMON_INTEROP_BASE_H + +#include + +#include "koala-types.h" + +#define KOALA_INTEROP_PROFILER 0 +#define KOALA_INTEROP_TRACER 0 + +#if KOALA_INTEROP_PROFILER +#include "profiler.h" +#define KOALA_INTEROP_LOGGER(name) InteropMethodCall logger(#name); +#endif + +#if KOALA_INTEROP_TRACER +#include "tracer.h" +#define KOALA_INTEROP_LOGGER(name) InteropMethodCall logger(#name); +#endif + + +#ifdef KOALA_INTEROP_LOGGER +#define KOALA_MAYBE_LOG(name) KOALA_INTEROP_LOGGER(name); +#else +#define KOALA_MAYBE_LOG(name) +#endif + +typedef void (*Callback_Caller_t)(KInt callbackKind, KByte* argsData, KInt argsLength); +typedef void (*Callback_Caller_Sync_t)(KVMContext vmContext, KInt callbackKind, KByte* argsData, KInt argsLength); +void setCallbackCaller(Callback_Caller_t caller); +void setCallbackCallerSync(Callback_Caller_Sync_t callerSync); + +KVMDeferred* CreateDeferred(KVMContext context, KVMObjectHandle* promise); + +std::vector makeStringVector(KStringArray strArray); +std::vector makeStringVector(KNativePointerArray arr, KInt size); + +#if KOALA_USE_NODE_VM || KOALA_USE_HZ_VM +#include "convertors-napi.h" +#elif KOALA_USE_JSC_VM +#include "convertors-jsc.h" +#elif KOALA_ETS_NAPI +#include "convertors-ets.h" +#elif KOALA_USE_JAVA_VM +#include "convertors-jni.h" +#elif KOALA_WASM +#include "convertors-wasm.h" +#elif KOALA_CJ +#include "convertors-cj.h" +#elif KOALA_ANI +#include "convertors-ani.h" +#else +#error "One of above branches must be taken" +#endif + +#endif // COMMON_INTEROP_BASE_H diff --git a/koala-wrapper/koalaui/interop/src/cpp/crashdump.h b/koala-wrapper/koalaui/interop/src/cpp/crashdump.h new file mode 100644 index 000000000..7d1bac040 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/crashdump.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 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 _INTEROP_CRASHDUMP_H +#define _INTEROP_CRASHDUMP_H + +#ifdef KOALA_LINUX +#include +#include + +sighandler_t oldCrashHandler = nullptr; + +static void onCrashHandler(int signo) { + void* stack[20]; + size_t size = backtrace(stack, 20); + backtrace_symbols_fd(stack, size, STDERR_FILENO); + if (oldCrashHandler) oldCrashHandler(signo); +} + +static void installCrashHandlers() { + static bool installed = false; + if (!installed) { + oldCrashHandler = signal(SIGSEGV, onCrashHandler); + installed = true; + } +} +#else +static void installCrashHandlers() {} +#endif + +#endif // _INTEROP_CRASHDUMP_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/dynamic-loader.h b/koala-wrapper/koalaui/interop/src/cpp/dynamic-loader.h new file mode 100644 index 000000000..f354a4f25 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/dynamic-loader.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2025 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 _DYNAMIC_LOADER_H +#define _DYNAMIC_LOADER_H + +#include + +#ifdef KOALA_WINDOWS +#include +// Here we need to find module where GetArkUINodeAPI() +// function is implemented. +inline void* loadLibrary(const std::string& libPath) { + return LoadLibraryA(libPath.c_str()); +} + +inline const char* libraryError() { + static char error[256]; + snprintf(error, sizeof error, "error %lu", GetLastError()); + return error; +} + +inline void* findSymbol(void* library, const char* name) { + return (void*)GetProcAddress(reinterpret_cast(library), name); +} + +inline std::string libName(const char* lib) { + return std::string(lib) + ".dll"; +} + +#elif defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_OHOS) +#include + +inline void* loadLibrary(const std::string& libPath) { + void* handle = dlopen(libPath.c_str(), RTLD_LOCAL | RTLD_NOW); + if (!handle) { + return nullptr; + } + return handle; +} + +inline const char* libraryError() { + return dlerror(); +} + +inline std::string symbolName(const char* name) { + return name; +} + +inline void* findSymbol(void* library, const char* name) { + return dlsym(library, symbolName(name).c_str()); +} + +inline std::string libName(const char* lib) { + std::string result; + std::string suffix = +#ifdef KOALA_MACOS + ".dylib" +#else + ".so" +#endif + ; + result = "lib" + std::string(lib) + suffix; + return result; +} + +#else + +#include + +inline void* loadLibrary(const std::string& libPath) { + fprintf(stderr, "No loadLibrary() on this platform\n"); + return nullptr; +} + +inline const char* libraryError() { + fprintf(stderr, "No libraryError() on this platform\n"); + return nullptr; +} + +inline std::string symbolName(const char* name) { + fprintf(stderr, "No symbolName() on this platform\n"); + return ""; +} + +inline void* findSymbol(void* library, const char* name) { + fprintf(stderr, "No findSymbol() on this platform\n"); + return nullptr; +} + +inline std::string libName(const char* lib) { + fprintf(stderr, "No libName() on this platform\n"); + return ""; +} + +#endif + +#endif // _DYNAMIC_LOADER_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.cc b/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.cc new file mode 100644 index 000000000..450804338 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.cc @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2022-2025 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 +#include "convertors-ets.h" +#include "signatures.h" +#include "interop-logging.h" +#include "interop-types.h" + +static const char* callCallbackFromNative = "callCallbackFromNative"; +static const char* callCallbackFromNativeSig = "I[BI:I"; + +static const char* FAST_NATIVE_PREFIX = "#F$"; + +const bool registerByOne = true; + +static bool registerNatives(ets_env *env, const ets_class clazz, const std::vector> impls) { + std::vector methods; + methods.reserve(impls.size()); + bool result = true; + for (const auto &[name, type, func, flag] : impls) { + EtsNativeMethod method; + method.name = name.c_str(); + method.func = func; + method.signature = (flag & ETS_SLOW_NATIVE_FLAG) == 0 ? FAST_NATIVE_PREFIX : nullptr; + if (registerByOne) { + result &= env->RegisterNatives(clazz, &method, 1) >= 0; + if (env->ErrorCheck()) { + //env->ErrorDescribe(); + env->ErrorClear(); + } + } + else { + methods.push_back(method); + } + } + if (!registerByOne) { + result = env->RegisterNatives(clazz, methods.data(), static_cast(methods.size())) >= 0; + } + return registerByOne ? true : result; +} + +bool registerAllModules(ets_env *env) { + auto moduleNames = EtsExports::getInstance()->getModules(); + + for (auto it = moduleNames.begin(); it != moduleNames.end(); ++it) { + std::string classpath = EtsExports::getInstance()->getClasspath(*it); + ets_class nativeModule = env->FindClass(classpath.c_str()); + if (nativeModule == nullptr) { + LOGE("Cannot find managed class %s", classpath.c_str()); + continue; + } + if (!registerNatives(env, nativeModule, EtsExports::getInstance()->getMethods(*it))) { + return false; + } + } + + return true; +} + +extern "C" ETS_EXPORT ets_int ETS_CALL EtsNapiOnLoad(ets_env *env) { + if (!registerAllModules(env)) { + LOGE("Failed to register ets modules"); + return ETS_ERR; + } + auto interopClasspath = EtsExports::getInstance()->getClasspath("InteropNativeModule"); + auto interopClass = env->FindClass(interopClasspath.c_str()); + if (interopClass == nullptr) { + LOGE("Can not find InteropNativeModule classpath to set callback dispatcher"); + return ETS_ERR; + } + if (!setKoalaEtsNapiCallbackDispatcher(env, interopClass, callCallbackFromNative, callCallbackFromNativeSig)) { + LOGE("Failed to set koala ets callback dispatcher"); + return ETS_ERR; + } + return ETS_NAPI_VERSION_1_0; +} + +EtsExports* EtsExports::getInstance() { + static EtsExports *instance = nullptr; + if (instance == nullptr) { + instance = new EtsExports(); + } + return instance; +} + +std::vector EtsExports::getModules() { + std::vector result; + for (auto it = implementations.begin(); it != implementations.end(); ++it) { + result.push_back(it->first); + } + return result; +} + +const std::vector>& EtsExports::getMethods(const std::string& module) { + auto it = implementations.find(module); + if (it == implementations.end()) { + LOGE("Module %s is not registered", module.c_str()); + } + return it->second; +} + +void EtsExports::addMethod(const char* module, const char *name, const char *type, void *impl, int flags) { + auto it = implementations.find(module); + if (it == implementations.end()) { + it = implementations.insert(std::make_pair(module, std::vector>())).first; + } + it->second.push_back(std::make_tuple(name, convertType(name, type), impl, flags)); +} + +void EtsExports::setClasspath(const char* module, const char *classpath) { + auto it = classpaths.find(module); + if (it == classpaths.end()) { + classpaths.insert(std::make_pair(module, classpath)); + } else { + LOGE("Classpath for module %s was redefined", module); + } +} + +static std::map g_defaultClasspaths = { + {"InteropNativeModule", "@koalaui/interop/InteropNativeModule/InteropNativeModule"}, + // todo leave just InteropNativeModule, define others via KOALA_ETS_INTEROP_MODULE_CLASSPATH + {"TestNativeModule", "@koalaui/arkts-arkui/generated/arkts/TestNativeModule/TestNativeModule"}, + {"ArkUINativeModule", "@koalaui/arkts-arkui/generated/arkts/ArkUINativeModule/ArkUINativeModule"}, + {"ArkUIGeneratedNativeModule", "@koalaui/arkts-arkui/generated/arkts/ArkUIGeneratedNativeModule/ArkUIGeneratedNativeModule"}, +}; +const std::string& EtsExports::getClasspath(const std::string& module) { + auto it = classpaths.find(module); + if (it != classpaths.end()) { + return it->second; + } + auto defaultClasspath = g_defaultClasspaths.find(module); + if (defaultClasspath != g_defaultClasspaths.end()) { + return defaultClasspath->second; + } + INTEROP_FATAL("Classpath for module %s was not registered", module.c_str()); +} diff --git a/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.h b/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.h new file mode 100644 index 000000000..c03b5af27 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.h @@ -0,0 +1,1349 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +#pragma once + +#ifdef KOALA_ETS_NAPI + +#include +#include +#include +#include +#include +#include +#include + +#include "etsapi.h" +#include "koala-types.h" + +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(EtsEnv* env, InteropType value) { return value; } + static InteropType convertTo(EtsEnv* env, T value) { return value; } + static void release(EtsEnv* env, InteropType value, T converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_string; + static KStringPtr convertFrom(EtsEnv* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + KStringPtr result; + // Notice that we use UTF length for buffer size, but counter is expressed in number of Unicode chars. + result.resize(env->GetStringUTFLength(value)); + env->GetStringUTFRegion(value, 0, env->GetStringLength(value), result.data()); + return result; + } + static InteropType convertTo(EtsEnv* env, const KStringPtr& value) { + return env->NewStringUTF(value.c_str()); + } + static void release(EtsEnv* env, InteropType value, const KStringPtr& converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_long; + static KNativePointer convertFrom(EtsEnv* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(EtsEnv* env, KNativePointer value) { + return reinterpret_cast(value); + } + static void release(EtsEnv* env, InteropType value, KNativePointer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_intArray; + static KInt* convertFrom(EtsEnv* env, InteropType value) { + if (!value) return nullptr; + return env->PinIntArray(value); + } + static InteropType convertTo(EtsEnv* env, KInt* value) = delete; + static void release(EtsEnv* env, InteropType value, KInt* converted) { + if (value) env->UnpinIntArray(value); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_floatArray; + static KFloat* convertFrom(EtsEnv* env, InteropType value) { + if (!value) return nullptr; + return env->PinFloatArray(value); + } + static InteropType convertTo(EtsEnv* env, KFloat* value) = delete; + static void release(EtsEnv* env, InteropType value, KFloat* converted) { + if (value) env->UnpinFloatArray(value); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_byteArray; + static KByte* convertFrom(EtsEnv* env, InteropType value) { + if (!value) return nullptr; + return (KByte*)env->PinByteArray(value); + } + static InteropType convertTo(EtsEnv* env, KByte* value) = delete; + static void release(EtsEnv* env, InteropType value, KByte* converted) { + if (value) env->UnpinByteArray((ets_byteArray)value); + } +}; + +template <> struct InteropTypeConverter { + using InteropType = ets_double; + static KInteropNumber convertFrom(EtsEnv *env, InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(EtsEnv *env, KInteropNumber value) { + return value.asDouble(); + } + static void release(EtsEnv *env, InteropType value, + KInteropNumber converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = ets_object; + static KLength convertFrom(EtsEnv* env, InteropType value) { + const static ets_class double_class = reinterpret_cast(env->NewGlobalRef(env->FindClass("std/core/Double"))); + const static ets_class int_class = reinterpret_cast(env->NewGlobalRef(env->FindClass("std/core/Int"))); + const static ets_class string_class = reinterpret_cast(env->NewGlobalRef(env->FindClass("std/core/String"))); + const static ets_class resource_class = reinterpret_cast( + env->NewGlobalRef(env->FindClass("@koalaui/arkts-arkui/generated/ArkResourceInterfaces/Resource"))); + + if (env->IsInstanceOf(value, double_class)) { + const static ets_method double_p = env->Getp_method(double_class, "unboxed", ":D"); + return KLength{ 1, (KFloat)env->CallDoubleMethod(value, double_p), 1, 0 }; + } else if (env->IsInstanceOf(value, int_class)) { + const static ets_method int_p = env->Getp_method(int_class, "unboxed", ":I"); + return KLength{ 1, (KFloat)env->CallIntMethod(value, int_p), 1, 0 }; + } else if (env->IsInstanceOf(value, string_class)) { + KStringPtr ptr = InteropTypeConverter::convertFrom(env, reinterpret_cast(value)); + KLength length = { 0 }; + parseKLength(ptr, &length); + length.type = 2; + length.resource = 0; + return length; + } else if (env->IsInstanceOf(value, resource_class)) { + const static ets_method resource_p = env->Getp_method(resource_class, "id", ":D"); + return KLength{ 3, 0, 1, (KInt)env->CallDoubleMethod(value, resource_p) }; + } else { + return KLength( { 0, 0, 0, 0}); + } + } + static InteropType convertTo(EtsEnv* env, KLength value) = delete; + static void release(EtsEnv* env, InteropType value, const KLength& converted) {} +}; + +template +inline typename InteropTypeConverter::InteropType makeResult(EtsEnv* env, Type value) { + return InteropTypeConverter::convertTo(env, value); +} + +template +inline Type getArgument(EtsEnv* env, typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(env, arg); +} + +template +inline void releaseArgument(EtsEnv* env, typename InteropTypeConverter::InteropType arg, Type& data) { + InteropTypeConverter::release(env, arg, data); +} + +#define ETS_SLOW_NATIVE_FLAG 1 + +class EtsExports { + std::unordered_map>> implementations; + std::unordered_map classpaths; + +public: + static EtsExports* getInstance(); + + std::vector getModules(); + void addMethod(const char* module, const char* name, const char* type, void* impl, int flags); + const std::vector>& getMethods(const std::string& module); + + void setClasspath(const char* module, const char* classpath); + const std::string& getClasspath(const std::string& module); +}; + +#define KOALA_QUOTE0(x) #x +#define KOALA_QUOTE(x) KOALA_QUOTE0(x) + +#ifdef _MSC_VER +#define MAKE_ETS_EXPORT(module, name, type, flag) \ + static void __init_##name() { \ + EtsExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Ark_##name), flag); \ + } \ + namespace { \ + struct __Init_##name { \ + __Init_##name() { __init_##name(); } \ + } __Init_##name##_v; \ + } +#define KOALA_ETS_INTEROP_MODULE_CLASSPATH(module, classpath) \ + static void __init_classpath_##module() { \ + EtsExports::getInstance()->setClasspath(KOALA_QUOTE(module), classpath); \ + } \ + namespace { \ + struct __Init_classpath_##module { \ + __Init_classpath_##module() { __init_classpath_##module(); } \ + } __Init_classpath_##module##_v; \ + } +#else +#define MAKE_ETS_EXPORT(module, name, type, flag) \ + __attribute__((constructor)) \ + static void __init_ets_##name() { \ + EtsExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Ark_##name), flag); \ + } +#define KOALA_ETS_INTEROP_MODULE_CLASSPATH(module, classpath) \ + __attribute__((constructor)) \ + static void __init_ets_classpath_##module() { \ + EtsExports::getInstance()->setClasspath(KOALA_QUOTE(module), classpath); \ + } +#endif + +#define KOALA_INTEROP_0(name, Ret) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(env, impl_##name()); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, 0) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + auto rv = makeResult(env, impl_##name(p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, 0) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + auto rv = makeResult(env, impl_##name(p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ +InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + return rv; \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + return rv; \ + } \ + MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + auto rv = makeResult(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V0(name) \ + void Ark_##name(EtsEnv *env) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void", 0) + +#define KOALA_INTEROP_V1(name, P0) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + impl_##name(p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0, 0) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + impl_##name(p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1, 0) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + impl_##name(p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2, 0) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + impl_##name(p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3, 0) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, 0) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5, 0) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6, 0) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7, 0) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8, 0) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9, 0) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10, 0) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11, 0) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12, 0) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13, 0) + +#define KOALA_INTEROP_V15(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13, \ + InteropTypeConverter::InteropType _p14) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + P14 p14 = getArgument(env, _p14); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + releaseArgument(env, _p14, p14); \ +} \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13 "|" #P14, 0) + +#define KOALA_INTEROP_CTX_0(name, Ret) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx)); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ + InteropTypeConverter::InteropType Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = makeResult(env, impl_##name(ctx, p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V0(name) \ + void Ark_##name(EtsEnv *env, ets_class clazz) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void", ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V1(name, P0) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3, ETS_SLOW_NATIVE_FLAG) + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ + void Ark_##name(EtsEnv *env, ets_class clazz, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + } \ +MAKE_ETS_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4, ETS_SLOW_NATIVE_FLAG) + +bool setKoalaEtsNapiCallbackDispatcher( + EtsEnv* etsEnv, + ets_class clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +); +void getKoalaEtsNapiCallbackDispatcher(ets_class* clazz, ets_method* method); + +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ + ets_class clazz = nullptr; \ + ets_method method = nullptr; \ + getKoalaEtsNapiCallbackDispatcher(&clazz, &method); \ + EtsEnv* etsEnv = reinterpret_cast(vmContext); \ + etsEnv->PushLocalFrame(1); \ + ets_byteArray args_ets = etsEnv->NewByteArray(length); \ + etsEnv->SetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ + etsEnv->CallStaticIntMethod(clazz, method, id, args_ets, length); \ + etsEnv->GetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ + etsEnv->PopLocalFrame(nullptr); \ +} + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + ets_class clazz = nullptr; \ + ets_method method = nullptr; \ + getKoalaEtsNapiCallbackDispatcher(&clazz, &method); \ + EtsEnv* etsEnv = reinterpret_cast(venv); \ + etsEnv->PushLocalFrame(1); \ + ets_byteArray args_ets = etsEnv->NewByteArray(length); \ + etsEnv->SetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ + int32_t rv = etsEnv->CallStaticIntMethod(clazz, method, id, args_ets, length); \ + etsEnv->GetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ + etsEnv->PopLocalFrame(nullptr); \ + return rv; \ +} + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + EtsEnv* env = reinterpret_cast(vmContext); \ + env->ThrowError(object); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + EtsEnv* env = reinterpret_cast(vmContext); \ + const static ets_class errorClass = env->FindClass("std/core/Error"); \ + env->ThrowErrorNew(errorClass, message); \ + } while (0) + +#endif // KOALA_ETS_NAPI diff --git a/koala-wrapper/koalaui/interop/src/cpp/ets/etsapi.h b/koala-wrapper/koalaui/interop/src/cpp/ets/etsapi.h new file mode 100644 index 000000000..15868ee90 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/ets/etsapi.h @@ -0,0 +1,1545 @@ +/** + * Copyright (c) 2021-2025 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 PANDA_RUNTIME_INTEROP_ETS_NAPI_H +#define PANDA_RUNTIME_INTEROP_ETS_NAPI_H + +// NOLINTBEGIN(modernize-use-using, readability-identifier-naming, cppcoreguidelines-pro-type-vararg) + +#ifdef __cplusplus +#include +#include +#else +#include +#include +#endif + +// NOLINTBEGIN(cppcoreguidelines-macro-usage) + +// Version Constants +#define ETS_NAPI_VERSION_1_0 0x00010000 + +// General return value constants +#define ETS_OK 0 // success +#define ETS_ERR (-1) // unknown error +#define ETS_ERR_VER (-2) // ETS version error +#define ETS_ERR_NOMEM (-3) // not enough memory +#define ETS_ERR_EXIST (-4) // VM already created +#define ETS_ERR_INVAL (-5) // invalid arguments + +// Boolean Constants +#define ETS_FALSE 0 +#define ETS_TRUE 1 + +// Mode Constants +#define ETS_COMMIT 1 +#define ETS_ABORT 2 + +// NOLINTEND(cppcoreguidelines-macro-usage) + +// Primitive Types +typedef uint8_t ets_boolean; +typedef int8_t ets_byte; +typedef uint16_t ets_char; +typedef int16_t ets_short; +typedef int32_t ets_int; +typedef int64_t ets_long; +typedef float ets_float; +typedef double ets_double; +typedef ets_int ets_size; + +// Reference Types +#ifdef __cplusplus +class __ets_object {}; +class __ets_class : public __ets_object {}; +class __ets_string : public __ets_object {}; +class __ets_array : public __ets_object {}; +class __ets_objectArray : public __ets_array {}; +class __ets_booleanArray : public __ets_array {}; +class __ets_byteArray : public __ets_array {}; +class __ets_charArray : public __ets_array {}; +class __ets_shortArray : public __ets_array {}; +class __ets_intArray : public __ets_array {}; +class __ets_longArray : public __ets_array {}; +class __ets_floatArray : public __ets_array {}; +class __ets_doubleArray : public __ets_array {}; +class __ets_error : public __ets_object {}; + +typedef __ets_object *ets_object; +typedef __ets_class *ets_class; +typedef __ets_string *ets_string; +typedef __ets_array *ets_array; +typedef __ets_objectArray *ets_objectArray; +typedef __ets_booleanArray *ets_booleanArray; +typedef __ets_byteArray *ets_byteArray; +typedef __ets_charArray *ets_charArray; +typedef __ets_shortArray *ets_shortArray; +typedef __ets_intArray *ets_intArray; +typedef __ets_longArray *ets_longArray; +typedef __ets_floatArray *ets_floatArray; +typedef __ets_doubleArray *ets_doubleArray; +typedef __ets_error *ets_error; +typedef __ets_object *ets_weak; + +#else // __cplusplus + +struct __ets_object; +typedef struct __ets_object *ets_object; +typedef ets_object ets_class; +typedef ets_object ets_string; +typedef ets_object ets_error; +typedef ets_object ets_weak; +typedef ets_object ets_array; +typedef ets_array ets_objectArray; +typedef ets_array ets_booleanArray; +typedef ets_array ets_byteArray; +typedef ets_array ets_charArray; +typedef ets_array ets_shortArray; +typedef ets_array ets_intArray; +typedef ets_array ets_longArray; +typedef ets_array ets_floatArray; +typedef ets_array ets_doubleArray; +#endif // __cplusplus + +struct __ets_deferred; +typedef struct __ets_deferred *ets_deferred; + +// Field and Method IDs +struct __ets_method; +struct __ets_field; +typedef struct __ets_method *ets_method; +typedef struct __ets_field *ets_field; + +// The Value Type +typedef union ets_value { + ets_boolean z; + ets_byte b; + ets_char c; + ets_short s; + ets_int i; + ets_long j; + ets_float f; + ets_double d; + ets_object l; +} ets_value; + +// Describe native method by name, signature and function pointer +typedef struct { + const char *name; + const char *signature; + void *func; +} EtsNativeMethod; + +// The object reference types +typedef enum { + ETS_INVALID_REF_TYPE = 0, + ETS_LOCAL_REF_TYPE = 1, + ETS_GLOBAL_REF_TYPE = 2, + ETS_WEAK_GLOBAL_REF_TYPE = 3 +} ets_objectRefType; + +#ifdef __cplusplus +typedef struct __EtsVM EtsVM; +typedef struct __EtsEnv ets_env; +#else +typedef const struct ETS_InvokeInterface *EtsVM; +typedef const struct ETS_NativeInterface *ets_env; +#endif + +// Deprecated types: +typedef ets_env EtsEnv; + +typedef enum { + ETS_OKAY, + ETS_INVALID_ARG, + ETS_GENERIC_FAILURE, + ETS_PENDING_EXCEPTION, + ETS_INVALID_VERSION, // NOTE(v.cherkashin): This status code doesn't match to napi interface. + // Should we probably delete this status code? +} ets_status; + +// clang-format off +// Interface Function Table +struct ETS_NativeInterface { + // NOTE(a.urakov): solve the "Array" naming problem + ets_int (*GetVersion)(EtsEnv *env); +#ifdef ETS_NAPI_DESIGN_FINISHED + ets_class (*DefineClass)(EtsEnv *env, const char *name, ets_object loader, const ets_byte *buf, ets_size bufLen); +#endif + ets_class (*FindClass)(EtsEnv *env, const char *name); +#ifdef ETS_NAPI_DESIGN_FINISHED + ets_method (*FromReflectedMethod)(EtsEnv *env, ets_object method); + ets_field (*FromReflectedField)(EtsEnv *env, ets_object field); + ets_object (*ToReflectedMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ets_boolean isStatic); +#endif + ets_class (*GetSuperclass)(EtsEnv *env, ets_class cls); + ets_boolean (*IsAssignableFrom)(EtsEnv *env, ets_class cls1, ets_class cls2); +#ifdef ETS_NAPI_DESIGN_FINISHED + ets_object (*ToReflectedField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_boolean isStatic); +#endif + ets_int (*ThrowError)(EtsEnv *env, ets_error obj); + ets_int (*ThrowErrorNew)(EtsEnv *env, ets_class cls, const char *message); + ets_error (*ErrorOccurred)(EtsEnv *env); + void (*ErrorDescribe)(EtsEnv *env); + void (*ErrorClear)(EtsEnv *env); + void (*FatalError)(EtsEnv *env, const char *message); + ets_int (*PushLocalFrame)(EtsEnv *env, ets_int capacity); + ets_object (*PopLocalFrame)(EtsEnv *env, ets_object result); + ets_object (*NewGlobalRef)(EtsEnv *env, ets_object obj); + void (*DeleteGlobalRef)(EtsEnv *env, ets_object globalRef); + void (*DeleteLocalRef)(EtsEnv *env, ets_object localRef); + ets_boolean (*IsSameObject)(EtsEnv *env, ets_object ref1, ets_object ref2); + ets_object (*NewLocalRef)(EtsEnv *env, ets_object ref); + ets_int (*EnsureLocalCapacity)(EtsEnv *env, ets_int capacity); + ets_object (*AllocObject)(EtsEnv *env, ets_class cls); + ets_object (*NewObject)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_object (*NewObjectList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_object (*NewObjectArray)(EtsEnv *env, ets_class cls, ets_method p_method, const ets_value *args); + ets_class (*GetObjectClass)(EtsEnv *env, ets_object obj); + ets_boolean (*IsInstanceOf)(EtsEnv *env, ets_object obj, ets_class cls); + ets_method (*Getp_method)(EtsEnv *env, ets_class cls, const char *name, const char *sig); + ets_object (*CallObjectMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_object (*CallObjectMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_object (*CallObjectMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_boolean (*CallBooleanMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_boolean (*CallBooleanMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_boolean (*CallBooleanMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_byte (*CallByteMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_byte (*CallByteMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_byte (*CallByteMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_char (*CallCharMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_char (*CallCharMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_char (*CallCharMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_short (*CallShortMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_short (*CallShortMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_short (*CallShortMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_int (*CallIntMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_int (*CallIntMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_int (*CallIntMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_long (*CallLongMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_long (*CallLongMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_long (*CallLongMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_float (*CallFloatMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_float (*CallFloatMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_float (*CallFloatMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + ets_double (*CallDoubleMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + ets_double (*CallDoubleMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + ets_double (*CallDoubleMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + void (*CallVoidMethod)(EtsEnv *env, ets_object obj, ets_method p_method, ...); + void (*CallVoidMethodList)(EtsEnv *env, ets_object obj, ets_method p_method, va_list args); + void (*CallVoidMethodArray)(EtsEnv *env, ets_object obj, ets_method p_method, const ets_value *args); + + ets_object (*CallNonvirtualObjectMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_object (*CallNonvirtualObjectMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_object (*CallNonvirtualObjectMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_boolean (*CallNonvirtualBooleanMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_boolean (*CallNonvirtualBooleanMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_boolean (*CallNonvirtualBooleanMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_byte (*CallNonvirtualByteMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_byte (*CallNonvirtualByteMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_byte (*CallNonvirtualByteMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_char (*CallNonvirtualCharMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_char (*CallNonvirtualCharMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_char (*CallNonvirtualCharMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_short (*CallNonvirtualShortMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_short (*CallNonvirtualShortMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_short (*CallNonvirtualShortMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_int (*CallNonvirtualIntMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_int (*CallNonvirtualIntMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_int (*CallNonvirtualIntMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_long (*CallNonvirtualLongMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_long (*CallNonvirtualLongMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_long (*CallNonvirtualLongMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_float (*CallNonvirtualFloatMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_float (*CallNonvirtualFloatMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_float (*CallNonvirtualFloatMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_double (*CallNonvirtualDoubleMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + ets_double (*CallNonvirtualDoubleMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + va_list args); + ets_double (*CallNonvirtualDoubleMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + void (*CallNonvirtualVoidMethod)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, ...); + void (*CallNonvirtualVoidMethodList)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, va_list args); + void (*CallNonvirtualVoidMethodArray)(EtsEnv *env, ets_object obj, ets_class cls, ets_method p_method, + const ets_value *args); + ets_field (*Getp_field)(EtsEnv *env, ets_class cls, const char *name, const char *sig); + ets_object (*GetObjectField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_boolean (*GetBooleanField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_byte (*GetByteField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_char (*GetCharField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_short (*GetShortField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_int (*GetIntField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_long (*GetLongField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_float (*GetFloatField)(EtsEnv *env, ets_object obj, ets_field p_field); + ets_double (*GetDoubleField)(EtsEnv *env, ets_object obj, ets_field p_field); + void (*SetObjectField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_object value); + void (*SetBooleanField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_boolean value); + void (*SetByteField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_byte value); + void (*SetCharField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_char value); + void (*SetShortField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_short value); + void (*SetIntField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_int value); + void (*SetLongField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_long value); + void (*SetFloatField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_float value); + void (*SetDoubleField)(EtsEnv *env, ets_object obj, ets_field p_field, ets_double value); + ets_method (*GetStaticp_method)(EtsEnv *env, ets_class cls, const char *name, const char *sig); + ets_object (*CallStaticObjectMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_object (*CallStaticObjectMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_object (*CallStaticObjectMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_boolean (*CallStaticBooleanMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_boolean (*CallStaticBooleanMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_boolean (*CallStaticBooleanMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_byte (*CallStaticByteMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_byte (*CallStaticByteMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_byte (*CallStaticByteMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_char (*CallStaticCharMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_char (*CallStaticCharMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_char (*CallStaticCharMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_short (*CallStaticShortMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_short (*CallStaticShortMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_short (*CallStaticShortMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_int (*CallStaticIntMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_int (*CallStaticIntMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_int (*CallStaticIntMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_long (*CallStaticLongMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_long (*CallStaticLongMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_long (*CallStaticLongMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_float (*CallStaticFloatMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_float (*CallStaticFloatMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_float (*CallStaticFloatMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_double (*CallStaticDoubleMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + ets_double (*CallStaticDoubleMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + ets_double (*CallStaticDoubleMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + void (*CallStaticVoidMethod)(EtsEnv *env, ets_class cls, ets_method p_method, ...); + void (*CallStaticVoidMethodList)(EtsEnv *env, ets_class cls, ets_method p_method, va_list args); + void (*CallStaticVoidMethodArray)(EtsEnv *env, ets_class cls, ets_method p_method, ets_value *args); + ets_field (*GetStaticp_field)(EtsEnv *env, ets_class cls, const char *name, const char *sig); + ets_object (*GetStaticObjectField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_boolean (*GetStaticBooleanField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_byte (*GetStaticByteField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_char (*GetStaticCharField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_short (*GetStaticShortField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_int (*GetStaticIntField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_long (*GetStaticLongField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_float (*GetStaticFloatField)(EtsEnv *env, ets_class cls, ets_field p_field); + ets_double (*GetStaticDoubleField)(EtsEnv *env, ets_class cls, ets_field p_field); + void (*SetStaticObjectField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_object value); + void (*SetStaticBooleanField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_boolean value); + void (*SetStaticByteField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_byte value); + void (*SetStaticCharField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_char value); + void (*SetStaticShortField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_short value); + void (*SetStaticIntField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_int value); + void (*SetStaticLongField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_long value); + void (*SetStaticFloatField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_float value); + void (*SetStaticDoubleField)(EtsEnv *env, ets_class cls, ets_field p_field, ets_double value); + ets_string (*NewString)(EtsEnv *env, const ets_char *unicodeChars, ets_size len); + ets_size (*GetStringLength)(EtsEnv *env, ets_string string); + const ets_char *(*GetStringChars)(EtsEnv *env, ets_string string, ets_boolean *isCopy); + void (*ReleaseStringChars)(EtsEnv *env, ets_string string, const ets_char *chars); + ets_string (*NewStringUTF)(EtsEnv *env, const char *bytes); + ets_size (*GetStringUTFLength)(EtsEnv *env, ets_string string); + const char *(*GetStringUTFChars)(EtsEnv *env, ets_string string, ets_boolean *isCopy); + void (*ReleaseStringUTFChars)(EtsEnv *env, ets_string string, const char *utf); + ets_size (*GetArrayLength)(EtsEnv *env, ets_array array); + ets_objectArray (*NewObjectsArray)(EtsEnv *env, ets_size length, ets_class element_class, + ets_object initial_element); + ets_object (*GetObjectArrayElement)(EtsEnv *env, ets_objectArray array, ets_size index); + void (*SetObjectArrayElement)(EtsEnv *env, ets_objectArray array, ets_size index, ets_object value); + ets_booleanArray (*NewBooleanArray)(EtsEnv *env, ets_size length); + ets_byteArray (*NewByteArray)(EtsEnv *env, ets_size length); + ets_charArray (*NewCharArray)(EtsEnv *env, ets_size length); + ets_shortArray (*NewShortArray)(EtsEnv *env, ets_size length); + ets_intArray (*NewIntArray)(EtsEnv *env, ets_size length); + ets_longArray (*NewLongArray)(EtsEnv *env, ets_size length); + ets_floatArray (*NewFloatArray)(EtsEnv *env, ets_size length); + ets_doubleArray (*NewDoubleArray)(EtsEnv *env, ets_size length); + ets_boolean *(*PinBooleanArray)(EtsEnv *env, ets_booleanArray array); + ets_byte *(*PinByteArray)(EtsEnv *env, ets_byteArray array); + ets_char *(*PinCharArray)(EtsEnv *env, ets_charArray array); + ets_short *(*PinShortArray)(EtsEnv *env, ets_shortArray array); + ets_int *(*PinIntArray)(EtsEnv *env, ets_intArray array); + ets_long *(*PinLongArray)(EtsEnv *env, ets_longArray array); + ets_float *(*PinFloatArray)(EtsEnv *env, ets_floatArray array); + ets_double *(*PinDoubleArray)(EtsEnv *env, ets_doubleArray array); + void (*UnpinBooleanArray)(EtsEnv *env, ets_booleanArray array); + void (*UnpinByteArray)(EtsEnv *env, ets_byteArray array); + void (*UnpinCharArray)(EtsEnv *env, ets_charArray array); + void (*UnpinShortArray)(EtsEnv *env, ets_shortArray array); + void (*UnpinIntArray)(EtsEnv *env, ets_intArray array); + void (*UnpinLongArray)(EtsEnv *env, ets_longArray array); + void (*UnpinFloatArray)(EtsEnv *env, ets_floatArray array); + void (*UnpinDoubleArray)(EtsEnv *env, ets_doubleArray array); + void (*GetBooleanArrayRegion)(EtsEnv *env, ets_booleanArray array, ets_size start, ets_size len, ets_boolean *buf); + void (*GetByteArrayRegion)(EtsEnv *env, ets_byteArray array, ets_size start, ets_size len, ets_byte *buf); + void (*GetCharArrayRegion)(EtsEnv *env, ets_charArray array, ets_size start, ets_size len, ets_char *buf); + void (*GetShortArrayRegion)(EtsEnv *env, ets_shortArray array, ets_size start, ets_size len, ets_short *buf); + void (*GetIntArrayRegion)(EtsEnv *env, ets_intArray array, ets_size start, ets_size len, ets_int *buf); + void (*GetLongArrayRegion)(EtsEnv *env, ets_longArray array, ets_size start, ets_size len, ets_long *buf); + void (*GetFloatArrayRegion)(EtsEnv *env, ets_floatArray array, ets_size start, ets_size len, ets_float *buf); + void (*GetDoubleArrayRegion)(EtsEnv *env, ets_doubleArray array, ets_size start, ets_size len, ets_double *buf); + void (*SetBooleanArrayRegion)(EtsEnv *env, ets_booleanArray array, ets_size start, ets_size len, + const ets_boolean *buf); + void (*SetByteArrayRegion)(EtsEnv *env, ets_byteArray array, ets_size start, ets_size len, const ets_byte *buf); + void (*SetCharArrayRegion)(EtsEnv *env, ets_charArray array, ets_size start, ets_size len, const ets_char *buf); + void (*SetShortArrayRegion)(EtsEnv *env, ets_shortArray array, ets_size start, ets_size len, const ets_short *buf); + void (*SetIntArrayRegion)(EtsEnv *env, ets_intArray array, ets_size start, ets_size len, const ets_int *buf); + void (*SetLongArrayRegion)(EtsEnv *env, ets_longArray array, ets_size start, ets_size len, const ets_long *buf); + void (*SetFloatArrayRegion)(EtsEnv *env, ets_floatArray array, ets_size start, ets_size len, const ets_float *buf); + void (*SetDoubleArrayRegion)(EtsEnv *env, ets_doubleArray array, ets_size start, ets_size len, + const ets_double *buf); + ets_int (*RegisterNatives)(EtsEnv *env, ets_class cls, const EtsNativeMethod *methods, ets_int nMethods); + ets_int (*UnregisterNatives)(EtsEnv *env, ets_class cls); + ets_int (*GetEtsVM)(EtsEnv *env, EtsVM **vm); + void (*GetStringRegion)(EtsEnv *env, ets_string str, ets_size start, ets_size len, ets_char *buf); + void (*GetStringUTFRegion)(EtsEnv *env, ets_string str, ets_size start, ets_size len, char *buf); + ets_weak (*NewWeakGlobalRef)(EtsEnv *env, ets_object obj); + void (*DeleteWeakGlobalRef)(EtsEnv *env, ets_weak obj); + ets_boolean (*ErrorCheck)(EtsEnv *env); +#ifdef ETS_NAPI_DESIGN_FINISHED + ets_object (*NewDirectByteBuffer)(EtsEnv *env, void *address, ets_long capacity); + void *(*GetDirectBufferAddress)(EtsEnv *env, ets_object buf); + ets_long (*GetDirectBufferCapacity)(EtsEnv *env, ets_object buf); +#endif + ets_objectRefType (*GetObjectRefType)(EtsEnv *env, ets_object obj); + + /* 227 methods */ + + // Promise API + ets_status (*PromiseCreate)(EtsEnv *env, ets_deferred *deferred, ets_object *promise); + ets_status (*DeferredResolve)(EtsEnv *env, ets_deferred deferred, ets_object resolution); + ets_status (*DeferredReject)(EtsEnv *env, ets_deferred deferred, ets_object rejection); +}; +// clang-format on + +// Invocation API Functions +typedef enum { + ETS_LOG_LEVEL, + ETS_MOBILE_LOG, + ETS_BOOT_FILE, + ETS_AOT_FILE, + ETS_ARK_FILE, + ETS_JIT, + ETS_NO_JIT, + ETS_AOT, + ETS_NO_AOT, + ETS_GC_TRIGGER_TYPE, + ETS_GC_TYPE, + ETS_RUN_GC_IN_PLACE, + ETS_INTERPRETER_TYPE, + ETS_NATIVE_LIBRARY_PATH, + ETS_VERIFICATION_MODE +} EtsOptionType; + +typedef struct EtsVMOption { + EtsOptionType option; + const void *extraInfo; +} EtsVMOption; + +typedef struct EtsVMInitArgs { + ets_int version; + ets_int nOptions; + EtsVMOption *options; +} EtsVMInitArgs; + +typedef enum { + ETS_MOBILE_LOG_LEVEL_UNKNOWN = 0, + ETS_MOBILE_LOG_LEVEL_DEFAULT, + ETS_MOBILE_LOG_LEVEL_VERBOSE, + ETS_MOBILE_LOG_LEVEL_DEBUG, + ETS_MOBILE_LOG_LEVEL_INFO, + ETS_MOBILE_LOG_LEVEL_WARN, + ETS_MOBILE_LOG_LEVEL_ERROR, + ETS_MOBILE_LOG_LEVEL_FATAL, + ETS_MOBILE_LOG_LEVEL_SILENT +} EtsMobileLogggerLevel; + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +#define ETS_EXPORT __declspec(dllexport) +#else +#define ETS_EXPORT __attribute__((visibility("default"))) +#endif +#define ETS_IMPORT +#define ETS_CALL + +ETS_EXPORT ets_int ETS_GetDefaultVMInitArgs(EtsVMInitArgs *vmArgs); +ETS_EXPORT ets_int ETS_GetCreatedVMs(EtsVM **vmBuf, ets_size bufLen, ets_size *nVms); +ETS_EXPORT ets_int ETS_CreateVM(EtsVM **pVm, EtsEnv **pEnv, EtsVMInitArgs *vmArgs); + +#ifdef __cplusplus +} +#endif + +struct ETS_InvokeInterface { + ets_int (*DestroyEtsVM)(EtsVM *vm); + ets_int (*GetEnv)(EtsVM *vm, EtsEnv **pEnv, ets_int version); +}; + +struct __EtsVM { + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + const struct ETS_InvokeInterface *invoke_interface; + +#ifdef __cplusplus + ets_int DestroyEtsVM() + { + return invoke_interface->DestroyEtsVM(this); + } + + ets_int GetEnv(EtsEnv **pEnv, ets_int version) + { + return invoke_interface->GetEnv(this, pEnv, version); + } +#endif +}; + +struct __EtsEnv { + // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes) + const struct ETS_NativeInterface *native_interface; + +#ifdef __cplusplus + + ets_int GetVersion() + { + return native_interface->GetVersion(this); + } + // DefineClass, + ets_class FindClass(const char *name) + { + return native_interface->FindClass(this, name); + } + // FromReflectedMethod, + // FromReflectedField, + // ToReflectedMethod, + ets_class GetSuperclass(ets_class cls) + { + return native_interface->GetSuperclass(this, cls); + } + ets_boolean IsAssignableFrom(ets_class cls1, ets_class cls2) + { + return native_interface->IsAssignableFrom(this, cls1, cls2); + } + // ToReflectedField, + ets_int ThrowError(ets_error obj) + { + return native_interface->ThrowError(this, obj); + } + ets_int ThrowErrorNew(ets_class cls, const char *message) + { + return native_interface->ThrowErrorNew(this, cls, message); + } + ets_error ErrorOccurred() + { + return native_interface->ErrorOccurred(this); + } + void ErrorDescribe() + { + native_interface->ErrorDescribe(this); + } + void ErrorClear() + { + native_interface->ErrorClear(this); + } + void FatalError(const char *message) + { + native_interface->FatalError(this, message); + } + ets_int PushLocalFrame(ets_int capacity) + { + return native_interface->PushLocalFrame(this, capacity); + } + ets_object PopLocalFrame(ets_object result) + { + return native_interface->PopLocalFrame(this, result); + } + ets_object NewGlobalRef(ets_object obj) + { + return native_interface->NewGlobalRef(this, obj); + } + void DeleteGlobalRef(ets_object globalRef) + { + native_interface->DeleteGlobalRef(this, globalRef); + } + void DeleteLocalRef(ets_object localRef) + { + native_interface->DeleteLocalRef(this, localRef); + } + ets_boolean IsSameObject(ets_object ref1, ets_object ref2) + { + return native_interface->IsSameObject(this, ref1, ref2); + } + ets_object NewLocalRef(ets_object ref) + { + return native_interface->NewLocalRef(this, ref); + } + ets_int EnsureLocalCapacity(ets_int capacity) + { + return native_interface->EnsureLocalCapacity(this, capacity); + } + ets_object AllocObject(ets_class cls) + { + return native_interface->AllocObject(this, cls); + } + ets_object NewObject(ets_class cls, ets_method p_method, ...) + { + va_list args; + va_start(args, p_method); + ets_object ret = native_interface->NewObjectList(this, cls, p_method, args); + va_end(args); + return ret; + } + ets_object NewObjectList(ets_class cls, ets_method p_method, va_list args) + { + return native_interface->NewObjectList(this, cls, p_method, args); + } + ets_object NewObjectArray(ets_class cls, ets_method p_method, const ets_value *args) + { + return native_interface->NewObjectArray(this, cls, p_method, args); + } + ets_class GetObjectClass(ets_object obj) + { + return native_interface->GetObjectClass(this, obj); + } + ets_boolean IsInstanceOf(ets_object obj, ets_class cls) + { + return native_interface->IsInstanceOf(this, obj, cls); + } + ets_method Getp_method(ets_class cls, const char *name, const char *sig) + { + return native_interface->Getp_method(this, cls, name, sig); + } + ets_object CallObjectMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_object res = native_interface->CallObjectMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_object CallObjectMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallObjectMethodList(this, obj, method_id, args); + } + ets_object CallObjectMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallObjectMethodArray(this, obj, method_id, args); + } + ets_boolean CallBooleanMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_boolean res = native_interface->CallBooleanMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_boolean CallBooleanMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallBooleanMethodList(this, obj, method_id, args); + } + ets_boolean CallBooleanMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallBooleanMethodArray(this, obj, method_id, args); + } + ets_byte CallByteMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_byte res = native_interface->CallByteMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_byte CallByteMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallByteMethodList(this, obj, method_id, args); + } + ets_byte CallByteMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallByteMethodArray(this, obj, method_id, args); + } + ets_char CallCharMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_char res = native_interface->CallCharMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_char CallCharMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallCharMethodList(this, obj, method_id, args); + } + ets_char CallCharMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallCharMethodArray(this, obj, method_id, args); + } + ets_short CallShortMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_short res = native_interface->CallShortMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_short CallShortMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallShortMethodList(this, obj, method_id, args); + } + ets_short CallShortMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallShortMethodArray(this, obj, method_id, args); + } + ets_int CallIntMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_int res = native_interface->CallIntMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_int CallIntMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallIntMethodList(this, obj, method_id, args); + } + ets_int CallIntMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallIntMethodArray(this, obj, method_id, args); + } + ets_long CallLongMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_long res = native_interface->CallLongMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_long CallLongMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallLongMethodList(this, obj, method_id, args); + } + ets_long CallLongMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallLongMethodArray(this, obj, method_id, args); + } + ets_float CallFloatMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_float res = native_interface->CallFloatMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_float CallFloatMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallFloatMethodList(this, obj, method_id, args); + } + ets_float CallFloatMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallFloatMethodArray(this, obj, method_id, args); + } + ets_double CallDoubleMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_double res = native_interface->CallDoubleMethodList(this, obj, method_id, args); + va_end(args); + return res; + } + ets_double CallDoubleMethodList(ets_object obj, ets_method method_id, va_list args) + { + return native_interface->CallDoubleMethodList(this, obj, method_id, args); + } + ets_double CallDoubleMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + return native_interface->CallDoubleMethodArray(this, obj, method_id, args); + } + void CallVoidMethod(ets_object obj, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + native_interface->CallVoidMethodList(this, obj, method_id, args); + va_end(args); + } + void CallVoidMethodList(ets_object obj, ets_method method_id, va_list args) + { + native_interface->CallVoidMethodList(this, obj, method_id, args); + } + void CallVoidMethodArray(ets_object obj, ets_method method_id, const ets_value *args) + { + native_interface->CallVoidMethodArray(this, obj, method_id, args); + } + ets_object CallNonvirtualObjectMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_object res = native_interface->CallNonvirtualObjectMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_object CallNonvirtualObjectMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualObjectMethodList(this, obj, cls, method_id, args); + } + ets_object CallNonvirtualObjectMethodArray(ets_object obj, ets_class cls, ets_method method_id, + const ets_value *args) + { + return native_interface->CallNonvirtualObjectMethodArray(this, obj, cls, method_id, args); + } + ets_boolean CallNonvirtualBooleanMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_boolean res = native_interface->CallNonvirtualBooleanMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_boolean CallNonvirtualBooleanMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualBooleanMethodList(this, obj, cls, method_id, args); + } + ets_boolean CallNonvirtualBooleanMethodArray(ets_object obj, ets_class cls, ets_method method_id, + const ets_value *args) + { + return native_interface->CallNonvirtualBooleanMethodArray(this, obj, cls, method_id, args); + } + ets_byte CallNonvirtualByteMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_byte res = native_interface->CallNonvirtualByteMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_byte CallNonvirtualByteMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualByteMethodList(this, obj, cls, method_id, args); + } + ets_byte CallNonvirtualByteMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualByteMethodArray(this, obj, cls, method_id, args); + } + ets_char CallNonvirtualCharMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_char res = native_interface->CallNonvirtualCharMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_char CallNonvirtualCharMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualCharMethodList(this, obj, cls, method_id, args); + } + ets_char CallNonvirtualCharMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualCharMethodArray(this, obj, cls, method_id, args); + } + ets_short CallNonvirtualShortMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_short res = native_interface->CallNonvirtualShortMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_short CallNonvirtualShortMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualShortMethodList(this, obj, cls, method_id, args); + } + ets_short CallNonvirtualShortMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualShortMethodArray(this, obj, cls, method_id, args); + } + ets_int CallNonvirtualIntMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_int res = native_interface->CallNonvirtualIntMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_int CallNonvirtualIntMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualIntMethodList(this, obj, cls, method_id, args); + } + ets_int CallNonvirtualIntMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualIntMethodArray(this, obj, cls, method_id, args); + } + ets_long CallNonvirtualLongMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_long res = native_interface->CallNonvirtualLongMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_long CallNonvirtualLongMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualLongMethodList(this, obj, cls, method_id, args); + } + ets_long CallNonvirtualLongMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualLongMethodArray(this, obj, cls, method_id, args); + } + ets_float CallNonvirtualFloatMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_float res = native_interface->CallNonvirtualFloatMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_float CallNonvirtualFloatMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualFloatMethodList(this, obj, cls, method_id, args); + } + ets_float CallNonvirtualFloatMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + return native_interface->CallNonvirtualFloatMethodArray(this, obj, cls, method_id, args); + } + ets_double CallNonvirtualDoubleMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_double res = native_interface->CallNonvirtualDoubleMethodList(this, obj, cls, method_id, args); + va_end(args); + return res; + } + ets_double CallNonvirtualDoubleMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallNonvirtualDoubleMethodList(this, obj, cls, method_id, args); + } + ets_double CallNonvirtualDoubleMethodArray(ets_object obj, ets_class cls, ets_method method_id, + const ets_value *args) + { + return native_interface->CallNonvirtualDoubleMethodArray(this, obj, cls, method_id, args); + } + void CallNonvirtualVoidMethod(ets_object obj, ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + native_interface->CallNonvirtualVoidMethodList(this, obj, cls, method_id, args); + va_end(args); + } + void CallNonvirtualVoidMethodList(ets_object obj, ets_class cls, ets_method method_id, va_list args) + { + native_interface->CallNonvirtualVoidMethodList(this, obj, cls, method_id, args); + } + void CallNonvirtualVoidMethodArray(ets_object obj, ets_class cls, ets_method method_id, const ets_value *args) + { + native_interface->CallNonvirtualVoidMethodArray(this, obj, cls, method_id, args); + } + ets_field Getp_field(ets_class cls, const char *name, const char *sig) + { + return native_interface->Getp_field(this, cls, name, sig); + } + ets_object GetObjectField(ets_object obj, ets_field p_field) + { + return native_interface->GetObjectField(this, obj, p_field); + } + ets_boolean GetBooleanField(ets_object obj, ets_field p_field) + { + return native_interface->GetBooleanField(this, obj, p_field); + } + ets_byte GetByteField(ets_object obj, ets_field p_field) + { + return native_interface->GetByteField(this, obj, p_field); + } + ets_char GetCharField(ets_object obj, ets_field p_field) + { + return native_interface->GetCharField(this, obj, p_field); + } + ets_short GetShortField(ets_object obj, ets_field p_field) + { + return native_interface->GetShortField(this, obj, p_field); + } + ets_int GetIntField(ets_object obj, ets_field p_field) + { + return native_interface->GetIntField(this, obj, p_field); + } + ets_long GetLongField(ets_object obj, ets_field p_field) + { + return native_interface->GetLongField(this, obj, p_field); + } + ets_float GetFloatField(ets_object obj, ets_field p_field) + { + return native_interface->GetFloatField(this, obj, p_field); + } + ets_double GetDoubleField(ets_object obj, ets_field p_field) + { + return native_interface->GetDoubleField(this, obj, p_field); + } + void SetObjectField(ets_object obj, ets_field p_field, ets_object value) + { + return native_interface->SetObjectField(this, obj, p_field, value); + } + void SetBooleanField(ets_object obj, ets_field p_field, ets_boolean value) + { + return native_interface->SetBooleanField(this, obj, p_field, value); + } + void SetByteField(ets_object obj, ets_field p_field, ets_byte value) + { + return native_interface->SetByteField(this, obj, p_field, value); + } + void SetCharField(ets_object obj, ets_field p_field, ets_char value) + { + return native_interface->SetCharField(this, obj, p_field, value); + } + void SetShortField(ets_object obj, ets_field p_field, ets_short value) + { + return native_interface->SetShortField(this, obj, p_field, value); + } + void SetIntField(ets_object obj, ets_field p_field, ets_int value) + { + return native_interface->SetIntField(this, obj, p_field, value); + } + void SetLongField(ets_object obj, ets_field p_field, ets_long value) + { + return native_interface->SetLongField(this, obj, p_field, value); + } + void SetFloatField(ets_object obj, ets_field p_field, ets_float value) + { + return native_interface->SetFloatField(this, obj, p_field, value); + } + void SetDoubleField(ets_object obj, ets_field p_field, ets_double value) + { + return native_interface->SetDoubleField(this, obj, p_field, value); + } + ets_method GetStaticp_method(ets_class cls, const char *name, const char *sig) + { + return native_interface->GetStaticp_method(this, cls, name, sig); + } + ets_object CallStaticObjectMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_object res = native_interface->CallStaticObjectMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_object CallStaticObjectMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticObjectMethodList(this, cls, method_id, args); + } + ets_object CallStaticObjectMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticObjectMethodArray(this, cls, method_id, args); + } + ets_boolean CallStaticBooleanMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_boolean res = native_interface->CallStaticBooleanMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_boolean CallStaticBooleanMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticBooleanMethodList(this, cls, method_id, args); + } + ets_boolean CallStaticBooleanMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticBooleanMethodArray(this, cls, method_id, args); + } + ets_byte CallStaticByteMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_byte res = native_interface->CallStaticByteMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_byte CallStaticByteMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticByteMethodList(this, cls, method_id, args); + } + ets_byte CallStaticByteMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticByteMethodArray(this, cls, method_id, args); + } + ets_char CallStaticCharMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_char res = native_interface->CallStaticCharMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_char CallStaticCharMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticCharMethodList(this, cls, method_id, args); + } + ets_char CallStaticCharMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticCharMethodArray(this, cls, method_id, args); + } + ets_short CallStaticShortMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_short res = native_interface->CallStaticShortMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_short CallStaticShortMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticShortMethodList(this, cls, method_id, args); + } + ets_short CallStaticShortMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticShortMethodArray(this, cls, method_id, args); + } + ets_int CallStaticIntMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_int res = native_interface->CallStaticIntMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_int CallStaticIntMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticIntMethodList(this, cls, method_id, args); + } + ets_int CallStaticIntMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticIntMethodArray(this, cls, method_id, args); + } + ets_long CallStaticLongMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_long res = native_interface->CallStaticLongMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_long CallStaticLongMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticLongMethodList(this, cls, method_id, args); + } + ets_long CallStaticLongMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticLongMethodArray(this, cls, method_id, args); + } + ets_float CallStaticFloatMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_float res = native_interface->CallStaticFloatMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_float CallStaticFloatMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticFloatMethodList(this, cls, method_id, args); + } + ets_float CallStaticFloatMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticFloatMethodArray(this, cls, method_id, args); + } + ets_double CallStaticDoubleMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + ets_double res = native_interface->CallStaticDoubleMethodList(this, cls, method_id, args); + va_end(args); + return res; + } + ets_double CallStaticDoubleMethodList(ets_class cls, ets_method method_id, va_list args) + { + return native_interface->CallStaticDoubleMethodList(this, cls, method_id, args); + } + ets_double CallStaticDoubleMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + return native_interface->CallStaticDoubleMethodArray(this, cls, method_id, args); + } + void CallStaticVoidMethod(ets_class cls, ets_method method_id, ...) + { + va_list args; + va_start(args, method_id); + native_interface->CallStaticVoidMethodList(this, cls, method_id, args); + va_end(args); + } + void CallStaticVoidMethodList(ets_class cls, ets_method method_id, va_list args) + { + native_interface->CallStaticVoidMethodList(this, cls, method_id, args); + } + void CallStaticVoidMethodArray(ets_class cls, ets_method method_id, ets_value *args) + { + native_interface->CallStaticVoidMethodArray(this, cls, method_id, args); + } + ets_field GetStaticp_field(ets_class cls, const char *name, const char *sig) + { + return native_interface->GetStaticp_field(this, cls, name, sig); + } + ets_object GetStaticObjectField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticObjectField(this, cls, p_field); + } + ets_boolean GetStaticBooleanField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticBooleanField(this, cls, p_field); + } + ets_byte GetStaticByteField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticByteField(this, cls, p_field); + } + ets_char GetStaticCharField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticCharField(this, cls, p_field); + } + ets_short GetStaticShortField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticShortField(this, cls, p_field); + } + ets_int GetStaticIntField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticIntField(this, cls, p_field); + } + ets_long GetStaticLongField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticLongField(this, cls, p_field); + } + ets_float GetStaticFloatField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticFloatField(this, cls, p_field); + } + ets_double GetStaticDoubleField(ets_class cls, ets_field p_field) + { + return native_interface->GetStaticDoubleField(this, cls, p_field); + } + void SetStaticObjectField(ets_class cls, ets_field p_field, ets_object value) + { + return native_interface->SetStaticObjectField(this, cls, p_field, value); + } + void SetStaticBooleanField(ets_class cls, ets_field p_field, ets_boolean value) + { + return native_interface->SetStaticBooleanField(this, cls, p_field, value); + } + void SetStaticByteField(ets_class cls, ets_field p_field, ets_byte value) + { + return native_interface->SetStaticByteField(this, cls, p_field, value); + } + void SetStaticCharField(ets_class cls, ets_field p_field, ets_char value) + { + return native_interface->SetStaticCharField(this, cls, p_field, value); + } + void SetStaticShortField(ets_class cls, ets_field p_field, ets_short value) + { + return native_interface->SetStaticShortField(this, cls, p_field, value); + } + void SetStaticIntField(ets_class cls, ets_field p_field, ets_int value) + { + return native_interface->SetStaticIntField(this, cls, p_field, value); + } + void SetStaticLongField(ets_class cls, ets_field p_field, ets_long value) + { + return native_interface->SetStaticLongField(this, cls, p_field, value); + } + void SetStaticFloatField(ets_class cls, ets_field p_field, ets_float value) + { + return native_interface->SetStaticFloatField(this, cls, p_field, value); + } + void SetStaticDoubleField(ets_class cls, ets_field p_field, ets_double value) + { + return native_interface->SetStaticDoubleField(this, cls, p_field, value); + } + ets_string NewString(const ets_char *unicode_chars, ets_size len) + { + return native_interface->NewString(this, unicode_chars, len); + } + ets_size GetStringLength(ets_string string) + { + return native_interface->GetStringLength(this, string); + } + const ets_char *GetStringChars(ets_string string, ets_boolean *is_copy) + { + return native_interface->GetStringChars(this, string, is_copy); + } + void ReleaseStringChars(ets_string string, const ets_char *chars) + { + native_interface->ReleaseStringChars(this, string, chars); + } + ets_string NewStringUTF(const char *bytes) + { + return native_interface->NewStringUTF(this, bytes); + } + ets_size GetStringUTFLength(ets_string string) + { + return native_interface->GetStringUTFLength(this, string); + } + const char *GetStringUTFChars(ets_string string, ets_boolean *is_copy) + { + return native_interface->GetStringUTFChars(this, string, is_copy); + } + void ReleaseStringUTFChars(ets_string string, const char *chars) + { + native_interface->ReleaseStringUTFChars(this, string, chars); + } + ets_size GetArrayLength(ets_array array) + { + return native_interface->GetArrayLength(this, array); + } + ets_objectArray NewObjectsArray(ets_size length, ets_class element_class, ets_object initial_element) + { + return native_interface->NewObjectsArray(this, length, element_class, initial_element); + } + ets_object GetObjectArrayElement(ets_objectArray array, ets_size index) + { + return native_interface->GetObjectArrayElement(this, array, index); + } + + void SetObjectArrayElement(ets_objectArray array, ets_size index, ets_object value) + { + native_interface->SetObjectArrayElement(this, array, index, value); + } + + // SetObjectArrayElement, + ets_booleanArray NewBooleanArray(ets_size length) + { + return native_interface->NewBooleanArray(this, length); + } + ets_byteArray NewByteArray(ets_size length) + { + return native_interface->NewByteArray(this, length); + } + ets_charArray NewCharArray(ets_size length) + { + return native_interface->NewCharArray(this, length); + } + ets_shortArray NewShortArray(ets_size length) + { + return native_interface->NewShortArray(this, length); + } + ets_intArray NewIntArray(ets_size length) + { + return native_interface->NewIntArray(this, length); + } + ets_longArray NewLongArray(ets_size length) + { + return native_interface->NewLongArray(this, length); + } + ets_floatArray NewFloatArray(ets_size length) + { + return native_interface->NewFloatArray(this, length); + } + ets_doubleArray NewDoubleArray(ets_size length) + { + return native_interface->NewDoubleArray(this, length); + } + ets_boolean *PinBooleanArray(ets_booleanArray array) + { + return native_interface->PinBooleanArray(this, array); + } + ets_byte *PinByteArray(ets_byteArray array) + { + return native_interface->PinByteArray(this, array); + } + ets_char *PinCharArray(ets_charArray array) + { + return native_interface->PinCharArray(this, array); + } + ets_short *PinShortArray(ets_shortArray array) + { + return native_interface->PinShortArray(this, array); + } + ets_int *PinIntArray(ets_intArray array) + { + return native_interface->PinIntArray(this, array); + } + ets_long *PinLongArray(ets_longArray array) + { + return native_interface->PinLongArray(this, array); + } + ets_float *PinFloatArray(ets_floatArray array) + { + return native_interface->PinFloatArray(this, array); + } + ets_double *PinDoubleArray(ets_doubleArray array) + { + return native_interface->PinDoubleArray(this, array); + } + void UnpinBooleanArray(ets_booleanArray array) + { + return native_interface->UnpinBooleanArray(this, array); + } + void UnpinByteArray(ets_byteArray array) + { + return native_interface->UnpinByteArray(this, array); + } + void UnpinCharArray(ets_charArray array) + { + return native_interface->UnpinCharArray(this, array); + } + void UnpinShortArray(ets_shortArray array) + { + return native_interface->UnpinShortArray(this, array); + } + void UnpinIntArray(ets_intArray array) + { + return native_interface->UnpinIntArray(this, array); + } + void UnpinLongArray(ets_longArray array) + { + return native_interface->UnpinLongArray(this, array); + } + void UnpinFloatArray(ets_floatArray array) + { + return native_interface->UnpinFloatArray(this, array); + } + void UnpinDoubleArray(ets_doubleArray array) + { + return native_interface->UnpinDoubleArray(this, array); + } + void GetBooleanArrayRegion(ets_booleanArray array, ets_size start, ets_size len, ets_boolean *buf) + { + return native_interface->GetBooleanArrayRegion(this, array, start, len, buf); + } + void GetByteArrayRegion(ets_byteArray array, ets_size start, ets_size len, ets_byte *buf) + { + return native_interface->GetByteArrayRegion(this, array, start, len, buf); + } + void GetCharArrayRegion(ets_charArray array, ets_size start, ets_size len, ets_char *buf) + { + return native_interface->GetCharArrayRegion(this, array, start, len, buf); + } + void GetShortArrayRegion(ets_shortArray array, ets_size start, ets_size len, ets_short *buf) + { + return native_interface->GetShortArrayRegion(this, array, start, len, buf); + } + void GetIntArrayRegion(ets_intArray array, ets_size start, ets_size len, ets_int *buf) + { + return native_interface->GetIntArrayRegion(this, array, start, len, buf); + } + void GetLongArrayRegion(ets_longArray array, ets_size start, ets_size len, ets_long *buf) + { + return native_interface->GetLongArrayRegion(this, array, start, len, buf); + } + void GetFloatArrayRegion(ets_floatArray array, ets_size start, ets_size len, ets_float *buf) + { + return native_interface->GetFloatArrayRegion(this, array, start, len, buf); + } + void GetDoubleArrayRegion(ets_doubleArray array, ets_size start, ets_size len, ets_double *buf) + { + return native_interface->GetDoubleArrayRegion(this, array, start, len, buf); + } + void SetBooleanArrayRegion(ets_booleanArray array, ets_size start, ets_size length, const ets_boolean *buf) + { + native_interface->SetBooleanArrayRegion(this, array, start, length, buf); + } + void SetByteArrayRegion(ets_byteArray array, ets_size start, ets_size length, const ets_byte *buf) + { + native_interface->SetByteArrayRegion(this, array, start, length, buf); + } + void SetCharArrayRegion(ets_charArray array, ets_size start, ets_size length, const ets_char *buf) + { + native_interface->SetCharArrayRegion(this, array, start, length, buf); + } + void SetShortArrayRegion(ets_shortArray array, ets_size start, ets_size length, const ets_short *buf) + { + native_interface->SetShortArrayRegion(this, array, start, length, buf); + } + void SetIntArrayRegion(ets_intArray array, ets_size start, ets_size length, const ets_int *buf) + { + native_interface->SetIntArrayRegion(this, array, start, length, buf); + } + void SetLongArrayRegion(ets_longArray array, ets_size start, ets_size length, const ets_long *buf) + { + native_interface->SetLongArrayRegion(this, array, start, length, buf); + } + void SetFloatArrayRegion(ets_floatArray array, ets_size start, ets_size length, const ets_float *buf) + { + native_interface->SetFloatArrayRegion(this, array, start, length, buf); + } + void SetDoubleArrayRegion(ets_doubleArray array, ets_size start, ets_size length, const ets_double *buf) + { + native_interface->SetDoubleArrayRegion(this, array, start, length, buf); + } + ets_int RegisterNatives(ets_class cls, const EtsNativeMethod *methods, ets_int nMethods) + { + return native_interface->RegisterNatives(this, cls, methods, nMethods); + } + ets_int UnregisterNatives(ets_class cls) + { + return native_interface->UnregisterNatives(this, cls); + } + ets_int GetEtsVM(EtsVM **vm) + { + return native_interface->GetEtsVM(this, vm); + } + void GetStringRegion(ets_string str, ets_size start, ets_size len, ets_char *buf) + { + native_interface->GetStringRegion(this, str, start, len, buf); + } + void GetStringUTFRegion(ets_string str, ets_size start, ets_size len, char *buf) + { + native_interface->GetStringUTFRegion(this, str, start, len, buf); + } + ets_weak NewWeakGlobalRef(ets_object obj) + { + return native_interface->NewWeakGlobalRef(this, obj); + } + void DeleteWeakGlobalRef(ets_weak obj) + { + native_interface->DeleteWeakGlobalRef(this, obj); + } + ets_boolean ErrorCheck() + { + return native_interface->ErrorCheck(this); + } + // NewDirectByteBuffer, + // GetDirectBufferAddress, + // GetDirectBufferCapacity, + ets_objectRefType GetObjectRefType(ets_object obj) + { + return native_interface->GetObjectRefType(this, obj); + } + + // Promise + ets_status PromiseCreate(ets_deferred *deferred, ets_object *promise) + { + return native_interface->PromiseCreate(this, deferred, promise); + } + ets_status DeferredResolve(ets_deferred deferred, ets_object resolution) + { + return native_interface->DeferredResolve(this, deferred, resolution); + } + ets_status DeferredReject(ets_deferred deferred, ets_object rejection) + { + return native_interface->DeferredReject(this, deferred, rejection); + } +#endif +}; + +// NOLINTEND(modernize-use-using, readability-identifier-naming, cppcoreguidelines-pro-type-vararg) + +#endif // PANDA_RUNTIME_INTEROP_ETS_NAPI_H diff --git a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc new file mode 100644 index 000000000..073878547 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2025 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 +#include + +#include "interop-logging.h" + +namespace { + +struct Log { + std::string log; + bool isActive = true; +}; + +std::vector groupedLogs; + +void startGroupedLog(int index) { + if (index >= (int)groupedLogs.size()) { + groupedLogs.resize(index + 1); + for (int i = 0; i <= index; i++) { + if (!groupedLogs[i]) groupedLogs[i] = new Log(); + } + } + groupedLogs[index]->isActive = true; + groupedLogs[index]->log.clear(); +} + +void stopGroupedLog(int index) { + if (index < (int)groupedLogs.size()) { + groupedLogs[index]->isActive = false; + } +} + +void appendGroupedLog(int index, const char* str) { + if (index < (int)groupedLogs.size()) { + groupedLogs[index]->log.append(str); + } +} + +const char* getGroupedLog(int index) { + if (index < (int)groupedLogs.size()) { + auto result = groupedLogs[index]->log.c_str(); + return result; + } + return ""; +} + +int needGroupedLog(int index) { + if (index < (int)groupedLogs.size()) { + return groupedLogs[index]->isActive; + } + return 0; +} + +const GroupLogger defaultInstance = { + startGroupedLog, + stopGroupedLog, + appendGroupedLog, + getGroupedLog, + needGroupedLog, +}; + +} // namespace + +const GroupLogger* GetDefaultLogger() { + return &defaultInstance; +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.h b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.h new file mode 100644 index 000000000..4d1b7bc0f --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 _INTEROP_LGGING_H +#define _INTEROP_LGGING_H + +#include +#include + +#if defined(KOALA_OHOS) +#include "oh_sk_log.h" +#define LOG(msg) OH_SK_LOG_INFO(msg); +#define LOGI(msg, ...) OH_SK_LOG_INFO_A(msg, ##__VA_ARGS__); +#define LOGE(msg, ...) OH_SK_LOG_ERROR_A(msg, ##__VA_ARGS__); +#define LOG_PUBLIC "{public}" +#else +#define LOG(msg) fprintf(stdout, msg "\n"); +#define LOGI(msg, ...) fprintf(stdout, msg "\n", ##__VA_ARGS__); +#define LOGE(msg, ...) fprintf(stderr, msg "\n", ##__VA_ARGS__); +#define LOG_PUBLIC "" +#endif + +#if defined(KOALA_WINDOWS) +#define INTEROP_API_EXPORT __declspec(dllexport) +#else +#define INTEROP_API_EXPORT __attribute__((visibility("default"))) +#endif + +// Grouped logs. Keep consistent with type in ServiceGroupLogger +typedef struct GroupLogger { + void (*startGroupedLog)(int kind); + void (*stopGroupedLog)(int kind); + void (*appendGroupedLog)(int kind, const char* str); + const char* (*getGroupedLog)(int kind); + int (*needGroupedLog)(int kind); +} GroupLogger; + +const GroupLogger* GetDefaultLogger(); + +#endif // _INTEROP_LOGGING_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/interop-types.h b/koala-wrapper/koalaui/interop/src/cpp/interop-types.h new file mode 100644 index 000000000..4c5c26187 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/interop-types.h @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2022-2025 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 _INTEROP_TYPES_H_ +#define _INTEROP_TYPES_H_ + +#include + +#define INTEROP_FATAL(msg, ...) do { fprintf(stderr, msg "\n", ##__VA_ARGS__); abort(); } while (0) + +typedef enum InteropTag +{ + INTEROP_TAG_UNDEFINED = 101, + INTEROP_TAG_INT32 = 102, + INTEROP_TAG_FLOAT32 = 103, + INTEROP_TAG_STRING = 104, + INTEROP_TAG_LENGTH = 105, + INTEROP_TAG_RESOURCE = 106, + INTEROP_TAG_OBJECT = 107, +} InteropTag; + +typedef enum InteropRuntimeType +{ + INTEROP_RUNTIME_UNEXPECTED = -1, + INTEROP_RUNTIME_NUMBER = 1, + INTEROP_RUNTIME_STRING = 2, + INTEROP_RUNTIME_OBJECT = 3, + INTEROP_RUNTIME_BOOLEAN = 4, + INTEROP_RUNTIME_UNDEFINED = 5, + INTEROP_RUNTIME_BIGINT = 6, + INTEROP_RUNTIME_FUNCTION = 7, + INTEROP_RUNTIME_SYMBOL = 8, + INTEROP_RUNTIME_MATERIALIZED = 9, +} InteropRuntimeType; + +typedef float InteropFloat32; +typedef double InteropFloat64; +typedef int32_t InteropInt32; +typedef unsigned int InteropUInt32; // TODO: update unsigned int +typedef int64_t InteropInt64; +typedef uint64_t InteropUInt64; +typedef int8_t InteropInt8; +typedef uint8_t InteropUInt8; +typedef int64_t InteropDate; +typedef int8_t InteropBoolean; +typedef const char* InteropCharPtr; +typedef void* InteropNativePointer; + +struct _InteropVMContext; +typedef struct _InteropVMContext* InteropVMContext; +struct _InteropPipelineContext; +typedef struct _InteropPipelineContext* InteropPipelineContext; +struct _InteropVMObject; +typedef struct _InteropVMObject* InteropVMObject; +struct _InteropNode; +typedef struct _InteropNode* InteropNodeHandle; +typedef struct InteropDeferred { + void* handler; + void* context; + void (*resolve)(struct InteropDeferred* thiz, uint8_t* data, int32_t length); + void (*reject)(struct InteropDeferred* thiz, const char* message); +} InteropDeferred; + +// Binary layout of InteropString must match that of KStringPtrImpl. +typedef struct InteropString { + const char* chars; + InteropInt32 length; +} InteropString; + +typedef struct InteropEmpty { + InteropInt32 dummy; // Empty structs are forbidden in C. +} InteropEmpty; + +typedef struct InteropNumber { + InteropInt8 tag; + union { + InteropFloat32 f32; + InteropInt32 i32; + }; +} InteropNumber; + +// Binary layout of InteropLength must match that of KLength. +typedef struct InteropLength +{ + InteropInt8 type; + InteropFloat32 value; + InteropInt32 unit; + InteropInt32 resource; +} InteropLength; + +typedef struct InteropCustomObject { + char kind[20]; + InteropInt32 id; + // Data of custom object. + union { + InteropInt32 ints[4]; + InteropFloat32 floats[4]; + void* pointers[4]; + InteropString string; + }; +} InteropCustomObject; + +typedef struct InteropUndefined { + InteropInt32 dummy; // Empty structs are forbidden in C. +} InteropUndefined; + +typedef struct InteropVoid { + InteropInt32 dummy; // Empty structs are forbidden in C. +} InteropVoid; + +typedef struct InteropFunction { + InteropInt32 id; +} InteropFunction; +typedef InteropFunction InteropCallback; +typedef InteropFunction InteropErrorCallback; + +typedef struct InteropMaterialized { + InteropNativePointer ptr; +} InteropMaterialized; + +typedef struct InteropCallbackResource { + InteropInt32 resourceId; + void (*hold)(InteropInt32 resourceId); + void (*release)(InteropInt32 resourceId); +} InteropCallbackResource; + +typedef struct InteropBuffer { + InteropCallbackResource resource; + InteropNativePointer data; + InteropInt64 length; +} InteropBuffer; + +#endif // _INTEROP_TYPES_H_ diff --git a/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.cc b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.cc new file mode 100644 index 000000000..782f2c2e3 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.cc @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2025 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. + */ + + +#define KOALA_INTEROP_MODULE +#include "convertors-jni.h" +#include "signatures.h" +#include "interop-logging.h" +#include "interop-types.h" + +static const char* nativeModule = "org/koalaui/arkoala/InteropNativeModule"; +static const char* nativeModulePrefix = "org/koalaui/arkoala/"; +static const char* callCallbackFromNative = "callCallbackFromNative"; +static const char* callCallbackFromNativeSig = "(I[BI)I"; + +const bool registerByOne = true; + +static bool registerNatives(JNIEnv *env, jclass clazz, const std::vector> impls) { + size_t numMethods = impls.size(); + JNINativeMethod *methods = new JNINativeMethod[numMethods]; + bool result = true; + for (size_t i = 0; i < numMethods; i++) + { + methods[i].name = (char *)std::get<0>(impls[i]).c_str(); + methods[i].signature = (char *)std::get<1>(impls[i]).c_str(); + methods[i].fnPtr = std::get<2>(impls[i]); + if (registerByOne) { + result &= (env->RegisterNatives(clazz, methods + i, 1) >= 0); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + result = false; + } + } + } + return registerByOne ? true : env->RegisterNatives(clazz, methods, numMethods) >= 0; +} + +constexpr bool splitPerModule = true; + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { + JNIEnv *env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_8) != JNI_OK) { + return JNI_ERR; + } + auto modules = JniExports::getInstance()->getModules(); + jclass defaultNativeModule = env->FindClass(nativeModule); + for (auto it = modules.begin(); it != modules.end(); ++it) { + std::string className = std::string(nativeModulePrefix) + *it; + jclass nativeModule = + (!splitPerModule) ? defaultNativeModule : env->FindClass(className.c_str()); + if (nativeModule == nullptr) { + LOGE("Cannot find managed class %s", className.c_str()); + continue; + } + registerNatives(env, nativeModule, JniExports::getInstance()->getMethods(*it)); + } + if (!setKoalaJniCallbackDispatcher(env, defaultNativeModule, callCallbackFromNative, callCallbackFromNativeSig)) return JNI_ERR; + return JNI_VERSION_1_8; +} + +JniExports *JniExports::getInstance() +{ + static JniExports *instance = nullptr; + if (instance == nullptr) + { + instance = new JniExports(); + } + return instance; +} + +std::vector JniExports::getModules() { + std::vector result; + for (auto it = implementations.begin(); it != implementations.end(); ++it) { + result.push_back(it->first); + } + return result; +} + +const std::vector>& JniExports::getMethods(const std::string& module) { + auto it = implementations.find(module); + if (it == implementations.end()) { + LOGE("Module %s is not registered", module.c_str()); + INTEROP_FATAL("Fatal error: not registered module %s", module.c_str()); + } + return it->second; +} + +void JniExports::addMethod(const char* module, const char *name, const char *type, void *impl) { + auto it = implementations.find(module); + if (it == implementations.end()) { + it = implementations.insert(std::make_pair(module, std::vector>())).first; + } + it->second.push_back(std::make_tuple(name, convertType(name, type), impl)); +} diff --git a/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h new file mode 100644 index 000000000..2ebefafe7 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h @@ -0,0 +1,1465 @@ +/* + * Copyright (c) 2025 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. + */ + +#pragma once + +#ifdef KOALA_JNI + +#include +#include + +#include +#include +#include +#include +#include + +#include "koala-types.h" + +#define KOALA_JNI_CALL(type) extern "C" JNIEXPORT type JNICALL + +class JniExports { + std::unordered_map>> implementations; + +public: + static JniExports* getInstance(); + + std::vector getModules(); + void addMethod(const char* module, const char* name, const char* type, void* impl); + const std::vector>& getMethods(const std::string& module); +}; + +#define KOALA_QUOTE0(x) #x +#define KOALA_QUOTE(x) KOALA_QUOTE0(x) + +#ifdef _MSC_VER +#define MAKE_JNI_EXPORT(module, name, type) \ + static void __init_##name() { \ + JniExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Java_org_##name)); \ + } \ + namespace { \ + struct __Init_##name { \ + __Init_##name() { __init_##name(); } \ + } __Init_##name##_v; \ + } +#else +#define MAKE_JNI_EXPORT(module, name, type) \ + __attribute__((constructor)) \ + static void __init_jni_##name() { \ + JniExports::getInstance()->addMethod(KOALA_QUOTE(module), "_"#name, type, reinterpret_cast(Java_org_##name)); \ + } +#endif + +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(JNIEnv* env, InteropType value) { return value; } + static InteropType convertTo(JNIEnv* env, T value) { return value; } + static void release(JNIEnv* env, InteropType value, T converted) {} +}; + +template +struct SlowInteropTypeConverter { + using InteropType = T; + static inline T convertFrom(JNIEnv* env, InteropType value) { return value; } + static inline InteropType convertTo(JNIEnv* env, T value) { return value; } + static void release(JNIEnv* env, InteropType value, T converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = jstring; + static inline KStringPtr convertFrom0(JNIEnv* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + jboolean isCopy; + // TODO: use GetStringCritical() instead and utf-8 encode manually. + const char* str_value = env->GetStringUTFChars(value, &isCopy); + int len = env->GetStringUTFLength(value); + KStringPtr result(str_value, len, false); + return result; + } + static KStringPtr convertFrom(JNIEnv* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + KStringPtr result; + // Notice that we use UTF length for buffer size, but counter is expressed in number of Unicode chars. + result.resize( env->GetStringUTFLength(value)); + env->GetStringUTFRegion(value, 0, env->GetStringLength(value), result.data()); + return result; + } + static InteropType convertTo(JNIEnv* env, KStringPtr value) = delete; + static inline void release(JNIEnv* env, InteropType value, const KStringPtr& converted) { + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jobject; + static inline KVMObjectHandle convertFrom(JNIEnv* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(JNIEnv* env, KVMObjectHandle value) { + return reinterpret_cast(value); + } + static inline void release(JNIEnv* env, InteropType value, KVMObjectHandle converted) { + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jstring; + static inline KStringPtr convertFrom(JNIEnv* env, InteropType value) { + if (value == nullptr) return KStringPtr(); + jboolean isCopy; + const char* str_value = env->GetStringUTFChars(value, &isCopy); + int len = env->GetStringLength(value); + KStringPtr result(str_value, len, false); + return result; + } + static InteropType convertTo(JNIEnv* env, KStringPtr value) { + return env->NewStringUTF(value.c_str()); + } + static inline void release(JNIEnv* env, InteropType value, const KStringPtr& converted) { + env->ReleaseStringUTFChars(value, converted.data()); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jarray; + static inline KInteropBuffer convertFrom(JNIEnv* env, InteropType value) { + if (value == nullptr) return KInteropBuffer(); + KInteropBuffer result({env->GetArrayLength(value), reinterpret_cast(env->GetPrimitiveArrayCritical(value, nullptr))}); + return result; + } + static InteropType convertTo(JNIEnv* env, KInteropBuffer value) { + jarray result = env->NewByteArray(value.length); + void* data = env->GetPrimitiveArrayCritical(result, nullptr); + memcpy(data, value.data, value.length); + env->ReleasePrimitiveArrayCritical(result, data, 0); + return result; + } + static inline void release(JNIEnv* env, InteropType value, const KInteropBuffer& converted) { + env->ReleasePrimitiveArrayCritical(value, converted.data, 0); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jarray; + static inline KInteropReturnBuffer convertFrom(JNIEnv* env, InteropType value) = delete; + static InteropType convertTo(JNIEnv* env, KInteropReturnBuffer value) { + jarray result = env->NewByteArray(value.length); + void* data = env->GetPrimitiveArrayCritical(result, nullptr); + memcpy(data, value.data, value.length); + env->ReleasePrimitiveArrayCritical(result, data, 0); + value.dispose(value.data, value.length); + return result; + } + static inline void release(JNIEnv* env, InteropType value, const KInteropReturnBuffer& converted) = delete; +}; + +template<> +struct InteropTypeConverter { + using InteropType = jbyteArray; + static inline KByte* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetPrimitiveArrayCritical(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KByte* value) = delete; + static inline void release(JNIEnv* env, InteropType value, KByte* converted) { + if (converted) env->ReleasePrimitiveArrayCritical(value, converted, 0); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jbyteArray; + static inline KByte* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetByteArrayElements(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KByte* value) = delete; + static inline void release(JNIEnv* env, InteropType value, KByte* converted) { + if (converted) env->ReleaseByteArrayElements(value, reinterpret_cast(converted), 0); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = jintArray; + static KInt* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetPrimitiveArrayCritical(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KInt* value) = delete; + static void release(JNIEnv* env, InteropType value, KInt* converted) { + env->ReleasePrimitiveArrayCritical(value, converted, 0); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jintArray; + static KInt* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetIntArrayElements(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KInt* value) = delete; + static void release(JNIEnv* env, InteropType value, KInt* converted) { + env->ReleaseIntArrayElements(value, reinterpret_cast(converted), 0); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = jfloatArray; + static KFloat* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetPrimitiveArrayCritical(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KFloat* value) = delete; + static void release(JNIEnv* env, InteropType value, KFloat* converted) { + env->ReleasePrimitiveArrayCritical(value, converted, 0); + } +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jfloatArray; + static KFloat* convertFrom(JNIEnv* env, InteropType value) { + return value ? reinterpret_cast(env->GetFloatArrayElements(value, nullptr)) : nullptr; + } + static InteropType convertTo(JNIEnv* env, KFloat* value) = delete; + static void release(JNIEnv* env, InteropType value, KFloat* converted) { + env->ReleaseFloatArrayElements(value, reinterpret_cast(converted), 0); + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = jlong; + static KNativePointer convertFrom(JNIEnv* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(JNIEnv* env, KNativePointer value) { + return reinterpret_cast(value); + } + static inline void release(JNIEnv* env, InteropType value, KNativePointer converted) {} +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jlong; + static KNativePointer convertFrom(JNIEnv* env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(JNIEnv* env, KNativePointer value) { + return reinterpret_cast(value); + } + static void release(JNIEnv* env, InteropType value, KNativePointer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = jdouble; + static KInteropNumber convertFrom(JNIEnv* env, InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(JNIEnv* env, KInteropNumber value) { + return value.asDouble(); + } + static inline void release(JNIEnv* env, InteropType value, KInteropNumber converted) {} +}; + +template<> +struct SlowInteropTypeConverter { + using InteropType = jdouble; + static KInteropNumber convertFrom(JNIEnv* env, InteropType value) { + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(JNIEnv* env, KInteropNumber value) { + return value.asDouble(); + } + static void release(JNIEnv* env, InteropType value, KInteropNumber converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = jstring; + static KLength convertFrom(JNIEnv* env, InteropType value) { + KLength result = { 0 }; + + if (value == nullptr) { + result.type = -1; // ARK_RUNTIME_UNEXPECTED + return result; + } + jboolean isCopy; + const char* str_value = env->GetStringUTFChars(value, &isCopy); + int len = env->GetStringLength(value); + KStringPtr kStr(str_value, len, false); + parseKLength(kStr, &result); + env->ReleaseStringUTFChars(value, str_value); + result.type = 2; // ARK_RUNTIME_STRING + result.resource = 0; + + return result; + } + static InteropType convertTo(JNIEnv* env, KLength value) = delete; + static inline void release(JNIEnv* env, InteropType value, KLength converted) {} +}; + +template +inline Type getArgument(JNIEnv* env, typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(env, arg); +} + +template +inline void releaseArgument(JNIEnv* env, typename InteropTypeConverter::InteropType arg, Type& data) { + InteropTypeConverter::release(env, arg, data); +} + +#ifndef KOALA_INTEROP_MODULE +#error KOALA_INTEROP_MODULE is undefined +#endif + +#define KOALA_INTEROP_0(name, Ret) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance) { \ + KOALA_MAYBE_LOG(name) \ + return InteropTypeConverter::convertTo(env, impl_##name()); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) \ + Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9"|" #P10 "|" #P11 "|" #P12) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + KOALA_JNI_CALL(InteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + auto rv = InteropTypeConverter::convertTo(env, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9"|" #P10 "|" #P11 "|" #P12 "|" #P13) + + +#define KOALA_INTEROP_V0(name) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void") + +#define KOALA_INTEROP_V1(name, P0) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + impl_##name(p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + impl_##name(p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + impl_##name(p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + impl_##name(p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13) + +#define KOALA_INTEROP_V15(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13, \ + InteropTypeConverter::InteropType _p14) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + P5 p5 = getArgument(env, _p5); \ + P6 p6 = getArgument(env, _p6); \ + P7 p7 = getArgument(env, _p7); \ + P8 p8 = getArgument(env, _p8); \ + P9 p9 = getArgument(env, _p9); \ + P10 p10 = getArgument(env, _p10); \ + P11 p11 = getArgument(env, _p11); \ + P12 p12 = getArgument(env, _p12); \ + P13 p13 = getArgument(env, _p13); \ + P14 p14 = getArgument(env, _p14); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ + releaseArgument(env, _p5, p5); \ + releaseArgument(env, _p6, p6); \ + releaseArgument(env, _p7, p7); \ + releaseArgument(env, _p8, p8); \ + releaseArgument(env, _p9, p9); \ + releaseArgument(env, _p10, p10); \ + releaseArgument(env, _p11, p11); \ + releaseArgument(env, _p12, p12); \ + releaseArgument(env, _p13, p13); \ + releaseArgument(env, _p14, p14); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4 "|" #P5 "|" #P6 "|" #P7 "|" #P8 "|" #P9 "|" #P10 "|" #P11 "|" #P12 "|" #P13 "|" #P14) + +#define KOALA_INTEROP_CTX_0(name, Ret) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) \ + Java_org_##name(JNIEnv* env, jclass instance) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx)); \ + return rv; \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret) + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) \ + Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx, p0)); \ + releaseArgument(env, _p0, p0); \ + return rv; \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0) + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx, p0, p1)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1) + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx, p0, p1, p2)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ + KOALA_JNI_CALL(SlowInteropTypeConverter::InteropType) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2, \ + SlowInteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + auto rv = SlowInteropTypeConverter::convertTo(env, impl_##name(ctx, p0, p1, p2, p3)); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + return rv; \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, #Ret "|" #P0 "|" #P1 "|" #P2 "|" #P3) + +#define KOALA_INTEROP_CTX_V0(name) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance) { \ + KOALA_MAYBE_LOG(name) \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void") + +#define KOALA_INTEROP_CTX_V1(name, P0) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0); \ + releaseArgument(env, _p0, p0); \ + } \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0) + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1) + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2, \ + SlowInteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3) + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ + KOALA_JNI_CALL(void) Java_org_##name(JNIEnv* env, jclass instance, \ + SlowInteropTypeConverter::InteropType _p0, \ + SlowInteropTypeConverter::InteropType _p1, \ + SlowInteropTypeConverter::InteropType _p2, \ + SlowInteropTypeConverter::InteropType _p3, \ + SlowInteropTypeConverter::InteropType _p4) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(env, _p0); \ + P1 p1 = getArgument(env, _p1); \ + P2 p2 = getArgument(env, _p2); \ + P3 p3 = getArgument(env, _p3); \ + P4 p4 = getArgument(env, _p4); \ + KVMContext ctx = (KVMContext)env; \ + impl_##name(ctx, p0, p1, p2, p3, p4); \ + releaseArgument(env, _p0, p0); \ + releaseArgument(env, _p1, p1); \ + releaseArgument(env, _p2, p2); \ + releaseArgument(env, _p3, p3); \ + releaseArgument(env, _p4, p4); \ +} \ +MAKE_JNI_EXPORT(KOALA_INTEROP_MODULE, name, "void|" #P0 "|" #P1 "|" #P2 "|" #P3 "|" #P4) + +bool setKoalaJniCallbackDispatcher( + JNIEnv* env, + jclass clazz, + const char* dispatcherMethodName, + const char* dispactherMethodSig +); +void getKoalaJniCallbackDispatcher(jclass* clazz, jmethodID* method); + +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ + jclass clazz = nullptr; \ + jmethodID method = nullptr; \ + getKoalaJniCallbackDispatcher(&clazz, &method); \ + JNIEnv* jniEnv = reinterpret_cast(venv); \ + jniEnv->PushLocalFrame(1); \ + jbyteArray args_jni = jniEnv->NewByteArray(length); \ + jniEnv->SetByteArrayRegion(args_jni, 0, length, reinterpret_cast(args)); \ + jniEnv->CallStaticIntMethod(clazz, method, id, args_jni, length); \ + jniEnv->GetByteArrayRegion(args_jni, 0, length, reinterpret_cast(args)); \ + jniEnv->PopLocalFrame(nullptr); \ +} + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + jclass clazz = nullptr; \ + jmethodID method = nullptr; \ + getKoalaJniCallbackDispatcher(&clazz, &method); \ + JNIEnv* jniEnv = reinterpret_cast(venv); \ + jniEnv->PushLocalFrame(1); \ + jbyteArray args_jni = jniEnv->NewByteArray(length); \ + jniEnv->SetByteArrayRegion(args_jni, 0, length, reinterpret_cast(args)); \ + int32_t rv = jniEnv->CallStaticIntMethod(clazz, method, id, args_jni, length); \ + jniEnv->GetByteArrayRegion(args_jni, 0, length, reinterpret_cast(args)); \ + jniEnv->PopLocalFrame(nullptr); \ + return rv; \ +} + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + JNIEnv* env = reinterpret_cast(vmContext); \ + env->Throw(object); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + JNIEnv* env = reinterpret_cast(vmContext); \ + const static jclass errorClass = env->FindClass("java/lang/RuntimeException"); \ + env->ThrowNew(errorClass, message); \ + } while (0) + +#endif // KOALA_JNI_CALL diff --git a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc new file mode 100644 index 000000000..b1edbde65 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2022-2025 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 +#include <_types/_uint32_t.h> +#include <_types/_uint8_t.h> +#include +#include + +#include "convertors-jsc.h" + +// See https://github.com/BabylonJS/BabylonNative/blob/master/Dependencies/napi/napi-direct/source/js_native_api_javascriptcore.cc +// for convertors logic. + + +KInt* getInt32Elements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +uint32_t* getUInt32Elements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +float* getFloat32Elements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +KByte* getByteElements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +KStringArray getKStringArray(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +KUShort* getUShortElements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +KShort* getShortElements(JSContextRef context, const JSValueRef arguments) { + return getTypedElements(context, arguments); +} + +int32_t getInt32(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +uint32_t getUInt32(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +uint8_t getUInt8(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +/* +static JSStringRef bigintToArrayCastFuncName = JSStringCreateWithUTF8CString("__JSC__castFromBigInt"); +static JSStringRef bigintToArrayCastFuncParams[] = { JSStringCreateWithUTF8CString("ptr") }; +static JSStringRef bigintToArrayCastFuncBody = JSStringCreateWithUTF8CString( + "return new Uint32Array([ptr & 0xFFFFFFFFn, (ptr >> 32n) & 0xFFFFFFFFn]);" +); + +static JSStringRef arrayToBigintCastFuncName = JSStringCreateWithUTF8CString("__JSC__castToBigInt"); +static JSStringRef arrayToBigintCastFuncParams[] = { JSStringCreateWithUTF8CString("ptr") }; +static JSStringRef arrayToBigintCastFuncBody = JSStringCreateWithUTF8CString( + "return BigInt(ptr[1]) << 32n | BigInt(ptr[0])" +); +*/ + +#ifdef KOALA_JSC_USE_CALLBACK_CAST + +static JSStringRef bigIntFromPartsFuncName = JSStringCreateWithUTF8CString("__JSC__bigIntFromParts"); +static JSStringRef bigIntFromPartsFuncParams[] = { JSStringCreateWithUTF8CString("hi"), JSStringCreateWithUTF8CString("lo") }; +static JSStringRef bigIntFromPartsFuncBody = JSStringCreateWithUTF8CString( + "return BigInt(hi) << 32n | BigInt(lo);" +); + +static JSObjectRef getGlobalCallback(JSContextRef context, JSStringRef name, JSStringRef params[], JSStringRef body) { + JSObjectRef globalThis = JSContextGetGlobalObject(context); + JSValueRef propname = JSValueMakeString(context, name); + JSValueRef castFunc = JSObjectGetPropertyForKey(context, globalThis, propname, nullptr); + if (JSValueIsUndefined(context, castFunc)) { + JSObjectRef castFuncObj = JSObjectMakeFunction(context, name, 1, params, body, nullptr, 0, nullptr); + JSPropertyAttributes attributes = kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum; + JSObjectSetPropertyForKey(context, globalThis, propname, castFuncObj, attributes, nullptr); + return castFuncObj; + } + return JSValueToObject(context, castFunc, nullptr); +} + +static JSObjectRef getBigIntFromParts(JSContextRef context) { + return getGlobalCallback(context, bigIntFromPartsFuncName, bigIntFromPartsFuncParams, bigIntFromPartsFuncBody); +} + +#endif + +static JSValueRef u64ToBigInt(JSContextRef context, uint64_t value) { + JSValueRef bigint; +#ifdef KOALA_JSC_USE_CALLBACK_CAST + // TODO benchmark this + JSObjectRef bigIntFromParts = getBigIntFromParts(context); + JSValueRef parts[2] = { + JSValueMakeNumber(context, (double) (value >> 32)), + JSValueMakeNumber(context, (double) (value & 0xFFFFFFFF)), + }; + bigint = JSObjectCallAsFunction(context, bigIntFromParts, nullptr, 2, parts, nullptr); +#else + char buffer[128] = {0}; + std::snprintf(buffer, sizeof(buffer) - 1, "%zun", (size_t) value); + JSStringRef script = JSStringCreateWithUTF8CString(buffer); + bigint = JSEvaluateScript(context, script, nullptr, nullptr, 0, nullptr); + JSStringRelease(script); +#endif + return bigint; +} + +static uint64_t bigIntToU64(JSContextRef ctx, JSValueRef value) { + char buf[128]; + JSStringRef strRef = JSValueToStringCopy(ctx, value, nullptr); + size_t len = JSStringGetUTF8CString(strRef, buf, sizeof(buf)); + JSStringRelease(strRef); + assert(len < sizeof(buf)); + char* suf; + uint64_t numValue = std::strtoull(buf, &suf, 10); + assert(*suf == '\0'); + return numValue; +} + +KNativePointer getPointer(JSContextRef context, JSValueRef value) { + uint64_t raw = bigIntToU64(context, value); + return reinterpret_cast(static_cast(raw)); +} + +KNativePointerArray getPointerElements(JSContextRef context, JSValueRef value) { + if (JSValueIsNull(context, value) || JSValueIsUndefined(context, value)) { + return nullptr; + } + + assert(JSValueIsObject(context, value)); + assert(JSValueGetTypedArrayType(context, value, nullptr) == kJSTypedArrayTypeBigUint64Array); + + JSObjectRef typedArray = JSValueToObject(context, value, nullptr); + return reinterpret_cast(JSObjectGetTypedArrayBytesPtr(context, typedArray, nullptr)); +} + +KFloat getFloat(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +KShort getShort(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +KUShort getUShort(JSContextRef context, JSValueRef value) { + JSValueRef exception {}; + if (JSValueIsNull(context, value)) { + return 0; + } + if (JSValueIsUndefined(context, value)) { + assert(false); + return 0; + } + double result = JSValueToNumber(context, value, &exception); + return static_cast(result); +} + +KStringPtr getString(JSContextRef context, JSValueRef value) { + if (JSValueIsNull(context, value)) { + return KStringPtr(); + } + if (JSValueIsUndefined(context, value)) { + return KStringPtr(); + } + KStringPtr result; + JSStringRef valueString = JSValueToStringCopy(context, value, NULL); + size_t size = JSStringGetMaximumUTF8CStringSize(valueString); + result.resize(size); + JSStringGetUTF8CString(valueString, result.data(), size); + JSStringRelease(valueString); + return result; +} + +KBoolean getBoolean(JSContextRef context, JSValueRef value) { + bool result = JSValueToBoolean(context, value); + return static_cast(result); +} + +JSValueRef makeInt32(JSContextRef context, int32_t value) { + return JSValueMakeNumber(context, value); +} + +JSValueRef makeUInt32(JSContextRef context, uint32_t value) { + return JSValueMakeNumber(context, value); +} + +JSValueRef makePointer(JSContextRef context, KNativePointer value) { + return u64ToBigInt(context, static_cast(reinterpret_cast(value))); +} + +JSValueRef makeFloat(JSContextRef context, KFloat value) { + return JSValueMakeNumber(context, value); +} + +JSValueRef makeBoolean(JSContextRef context, KBoolean value) { + return JSValueMakeBoolean(context, value); +} + +JSValueRef makeVoid(JSContextRef context) { + return JSValueMakeUndefined(context); +} + +Exports* Exports::getInstance() { + static Exports *instance = nullptr; + if (instance == nullptr) { + instance = new Exports(); + } + return instance; +} + +void InitExports(JSGlobalContextRef globalContext) { + JSObjectRef globalObject = JSContextGetGlobalObject(globalContext); + for (auto impl: Exports::getInstance()->getImpls()) { + JSStringRef functionName = JSStringCreateWithUTF8CString(impl.first.c_str()); + JSObjectRef functionObject = JSObjectMakeFunctionWithCallback(globalContext, functionName, impl.second); + JSObjectSetProperty(globalContext, globalObject, functionName, functionObject, kJSPropertyAttributeNone, nullptr); + JSStringRelease(functionName); + } +} diff --git a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h new file mode 100644 index 000000000..b100dff7d --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h @@ -0,0 +1,722 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +#pragma once + +#if defined(linux) +#include // For IDE completion +#else +#include +#endif +#include <_types/_uint8_t.h> +#include +#include +#include + +#include + +#include "koala-types.h" + +template +inline ElemType* getTypedElements(JSContextRef context, const JSValueRef arguments) { + if (JSValueIsNull(context, arguments)) { + return nullptr; + } + if (JSValueIsUndefined(context, arguments)) { + assert(false); + return nullptr; + } + JSValueRef exception {}; + ElemType* data = reinterpret_cast(JSObjectGetTypedArrayBytesPtr(context, + JSValueToObject(context, arguments, &exception), &exception)); + return data; +} + +template +inline ElemType* getTypedElements(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getTypedElements(context, arguments[index]); +} + +uint8_t* getUInt8Elements(JSContextRef context, const JSValueRef arguments); +int32_t* getInt32Elements(JSContextRef context, const JSValueRef arguments); +uint32_t* getUInt32Elements(JSContextRef context, const JSValueRef arguments); +float* getFloat32Elements(JSContextRef context, const JSValueRef arguments); +KByte* getByteElements(JSContextRef context, const JSValueRef arguments); +KUShort* getUShortElements(JSContextRef context, const JSValueRef arguments); +KShort* getShortElements(JSContextRef context, const JSValueRef arguments); +KNativePointerArray getPointerElements(JSContextRef context, const JSValueRef arguments); +KStringArray getKStringArray(JSContextRef context, const JSValueRef arguments); + +uint8_t getUInt8(JSContextRef context, JSValueRef value); +int32_t getInt32(JSContextRef context, JSValueRef value); +uint32_t getUInt32(JSContextRef context, JSValueRef value); +KNativePointer getPointer(JSContextRef context, JSValueRef value); +KFloat getFloat(JSContextRef context, JSValueRef value); +KStringPtr getString(JSContextRef context, JSValueRef value); +KBoolean getBoolean(JSContextRef context, JSValueRef value); +KStringPtr getString(JSContextRef context, JSValueRef value); + +template +inline Type getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) = delete; + +template <> +inline int32_t getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getInt32(context, arguments[index]); +} + +template <> +inline uint32_t getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getUInt32(context, arguments[index]); +} + +template <> +inline uint8_t getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getUInt8(context, arguments[index]); +} + +template <> +inline KNativePointer getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getPointer(context, arguments[index]); +} + +template <> +inline KFloat getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getFloat(context, arguments[index]); +} + +template <> +inline KStringPtr getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getString(context, arguments[index]); +} + +template <> +inline KBoolean getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getBoolean(context, arguments[index]); +} + +template <> +inline KInt* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getInt32Elements(context, arguments[index]); +} + +template <> +inline float* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getFloat32Elements(context, arguments[index]); +} + +template <> +inline KByte* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getByteElements(context, arguments[index]); +} + +template <> +inline KStringArray getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getKStringArray(context, arguments[index]); +} + +template <> +inline KUShort* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getUShortElements(context, arguments[index]); +} + +template <> +inline KNativePointerArray getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getPointerElements(context, arguments[index]); +} + +template <> +inline KShort* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { + assert(index < argumentCount); + return getShortElements(context, arguments[index]); +} + +JSValueRef makeInt32(JSContextRef context, int32_t value); +JSValueRef makeUInt32(JSContextRef context, uint32_t value); +JSValueRef makePointer(JSContextRef context, KNativePointer value); +JSValueRef makeFloat(JSContextRef context, KFloat value); +JSValueRef makeBoolean(JSContextRef context, KBoolean value); +JSValueRef makeVoid(JSContextRef context); + +template +inline JSValueRef makeResult(JSContextRef context, Type value) = delete; + +template <> +inline JSValueRef makeResult(JSContextRef context, int32_t value) { + return makeInt32(context, value); +} + +template <> +inline JSValueRef makeResult(JSContextRef context, uint32_t value) { + return makeUInt32(context, value); +} + +template <> +inline JSValueRef makeResult(JSContextRef context, KNativePointer value) { + return makePointer(context, value); +} + +template <> +inline JSValueRef makeResult(JSContextRef context, KFloat value) { + return makeFloat(context, value); +} + +template <> +inline JSValueRef makeResult(JSContextRef context, KBoolean value) { + return makeBoolean(context, value); +} + +typedef JSValueRef (*jsc_type_t)(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +class Exports { + std::vector> implementations; + +public: + static Exports* getInstance(); + + void addImpl(const char* name, jsc_type_t impl) { + implementations.push_back(std::make_pair(name, impl)); + } + + const std::vector>& getImpls() { + return implementations; + } +}; + +void InitExports(JSGlobalContextRef globalContext); + +#define MAKE_JSC_EXPORT(name) \ + __attribute__((constructor)) \ + static void __init_##name() { \ + Exports::getInstance()->addImpl("_"#name, Jsc_##name); \ + } + +#define MAKE_JSC_EXPORT_V1(name) \ + __attribute__((constructor)) \ + static void __init_##name() { \ + Exports::getInstance()->addImpl(#name, Jsc_##name); \ + } + +#define KOALA_INTEROP_0(name, Ret) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(ctx, impl_##name()); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + return makeResult(ctx, impl_##name(p0)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + return makeResult(ctx, impl_##name(p0, p1)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + return makeResult(ctx, impl_##name(p0,p1,p2)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + P12 p12 = getArgument(ctx, argumentCount, arguments, 12); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + P12 p12 = getArgument(ctx, argumentCount, arguments, 12); \ + P13 p13 = getArgument(ctx, argumentCount, arguments, 13); \ + return makeResult(ctx, impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V0(name) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V1(name, P0) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + impl_##name(p0); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + impl_##name(p0,p1); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + impl_##name(p0,p1,p2); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + impl_##name(p0,p1,p2,p3); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + impl_##name(p0,p1,p2,p3,p4); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + impl_##name(p0,p1,p2,p3,p4,p5); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + P12 p12 = getArgument(ctx, argumentCount, arguments, 12); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + P4 p4 = getArgument(ctx, argumentCount, arguments, 4); \ + P5 p5 = getArgument(ctx, argumentCount, arguments, 5); \ + P6 p6 = getArgument(ctx, argumentCount, arguments, 6); \ + P7 p7 = getArgument(ctx, argumentCount, arguments, 7); \ + P8 p8 = getArgument(ctx, argumentCount, arguments, 8); \ + P9 p9 = getArgument(ctx, argumentCount, arguments, 9); \ + P10 p10 = getArgument(ctx, argumentCount, arguments, 10); \ + P11 p11 = getArgument(ctx, argumentCount, arguments, 11); \ + P12 p12 = getArgument(ctx, argumentCount, arguments, 12); \ + P13 p13 = getArgument(ctx, argumentCount, arguments, 13); \ + impl_##name(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +// todo: implement properly +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception) \ + { \ + printf("TODO: implement KOALA_INTEROP_CTX_3 for jsc"); \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + return makeResult(ctx, impl_##name(nullptr, p0, p1, p2)); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P4) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception) \ + { \ + printf("TODO: implement KOALA_INTEROP_CTX_4 for jsc"); \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + return makeResult(ctx, impl_##name(nullptr, p0, p1, p2, p3)); \ + } \ + MAKE_JSC_EXPORT(name) + +// todo: implement properly +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + printf("TODO: implement KOALA_INTEROP_CTX_V3 for jsc"); \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + impl_##name(nullptr, p0, p1, p2); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + JSValueRef Jsc_##name(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { \ + printf("TODO: implement KOALA_INTEROP_CTX_V4 for jsc"); \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(ctx, argumentCount, arguments, 0); \ + P1 p1 = getArgument(ctx, argumentCount, arguments, 1); \ + P2 p2 = getArgument(ctx, argumentCount, arguments, 2); \ + P3 p3 = getArgument(ctx, argumentCount, arguments, 3); \ + impl_##name(nullptr, p0, p1, p2, p3); \ + return makeVoid(ctx); \ + } \ + MAKE_JSC_EXPORT(name) + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + /* TODO: implement*/ assert(false); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + assert(false); /* TODO: implement*/ \ + return __VA_ARGS__; \ + } while (0) diff --git a/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.cc b/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.cc new file mode 100644 index 000000000..1bb1fc9b5 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.cc @@ -0,0 +1,389 @@ +/* + * Copyright (c) 2022-2025 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 +#include +#include +#include + +#include "interop-logging.h" + +#ifdef KOALA_INTEROP_MODULE +#undef KOALA_INTEROP_MODULE +#endif +#define KOALA_INTEROP_MODULE InteropNativeModule +#include "convertors-napi.h" + + +// Adapter for NAPI_MODULE +#define NODE_API_MODULE_ADAPTER(modname, regfunc) \ + static napi_value __napi_##regfunc(napi_env env, napi_value exports) { \ + return Napi::RegisterModule(env, exports, regfunc); \ + } \ + NAPI_MODULE(modname, __napi_##regfunc) + +napi_valuetype getValueTypeChecked(napi_env env, napi_value value) { + napi_valuetype type; + napi_status status = napi_typeof(env, value, &type); + KOALA_NAPI_THROW_IF_FAILED(env, status, napi_undefined); + return type; +} + +bool isTypedArray(napi_env env, napi_value value) { + bool result = false; + napi_status status = napi_is_typedarray(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, false); + return result; +} + +KBoolean getBoolean(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) == napi_valuetype::napi_boolean) { + bool result = false; + napi_get_value_bool(env, value, &result); + return static_cast(result); + } + return static_cast(getInt32(env, value) != 0); +} + +KInt getInt32(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_number) { + napi_throw_error(env, nullptr, "Expected Number"); + return 0; + } + int32_t result = false; + napi_get_value_int32(env, value, &result); + return static_cast(result); +} + +KUInt getUInt32(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_number) { + napi_throw_error(env, nullptr, "Expected Number"); + return 0; + } + uint32_t result = false; + napi_get_value_uint32(env, value, &result); + return static_cast(result); +} + +KFloat getFloat32(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_number) { + napi_throw_error(env, nullptr, "Expected Number"); + return 0.0f; + } + double result = false; + napi_get_value_double(env, value, &result); + return static_cast(static_cast(result)); +} + +KDouble getFloat64(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_number) { + napi_throw_error(env, nullptr, "Expected Number"); + return 0.0; + } + double result = false; + napi_get_value_double(env, value, &result); + return static_cast(result); +} + +KStringPtr getString(napi_env env, napi_value value) { + KStringPtr result {}; + napi_valuetype valueType = getValueTypeChecked(env, value); + if (valueType == napi_valuetype::napi_null || valueType == napi_valuetype::napi_undefined) { + return result; + } + + if (valueType != napi_valuetype::napi_string) { + napi_throw_error(env, nullptr, "Expected String"); + return result; + } + + size_t length = 0; + napi_status status = napi_get_value_string_utf8(env, value, nullptr, 0, &length); + if (status != 0) return result; + result.resize(length); + status = napi_get_value_string_utf8(env, value, result.data(), length + 1, nullptr); + return result; +} + +KNativePointer getPointer(napi_env env, napi_value value) { + napi_valuetype valueType = getValueTypeChecked(env, value); + if (valueType == napi_valuetype::napi_external) { + KNativePointer result = nullptr; + napi_status status = napi_get_value_external(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, nullptr); + return result; + } + + if (valueType != napi_valuetype::napi_bigint) { + napi_throw_error(env, nullptr, "cannot be coerced to pointer"); + return nullptr; + } + + bool isWithinRange = true; + uint64_t ptrU64 = 0; + napi_status status = napi_get_value_bigint_uint64(env, value, &ptrU64, &isWithinRange); + KOALA_NAPI_THROW_IF_FAILED(env, status, nullptr); + if (!isWithinRange) { + napi_throw_error(env, nullptr, "cannot be coerced to uint64, value is too large"); + return nullptr; + } + return reinterpret_cast(ptrU64); +} + +KLong getInt64(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_bigint) { + napi_throw_error(env, nullptr, "cannot be coerced to int64"); + return -1; + } + + bool isWithinRange = true; + int64_t ptr64 = 0; + napi_get_value_bigint_int64(env, value, &ptr64, &isWithinRange); + if (!isWithinRange) { + napi_throw_error(env, nullptr, "cannot be coerced to int64, value is too large"); + return -1; + } + return static_cast(ptr64); +} + +KULong getUInt64(napi_env env, napi_value value) { + if (getValueTypeChecked(env, value) != napi_valuetype::napi_bigint) { + napi_throw_error(env, nullptr, "cannot be coerced to uint64"); + return -1; + } + + bool isWithinRange = true; + uint64_t ptr64 = 0; + napi_get_value_bigint_uint64(env, value, &ptr64, &isWithinRange); + if (!isWithinRange) { + napi_throw_error(env, nullptr, "cannot be coerced to uint64, value is too large"); + return -1; + } + return static_cast(ptr64); +} + +napi_value makeString(napi_env env, const KStringPtr& value) { + napi_value result; + napi_status status; + status = napi_create_string_utf8(env, value.isNull() ? "" : value.data(), value.length(), &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeString(napi_env env, const std::string& value) { + napi_value result; + napi_status status; + status = napi_create_string_utf8(env, value.c_str(), value.length(), &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeBoolean(napi_env env, int8_t value) { + napi_value result; + napi_status status; + status = napi_get_boolean(env, value != 0, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeInt32(napi_env env, int32_t value) { + napi_value result; + napi_status status; + status = napi_create_int32(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeUInt32(napi_env env, uint32_t value) { + napi_value result; + napi_status status; + status = napi_create_uint32(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeInt64(napi_env env, int64_t value) { + napi_value result; + napi_status status; + status = napi_create_bigint_int64(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeUInt64(napi_env env, uint64_t value) { + napi_value result; + napi_status status; + status = napi_create_bigint_uint64(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeFloat32(napi_env env, float value) { + napi_value result; + napi_status status; + status = napi_create_double(env, value, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makePointer(napi_env env, void* value) { + napi_value result; + napi_status status; + status = napi_create_bigint_uint64(env, static_cast(reinterpret_cast(value)), &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeVoid(napi_env env) { + napi_value result; + napi_status status; + status = napi_get_undefined(env, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +napi_value makeObject(napi_env env, napi_value object) { + napi_value result; + napi_status status; + status = napi_create_object(env, &result); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + return result; +} + +#if _MSC_VER >= 1932 // Visual Studio 2022 version 17.2+ +# pragma comment(linker, "/alternatename:__imp___std_init_once_complete=__imp_InitOnceComplete") +# pragma comment(linker, "/alternatename:__imp___std_init_once_begin_initialize=__imp_InitOnceBeginInitialize") +#endif + +Exports* Exports::getInstance() { + static Exports *instance = nullptr; + if (instance == nullptr) { + instance = new Exports(); + } + return instance; +} + +std::vector Exports::getModules() { + std::vector result; + for (auto it = implementations.begin(); it != implementations.end(); ++it) { + result.push_back(it->first); + } + return result; +} + +void Exports::addMethod(const char* module, const char* name, napi_type_t impl) { + auto it = implementations.find(module); + if (it == implementations.end()) { + it = implementations.insert(std::make_pair(module, std::vector>())).first; + } + it->second.push_back(std::make_pair(name, impl)); + +} + +const std::vector>& Exports::getMethods(const std::string& module) { + auto it = implementations.find(module); + if (it == implementations.end()) { + LOGE("Module %s is not registered", module.c_str()); + INTEROP_FATAL("Fatal error"); + } + return it->second; +} + +// +// Callback dispatcher +// +// TODO Should we get rid of explicit Node_* declrations and hide the naming convention behind the macro definitions? + +static napi_ref g_koalaNapiCallbackDispatcher = nullptr; + +// TODO: shall we pass name in globalThis instead of object reference? +napi_value Node_SetCallbackDispatcher(napi_env env, napi_callback_info cbinfo) { + fprintf(stderr, "Node_SetCallbackDispatcher!\n"); + + CallbackInfo info(env, cbinfo); + napi_value dispatcher = info[0]; + napi_value result = makeVoid(env); + napi_status status = napi_create_reference(env, dispatcher, 1, &g_koalaNapiCallbackDispatcher); + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + + return result; +} +MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, SetCallbackDispatcher) + +napi_value Node_CleanCallbackDispatcher(napi_env env, napi_callback_info cbinfo) { + napi_value result = makeVoid(env); + if (g_koalaNapiCallbackDispatcher) { + napi_status status = napi_delete_reference(env, g_koalaNapiCallbackDispatcher); + g_koalaNapiCallbackDispatcher = nullptr; + KOALA_NAPI_THROW_IF_FAILED(env, status, result); + } + return result; +} +MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, CleanCallbackDispatcher) + +napi_value getKoalaNapiCallbackDispatcher(napi_env env) { + if (!g_koalaNapiCallbackDispatcher) { + abort(); + } + napi_value value; + napi_status status = napi_get_reference_value(env, g_koalaNapiCallbackDispatcher, &value); + KOALA_NAPI_THROW_IF_FAILED(env, status, makeVoid(env)); + return value; +} + +// +// Module initialization +// + +using ModuleRegisterCallback = napi_value (*)(napi_env env, napi_value exports); + +/** + * Sets a new callback and returns its previous value. + */ +ModuleRegisterCallback ProvideModuleRegisterCallback(ModuleRegisterCallback value = nullptr) { + static const ModuleRegisterCallback DEFAULT_CB = [](napi_env env, napi_value exports) { return exports; }; + static ModuleRegisterCallback curCallback = DEFAULT_CB; + + ModuleRegisterCallback prevCallback = curCallback; + curCallback = value ? value : DEFAULT_CB; + return prevCallback; +} + +static constexpr bool splitModules = true; + +static napi_value InitModule(napi_env env, napi_value exports) { + LOG("InitModule: " QUOTE(INTEROP_LIBRARY_NAME) "\n"); + Exports* inst = Exports::getInstance(); + napi_status status; + napi_value target = exports; + for (const auto &module : inst->getModules()) { + if (splitModules) { + status = napi_create_object(env, &target); + KOALA_NAPI_THROW_IF_FAILED(env, status, exports); + status = napi_set_named_property(env, exports, module.c_str(), target); + KOALA_NAPI_THROW_IF_FAILED(env, status, exports); + } + + for (const auto &impl : inst->getMethods(module)) { + napi_value implFunc; + status = napi_create_function(env, impl.first.c_str(), NAPI_AUTO_LENGTH, impl.second, nullptr, &implFunc); + KOALA_NAPI_THROW_IF_FAILED(env, status, exports); + status = napi_set_named_property(env, target, impl.first.c_str(), implFunc); + KOALA_NAPI_THROW_IF_FAILED(env, status, exports); + } + } + return ProvideModuleRegisterCallback()(env, exports); +} + +NAPI_MODULE(INTEROP_LIBRARY_NAME, InitModule) diff --git a/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.h b/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.h new file mode 100644 index 000000000..720d423f1 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.h @@ -0,0 +1,1374 @@ +/* + * Copyright (c) 2022-2025 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 _CONVERTORS_NAPI_H_ +#define _CONVERTORS_NAPI_H_ + +#ifdef KOALA_NAPI + +#include +#include +#include + +#ifndef KOALA_NAPI_OHOS +#include +#else +#include +#include +#endif +#include "koala-types.h" +#include "interop-types.h" + +// TODO: switch to more generic convertors eventually. +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(napi_env env, InteropType value) { return value; } + static InteropType convertTo(napi_env env, T value) { return value; } + static void release(napi_env env, InteropType value, T converted) {} +}; + +template +inline typename InteropTypeConverter::InteropType makeResult(napi_env env, Type value) { + return InteropTypeConverter::convertTo(env, value); +} + +template +inline Type getArgument(napi_env env, typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(env, arg); +} + +template +inline void releaseArgument(napi_env env, typename InteropTypeConverter::InteropType arg, Type data) { + InteropTypeConverter::release(env, arg, data); +} + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static KInteropBuffer convertFrom(napi_env env, InteropType value) { + KInteropBuffer result = { 0 }; + bool isArrayBuffer = false; + napi_is_arraybuffer(env, value, &isArrayBuffer); + if (isArrayBuffer) { + napi_get_arraybuffer_info(env, value, &result.data, (size_t*)&result.length); + } else { + bool isDataView = false; + napi_is_dataview(env, value, &isDataView); + if (isDataView) { + napi_get_dataview_info(env, value, (size_t*)&result.length, &result.data, nullptr, nullptr); + } + } + return result; + } + static InteropType convertTo(napi_env env, KInteropBuffer value) { + KInteropBuffer* copy = new KInteropBuffer(value); + napi_value result; + napi_status status = napi_create_external_arraybuffer( + env, + value.data, + value.length, + [](napi_env env, void* finalize_data, void* finalize_hint) { + KInteropBuffer* buffer = reinterpret_cast(finalize_hint); + buffer->dispose(buffer->resourceId); + delete buffer; + }, + (void*)copy, + &result + ); + if (status != napi_ok) { + // do smth here + } + return result; + }; + static void release(napi_env env, InteropType value, KInteropBuffer converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static KStringPtr convertFrom(napi_env env, InteropType value) { + if (value == nullptr) return KStringPtr(); + KStringPtr result; + size_t length = 0; + napi_status status = napi_get_value_string_utf8(env, value, nullptr, 0, &length); + if (status != 0) return result; + result.resize(length); + status = napi_get_value_string_utf8(env, value, result.data(), length + 1, nullptr); + return result; + } + static InteropType convertTo(napi_env env, const KStringPtr& value) { + napi_value result; + napi_create_string_utf8(env, value.c_str(), value.length(), &result); + return result; + } + static void release(napi_env env, InteropType value, const KStringPtr& converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static KInteropNumber convertFrom(napi_env env, InteropType interopValue) { + double value = 0.0; + napi_get_value_double(env, interopValue, &value); + return KInteropNumber::fromDouble(value); + } + static InteropType convertTo(napi_env env, KInteropNumber value) { + napi_value result; + napi_create_double(env, value.asDouble(), &result); + return result; + } + static void release(napi_env env, InteropType value, KInteropNumber converted) {} +}; + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static inline KVMObjectHandle convertFrom(napi_env env, InteropType value) { + return reinterpret_cast(value); + } + static InteropType convertTo(napi_env env, KVMObjectHandle value) { + return reinterpret_cast(value); + } + static inline void release(napi_env env, InteropType value, KVMObjectHandle converted) { + } +}; + +template<> +struct InteropTypeConverter { + using InteropType = napi_value; + static inline KInteropReturnBuffer convertFrom(napi_env env, InteropType value) = delete; + static void disposer(napi_env env, void* data, void* hint) { + KInteropReturnBuffer* bufferCopy = (KInteropReturnBuffer*)hint; + bufferCopy->dispose(bufferCopy->data, bufferCopy->length); + delete bufferCopy; + } + static InteropType convertTo(napi_env env, KInteropReturnBuffer value) { + napi_value result = nullptr; + napi_value arrayBuffer = nullptr; + auto clone = new KInteropReturnBuffer(); + *clone = value; + napi_create_external_arraybuffer(env, value.data, value.length, disposer, clone, &arrayBuffer); + napi_create_typedarray(env, napi_uint8_array, value.length, arrayBuffer, 0, &result); + return result; + } + static inline void release(napi_env env, InteropType value, const KInteropReturnBuffer& converted) = delete; +}; + + +#define KOALA_INTEROP_THROW(vmcontext, object, ...) \ + do { \ + napi_env env = (napi_env)vmcontext; \ + napi_handle_scope scope = nullptr; \ + napi_open_handle_scope(env, &scope); \ + napi_throw((napi_env)vmcontext, object); \ + napi_close_handle_scope(env, scope); \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + napi_value value; \ + napi_create_string_utf8((napi_env)vmContext, message, strlen(message), &value); \ + KOALA_INTEROP_THROW(vmContext, value, __VA_ARGS__); \ + } while (0) + +#define NAPI_ASSERT_INDEX(info, index, result) \ + do { \ + if (static_cast(index) >= info.Length()) { \ + napi_throw_error(info.Env(), nullptr, "No such element");\ + return result; \ + } \ + } while (0) + +// Helpers from node-addon-api +#define KOALA_NAPI_THROW_IF_FAILED(env, status, ...) \ + if ((status) != napi_ok) { \ + const napi_extended_error_info* errorInfo; \ + napi_get_last_error_info(env, &errorInfo); \ + napi_throw_error(env, nullptr, errorInfo->error_message); \ + return __VA_ARGS__; \ + } +#define KOALA_NAPI_THROW_IF_FAILED_VOID(env, status) \ + if ((status) != napi_ok) { \ + const napi_extended_error_info* errorInfo; \ + napi_get_last_error_info(env, &errorInfo); \ + napi_throw_error(env, nullptr, errorInfo->error_message); \ + return; \ + } + +class CallbackInfo { +public: + CallbackInfo(napi_env env, napi_callback_info info) : _env(env) { + size_t size = 0; + napi_status status; + status = napi_get_cb_info(env, info, &size, nullptr, nullptr, nullptr); + KOALA_NAPI_THROW_IF_FAILED_VOID(env, status); + if (size > 0) { + args.resize(size); // TODO statically allocate small array for common case with few arguments passed + status = napi_get_cb_info(env, info, &size, args.data(), nullptr, nullptr); + KOALA_NAPI_THROW_IF_FAILED_VOID(env, status); + } + } + + napi_value operator[](size_t idx) const { + if (idx >= Length()) { + napi_value result; + napi_get_undefined(_env, &result); + return result; + } + return args[idx]; + } + + napi_env Env() const { + return _env; + } + + size_t Length() const { + return args.size(); + } +private: + napi_env _env; + // napi_callback_info _info; + std::vector args; +}; + +template +inline napi_typedarray_type getNapiType() = delete; + +template <> +inline napi_typedarray_type getNapiType() { + return napi_float32_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_int8_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_uint8_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_int16_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_uint16_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_int32_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_uint32_array; +} + +template <> +inline napi_typedarray_type getNapiType() { + return napi_biguint64_array; +} + +napi_valuetype getValueTypeChecked(napi_env env, napi_value value); +bool isTypedArray(napi_env env, napi_value value); + +template +inline ElemType* getTypedElements(napi_env env, napi_value value) { + napi_valuetype valueType = getValueTypeChecked(env, value); + if (valueType == napi_null) { + return nullptr; + } + if (!isTypedArray(env, value)) { + napi_throw_error(env, nullptr, "Expected TypedArray"); + return nullptr; + } + napi_value arrayBuffer; + void* data = nullptr; + size_t byteLength; + size_t byteOffset; + napi_typedarray_type type; + napi_status status = napi_get_typedarray_info(env, + value, + &type, + &byteLength, + &data, + &arrayBuffer, + &byteOffset); + KOALA_NAPI_THROW_IF_FAILED(env, status, nullptr); + if (type != getNapiType()) { + printf("Array type mismatch. Expected %d got %d\n", getNapiType(), type); + napi_throw_error(env, nullptr, "Array type mismatch"); + return nullptr; + } + return reinterpret_cast(data); +} + +template +inline ElemType* getTypedElements(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, nullptr); + return getTypedElements(info.Env(), info[index]); +} + +inline uint8_t* getUInt8Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline int8_t* getInt8Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline uint16_t* getUInt16Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline int16_t* getInt16Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline uint32_t* getUInt32Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline uint32_t* getUInt32Elements(napi_env env, napi_value value) { + return getTypedElements(env, value); +} + +inline int32_t* getInt32Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline float* getFloat32Elements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +inline KNativePointer* getPointerElements(const CallbackInfo& info, int index) { + return getTypedElements(info, index); +} + +KInt getInt32(napi_env env, napi_value value); +inline int32_t getInt32(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0); + return getInt32(info.Env(), info[index]); +} +KUInt getUInt32(napi_env env, napi_value value); +inline uint32_t getUInt32(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0); + return getUInt32(info.Env(), info[index]); +} +KFloat getFloat32(napi_env env, napi_value value); +inline float getFloat32(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0.0f); + return getFloat32(info.Env(), info[index]); +} +KDouble getFloat64(napi_env env, napi_value value); +inline KDouble getFloat64(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0.0); + return getFloat64(info.Env(), info[index]); +} +KStringPtr getString(napi_env env, napi_value value); +inline KStringPtr getString(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, KStringPtr()); + return getString(info.Env(), info[index]); +} +void* getPointer(napi_env env, napi_value value); +inline void* getPointer(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, nullptr); + return getPointer(info.Env(), info[index]); +} +KULong getUInt64(napi_env env, napi_value value); +inline KULong getUInt64(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0); + return getUInt64(info.Env(), info[index]); +} +KLong getInt64(napi_env env, napi_value value); +inline KLong getInt64(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, 0); + return getInt64(info.Env(), info[index]); +} +KBoolean getBoolean(napi_env env, napi_value value); +inline KBoolean getBoolean(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, false); + return getBoolean(info.Env(), info[index]); +} + +template +inline Type getArgument(const CallbackInfo& info, int index) = delete; + +template <> +inline KBoolean getArgument(const CallbackInfo& info, int index) { + return getBoolean(info, index); +} + +template <> +inline KUInt getArgument(const CallbackInfo& info, int index) { + return getUInt32(info, index); +} + +template <> +inline KInt getArgument(const CallbackInfo& info, int index) { + return getInt32(info, index); +} + +template <> +inline KInteropNumber getArgument(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, { 0 }); + return getArgument(info.Env(), info[index]); +} + +template <> +inline KLength getArgument(const CallbackInfo& info, int index) { + KLength result = { 0 }; + NAPI_ASSERT_INDEX(info, index, result); + auto value = info[index]; + napi_valuetype type; + auto status = napi_typeof(info.Env(), value, &type); + if (status != 0) return result; + switch (type) { + case napi_number: { + result.value = getFloat32(info.Env(), value); + result.unit = 1; + result.type = 0; + break; + } + case napi_string: { + KStringPtr string = getString(info.Env(), value); + parseKLength(string, &result); + result.type = 1; + result.resource = 0; + break; + } + case napi_object: { + result.value = 0; + result.unit = 1; + result.type = 2; + napi_value field; + napi_status status = napi_get_named_property(info.Env(), value, "id", &field); + if (status == 0) { + status = napi_get_value_int32(info.Env(), field, &result.resource); + if (status != 0) result.resource = 0; + } else { + result.resource = 0; + } + break; + } + default: + INTEROP_FATAL("Error, unexpected KLength type"); + } + return result; +} + + +template <> +inline KInteropBuffer getArgument(const CallbackInfo& info, int index) { + NAPI_ASSERT_INDEX(info, index, { 0 }); + return getArgument((napi_env)info.Env(), (napi_value)info[index]); +} + +template <> +inline KFloat getArgument(const CallbackInfo& info, int index) { + return getFloat32(info, index); +} + +template <> +inline KDouble getArgument(const CallbackInfo& info, int index) { + return getFloat64(info, index); +} + +template <> +inline KNativePointer getArgument(const CallbackInfo& info, int index) { + return getPointer(info, index); +} + +template <> +inline KLong getArgument(const CallbackInfo& info, int index) { + return getInt64(info, index); +} + +template <> +inline KULong getArgument(const CallbackInfo& info, int index) { + return getUInt64(info, index); +} + +template <> +inline KNativePointerArray getArgument(const CallbackInfo& info, int index) { + return getPointerElements(info, index); +} + +// template <> +// inline napi_value getArgument(const CallbackInfo& info, int index) { +// return getObject(info, index); +// } + +template <> +inline uint8_t* getArgument(const CallbackInfo& info, int index) { + return getUInt8Elements(info, index); +} + +template <> +inline const uint8_t* getArgument(const CallbackInfo& info, int index) { + return getUInt8Elements(info, index); +} + +template <> +inline int8_t* getArgument(const CallbackInfo& info, int index) { + return getInt8Elements(info, index); +} + +template <> +inline int16_t* getArgument(const CallbackInfo& info, int index) { + return getInt16Elements(info, index); +} + +template <> +inline uint16_t* getArgument(const CallbackInfo& info, int index) { + return getUInt16Elements(info, index); +} + +template <> +inline int32_t* getArgument(const CallbackInfo& info, int index) { + return getInt32Elements(info, index); +} + +template <> +inline uint32_t* getArgument(const CallbackInfo& info, int index) { + return getUInt32Elements(info, index); +} + +template <> +inline float* getArgument(const CallbackInfo& info, int index) { + return getFloat32Elements(info, index); +} + +template <> +inline KStringPtr getArgument(const CallbackInfo& info, int index) { + return getString(info, index); +} + +napi_value makeString(napi_env env, KStringPtr value); +napi_value makeString(napi_env env, const std::string& value); +napi_value makeBoolean(napi_env env, KBoolean value); +napi_value makeInt32(napi_env env, int32_t value); +napi_value makeUInt32(napi_env env, uint32_t value); +napi_value makeInt64(napi_env env, int32_t value); +napi_value makeUInt64(napi_env env, uint32_t value); +napi_value makeFloat32(napi_env env, float value); +napi_value makePointer(napi_env env, void* value); +napi_value makeVoid(napi_env env); +// napi_value makeObject(napi_env env, napi_value object); + +inline napi_value makeVoid(const CallbackInfo& info) { + return makeVoid(info.Env()); +} + +template +inline napi_value makeResult(const CallbackInfo& info, Type value) = delete; + +template <> +inline napi_value makeResult(const CallbackInfo& info, KBoolean value) { + return makeBoolean(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, int32_t value) { + return makeInt32(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, uint32_t value) { + return makeUInt32(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, int64_t value) { + return makeInt64(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, uint64_t value) { + return makeUInt64(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, float value) { + return makeFloat32(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KNativePointer value) { + return makePointer(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KVMObjectHandle value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KStringPtr value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KInteropBuffer value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KInteropReturnBuffer value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +template <> +inline napi_value makeResult(const CallbackInfo& info, KInteropNumber value) { + return InteropTypeConverter::convertTo(info.Env(), value); +} + +typedef napi_value (*napi_type_t)(napi_env, napi_callback_info); + +class Exports { + std::unordered_map>> implementations; + +public: + static Exports* getInstance(); + + std::vector getModules(); + void addMethod(const char* module, const char* name, napi_type_t impl); + const std::vector>& getMethods(const std::string& module); +}; + +#define __QUOTE(x) #x +#define QUOTE(x) __QUOTE(x) + +#ifdef _MSC_VER +#define MAKE_NODE_EXPORT(module, name) \ + static void __init_##name() { \ + Exports::getInstance()->addMethod(QUOTE(module), "_"#name, Node_##name); \ + } \ + namespace { \ + struct __Init_##name { \ + __Init_##name() { __init_##name(); } \ + } __Init_##name##_v; \ + } +#else +#define MAKE_NODE_EXPORT(module, name) \ + __attribute__((constructor)) \ + static void __init_##name() { \ + Exports::getInstance()->addMethod(QUOTE(module), "_"#name, Node_##name); \ + } +#endif + +#ifndef KOALA_INTEROP_MODULE +#error KOALA_INTEROP_MODULE is undefined +#endif + +#define MAKE_INTEROP_NODE_EXPORT(name) MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_0(name, Ret) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + return makeResult(info, impl_##name()); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_1(name, Ret, P0) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + return makeResult(info, impl_##name(p0)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + return makeResult(info, impl_##name(p0, p1)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + return makeResult(info, impl_##name(p0, p1, p2)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + return makeResult(info, impl_##name(p0, p1, p2, p3)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + P13 p13 = getArgument(info, 13); \ + return makeResult(info, impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V0(name) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + impl_##name(); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V1(name, P0) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + impl_##name(p0); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V2(name, P0, P1) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + impl_##name(p0, p1); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + impl_##name(p0, p1, p2); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + impl_##name(p0, p1, p2, p3); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + impl_##name(p0, p1, p2, p3, p4); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + P13 p13 = getArgument(info, 13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_V15(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + P5 p5 = getArgument(info, 5); \ + P6 p6 = getArgument(info, 6); \ + P7 p7 = getArgument(info, 7); \ + P8 p8 = getArgument(info, 8); \ + P9 p9 = getArgument(info, 9); \ + P10 p10 = getArgument(info, 10); \ + P11 p11 = getArgument(info, 11); \ + P12 p12 = getArgument(info, 12); \ + P13 p13 = getArgument(info, 13); \ + P14 p14 = getArgument(info, 14); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_0(name, Ret) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + return makeResult(info, impl_##name(ctx)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(impl_##name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + return makeResult(info, impl_##name(ctx, p0)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + return makeResult(info, impl_##name(ctx, p0, p1)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + return makeResult(info, impl_##name(ctx, p0, p1, p2)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + return makeResult(info, impl_##name(ctx, p0, p1, p2, p3)); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V0(name) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + impl_##name(ctx); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + + +#define KOALA_INTEROP_CTX_V1(name, P0) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + impl_##name(ctx, p0); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V2(name, P0, P1) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + impl_##name(ctx, p0, p1); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + impl_##name(ctx, p0, p1, p2); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + impl_##name(ctx, p0, p1, p2, p3); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define KOALA_INTEROP_CTX_V5(name, P0, P1, P2, P3, P4) \ + napi_value Node_##name(napi_env env, napi_callback_info cbinfo) { \ + KOALA_MAYBE_LOG(name) \ + CallbackInfo info(env, cbinfo); \ + KVMContext ctx = reinterpret_cast((napi_env)info.Env()); \ + P0 p0 = getArgument(info, 0); \ + P1 p1 = getArgument(info, 1); \ + P2 p2 = getArgument(info, 2); \ + P3 p3 = getArgument(info, 3); \ + P4 p4 = getArgument(info, 4); \ + impl_##name(ctx, p0, p1, p2, p3, p4); \ + return makeVoid(info); \ + } \ + MAKE_NODE_EXPORT(KOALA_INTEROP_MODULE, name) + +#define NODEJS_GET_AND_THROW_LAST_ERROR(env) \ + do { \ + const napi_extended_error_info *error_info; \ + napi_get_last_error_info((env), &error_info); \ + bool is_pending; \ + napi_is_exception_pending((env), &is_pending); \ + /* If an exception is already pending, don't rethrow it */ \ + if (!is_pending) { \ + const char* error_message = error_info->error_message != NULL ? \ + error_info->error_message : \ + "empty error message"; \ + napi_throw_error((env), NULL, error_message); \ + } \ + } while (0) + +napi_value getKoalaNapiCallbackDispatcher(napi_env env); +// TODO: can/shall we cache bridge reference? + +#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ +{ \ + napi_env env = reinterpret_cast(venv); \ + napi_value bridge = getKoalaNapiCallbackDispatcher(env), \ + global = nullptr, return_val = nullptr; \ + napi_handle_scope scope = nullptr; \ + napi_open_handle_scope(env, &scope); \ + napi_status status = napi_get_global(env, &global); \ + napi_value node_args[3]; \ + napi_create_int32(env, id, &node_args[0]); \ + napi_value buffer = nullptr; \ + napi_create_external_arraybuffer(env, \ + args, length, \ + [](napi_env, void* data, void* hint) {}, nullptr, &buffer); \ + napi_create_typedarray(env, napi_uint8_array, length, buffer, 0, &node_args[1]); \ + napi_create_int32(env, length, &node_args[2]); \ + status = napi_call_function(env, global, bridge, 3, node_args, &return_val); \ + if (status != napi_ok) NODEJS_GET_AND_THROW_LAST_ERROR((env)); \ + napi_close_handle_scope(env, scope); \ +} + +#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ +{ \ + napi_env env = reinterpret_cast(venv); \ + napi_value bridge = getKoalaNapiCallbackDispatcher(env), \ + global = nullptr, return_val = nullptr; \ + napi_handle_scope scope = nullptr; \ + napi_open_handle_scope(env, &scope); \ + napi_status status = napi_get_global(env, &global); \ + napi_value node_args[3]; \ + napi_create_int32(env, id, &node_args[0]); \ + napi_value buffer = nullptr; \ + napi_create_external_arraybuffer(env, \ + args, length, \ + [](napi_env, void* data, void* hint) {}, nullptr, &buffer); \ + napi_create_typedarray(env, napi_uint8_array, length, buffer, 0, &node_args[1]); \ + napi_create_int32(env, length, &node_args[2]); \ + status = napi_call_function(env, global, bridge, 3, node_args, &return_val); \ + if (status != napi_ok) NODEJS_GET_AND_THROW_LAST_ERROR((env)); \ + int result; \ + status = napi_get_value_int32(env, return_val, &result); \ + napi_close_handle_scope(env, scope); \ + return result; \ +} + +#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) +#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) + +#endif // KOALA_NAPI + +#endif // _CONVERTORS_NAPI_H_ \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/napi/win-dynamic-node.cc b/koala-wrapper/koalaui/interop/src/cpp/napi/win-dynamic-node.cc new file mode 100644 index 000000000..6ec8fcc34 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/napi/win-dynamic-node.cc @@ -0,0 +1,672 @@ +/* + * Copyright (c) 2025 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 +#include +#include +#include "node_api.h" + +#define NAPI_CDECL __cdecl + +#define NAPI_FUNCTIONS(op) \ + op(napi_module_register) \ + op(napi_create_function) \ + op(napi_set_named_property) \ + op(napi_create_string_utf8) \ + op(napi_add_env_cleanup_hook) \ + op(napi_get_last_error_info) \ + op(napi_get_value_bigint_int64) \ + op(napi_get_value_bigint_uint64) \ + op(napi_create_object) \ + op(napi_get_arraybuffer_info) \ + op(napi_create_bigint_uint64) \ + op(napi_is_typedarray) \ + op(napi_add_finalizer) \ + op(napi_get_typedarray_info) \ + op(napi_set_property) \ + op(napi_get_value_bool) \ + op(napi_coerce_to_string) \ + op(napi_get_value_uint32) \ + op(napi_get_value_int32) \ + op(napi_throw) \ + op(napi_get_cb_info) \ + op(napi_create_error) \ + op(napi_get_value_string_utf8) \ + op(napi_define_properties) \ + op(napi_delete_reference) \ + op(napi_get_reference_value) \ + op(napi_open_handle_scope) \ + op(napi_close_handle_scope) \ + op(napi_open_escapable_handle_scope) \ + op(napi_close_escapable_handle_scope) \ + op(napi_is_exception_pending) \ + op(napi_create_type_error) \ + op(napi_escape_handle) \ + op(napi_get_and_clear_last_exception) \ + op(napi_fatal_error) \ + op(napi_create_double) \ + op(napi_typeof) \ + op(napi_get_property) \ + op(napi_get_named_property) \ + op(napi_create_reference) \ + op(napi_get_global) \ + op(napi_has_property) \ + op(napi_get_undefined) \ + op(napi_get_value_double) \ + op(napi_close_callback_scope) \ + op(napi_async_destroy) \ + op(napi_call_function) \ + op(napi_get_value_external) \ + op(napi_throw_error) \ + op(napi_create_int32) \ + op(napi_create_external_arraybuffer) \ + op(napi_create_typedarray) \ + op(napi_create_string_latin1) \ + op(napi_create_async_work) \ + op(napi_delete_async_work) \ + op(napi_queue_async_work) \ + op(napi_resolve_deferred) \ + op(napi_reject_deferred) \ + op(napi_create_promise) \ + op(napi_create_threadsafe_function) \ + op(napi_acquire_threadsafe_function) \ + op(napi_release_threadsafe_function) \ + op(napi_call_threadsafe_function) \ + op(napi_is_dataview) \ + op(napi_is_arraybuffer) \ + op(napi_get_dataview_info)\ + op(napi_get_boolean)\ + op(napi_create_uint32)\ + op(napi_create_bigint_int64)\ + +#define DECL_NAPI_IMPL(fn_name, ...) decltype(&fn_name) p_##fn_name; + +NAPI_FUNCTIONS(DECL_NAPI_IMPL) + +bool LoadNapiFunctions() { + static bool isLoaded = false; + if (isLoaded) return true; + HMODULE nodeModule = GetModuleHandle(NULL); + FARPROC fn_addr = GetProcAddress(nodeModule, "napi_module_register"); + + if (fn_addr == NULL) { + nodeModule = GetModuleHandleA("node.dll"); + if (nodeModule == NULL) return false; + fn_addr = GetProcAddress(nodeModule, "napi_module_register"); + if (fn_addr == NULL) { + return false; + } + } + bool apiLoadFailed = false; + +#define GET_NAPI_IMPL(fn_name) \ + fn_addr = GetProcAddress(nodeModule, #fn_name); \ + if (fn_addr == NULL) apiLoadFailed = true; \ + p_##fn_name = (decltype(p_##fn_name))fn_addr; + + // Assign the addresses of the needed functions to the "p*" named pointers. + NAPI_FUNCTIONS(GET_NAPI_IMPL); + + // If any required APIs failed to load, return false + if (apiLoadFailed) return false; + + isLoaded = true; + + return true; +} + +NAPI_EXTERN void NAPI_CDECL +napi_module_register(napi_module* mod) { + LoadNapiFunctions(); + p_napi_module_register(mod); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_last_error_info(napi_env env, const napi_extended_error_info** result) { + LoadNapiFunctions(); + return p_napi_get_last_error_info(env, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_bigint_int64( + napi_env env, napi_value value, int64_t* result, bool* lossless) { + LoadNapiFunctions(); + return p_napi_get_value_bigint_int64(env, value, result, lossless); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_bigint_uint64( + napi_env env, napi_value value, uint64_t* result, bool* lossless) { + LoadNapiFunctions(); + return p_napi_get_value_bigint_uint64(env, value, result, lossless); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_object(napi_env env, napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_object(env, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_arraybuffer_info(napi_env env, napi_value arraybuffer, void** data, size_t* byte_length) { + LoadNapiFunctions(); + return p_napi_get_arraybuffer_info(env, arraybuffer, data, byte_length); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_create_bigint_uint64(napi_env env, uint64_t value, napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_bigint_uint64(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_is_typedarray(napi_env env, napi_value value, bool* result) { + LoadNapiFunctions(); + return p_napi_is_typedarray(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_add_finalizer(napi_env env, + napi_value js_object, + void* finalize_data, + napi_finalize finalize_cb, + void* finalize_hint, + napi_ref* result) { + LoadNapiFunctions(); + return p_napi_add_finalizer(env, js_object, finalize_data, finalize_cb, finalize_hint, result); +} + + +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_typedarray_info(napi_env env, + napi_value typedarray, + napi_typedarray_type* type, + size_t* length, + void** data, + napi_value* arraybuffer, + size_t* byte_offset) { + LoadNapiFunctions(); + return p_napi_get_typedarray_info(env, typedarray, type, length, data, arraybuffer, byte_offset); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_set_property(napi_env env, + napi_value object, + napi_value key, + napi_value value) { + LoadNapiFunctions(); + return p_napi_set_property(env, object, key, value); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_bool(napi_env env, + napi_value value, + bool* result) { + LoadNapiFunctions(); + return p_napi_get_value_bool(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_coerce_to_string(napi_env env, + napi_value value, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_coerce_to_string(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_int32(napi_env env, + napi_value value, + int32_t* result) { + LoadNapiFunctions(); + return p_napi_get_value_int32(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_cb_info( + napi_env env, + napi_callback_info cbinfo, + size_t* argc, + napi_value* argv, + napi_value* this_arg, + void** data) { + LoadNapiFunctions(); + return p_napi_get_cb_info(env, cbinfo, argc, argv, this_arg, data); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_string_utf8(napi_env env, + const char* str, + size_t length, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_string_utf8(env, str, length, result); +} + + +NAPI_EXTERN napi_status NAPI_CDECL napi_throw(napi_env env, napi_value error) { + LoadNapiFunctions(); + return p_napi_throw(env, error); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_error(napi_env env, + napi_value code, + napi_value msg, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_error(env, code, msg, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_string_utf8( + napi_env env, napi_value value, char* buf, size_t bufsize, size_t* result) { + LoadNapiFunctions(); + return p_napi_get_value_string_utf8(env, value, buf, bufsize, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_define_properties(napi_env env, + napi_value object, + size_t property_count, + const napi_property_descriptor* properties) { + LoadNapiFunctions(); + return p_napi_define_properties(env, object, property_count, properties); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_delete_reference(napi_env env, + napi_ref ref) { + LoadNapiFunctions(); + return p_napi_delete_reference(env, ref); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_reference_value(napi_env env, + napi_ref ref, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_reference_value(env, ref, result); +} +NAPI_EXTERN napi_status NAPI_CDECL +napi_open_handle_scope(napi_env env, napi_handle_scope* result) { + LoadNapiFunctions(); + return p_napi_open_handle_scope(env, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_close_handle_scope(napi_env env, napi_handle_scope scope) { + LoadNapiFunctions(); + return p_napi_close_handle_scope(env, scope); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_open_escapable_handle_scope( + napi_env env, napi_escapable_handle_scope* result) { + return p_napi_open_escapable_handle_scope(env, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_close_escapable_handle_scope( + napi_env env, napi_escapable_handle_scope scope) { + LoadNapiFunctions(); + return p_napi_close_escapable_handle_scope(env, scope); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_is_exception_pending(napi_env env, + bool* result) { + LoadNapiFunctions(); + return p_napi_is_exception_pending(env, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_property(napi_env env, + napi_value object, + napi_value key, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_property(env, object, key, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_uint32(napi_env env, + napi_value value, + uint32_t* result) { + LoadNapiFunctions(); + return p_napi_get_value_uint32(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_typeof(napi_env env, + napi_value value, + napi_valuetype* result) { + LoadNapiFunctions(); + return p_napi_typeof(env, value, result); +} +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_and_clear_last_exception(napi_env env, napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_and_clear_last_exception(env, result); +} +NAPI_EXTERN NAPI_NO_RETURN void NAPI_CDECL +napi_fatal_error(const char* location, + size_t location_len, + const char* message, + size_t message_len) { + LoadNapiFunctions(); + p_napi_fatal_error(location, location_len, message, message_len); + // Not reachable, but not represented in type signature. + exit(0); +} +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_value_external(napi_env env, napi_value value, void** result) { + LoadNapiFunctions(); + return p_napi_get_value_external(env, value, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_create_double(napi_env env, + double value, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_double(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_type_error(napi_env env, + napi_value code, + napi_value msg, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_type_error(env, code, msg, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_get_named_property(napi_env env, + napi_value object, + const char* utf8name, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_named_property(env, object, utf8name, result); +} +NAPI_EXTERN napi_status NAPI_CDECL +napi_create_reference(napi_env env, + napi_value value, + uint32_t initial_refcount, + napi_ref* result) { + LoadNapiFunctions(); + return p_napi_create_reference(env, value, initial_refcount, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_escape_handle(napi_env env, + napi_escapable_handle_scope scope, + napi_value escapee, + napi_value* result); +NAPI_EXTERN napi_status NAPI_CDECL napi_get_global(napi_env env, + napi_value* result) { + + LoadNapiFunctions(); + return p_napi_get_global(env, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_has_property(napi_env env, + napi_value object, + napi_value key, + bool* result) { + LoadNapiFunctions(); + return p_napi_has_property(env, object, key, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_create_function(napi_env env, + const char* utf8name, + size_t length, + napi_callback cb, + void* data, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_create_function(env, utf8name, length, cb, data, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_escape_handle(napi_env env, + napi_escapable_handle_scope scope, + napi_value escapee, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_escape_handle(env, scope, escapee, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_get_undefined(napi_env env, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_get_undefined(env, result); +} +NAPI_EXTERN napi_status NAPI_CDECL napi_get_value_double(napi_env env, + napi_value value, + double* result) { + LoadNapiFunctions(); + return p_napi_get_value_double(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_close_callback_scope(napi_env env, napi_callback_scope scope) { + LoadNapiFunctions(); + return p_napi_close_callback_scope(env, scope); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_async_destroy(napi_env env, napi_async_context async_context) { + LoadNapiFunctions(); + return p_napi_async_destroy(env, async_context); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_call_function(napi_env env, + napi_value recv, + napi_value func, + size_t argc, + const napi_value* argv, + napi_value* result) { + LoadNapiFunctions(); + return p_napi_call_function(env, recv, func, argc, argv, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_throw_error(napi_env env, + const char* code, + const char* msg) + { + LoadNapiFunctions(); + return p_napi_throw_error(env, code, msg); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_int32(napi_env env, + int32_t value, + napi_value* result) + { + LoadNapiFunctions(); + return p_napi_create_int32(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_boolean(napi_env env, + int32_t value, + napi_value* result) +{ +LoadNapiFunctions(); +return p_napi_create_int32(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_get_boolean(napi_env env, + bool value, + napi_value* result) +{ +LoadNapiFunctions(); +return p_napi_get_boolean(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_uint32(napi_env env, + uint32_t value, + napi_value* result) +{ + LoadNapiFunctions(); +return p_napi_create_uint32(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_bigint_int64(napi_env env, + int64_t value, + napi_value* result) +{ + LoadNapiFunctions(); + return p_napi_create_bigint_int64(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_external_arraybuffer( + napi_env env, + void* external_data, + size_t byte_length, + napi_finalize finalize_cb, + void* finalize_hint, + napi_value* result) +{ + LoadNapiFunctions(); + return p_napi_create_external_arraybuffer(env, external_data, byte_length, finalize_cb, finalize_hint, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_typedarray( + napi_env env, + napi_typedarray_type type, + size_t length, + napi_value array_buffer, + size_t byte_offset, + napi_value* result +) +{ + LoadNapiFunctions(); + return p_napi_create_typedarray(env, type, length, array_buffer, byte_offset, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_string_latin1( + napi_env env, + const char* str, + size_t length, + napi_value* result +) +{ + LoadNapiFunctions(); + return p_napi_create_string_latin1(env, str, length, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_async_work( + napi_env env, + napi_value async_resource, + napi_value async_resource_name, + napi_async_execute_callback execute, + napi_async_complete_callback complete, + void* data, + napi_async_work* result +) +{ + LoadNapiFunctions(); + return p_napi_create_async_work(env, async_resource, async_resource_name, execute, complete, data, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_delete_async_work( + napi_env env, + napi_async_work work +) +{ + LoadNapiFunctions(); + return p_napi_delete_async_work(env, work); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work( + napi_env env, + napi_async_work work +) +{ + LoadNapiFunctions(); + return p_napi_queue_async_work(env, work); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_promise( + napi_env env, + napi_deferred* deferred, + napi_value* promise) +{ + LoadNapiFunctions(); + return p_napi_create_promise(env, deferred, promise); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_resolve_deferred( + napi_env env, + napi_deferred deferred, + napi_value resolution) +{ + LoadNapiFunctions(); + return p_napi_resolve_deferred(env, deferred, resolution); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_reject_deferred( + napi_env env, + napi_deferred deferred, + napi_value rejection) +{ + LoadNapiFunctions(); + return p_napi_reject_deferred(env, deferred, rejection); +} + +NAPI_EXTERN napi_status NAPI_CDECL napi_create_threadsafe_function( + napi_env env, + napi_value func, + napi_value async_resource, + napi_value async_resource_name, + size_t max_queue_size, + size_t initial_thread_count, + void* thread_finalize_data, + napi_finalize thread_finalize_cb, + void* context, + napi_threadsafe_function_call_js call_js_cb, + napi_threadsafe_function* result) +{ + LoadNapiFunctions(); + return p_napi_create_threadsafe_function(env, func, async_resource, async_resource_name, max_queue_size, initial_thread_count, thread_finalize_data, thread_finalize_cb, context, call_js_cb, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_acquire_threadsafe_function(napi_threadsafe_function func) +{ + LoadNapiFunctions(); + return p_napi_acquire_threadsafe_function(func); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_release_threadsafe_function(napi_threadsafe_function func, napi_threadsafe_function_release_mode mode) +{ + LoadNapiFunctions(); + return p_napi_release_threadsafe_function(func, mode); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_call_threadsafe_function( + napi_threadsafe_function func, + void* data, + napi_threadsafe_function_call_mode is_blocking) +{ + LoadNapiFunctions(); + return p_napi_call_threadsafe_function(func, data, is_blocking); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_is_dataview(napi_env env, + napi_value value, + bool* result) { + LoadNapiFunctions(); + return p_napi_is_dataview(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_is_arraybuffer(napi_env env, + napi_value value, + bool* result) { + LoadNapiFunctions(); + return p_napi_is_arraybuffer(env, value, result); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_get_dataview_info(napi_env env, + napi_value dataview, + size_t* bytelength, + void** data, + napi_value* arraybuffer, + size_t* byte_offset) { + LoadNapiFunctions(); + return p_napi_get_dataview_info(env, dataview, bytelength, data, arraybuffer, byte_offset); +} + +NAPI_EXTERN napi_status NAPI_CDECL +napi_set_named_property(napi_env env, + napi_value object, + const char* utf8name, + napi_value value) { + LoadNapiFunctions(); + return p_napi_set_named_property(env, object, utf8name, value); +} diff --git a/koala-wrapper/koalaui/interop/src/cpp/ohos/hilog/log.h b/koala-wrapper/koalaui/interop/src/cpp/ohos/hilog/log.h new file mode 100644 index 000000000..7452137c2 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/ohos/hilog/log.h @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2021-2022 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 HIVIEWDFX_HILOG_H +#define HIVIEWDFX_HILOG_H +/** + * @addtogroup HiLog + * @{ + * + * @brief Provides logging functions. + * + * For example, you can use these functions to output logs of the specified log type, service domain, log tag, + * and log level. + * + * @syscap SystemCapability.HiviewDFX.HiLog + * + * @since 8 + */ + +/** + * @file log.h + * + * @brief Defines the logging functions of the HiLog module. + * + * Before outputting logs, you must define the service domain, and log tag, use the function with + * the specified log type and level, and specify the privacy identifier.\n + *
  • Service domain: used to identify the subsystem and module of a service. Its value is a hexadecimal + * integer ranging from 0x0 to 0xFFFF. \n + *
  • Log tag: a string used to identify the class, file, or service.
  • \n + *
  • Log level: DEBUG, INFO, WARN, ERROR, and FATAL
  • \n + *
  • Parameter format: a printf format string that starts with a % character, including format specifiers + * and variable parameters.
  • \n + *
  • Privacy identifier: {public} or {private} added between the % character and the format specifier in + * each parameter. Note that each parameter has a privacy identifier. If no privacy identifier is added, + * the parameter is considered to be private.
\n + * + * Sample code:\n + * Defining the service domain and log tag:\n + * #include \n + * #define LOG_DOMAIN 0x0201\n + * #define LOG_TAG "MY_TAG"\n + * Outputting logs:\n + * HILOG_WARN({@link LOG_APP}, "Failed to visit %{private}s, reason:%{public}d.", url, errno);\n + * Output result:\n + * 05-06 15:01:06.870 1051 1051 W 0201/MY_TAG: Failed to visit , reason:503.\n + * + * @since 8 + */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Defines the service domain for a log file. + * + * The service domain is used to identify the subsystem and module of a service. Its value is a hexadecimal integer + * ranging from 0x0 to 0xFFFF. If the value is beyond the range, its significant bits are automatically truncated. \n + * + * @since 8 + */ +#ifndef LOG_DOMAIN +#define LOG_DOMAIN 0 +#endif + +/** + * @brief Defines a string constant used to identify the class, file, or service. + * + * @since 8 + */ +#ifndef LOG_TAG +#define LOG_TAG NULL +#endif + +/** + * @brief Enumerates log types. + * + * Currently, LOG_APP is available. \n + * + * @since 8 + */ +typedef enum { + /** Third-party application logs */ + LOG_APP = 0, +} LogType; + +/** + * @brief Enumerates log levels. + * + * You are advised to select log levels based on their respective usage scenarios:\n + *
  • DEBUG: used for debugging and disabled from commercial releases
  • \n + *
  • INFO: used for logging important system running status and steps in key processes
  • \n + *
  • WARN: used for logging unexpected exceptions that have little impact on user experience and can + * automatically recover. Logs at this level are generally output when such exceptions are detected and + * captured.
  • \n + *
  • ERROR: used for logging malfunction that affects user experience and cannot automatically + * recover
  • \n + *
  • FATAL: used for logging major exceptions that have severely affected user experience and should + * not occur.
\n + * + * @since 8 + */ +typedef enum { + /** Debug level to be used by {@link OH_LOG_DEBUG} */ + LOG_DEBUG = 3, + /** Informational level to be used by {@link OH_LOG_INFO} */ + LOG_INFO = 4, + /** Warning level to be used by {@link OH_LOG_WARN} */ + LOG_WARN = 5, + /** Error level to be used by {@link OH_LOG_ERROR} */ + LOG_ERROR = 6, + /** Fatal level to be used by {@link OH_LOG_FATAL} */ + LOG_FATAL = 7, +} LogLevel; + +/** + * @brief Outputs logs. + * + * You can use this function to output logs based on the specified log type, log level, service domain, log tag, + * and variable parameters determined by the format specifier and privacy identifier in the printf format. + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param level Indicates the log level, which can be LOG_DEBUG, LOG_INFO, LOG_WARN, + * LOG_ERROR, and LOG_FATAL. + * @param domain Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. + * @param tag Indicates the log tag, which is a string used to identify the class, file, or service behavior. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier + * in each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @return Returns 0 or a larger value if the operation is successful; returns a value smaller + * than 0 otherwise. + * @since 8 + */ +int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) + __attribute__((__format__(os_log, 5, 6))); + +/** + * @brief Checks whether logs of the specified service domain, log tag, and log level can be output. + * + * @param domain Indicates the service domain of logs. + * @param tag Indicates the log tag. + * @param level Indicates the log level. + * @return Returns true if the specified logs can be output; returns false otherwise. + * @since 8 + */ +bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level); + +/** + * @brief Outputs debug logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them at + * the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the + * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier + * in each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs informational logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them + * at the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in + * each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs warning logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them + * at the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the + * privacy identifier. Specifically, {public} or {private} is added between the % character and the format specifier + * in each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs error logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define + * them at the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in each + * parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Outputs fatal logs. This is a function-like macro. + * + * Before calling this function, define the log service domain and log tag. Generally, you need to define them at + * the beginning of the source file. \n + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param fmt Indicates the format string, which is an enhancement of a printf format string and supports the privacy + * identifier. Specifically, {public} or {private} is added between the % character and the format specifier in + * each parameter. \n + * @param ... Indicates a list of parameters. The number and type of parameters must map onto the format specifiers + * in the format string. + * @see OH_LOG_Print + * @since 8 + */ +#define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, __VA_ARGS__)) + +/** + * @brief Defines the function pointer type for the user-defined log processing function. + * + * @param type Indicates the log type. The type for third-party applications is defined by {@link LOG_APP}. + * @param level Indicates the log level, which can be LOG_DEBUG, LOG_INFO, LOG_WARN, + * LOG_ERROR, and LOG_FATAL. + * @param domain Indicates the service domain of logs. Its value is a hexadecimal integer ranging from 0x0 to 0xFFFF. + * @param tag Indicates the log tag, which is a string used to identify the class, file, or service behavior. + * @param msg Indicates the log message itself, which is a formatted log string. + * @since 11 + */ +typedef void (*LogCallback)(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg); + +/** + * @brief Set the user-defined log processing function. + * + * After calling this function, the callback function implemented by the user can receive all hilogs of the + * current process. + * Note that it will not change the default behavior of hilog logs of the current process, no matter whether this + * interface is called or not. \n + * + * @param callback Indicates the callback function implemented by the user. If you do not need to process hilog logs, + * you can transfer a null pointer. + * @since 11 + */ +void OH_LOG_SetCallback(LogCallback callback); + +#ifdef __cplusplus +} +#endif +/** @} */ + +#ifdef HILOG_RAWFORMAT +#include "hilog/log_inner.h" +#endif + +#endif // HIVIEWDFX_HILOG_C_H diff --git a/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.cc b/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.cc new file mode 100644 index 000000000..6aa01fe5e --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.cc @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022-2025 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 +#include +#include +#include +#include +#include +#include +#include "oh_sk_log.h" + +static const char* KOALAUI_OHOS_LOG_ROOT = "/data/storage/el2/base/files/logs"; + +#define APPLY_LOG_FILE_PATTERN(buf, t, ms, pid) \ + sprintf(buf, "%s/%d_%d_%d_%ld.pid%d.log", \ + KOALAUI_OHOS_LOG_ROOT, t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, ms.tv_sec, pid) + +const char* oh_sk_log_type_str(oh_sk_log_type type) { + switch (type) { + case Log_Debug: return "D"; + case Log_Info: return "I"; + case Log_Warn: return "W"; + case Log_Error: return "E"; + case Log_Fatal: return "F"; + } +} + +void oh_sk_file_log(oh_sk_log_type type, const char* msg, ...) { + time_t t = time(nullptr); + struct tm lt = *localtime(&t); + struct timeval ms{}; + gettimeofday(&ms, nullptr); + + static char* path = nullptr; + if (!path) { + path = new char[strlen(KOALAUI_OHOS_LOG_ROOT) + 100]; + APPLY_LOG_FILE_PATTERN(path, lt, ms, getpid()); + mkdir(KOALAUI_OHOS_LOG_ROOT, 0777); + } + + std::unique_ptr file(fopen(path, "a"), fclose); + if (!file) return; + + fprintf(file.get(), "%02d-%02d %02d:%02d:%02d.%03ld %s koala: ", + lt.tm_mon + 1, lt.tm_mday, lt.tm_hour, lt.tm_min, lt.tm_sec, ms.tv_usec / 1000, + oh_sk_log_type_str(type)); + + va_list args; + va_start(args, msg); + vfprintf(file.get(), msg, args); + va_end(args); + + fprintf(file.get(), "\n"); +} diff --git a/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.h b/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.h new file mode 100644 index 000000000..961e2c0f1 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +#pragma once + +#include + +typedef enum { + Log_Debug, + Log_Info, + Log_Warn, + Log_Error, + Log_Fatal +} oh_sk_log_type; + +void oh_sk_file_log(oh_sk_log_type type, const char* msg, ...); +const char* oh_sk_log_type_str(oh_sk_log_type type); + +#ifdef OH_SK_LOG_TO_FILE + +#define OH_SK_LOG_INFO(msg) oh_sk_file_log(oh_sk_log_type::Log_Info, msg) +#define OH_SK_LOG_INFO_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Info, msg, ##__VA_ARGS__) +#define OH_SK_LOG_ERROR(msg) oh_sk_file_log(oh_sk_log_type::Log_Error, msg) +#define OH_SK_LOG_ERROR_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Error, msg, ##__VA_ARGS__) +#define OH_SK_LOG_DEBUG(msg) oh_sk_file_log(oh_sk_log_type::Log_Debug, msg) +#define OH_SK_LOG_DEBUG_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Debug, msg, ##__VA_ARGS__) +#define OH_SK_LOG_WARN(msg) oh_sk_file_log(oh_sk_log_type::Log_Warn, msg) +#define OH_SK_LOG_WARN_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Warn, msg, ##__VA_ARGS__) +#define OH_SK_LOG_FATAL(msg) oh_sk_file_log(oh_sk_log_type::Log_Fatal, msg) +#define OH_SK_LOG_FATAL_A(msg, ...) oh_sk_file_log(oh_sk_log_type::Log_Fatal, msg, ##__VA_ARGS__) + +#else + +#define OH_SK_LOG_INFO(msg) OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Koala", msg) +#define OH_SK_LOG_INFO_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Koala", msg, ##__VA_ARGS__) +#define OH_SK_LOG_ERROR(msg) OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "Koala", msg) +#define OH_SK_LOG_ERROR_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_ERROR, 0xFF00, "Koala", msg, ##__VA_ARGS__) +#define OH_SK_LOG_DEBUG(msg) OH_LOG_Print(LOG_APP, LOG_DEBUG, 0xFF00, "Koala", msg) +#define OH_SK_LOG_DEBUG_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_DEBUG, 0xFF00, "Koala", msg, ##__VA_ARGS__) +#define OH_SK_LOG_WARN(msg) OH_LOG_Print(LOG_APP, LOG_WARN, 0xFF00, "Koala", msg) +#define OH_SK_LOG_WARN_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_WARN, 0xFF00, "Koala", msg, ##__VA_ARGS__) +#define OH_SK_LOG_FATAL(msg) OH_LOG_Print(LOG_APP, LOG_FATAL, 0xFF00, "Koala", msg) +#define OH_SK_LOG_FATAL_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_FATAL, 0xFF00, "Koala", msg, ##__VA_ARGS__) + +#endif diff --git a/koala-wrapper/koalaui/interop/src/cpp/profiler.h b/koala-wrapper/koalaui/interop/src/cpp/profiler.h new file mode 100644 index 000000000..a3b9da38c --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/profiler.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2022-2025 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 _KOALA_PROFILER_ +#define _KOALA_PROFILER_ + +#include +#include + +#include +#include +#include +#include +#include + +struct InteropProfilerRecord { + int64_t time; + int64_t count; + InteropProfilerRecord(int64_t time, int64_t count) : time(time), count(count) {} +}; + +class InteropProfiler { + private: + std::unordered_map records; + static InteropProfiler* _instance; + InteropProfiler() {} + + public: + static InteropProfiler* instance() { + if (!_instance) _instance = new InteropProfiler(); + return _instance; + } + + void record(const char* name, int64_t ns) { + auto it = records.find(name); + if (it == records.end()) { + records.insert({name, InteropProfilerRecord(ns, 1)}); + } else { + it->second.time += ns; + it->second.count++; + } + } + + std::string report() { + std::vector> elems(records.begin(), records.end()); + std::sort(elems.begin(), elems.end(), + [](const std::pair&a, const std::pair&b) { + return b.second.time < a.second.time; + }); + int64_t total = 0; + std::for_each(elems.begin(), elems.end(), [&total](const std::pair&a) { + total += a.second.time; + }); + std::string result; + std::for_each(elems.begin(), elems.end(), [total, &result](const std::pair&a) { + auto ns = a.second.time; + auto count = a.second.count; + char buffer[1024]; + snprintf(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), (long long)count, (double)ns / total * 100.0, (long long)ns); + result += buffer; + }); + return result; + } + + void reset() { + records.clear(); + } +}; + + +class InteropMethodCall { + private: + const char* name; + std::chrono::steady_clock::time_point begin; + public: + InteropMethodCall(const char* name) : name(name) { + begin = std::chrono::steady_clock::now(); + } + ~InteropMethodCall() { + auto end = std::chrono::steady_clock::now(); + int64_t ns = std::chrono::duration_cast(end - begin).count(); + InteropProfiler::instance()->record(name, ns); + } +}; + +#endif // _KOALA_PROFILER_ \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/tracer.h b/koala-wrapper/koalaui/interop/src/cpp/tracer.h new file mode 100644 index 000000000..f3b7ad20b --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/tracer.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022-2025 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 _KOALA_TRACER_ +#define _KOALA_TRACER_ + +#ifdef KOALA_OHOS +#include +#define KOALA_TRACE(msg, str) OH_LOG_Print(LOG_APP, LOG_INFO, 0xFF00, "Koala", msg, str) +// Also do +// hdc shell hilog -p off +// hdc shell hilog -Q pidoff +// to see the output. +#define KOALA_TRACE_PUBLIC "%{public}s" +#else +#include +#define KOALA_TRACE(msg, str) fprintf(stderr, "Koala: " msg "\n", str) +#define KOALA_TRACE_PUBLIC "%s" +#endif + +class InteropMethodCall { + private: + const char* name; + public: + InteropMethodCall(const char* name) : name(name) { + KOALA_TRACE(">>> " KOALA_TRACE_PUBLIC, name); + } + ~InteropMethodCall() { + KOALA_TRACE("<<< " KOALA_TRACE_PUBLIC, name); + } +}; + +#endif // _KOALA_TRACER_ \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h b/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h new file mode 100644 index 000000000..2c5e88754 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2025 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 _KOALA_TYPES_H +#define _KOALA_TYPES_H + +#include +#include +#include +#include + +struct KStringPtrImpl { + KStringPtrImpl(const char* str) : _value(nullptr), _owned(true) { + int len = str ? strlen(str) : 0; + assign(str, len); + } + KStringPtrImpl(const char* str, int len, bool owned) : _value(nullptr), _owned(owned) { + assign(str, len); + } + KStringPtrImpl() : _value(nullptr), _length(0), _owned(true) {} + + KStringPtrImpl(const KStringPtrImpl& other) = delete; + KStringPtrImpl& operator=(const KStringPtrImpl& other) = delete; + + KStringPtrImpl(KStringPtrImpl&& other) { + this->_value = other.release(); + this->_owned = other._owned; + other._owned = false; + this->_length = other._length; + } + + ~KStringPtrImpl() { if (_value && _owned) free(_value); } + + bool isNull() const { return _value == nullptr; } + const char* c_str() const { return _value; } + char* data() const { return _value; } + int length() const { return _length; } + + void resize(int size) { + _length = size; + if (!_owned) return; + // Ignore old content. + if (_value && _owned) free(_value); + _value = reinterpret_cast(malloc(size + 1)); + _value[size] = 0; + } + + void assign(const char* data) { + assign(data, data ? strlen(data) : 0); + } + + void assign(const char* data, int len) { + if (_value && _owned) free(_value); + if (data) { + if (_owned) { + _value = reinterpret_cast(malloc(len + 1)); + memcpy(_value, data, len); + _value[len] = 0; + } else { + _value = const_cast(data); + } + } else { + _value = nullptr; + } + _length = len; + } + + protected: + char* release() { + char* result = this->_value; + this->_value = nullptr; + return result; + } + private: + char* _value; + int _length; + bool _owned; +}; + +struct KInteropNumber { + int8_t tag; + union { + int32_t i32; + float f32; + }; + static inline KInteropNumber fromDouble(double value) { + KInteropNumber result = { 0 }; + // TODO: boundary check + if (value == std::floor(value)) { + result.tag = 102; // ARK_TAG_INT32 + result.i32 = (int)value; + } else { + result.tag = 103; // ARK_TAG_FLOAT32 + result.f32 = (float)value; + } + return result; + } + inline double asDouble() { + if (tag == 102) // ARK_TAG_INT32 + return (double)i32; + else + return (double)f32; + } +}; + +typedef int8_t KBoolean; +typedef uint8_t KByte; +typedef int16_t KChar; +typedef int16_t KShort; +typedef uint16_t KUShort; +typedef int32_t KInt; +typedef uint32_t KUInt; +typedef float KFloat; +typedef int64_t KLong; +typedef uint64_t KULong; +typedef double KDouble; +typedef void* KNativePointer; +typedef KStringPtrImpl KStringPtr; +typedef float* KFloatArray; +typedef const uint8_t* KStringArray; +typedef void** KNativePointerArray; + +struct KInteropBuffer { + KLong length; + KNativePointer data; + + KInt resourceId; + void (*dispose)(KInt /* resourceId for now */); +}; + +struct KInteropReturnBuffer { + KInt length; + KNativePointer data; + void (*dispose)(KNativePointer data, KInt length); +}; + +struct KLength { + KByte type; + KFloat value; + KInt unit; + KInt resource; +}; + +inline void parseKLength(const KStringPtrImpl &string, KLength *result) +{ + char *suffixPtr = nullptr; + + float value = std::strtof(string.c_str(), &suffixPtr); + + if (!suffixPtr || suffixPtr == string.c_str()) + { + // not a numeric value + result->unit = -1; + return; + } + result->value = value; + if (suffixPtr[0] == '\0' || (suffixPtr[0] == 'v' && suffixPtr[1] == 'p')) + { + result->unit = 1; + } + else if (suffixPtr[0] == '%') + { + result->unit = 3; + } + else if (suffixPtr[0] == 'p' && suffixPtr[1] == 'x') + { + result->unit = 0; + } + else if (suffixPtr[0] == 'l' && suffixPtr[1] == 'p' && suffixPtr[2] == 'x') + { + result->unit = 4; + } + else if (suffixPtr[0] == 'f' && suffixPtr[1] == 'p') + { + result->unit = 2; + } + else + { + result->unit = -1; + } +} + +struct _KVMContext; +typedef _KVMContext *KVMContext; + +// BEWARE: this MUST never be used in user code, only in very rare service code. +struct _KVMObject; +typedef _KVMObject *KVMObjectHandle; + +typedef struct KVMDeferred { + void* handler; + void* context; + void (*resolve)(KVMDeferred* thiz, uint8_t* data, int32_t length); + void (*reject)(KVMDeferred* thiz, const char* message); +} KVMDeferred; + +template T* ptr(KNativePointer ptr) { + return reinterpret_cast(ptr); +} + +template T& ref(KNativePointer ptr) { + return *reinterpret_cast(ptr); +} + +inline KNativePointer nativePtr(void* pointer) { + return reinterpret_cast(pointer); +} + +template KNativePointer fnPtr(void (*pointer)(T*)) { + return reinterpret_cast(pointer); +} + +#endif /* _KOALA_TYPES_H */ diff --git a/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc b/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc new file mode 100644 index 000000000..7f556adaf --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2025 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 "stdio.h" +#include +#include + +#include "signatures.h" +#include "interop-types.h" + +// For types with the same name on ets and jni +#define KOALA_INTEROP_TYPEDEF(func, lang, CPP_TYPE, SIG_TYPE, CODE_TYPE) \ + if (std::strcmp(func, "sigType") == 0) if (type == CPP_TYPE) return SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0) if (type == CPP_TYPE) return CODE_TYPE; + +// For types with distinct names on ets and jni +#define KOALA_INTEROP_TYPEDEF_LS(func, lang, CPP_TYPE, ETS_SIG_TYPE, ETS_CODE_TYPE, JNI_SIG_TYPE, JNI_CODE_TYPE) \ + if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "ets") == 0) if (type == CPP_TYPE) return ETS_SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "ets") == 0) if (type == CPP_TYPE) return ETS_CODE_TYPE; \ + if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "jni") == 0) if (type == CPP_TYPE) return JNI_SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "jni") == 0) if (type == CPP_TYPE) return JNI_CODE_TYPE; + +#define KOALA_INTEROP_TYPEDEFS(func, lang) \ + KOALA_INTEROP_TYPEDEF(func, lang, "void", "V", "void") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KBoolean", "Z", "boolean") \ + KOALA_INTEROP_TYPEDEF(func, lang, "OH_Boolean", "Z", "boolean") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Boolean", "Z", "boolean") \ + KOALA_INTEROP_TYPEDEF(func, lang, "int32_t", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "uint32_t", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "int", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInt", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KUInt", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "OH_Int32", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "OH_Int64", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Int32", "I", "int") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Int64", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KNativePointer", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_NativePointer", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "OH_NativePointer", "J", "long") \ + KOALA_INTEROP_TYPEDEF(func, lang, "float", "F", "float") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KFloat", "F", "float") \ + KOALA_INTEROP_TYPEDEF(func, lang, "Ark_Float32", "F", "float") \ + KOALA_INTEROP_TYPEDEF(func, lang, "double", "D", "double") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KDouble", "D", "double") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInteropNumber", "D", "double") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KVMObjectHandle", "Ljava/lang/Object;", "Object") \ + KOALA_INTEROP_TYPEDEF(func, lang, "uint8_t*", "[B", "byte[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KByte*", "[B", "byte[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInteropBuffer", "[B", "byte[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KShort*", "[S", "short[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KUShort*", "[S", "short[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "int32_t*", "[I", "int[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInt*", "[I", "int[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KNativePointerArray", "[J", "long[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KInteropReturnBuffer", "[B", "byte[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "float*", "[F", "float[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KFloatArray", "[F", "float[]") \ + KOALA_INTEROP_TYPEDEF(func, lang, "KFloat*", "[F", "float[]") \ + KOALA_INTEROP_TYPEDEF_LS(func, lang, "KStringPtr", "Lstd/core/String;", "String", "Ljava/lang/String;", "String") \ + KOALA_INTEROP_TYPEDEF_LS(func, lang, "KStringArray", "[Lstd/core/String;", "String[]", "[Ljava/lang/String;", "String[]") \ + KOALA_INTEROP_TYPEDEF_LS(func, lang, "KLength", "Lstd/core/String;", "String", "Ljava/lang/String;", "String") + +std::string sigType(const std::string &type) { +#if KOALA_USE_PANDA_VM + KOALA_INTEROP_TYPEDEFS("sigType", "ets") +#elif KOALA_USE_JAVA_VM + KOALA_INTEROP_TYPEDEFS("sigType", "jni") +#endif + INTEROP_FATAL("Unhandled type: %s\n", type.c_str()); + return type; +} + +std::string codeType(const std::string &type) { +#if KOALA_USE_PANDA_VM + KOALA_INTEROP_TYPEDEFS("codeType", "ets") +#elif KOALA_USE_JAVA_VM + KOALA_INTEROP_TYPEDEFS("codeType", "jni") +#endif + INTEROP_FATAL("Unhandled type: %s\n", type.c_str()); + return ""; +} + +std::string convertType(const char* name, const char* koalaType) { + std::string result; + size_t current = 0, last = 0; + std::string input(koalaType); + std::vector tokens; + while ((current = input.find('|', last)) != std::string::npos) + { + auto token = input.substr(last, current - last); + tokens.push_back(token); + last = current + 1; + } + tokens.push_back(input.substr(last, input.length() - last)); + +#if KOALA_USE_PANDA_VM + + for (int i = 1; i < (int)tokens.size(); i++) + { + result.append(sigType(tokens[i])); + } + result.append(":"); + result.append(sigType(tokens[0])); + +#elif KOALA_USE_JAVA_VM + + result.append("("); + for (int i = 1; i < (int)tokens.size(); i++) + { + result.append(sigType(tokens[i])); + } + result.append(")"); + result.append(sigType(tokens[0])); + +#endif + +#ifdef KOALA_BUILD_FOR_SIGNATURES + #ifdef KOALA_USE_PANDA_VM + std::string params; + for (int i = 1; i < (int)tokens.size(); i++) + { + params.append("arg"); + params.append(std::to_string(i)); + params.append(": "); + params.append(codeType(tokens[i])); + if (i < (int)(tokens.size() - 1)) + params.append(", "); + } + fprintf(stderr, " static native %s(%s): %s;\n", name, params.c_str(), codeType(tokens[0]).c_str()); + #elif KOALA_USE_JAVA_VM + std::string params; + for (int i = 1; i < (int)tokens.size(); i++) + { + params.append(codeType(tokens[i])); + params.append(" arg"); + params.append(std::to_string(i)); + if (i < (int)(tokens.size() - 1)) + params.append(", "); + } + fprintf(stderr, " public static native %s %s(%s);\n", codeType(tokens[0]).c_str(), name, params.c_str()); + #endif +#endif + + return result; +} diff --git a/koala-wrapper/koalaui/interop/src/cpp/types/signatures.h b/koala-wrapper/koalaui/interop/src/cpp/types/signatures.h new file mode 100644 index 000000000..48a76f3d8 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/types/signatures.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 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 _SIGNATURES_H +#define _SIGNATURES_H + +#include + +std::string sigType(const std::string &type); +std::string codeType(const std::string &type); +std::string convertType(const char* name, const char* koalaType); + +#endif // _SIGNATURES_H diff --git a/koala-wrapper/koalaui/interop/src/cpp/vmloader.cc b/koala-wrapper/koalaui/interop/src/cpp/vmloader.cc new file mode 100644 index 000000000..995d2623c --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/vmloader.cc @@ -0,0 +1,638 @@ +/* + * Copyright (c) 2025 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 +#include +#include + +#include "interop-logging.h" +#include "dynamic-loader.h" +#include "koala-types.h" + +// DO NOT USE KOALA INTEROP MECHANISMS IN THIS FILE! + +#ifdef KOALA_JNI +#include "jni.h" +#endif + +#ifdef KOALA_ETS_NAPI +#include "etsapi.h" +#endif + +#if defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_OHOS) +#include "sys/stat.h" +#include "dirent.h" +#endif + +#define OHOS_USER_LIBS "/data/storage/el1/bundle/libs" +#ifdef KOALA_OHOS_ARM32 +#define USE_SYSTEM_ARKVM 1 +#elif KOALA_OHOS_ARM64 +#define USE_SYSTEM_ARKVM 1 +#else +#define USE_SYSTEM_ARKVM 0 +#endif + +#if USE_SYSTEM_ARKVM +#define SYSTEM_ARK_STDLIB_PATH "/system/etc/etsstdlib.abc" +#endif + +void traverseDir(std::string root, std::vector& paths, int depth = 0); + +struct VMLibInfo { + const char* sdkPath; + const char* platform; + const char* lib; + const char* createVM; +}; + +#ifdef KOALA_JNI +const VMLibInfo javaVMLib = { + getenv("JAVA_HOME"), + #if defined(KOALA_LINUX) || defined(KOALA_MACOS) + "lib/server" + #elif KOALA_WINDOWS + "bin/server" + #else + #error "Unknown platform" + #endif + , + "jvm", + "JNI_CreateJavaVM", +}; +#endif + +#ifdef KOALA_ETS_NAPI +const VMLibInfo pandaVMLib = { + // sdkPath + #if defined(KOALA_OHOS) + #ifdef KOALA_OHOS_ARM32 + "/system/lib" + #elif KOALA_OHOS_ARM64 + "/system/lib64" + #else + OHOS_USER_LIBS + #endif + #else + getenv("PANDA_HOME") + #endif + , + + // platform + #ifdef KOALA_LINUX + #ifdef KOALA_LINUX_ARM64 + "linux_arm64_host_tools/lib" + #else + "linux_host_tools/lib" + #endif + #elif KOALA_MACOS + "macos_host_tools/lib" + #elif KOALA_WINDOWS + "_host_tools/lib" + #elif KOALA_OHOS_ARM64 + "arm64" + #elif KOALA_OHOS_ARM32 + "arm" + #else + #error "Unknown platform" + #endif + , + + // lib + "arkruntime" + , + + // createVM + "ETS_CreateVM" +}; +#endif + +struct VMInitArgs { + int version; + int nOptions; + void* options; +}; + +#define JAVA_VM_KIND 1 +#define PANDA_VM_KIND 2 +#define ES2PANDA_KIND 3 + +struct ForeignVMContext { + void* currentVMContext; + int32_t (*callSync)(void* vmContext, int32_t callback, int8_t* data, int32_t length); +}; + +struct VMEntry { + int vmKind; + void* env; + void* app; + void* enter; + void* emitEvent; + void* restartWith; + ForeignVMContext foreignVMContext; +}; + +VMEntry g_vmEntry = {}; + +typedef int (*createVM_t)(void** pVM, void** pEnv, void* vmInitArgs); +typedef int (*getVMs_t)(void** pVM, int32_t bufLen, int32_t* nVMs); + +#ifdef KOALA_WINDOWS +#define DLL_EXPORT __declspec(dllexport) +#else +#define DLL_EXPORT __attribute__ ((visibility ("default"))) +#endif + +int loadES2Panda(const char* appClassPath, const char* appLibPath) { + fprintf(stderr, "native: es2panda %s\n", appClassPath); + return 0; +} + +static int ArkMobileLog(int id, int level, const char *component, const char *fmt, const char *msg) { + LOGE("ArkMobileLog: %" LOG_PUBLIC "s", msg); + return 0; +} + +extern "C" DLL_EXPORT KInt LoadVirtualMachine(KInt vmKind, const char* appClassPath, const char* appLibPath, const ForeignVMContext* foreignVMContext) { + if (vmKind == ES2PANDA_KIND) { + return loadES2Panda(appClassPath, appLibPath); + } + + const VMLibInfo* thisVM = + #ifdef KOALA_JNI + (vmKind == JAVA_VM_KIND) ? &javaVMLib : + #endif + #ifdef KOALA_ETS_NAPI + (vmKind == PANDA_VM_KIND) ? &pandaVMLib : + #endif + nullptr; + + if (!thisVM) { + LOGE("Unknown VM kind: %" LOG_PUBLIC "d\n (possibly %" LOG_PUBLIC "s is compiled without expected flags)", vmKind, __FILE__); + return -1; + } + + LOGI("Starting VM %" LOG_PUBLIC "d with classpath=%" LOG_PUBLIC "s native=%" LOG_PUBLIC "s", vmKind, appClassPath, appLibPath); + + std::string libPath = +#if USE_SYSTEM_ARKVM + std::string(thisVM->sdkPath) + "/" + libName(thisVM->lib) +#elif defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_WINDOWS) + std::string(thisVM->sdkPath) + "/" + std::string(thisVM->platform) + "/" + libName(thisVM->lib) +#elif defined(KOALA_OHOS) + std::string(OHOS_USER_LIBS) + "/" + libName(thisVM->lib) +#else + #error "Library path not specified for this platform" +#endif + ; + void *handle = loadLibrary(libPath); + if (!handle) { + LOGE("Cannot load library %" LOG_PUBLIC "s: %" LOG_PUBLIC "s\n", libPath.c_str(), libraryError()); + return -1; + } + + createVM_t createVM = (createVM_t)findSymbol(handle, thisVM->createVM); + getVMs_t getVMs = (getVMs_t)findSymbol(handle, "ETS_GetCreatedVMs"); + + if (!createVM) { + LOGE("Cannot find %" LOG_PUBLIC "s\n", thisVM->createVM); + return -1; + } + + void* vm = nullptr; + void* env = nullptr; + int32_t nVMs = 0; + int result = 0; + +#ifdef KOALA_JNI + if (vmKind == JAVA_VM_KIND) { + JavaVMInitArgs javaVMArgs; + javaVMArgs.version = JNI_VERSION_10; + javaVMArgs.ignoreUnrecognized = false; + std::vector javaVMOptions; + javaVMOptions = { + {(char*)strdup((std::string("-Djava.class.path=") + appClassPath).c_str())}, + {(char*)strdup((std::string("-Djava.library.path=") + appLibPath).c_str())}, + }; + javaVMArgs.nOptions = javaVMOptions.size(); + javaVMArgs.options = javaVMOptions.data(); + g_vmEntry.vmKind = JAVA_VM_KIND; + result = createVM(&vm, &env, &javaVMArgs); + } +#endif + +#ifdef KOALA_ETS_NAPI + if (vmKind == PANDA_VM_KIND) { + EtsVMInitArgs pandaVMArgs; + pandaVMArgs.version = ETS_NAPI_VERSION_1_0; + std::vector etsVMOptions; + std::vector files; + traverseDir(std::string(appClassPath), files); + std::sort(files.begin(), files.end()); + etsVMOptions = { +#if USE_SYSTEM_ARKVM + {EtsOptionType::ETS_BOOT_FILE, SYSTEM_ARK_STDLIB_PATH}, +#elif defined(KOALA_OHOS) + {EtsOptionType::ETS_BOOT_FILE, (std::string(OHOS_USER_LIBS) + "/" + "etsstdlib.abc").c_str() }, + +#elif defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_WINDOWS) + {EtsOptionType::ETS_BOOT_FILE, (char*)strdup((std::string(thisVM->sdkPath) + "/ets/etsstdlib.abc").c_str())}, +#endif + }; + for (const std::string& path : files) { + etsVMOptions.push_back({EtsOptionType::ETS_BOOT_FILE, (char*)strdup(path.c_str())}); + } + etsVMOptions.push_back({EtsOptionType::ETS_NATIVE_LIBRARY_PATH, (char*)strdup(std::string(appLibPath).c_str())}); + etsVMOptions.push_back({EtsOptionType::ETS_VERIFICATION_MODE, "on-the-fly"}); + etsVMOptions.push_back({EtsOptionType::ETS_NO_JIT, nullptr}); + etsVMOptions.push_back({EtsOptionType::ETS_MOBILE_LOG, (void*)ArkMobileLog}); + etsVMOptions.push_back({EtsOptionType::ETS_AOT, nullptr}); + // etsVMOptions.push_back({EtsOptionType::ETS_LOG_LEVEL, "info"}); + pandaVMArgs.nOptions = etsVMOptions.size(); + pandaVMArgs.options = etsVMOptions.data(); + g_vmEntry.vmKind = PANDA_VM_KIND; + + result = getVMs ? getVMs(&vm, 1, &nVMs) : 0; + if (nVMs != 0) { + __EtsVM* vmInstance = (__EtsVM*)vm; + EtsEnv* pEnv = nullptr; + vmInstance->GetEnv(&pEnv, ETS_NAPI_VERSION_1_0); + env = static_cast(pEnv); + } else { + result = createVM(&vm, &env, &pandaVMArgs); + } + + } +#endif + + if (result != 0) { + LOGE("Error creating a VM of kind %" LOG_PUBLIC "d: %" LOG_PUBLIC "d\n", vmKind, result); + return result; + } + g_vmEntry.env = env; + g_vmEntry.foreignVMContext = *foreignVMContext; + return 0; +} + +struct AppInfo { + const char* className; + const char* createMethodName; + const char* createMethodSig; + const char* startMethodName; + const char* startMethodSig; + const char* enterMethodName; + const char* enterMethodSig; + const char* emitEventMethodName; + const char* emitEventMethodSig; + const char* restartWithMethodName; + const char* restartWithMethodSig; +}; + +#ifdef KOALA_JNI +const AppInfo javaAppInfo = { + "org/koalaui/arkoala/Application", + "createApplication", + "(Ljava/lang/String;Ljava/lang/String;)Lorg/koalaui/arkoala/Application;", + "start", + "()J", + "enter", + "(IIJ)Z", + "emitEvent", + "(IIII)Ljava/lang/String;", +}; +#endif + +#ifdef KOALA_ETS_NAPI +const AppInfo pandaAppInfo = { + "@koalaui/arkts-arkui/Application/Application", + "createApplication", + "Lstd/core/String;Lstd/core/String;Z:L@koalaui/arkts-arkui/Application/Application;", + "start", + ":J", + "enter", + "IIJ:Z", + "emitEvent", + "IIII:Lstd/core/String;", +}; +const AppInfo harnessAppInfo = { + "@koalaui/ets-harness/src/EtsHarnessApplication/EtsHarnessApplication", + "createApplication", + "Lstd/core/String;Lstd/core/String;Z:L@koalaui/ets-harness/src/EtsHarnessApplication/EtsHarnessApplication;", + "start", + ":J", + "enter", + "II:Z", + "emitEvent", + "IIII:Lstd/core/String;", + "restartWith", + "Lstd/core/String;:V" +}; +#endif + +extern "C" DLL_EXPORT KNativePointer StartApplication(const char* appUrl, const char* appParams) { + const auto isTestEnv = std::string(appUrl) == "EtsHarness"; + const AppInfo* appInfo = + #ifdef KOALA_JNI + (g_vmEntry.vmKind == JAVA_VM_KIND) ? &javaAppInfo : + #endif + #ifdef KOALA_ETS_NAPI + (g_vmEntry.vmKind == PANDA_VM_KIND) ? isTestEnv ? &harnessAppInfo : &pandaAppInfo : + #endif + nullptr; + + if (!appInfo) { + LOGE("No appInfo provided for VM kind %" LOG_PUBLIC "d (recompile vmloader.cc with the missing flags)\n", g_vmEntry.vmKind); + return nullptr; + } + + LOGI("Starting application %" LOG_PUBLIC "s with params %" LOG_PUBLIC "s", appUrl, appParams); + +#ifdef KOALA_JNI + if (g_vmEntry.vmKind == JAVA_VM_KIND) { + JNIEnv* jEnv = (JNIEnv*)(g_vmEntry.env); + jclass appClass = jEnv->FindClass(appInfo->className); + if (!appClass) { + LOGE("Cannot load main class %s\n", appInfo->className); + return nullptr; + } + jmethodID create = jEnv->GetStaticMethodID(appClass, appInfo->createMethodName, appInfo->createMethodSig); + if (!create) { + LOGE("Cannot find create method %s\n", appInfo->createMethodName); + return nullptr; + } + auto app = jEnv->NewGlobalRef(jEnv->CallStaticObjectMethod(appClass, create, jEnv->NewStringUTF(appUrl), jEnv->NewStringUTF(appParams))); + g_vmEntry.app = app; + auto start = jEnv->GetMethodID(appClass, appInfo->startMethodName, appInfo->startMethodSig); + if (!start) { + LOGE("Cannot find start method \"%s %s\"\n", appInfo->startMethodName, appInfo->startMethodSig); + return nullptr; + } + g_vmEntry.enter = (void*)(jEnv->GetMethodID(appClass, appInfo->enterMethodName, appInfo->enterMethodSig)); + if (!g_vmEntry.enter) { + LOGE("Cannot find enter method %s\n", appInfo->enterMethodName); + return nullptr; + } + g_vmEntry.emitEvent = (void*)(jEnv->GetMethodID(appClass, appInfo->emitEventMethodName, appInfo->emitEventMethodSig)); + if (!g_vmEntry.emitEvent) { + LOGE("Cannot find emitEvent method %s\n", appInfo->emitEventMethodName); + return nullptr; + } + return reinterpret_cast(jEnv->CallLongMethod( + app, start)); + } +#endif +#ifdef KOALA_ETS_NAPI + if (g_vmEntry.vmKind == PANDA_VM_KIND) { + EtsEnv* etsEnv = (EtsEnv*)g_vmEntry.env; + ets_class appClass = etsEnv->FindClass(appInfo->className); + if (!appClass) { + LOGE("Cannot load main class %" LOG_PUBLIC "s\n", appInfo->className); + return nullptr; + } + ets_method create = etsEnv->GetStaticp_method(appClass, appInfo->createMethodName, appInfo->createMethodSig); + if (!create) { + LOGE("Cannot find create method %" LOG_PUBLIC "s\n", appInfo->createMethodName); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } +#if defined (KOALA_OHOS_ARM64) + auto useNativeLog = true; +#else + auto useNativeLog = false; +#endif + auto app = etsEnv->NewGlobalRef(etsEnv->CallStaticObjectMethod( + appClass, create, + etsEnv->NewStringUTF(appUrl), etsEnv->NewStringUTF(appParams), + useNativeLog + )); + if (!app) { + LOGE("createApplication returned null"); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } + g_vmEntry.app = (void*)app; + auto start = etsEnv->Getp_method(appClass, appInfo->startMethodName, appInfo->startMethodSig); + g_vmEntry.enter = (void*)(etsEnv->Getp_method(appClass, appInfo->enterMethodName, nullptr /*appInfo->enterMethodSig */)); + if (!g_vmEntry.enter) { + LOGE("Cannot find enter method %" LOG_PUBLIC "s", appInfo->enterMethodName); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } + g_vmEntry.emitEvent = (void*)(etsEnv->Getp_method(appClass, appInfo->emitEventMethodName, appInfo->emitEventMethodSig)); + if (!g_vmEntry.emitEvent) { + LOGE("Cannot find enter emitEvent %" LOG_PUBLIC "s", appInfo->emitEventMethodSig); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } + if (isTestEnv) { + g_vmEntry.restartWith = (void*)(etsEnv->Getp_method(appClass, appInfo->restartWithMethodName, appInfo->restartWithMethodSig)); + if (!g_vmEntry.restartWith) { + LOGE("Cannot find enter restartWith %" LOG_PUBLIC "s", appInfo->restartWithMethodSig); + if (etsEnv->ErrorCheck()) { + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return nullptr; + } + } + // TODO: pass app entry point! + return reinterpret_cast(etsEnv->CallLongMethod((ets_object)(app), start)); + } +#endif + return nullptr; +} + +extern "C" DLL_EXPORT KBoolean RunApplication(const KInt arg0, const KInt arg1) { +#ifdef KOALA_JNI + if (g_vmEntry.vmKind == JAVA_VM_KIND) { + JNIEnv* jEnv = (JNIEnv*)(g_vmEntry.env); + auto result = jEnv->CallBooleanMethod( + (jobject)(g_vmEntry.app), + (jmethodID)(g_vmEntry.enter), + (jint)arg0, + (jint)arg1, + (int64_t)(intptr_t)(&g_vmEntry.foreignVMContext) + ); + if (jEnv->ExceptionCheck()) { + jEnv->ExceptionDescribe(); + jEnv->ExceptionClear(); + } + return result; + } +#endif +#ifdef KOALA_ETS_NAPI + if (g_vmEntry.vmKind == PANDA_VM_KIND) { + EtsEnv* etsEnv = (EtsEnv*)(g_vmEntry.env); + if (!g_vmEntry.enter) { + LOGE("Cannot find enter method"); + return -1; + } + auto result = etsEnv->CallBooleanMethod( + (ets_object)(g_vmEntry.app), + (ets_method)(g_vmEntry.enter), + (ets_int)arg0, + (ets_int)arg1, + (int64_t)(intptr_t)(&g_vmEntry.foreignVMContext) + ); + if (etsEnv->ErrorCheck()) { + LOGE("Calling enter() method gave an error"); + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + return result; + } + #endif + return 1; +} + +extern "C" DLL_EXPORT const char* EmitEvent(const KInt type, const KInt target, const KInt arg0, const KInt arg1) { +#ifdef KOALA_JNI + if (g_vmEntry.vmKind == JAVA_VM_KIND) { + JNIEnv* jEnv = (JNIEnv*)(g_vmEntry.env); + if (!g_vmEntry.emitEvent) { + LOGE("Cannot find emitEvent method"); + return "-1"; + } + auto rv = (jstring)jEnv->CallObjectMethod( + (jobject)(g_vmEntry.app), + (jmethodID)(g_vmEntry.emitEvent), + (jint)type, + (jint)target, + (jint)arg0, + (jint)arg1 + ); + if (jEnv->ExceptionCheck()) { + jEnv->ExceptionDescribe(); + jEnv->ExceptionClear(); + } + const char *result = jEnv->GetStringUTFChars(rv, 0); + return result; + } +#endif +#ifdef KOALA_ETS_NAPI + if (g_vmEntry.vmKind == PANDA_VM_KIND) { + EtsEnv* etsEnv = (EtsEnv*)(g_vmEntry.env); + if (!g_vmEntry.emitEvent) { + LOGE("Cannot find emitEvent method"); + return "-1"; + } + auto rv = (ets_string)etsEnv->CallObjectMethod( + (ets_object)(g_vmEntry.app), + (ets_method)(g_vmEntry.emitEvent), + (ets_int)type, + (ets_int)target, + (ets_int)arg0, + (ets_int)arg1 + ); + if (etsEnv->ErrorCheck()) { + LOGE("Calling emitEvent() method gave an error"); + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + const char *result = etsEnv->GetStringUTFChars(rv, 0); + return result; + } + #endif + return "-1"; +} + +extern "C" DLL_EXPORT void RestartWith(const char* page) { +#ifdef KOALA_JNI + if (g_vmEntry.vmKind == JAVA_VM_KIND) { + JNIEnv* jEnv = (JNIEnv*)(g_vmEntry.env); + if (!g_vmEntry.restartWith) { + LOGE("Cannot find restartWith method"); + return; + } + jEnv->CallVoidMethod( + (jobject)(g_vmEntry.app), + (jmethodID)(g_vmEntry.restartWith), + jEnv->NewStringUTF(page) + ); + if (jEnv->ExceptionCheck()) { + jEnv->ExceptionDescribe(); + jEnv->ExceptionClear(); + } + } +#endif +#ifdef KOALA_ETS_NAPI + if (g_vmEntry.vmKind == PANDA_VM_KIND) { + EtsEnv* etsEnv = (EtsEnv*)(g_vmEntry.env); + if (!g_vmEntry.restartWith) { + LOGE("Cannot find restartWith method"); + return; + } + etsEnv->CallVoidMethod( + (ets_object)(g_vmEntry.app), + (ets_method)(g_vmEntry.restartWith), + etsEnv->NewStringUTF(page) + ); + if (etsEnv->ErrorCheck()) { + LOGE("Calling restartWith() method gave an error"); + etsEnv->ErrorDescribe(); + etsEnv->ErrorClear(); + } + } + #endif +} + +void traverseDir(std::string root, std::vector& paths, int depth) { + if (depth >= 50) { + return; + } +#if defined(KOALA_LINUX) || defined(KOALA_MACOS) || defined(KOALA_OHOS) + std::string suffix = ".abc"; + #if defined(KOALA_OHOS) + suffix += ".so"; + #endif + DIR* directory = opendir(root.c_str()); + if (!directory) { + LOGE("Cannot open dir %" LOG_PUBLIC "s\n", root.c_str()); + return; + } + struct dirent* ent = NULL; + struct stat statbuf; + + LOGI("Searching for *%" LOG_PUBLIC "s in %" LOG_PUBLIC "s\n", suffix.c_str(), root.c_str()); + while ((ent = readdir(directory)) != nullptr) { + std::string filename = std::string(ent->d_name); + if (filename == "." || filename == "..") { + continue; + } + std::string filepath = root + "/" + filename; + int rv = stat(filepath.c_str(), &statbuf); + if (rv < 0) continue; + if (filepath.size() >= suffix.size() && filepath.substr(filepath.size() - suffix.size()) == suffix && (statbuf.st_mode & S_IFMT) == S_IFREG) { + paths.push_back(filepath); + } + if ((statbuf.st_mode & S_IFMT) == S_IFDIR) { + traverseDir(filepath, paths, depth + 1); + } + } + closedir(directory); +#endif +} diff --git a/koala-wrapper/koalaui/interop/src/cpp/wasm/convertors-wasm.h b/koala-wrapper/koalaui/interop/src/cpp/wasm/convertors-wasm.h new file mode 100644 index 000000000..eea97a98e --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/cpp/wasm/convertors-wasm.h @@ -0,0 +1,778 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +#pragma once + +#include "koala-types.h" + +#include +#include +#define KOALA_INTEROP_EXPORT EMSCRIPTEN_KEEPALIVE extern "C" + +template +struct InteropTypeConverter { + using InteropType = T; + static T convertFrom(InteropType value) { return value; } + static InteropType convertTo(T value) { return value; } +}; + +template<> +struct InteropTypeConverter { + using InteropType = const uint8_t*; + static KStringPtr convertFrom(InteropType value) { + KStringPtr result; + if (value == nullptr) { + return KStringPtr(); + } else { + int len = (value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24)); + return KStringPtr((const char*)(value + 4), len, true); + } + } + static InteropType convertTo(KStringPtr value) = delete; +}; + +template +inline T getArgument(typename InteropTypeConverter::InteropType arg) { + return InteropTypeConverter::convertFrom(arg); +} + +template +inline typename InteropTypeConverter::InteropType makeResult(T value) { + return InteropTypeConverter::convertTo(value); +} + +// TODO: Rewrite all others to typed convertors. + +#define KOALA_INTEROP_0(name, Ret) \ +KOALA_INTEROP_EXPORT Ret name() { \ + KOALA_MAYBE_LOG(name) \ + return makeResult(impl_##name()); \ +} + +#define KOALA_INTEROP_1(name, Ret, P0) \ +KOALA_INTEROP_EXPORT Ret name(InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + return makeResult(impl_##name(p0)); \ +} + +#define KOALA_INTEROP_2(name, Ret, P0, P1) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + return makeResult(impl_##name(p0, p1)); \ +} + +#define KOALA_INTEROP_3(name, Ret, P0, P1, P2) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + return makeResult(impl_##name(p0, p1, p2)); \ +} + +#define KOALA_INTEROP_4(name, Ret, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + return makeResult(impl_##name(p0, p1, p2, p3)); \ +} + +#define KOALA_INTEROP_5(name, Ret, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4)); \ +} + +#define KOALA_INTEROP_6(name, Ret, P0, P1, P2, P3, P4, P5) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5)); \ +} + +#define KOALA_INTEROP_7(name, Ret, P0, P1, P2, P3, P4, P5, P6) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6)); \ +} + +#define KOALA_INTEROP_8(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7)); \ +} + +#define KOALA_INTEROP_9(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8)); \ +} + +#define KOALA_INTEROP_10(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)); \ +} + +#define KOALA_INTEROP_11(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); \ +} + +#define KOALA_INTEROP_12(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); \ +} + +#define KOALA_INTEROP_13(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); \ +} + +#define KOALA_INTEROP_14(name, Ret, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3, \ + InteropTypeConverter::InteropType _p4, \ + InteropTypeConverter::InteropType _p5, \ + InteropTypeConverter::InteropType _p6, \ + InteropTypeConverter::InteropType _p7, \ + InteropTypeConverter::InteropType _p8, \ + InteropTypeConverter::InteropType _p9, \ + InteropTypeConverter::InteropType _p10, \ + InteropTypeConverter::InteropType _p11, \ + InteropTypeConverter::InteropType _p12, \ + InteropTypeConverter::InteropType _p13 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + P13 p13 = getArgument(_p13); \ + return makeResult(impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); \ +} + + + +#define KOALA_INTEROP_V0(name) \ +KOALA_INTEROP_EXPORT void name() { \ + KOALA_MAYBE_LOG(name) \ + impl_##name(); \ + return; \ +} + +#define KOALA_INTEROP_V1(name, P0) \ +KOALA_INTEROP_EXPORT void name(typename InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + impl_##name(p0); \ + return; \ +} + +#define KOALA_INTEROP_V2(name, P0, P1) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + impl_##name(p0, p1); \ + return; \ +} + +#define KOALA_INTEROP_V3(name, P0, P1, P2) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + impl_##name(p0, p1, p2); \ + return; \ +} + +#define KOALA_INTEROP_V4(name, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + impl_##name(p0, p1, p2, p3); \ + return; \ +} + +#define KOALA_INTEROP_V5(name, P0, P1, P2, P3, P4) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + impl_##name(p0, p1, p2, p3, p4); \ + return; \ +} + +#define KOALA_INTEROP_V6(name, P0, P1, P2, P3, P4, P5) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + impl_##name(p0, p1, p2, p3, p4, p5); \ + return; \ +} + +#define KOALA_INTEROP_V7(name, P0, P1, P2, P3, P4, P5, P6) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6); \ + return; \ +} + +#define KOALA_INTEROP_V8(name, P0, P1, P2, P3, P4, P5, P6, P7) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7); \ + return; \ +} + +#define KOALA_INTEROP_V9(name, P0, P1, P2, P3, P4, P5, P6, P7, P8) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8); \ + return; \ +} + +#define KOALA_INTEROP_V10(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + return; \ +} + +#define KOALA_INTEROP_V11(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + return; \ +} + +#define KOALA_INTEROP_V12(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + return; \ +} + +#define KOALA_INTEROP_V13(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11, \ + typename InteropTypeConverter::InteropType _p12 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + return; \ +} + +#define KOALA_INTEROP_V14(name, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13) \ +KOALA_INTEROP_EXPORT void name( \ + typename InteropTypeConverter::InteropType _p0, \ + typename InteropTypeConverter::InteropType _p1, \ + typename InteropTypeConverter::InteropType _p2, \ + typename InteropTypeConverter::InteropType _p3, \ + typename InteropTypeConverter::InteropType _p4, \ + typename InteropTypeConverter::InteropType _p5, \ + typename InteropTypeConverter::InteropType _p6, \ + typename InteropTypeConverter::InteropType _p7, \ + typename InteropTypeConverter::InteropType _p8, \ + typename InteropTypeConverter::InteropType _p9, \ + typename InteropTypeConverter::InteropType _p10, \ + typename InteropTypeConverter::InteropType _p11, \ + typename InteropTypeConverter::InteropType _p12, \ + typename InteropTypeConverter::InteropType _p13 \ +) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + P4 p4 = getArgument(_p4); \ + P5 p5 = getArgument(_p5); \ + P6 p6 = getArgument(_p6); \ + P7 p7 = getArgument(_p7); \ + P8 p8 = getArgument(_p8); \ + P9 p9 = getArgument(_p9); \ + P10 p10 = getArgument(_p10); \ + P11 p11 = getArgument(_p11); \ + P12 p12 = getArgument(_p12); \ + P13 p13 = getArgument(_p13); \ + impl_##name(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + return; \ +} + +#define KOALA_INTEROP_CTX_1(name, Ret, P0) \ +KOALA_INTEROP_EXPORT Ret name(InteropTypeConverter::InteropType _p0) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + return makeResult(impl_##name(nullptr, p0)); \ +} + +#define KOALA_INTEROP_CTX_2(name, Ret, P0, P1) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + return makeResult(impl_##name(nullptr, p0, p1)); \ +} + +#define KOALA_INTEROP_CTX_3(name, Ret, P0, P1, P2) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + return makeResult(impl_##name(nullptr, p0, p1, p2)); \ +} + +#define KOALA_INTEROP_CTX_4(name, Ret, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT Ret name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + return makeResult(impl_##name(nullptr, p0, p1, p2, p3)); \ +} + +#define KOALA_INTEROP_CTX_V3(name, P0, P1, P2) \ +KOALA_INTEROP_EXPORT void name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + impl_##name(nullptr, p0, p1, p2); \ +} + +#define KOALA_INTEROP_CTX_V4(name, P0, P1, P2, P3) \ +KOALA_INTEROP_EXPORT void name( \ + InteropTypeConverter::InteropType _p0, \ + InteropTypeConverter::InteropType _p1, \ + InteropTypeConverter::InteropType _p2, \ + InteropTypeConverter::InteropType _p3) { \ + KOALA_MAYBE_LOG(name) \ + P0 p0 = getArgument(_p0); \ + P1 p1 = getArgument(_p1); \ + P2 p2 = getArgument(_p2); \ + P3 p3 = getArgument(_p3); \ + impl_##name(nullptr, p0, p1, p2, p3); \ +} + +#define KOALA_INTEROP_THROW(vmContext, object, ...) \ + do { \ + assert(false); /* TODO: implement*/ \ + return __VA_ARGS__; \ + } while (0) + +#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ + do { \ + assert(false); /* TODO: implement*/ \ + return __VA_ARGS__; \ + } while (0) diff --git a/koala-wrapper/koalaui/interop/src/interop/DeserializerBase.ts b/koala-wrapper/koalaui/interop/src/interop/DeserializerBase.ts new file mode 100644 index 000000000..af06948a3 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/DeserializerBase.ts @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2025 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 { CustomTextDecoder, float32, int32, int64 } from "@koalaui/common" +import { Tags, CallbackResource } from "./SerializerBase"; +import { pointer } from "./InteropTypes" +import { InteropNativeModule } from "./InteropNativeModule" + +export class DeserializerBase { + private position = 0 + private readonly buffer: ArrayBuffer + private readonly length: int32 + private view: DataView + private static textDecoder = new CustomTextDecoder() + private static customDeserializers: CustomDeserializer | undefined = undefined + + static registerCustomDeserializer(deserializer: CustomDeserializer) { + let current = DeserializerBase.customDeserializers + if (current == undefined) { + DeserializerBase.customDeserializers = deserializer + } else { + while (current.next != undefined) { + current = current.next + } + current.next = deserializer + } + } + + constructor(buffer: ArrayBuffer, length: int32) { + this.buffer = buffer + this.length = length + this.view = new DataView(this.buffer) + } + + static get( + factory: (args: Uint8Array, length: int32) => T, + args: Uint8Array, length: int32): T { + + // TBD: Use cache + return factory(args, length); + } + + asArray(position?: number, length?: number): Uint8Array { + return new Uint8Array(this.buffer, position, length) + } + + currentPosition(): int32 { + return this.position + } + + resetCurrentPosition(): void { + this.position = 0 + } + + private checkCapacity(value: int32) { + if (value > this.length) { + throw new Error(`${value} is less than remaining buffer length`) + } + } + + readInt8(): int32 { + this.checkCapacity(1) + const value = this.view.getInt8(this.position) + this.position += 1 + return value + } + + readInt32(): int32 { + this.checkCapacity(4) + const value = this.view.getInt32(this.position, true) + this.position += 4 + return value + } + + readInt64(): int64 { + this.checkCapacity(8) + const value = this.view.getBigInt64(this.position, true) + this.position += 8 + return Number(value) + } + + readPointer(): pointer { + this.checkCapacity(8) + const value = this.view.getBigInt64(this.position, true) + this.position += 8 + return value + } + + readFloat32(): float32 { + this.checkCapacity(4) + const value = this.view.getFloat32(this.position, true) + this.position += 4 + return value + } + + readBoolean(): boolean { + this.checkCapacity(1) + const value = this.view.getInt8(this.position) + this.position += 1 + return value == 1 + } + + readFunction(): any { + // TODO: not exactly correct. + const id = this.readInt32() + return id + } + + readMaterialized(): object { + const ptr = this.readPointer() + return { ptr: ptr } + } + + readString(): string { + const length = this.readInt32() + this.checkCapacity(length) + // read without null-terminated byte + const value = DeserializerBase.textDecoder.decode(this.asArray(this.position, length - 1)); + this.position += length + return value + } + + readCustomObject(kind: string): any { + let current = DeserializerBase.customDeserializers + while (current) { + if (current.supports(kind)) { + return current.deserialize(this, kind) + } + current = current.next + } + // consume tag + const tag = this.readInt8() + return undefined + } + + readNumber(): number | undefined { + const tag = this.readInt8() + switch (tag) { + case Tags.UNDEFINED: + return undefined; + case Tags.INT32: + return this.readInt32() + case Tags.FLOAT32: + return this.readFloat32() + default: + throw new Error(`Unknown number tag: ${tag}`) + break + } + } + + readCallbackResource(): CallbackResource { + return { + resourceId: this.readInt32(), + hold: this.readPointer(), + release: this.readPointer(), + } + } + + static lengthUnitFromInt(unit: int32): string { + let suffix: string + switch (unit) { + case 0: + suffix = "px" + break + case 1: + suffix = "vp" + break + case 3: + suffix = "%" + break + case 4: + suffix = "lpx" + break + default: + suffix = "" + } + return suffix + } + readBuffer(): ArrayBuffer { + const resource = this.readCallbackResource() + const data = this.readPointer() + const length = this.readInt64() + + return InteropNativeModule._MaterializeBuffer(data, length, resource.resourceId, resource.hold, resource.release) + } +} + +export abstract class CustomDeserializer { + protected constructor(protected supported: Array) { + } + + supports(kind: string): boolean { + return this.supported.includes(kind) + } + + abstract deserialize(serializer: DeserializerBase, kind: string): any + + next: CustomDeserializer | undefined = undefined +} + +class DateDeserializer extends CustomDeserializer { + constructor() { + super(["Date"]); + } + + deserialize(serializer: DeserializerBase, kind: string): any { + return new Date(serializer.readString()) + } +} +DeserializerBase.registerCustomDeserializer(new DateDeserializer()) diff --git a/koala-wrapper/koalaui/interop/src/interop/Finalizable.ts b/koala-wrapper/koalaui/interop/src/interop/Finalizable.ts new file mode 100644 index 000000000..dc0e8a980 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/Finalizable.ts @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2022-2025 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 { Wrapper, nullptr, isNullPtr } from "./Wrapper" +import { finalizerRegister, finalizerUnregister, Thunk } from "@koalaui/common" +import { InteropNativeModule } from "./InteropNativeModule" +import { pointer } from "./InteropTypes" + +export class NativeThunk implements Thunk { + finalizer: pointer + obj: pointer + name: string|undefined + + constructor(obj: pointer, finalizer: pointer, name?: string) { + this.finalizer = finalizer + this.obj = obj + this.name = name + } + + clean() { + if (!isNullPtr(this.obj)) { + this.destroyNative(this.obj, this.finalizer) + } + this.obj = nullptr + } + + destroyNative(ptr: pointer, finalizer: pointer): void { + InteropNativeModule._InvokeFinalizer(ptr, finalizer) + } +} + +/** + * Class with the custom finalizer, usually used to release a native peer. + * Do not use directly, only via subclasses. + */ +export class Finalizable extends Wrapper { + finalizer: pointer + cleaner?: NativeThunk = undefined + managed: boolean + constructor(ptr: pointer, finalizer: pointer, managed: boolean = true) { + super(ptr) + this.finalizer = finalizer + this.managed = managed + const handle = this.createHandle() + + if (this.managed) { + // TODO: reenable exception. + if (this.ptr == nullptr) return // throw new Error("Can't have nullptr ptr ${}") + if (this.finalizer == nullptr) throw new Error("Managed finalizer is 0") + + const thunk = this.makeNativeThunk(ptr, finalizer, handle) + finalizerRegister(this, thunk) + this.cleaner = thunk + } + } + + createHandle(): string | undefined { + return undefined + } + + makeNativeThunk(ptr: pointer, finalizer: pointer, handle: string | undefined): NativeThunk { + return new NativeThunk(ptr, finalizer, handle) + } + + close() { + if (isNullPtr(this.ptr)) { + throw new Error(`Closing a closed object: ` + this.toString()) + } else if (this.cleaner == null) { + throw new Error(`No thunk assigned to ` + this.toString()) + } else { + finalizerUnregister(this) + this.cleaner.clean() + this.cleaner = undefined + this.ptr = nullptr + } + } + + release(): pointer { + finalizerUnregister(this) + if (this.cleaner) + this.cleaner.obj = nullptr + let result = this.ptr + this.ptr = nullptr + return result + } + + resetPeer(pointer: pointer) { + if (this.managed) throw new Error("Can only reset peer for an unmanaged object") + this.ptr = pointer + } + + use(body: (value: Finalizable) => R): R { + let result = body(this) + this.close() + return result + } +} diff --git a/koala-wrapper/koalaui/interop/src/interop/InteropNativeModule.ts b/koala-wrapper/koalaui/interop/src/interop/InteropNativeModule.ts new file mode 100644 index 000000000..b3677da97 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/InteropNativeModule.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/common"; +import { KPointer, KStringPtr, KUint8ArrayPtr } from "./InteropTypes"; +import { loadNativeModuleLibrary } from "./loadLibraries"; + +export class InteropNativeModule { + public static _SetCallbackDispatcher(dispatcher: (id: int32, args: Uint8Array, length: int32) => int32): void { throw "method not loaded" } + public static _CleanCallbackDispatcher(): void { throw "method not loaded" } + + public static _GetGroupedLog(index: int32): KPointer { throw "method not loaded" } + public static _StartGroupedLog(index: int32): void { throw "method not loaded" } + public static _StopGroupedLog(index: int32): void { throw "method not loaded" } + public static _AppendGroupedLog(index: int32, message: string): void { throw "method not loaded" } + public static _PrintGroupedLog(index: int32): void { throw "method not loaded" } + public static _GetStringFinalizer(): KPointer { throw "method not loaded" } + public static _InvokeFinalizer(ptr1: KPointer, ptr2: KPointer): void { throw "method not loaded" } + public static _GetPtrVectorElement(ptr1: KPointer, arg: int32): KPointer { throw "method not loaded" } + public static _StringLength(ptr1: KPointer): int32 { throw "method not loaded" } + public static _StringData(ptr1: KPointer, arr: KUint8ArrayPtr, i: int32): void { throw "method not loaded" } + public static _StringMake(str1: KStringPtr): KPointer { throw "method not loaded" } + public static _GetPtrVectorSize(ptr1: KPointer): int32 { throw "method not loaded" } + public static _ManagedStringWrite(str1: string, arr: Uint8Array, arg: int32): int32 { throw "method not loaded" } + public static _NativeLog(str1: string): void { throw "method not loaded" } + public static _Utf8ToString(data: KUint8ArrayPtr, offset: int32, length: int32): string { throw "method not loaded" } + public static _StdStringToString(cstring: KPointer): string { throw "method not loaded" } + public static _CheckCallbackEvent(buffer: KUint8ArrayPtr, bufferLength: int32): int32 { throw "method not loaded" } + public static _HoldCallbackResource(resourceId: int32): void { throw "method not loaded" } + public static _ReleaseCallbackResource(resourceId: int32): void { throw "method not loaded" } + public static _CallCallback(callbackKind: int32, args: Uint8Array, argsSize: int32): void { throw "method not loaded" } + public static _CallCallbackSync(callbackKind: int32, args: Uint8Array, argsSize: int32): void { throw "method not loaded" } + public static _CallCallbackResourceHolder(holder: KPointer, resourceId: int32): void { throw "method not loaded" } + public static _CallCallbackResourceReleaser(releaser: KPointer, resourceId: int32): void { throw "method not loaded" } + public static _MaterializeBuffer(data: KPointer, length: int32, resourceId: int32, hold: KPointer, release: KPointer): ArrayBuffer { throw "method not loaded" } + public static _GetNativeBufferPointer(data: ArrayBuffer): KPointer { throw "method not loaded" } + + public static _LoadVirtualMachine(arg0: int32, arg1: string, arg2: string): int32 { throw "method not loaded" } + public static _RunApplication(arg0: int32, arg1: int32): number { throw "method not loaded" } + public static _StartApplication(appUrl: string, appParams: string): KPointer { throw "method not loaded" } + public static _EmitEvent(eventType: int32, target: int32, arg0: int32, arg1: int32): void { throw "method not loaded" } + public static _CallForeignVM(foreignContext: KPointer, kind: int32, args: Uint8Array, argsSize: int32): int32 { throw "method not loaded" } +} + +export function loadInteropNativeModule() { + loadNativeModuleLibrary("InteropNativeModule", InteropNativeModule) +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/interop/InteropOps.ts b/koala-wrapper/koalaui/interop/src/interop/InteropOps.ts new file mode 100644 index 000000000..71d84f0a4 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/InteropOps.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2025 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 { int32 } from "@koalaui/common" +import { withStringResult } from "./Platform" +import { KInt, KStringPtr, KUint8ArrayPtr, pointer } from "./InteropTypes" + +export type CallbackType = (args: Uint8Array, length: int32) => int32 + +class CallbackRecord { + constructor( + public readonly callback: CallbackType, + public readonly autoDisposable: boolean + ) { } +} + +class CallbackRegistry { + + static INSTANCE = new CallbackRegistry() + + private callbacks = new Map() + private id = 1024 + + constructor() { + this.callbacks.set(0, new CallbackRecord( + (args: Uint8Array, length: int32): int32 => { + console.log(`Callback 0 called with args = ${args} and length = ${length}`) + throw new Error(`Null callback called`) + }, false) + ) + } + + wrap(callback: CallbackType, autoDisposable: boolean): int32 { + const id = this.id++ + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)) + return id + } + + wrapSystem(id: number, callback: CallbackType, autoDisposable: boolean): int32 { + this.callbacks.set(id, new CallbackRecord(callback, autoDisposable)) + return id + } + + call(id: int32, args: Uint8Array, length: int32): int32 { + const record = this.callbacks.get(id) + if (!record) { + console.log(`Callback ${id} is not known`) + // throw new Error(`Disposed or unwrapped callback called (id = ${id})`) + return 0; // todo + } + if (record.autoDisposable) { + this.dispose(id) + } + return record.callback(args, length) + } + + dispose(id: int32) { + this.callbacks.delete(id) + } +} + +export function wrapCallback(callback: CallbackType, autoDisposable: boolean = true): int32 { + return CallbackRegistry.INSTANCE.wrap(callback, autoDisposable) +} + +export function wrapSystemCallback(id:number, callback: CallbackType): int32 { + return CallbackRegistry.INSTANCE.wrapSystem(id, callback, false) +} + +export function disposeCallback(id: int32) { + CallbackRegistry.INSTANCE.dispose(id) +} + +export function callCallback(id: int32, args: Uint8Array, length: int32): int32 { + return CallbackRegistry.INSTANCE.call(id, args, length) +} diff --git a/koala-wrapper/koalaui/interop/src/interop/InteropTypes.ts b/koala-wrapper/koalaui/interop/src/interop/InteropTypes.ts new file mode 100644 index 000000000..7373008e6 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/InteropTypes.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 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 { int32, int64, float32, float64 } from "@koalaui/common" + +export type KStringPtr = int32 | string | null +export type KStringArrayPtr = int32 | Uint8Array | null +export type KInt32ArrayPtr = int32 | Int32Array | null +export type KFloat32ArrayPtr = int32 | Float32Array | null +export type KUint8ArrayPtr = int32 | Uint8Array | null +export type KInt = int32 +export type KUInt = int32 +export type KLong = int64 +export type KFloat = float32 +export type KDouble = float64 +export type KBoolean = int32 +export type KPointer = number | bigint +export type pointer = KPointer +export type KNativePointer = KPointer +export type KInteropReturnBuffer = Uint8Array \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/interop/MaterializedBase.ts b/koala-wrapper/koalaui/interop/src/interop/MaterializedBase.ts new file mode 100644 index 000000000..c1aa09b05 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/MaterializedBase.ts @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 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/koala-wrapper/koalaui/interop/src/interop/NativeBuffer.ts b/koala-wrapper/koalaui/interop/src/interop/NativeBuffer.ts new file mode 100644 index 000000000..d3b23d72e --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/NativeBuffer.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 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 { pointer } from './InteropTypes' +import { int32, int64 } from '@koalaui/common' + +// stub wrapper for KInteropBuffer +export class NativeBuffer extends ArrayBuffer { + public data:pointer = 0 + public length: int64 = 0 + public resourceId: int32 = 0 + public hold:pointer = 0 + public release: pointer = 0 + + constructor(data:pointer, length: int64, resourceId: int32, hold:pointer, release: pointer) { + super(length) + this.data = data + this.length = length + this.resourceId = resourceId + this.hold = hold + this.release = release + } + + static wrap(data:pointer, length: int64, resourceId: int32, hold:pointer, release: pointer): NativeBuffer { + return new NativeBuffer(data, length, resourceId, hold, release) + } +} diff --git a/koala-wrapper/koalaui/interop/src/interop/NativeString.ts b/koala-wrapper/koalaui/interop/src/interop/NativeString.ts new file mode 100644 index 000000000..8e04674be --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/NativeString.ts @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2025 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" +import { InteropNativeModule } from "./InteropNativeModule" +import { pointer } from "./InteropTypes" + +export class NativeString extends Finalizable { + constructor(ptr: pointer) { + super(ptr, InteropNativeModule._GetStringFinalizer()) + } + static Make(value: string): NativeString { + return new NativeString(InteropNativeModule._StringMake(value)) + } + toString(): string { + return InteropNativeModule._StdStringToString(this.ptr) + } +} diff --git a/koala-wrapper/koalaui/interop/src/interop/Platform.ts b/koala-wrapper/koalaui/interop/src/interop/Platform.ts new file mode 100644 index 000000000..fb74d312c --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/Platform.ts @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/common" +import { isNullPtr, nullptr, Wrapper } from "./Wrapper" +import { decodeToString } from "#common/wrappers/arrays" +import { setCallbackRegistry } from "#common/wrappers/Callback" +import { KPointer } from "./InteropTypes" + +export abstract class NativeStringBase extends Wrapper { + constructor(ptr: KPointer) { + super(ptr) + } + + protected abstract bytesLength(): int32 + protected abstract getData(data: Uint8Array): void + + toString(): string { + let length = this.bytesLength() + let data = new Uint8Array(length) + this.getData(data) + return decodeToString(data) + } + + abstract close(): void +} + +export abstract class ArrayDecoder { + abstract getArraySize(blob: KPointer): int32 + abstract disposeArray(blob: KPointer): void + abstract getArrayElement(blob: KPointer, index: int32): T + + decode(blob: KPointer): Array { + const size = this.getArraySize(blob) + const result = new Array(size) + for (let index = 0; index < size; index++) { + result[index] = this.getArrayElement(blob, index) + } + this.disposeArray(blob) + return result + } +} + + +// TODO: the semicolons after methods in these interfaces are to +// workaround ArkTS compiler parser bug +export interface CallbackRegistry { + registerCallback(callback: any, obj: any): KPointer; +} + +export interface PlatformDefinedData { + nativeString(ptr: KPointer): NativeStringBase; + nativeStringArrayDecoder(): ArrayDecoder; + callbackRegistry(): CallbackRegistry | undefined; +} + +let platformData: PlatformDefinedData|undefined = undefined + +export function providePlatformDefinedData(platformDataParam: PlatformDefinedData) { + platformData = platformDataParam + let registry = platformDataParam.callbackRegistry() + if (registry) setCallbackRegistry(registry) +} + +export function withStringResult(ptr: KPointer): string|undefined { + if (isNullPtr(ptr)) return undefined + let managedString = platformData!.nativeString(ptr) + let result = managedString?.toString() + managedString?.close() + return result +} + +export function withStringArrayResult(ptr: KPointer): Array { + if (ptr == nullptr) return new Array() + let managedStringArray = platformData!.nativeStringArrayDecoder().decode(ptr) + return managedStringArray.map((nativeString:NativeStringBase) => nativeString.toString()) +} diff --git a/koala-wrapper/koalaui/interop/src/interop/SerializerBase.ts b/koala-wrapper/koalaui/interop/src/interop/SerializerBase.ts new file mode 100644 index 000000000..c1df42d43 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/SerializerBase.ts @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2025 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 { float32, int32, int64 } from "@koalaui/common" +import { pointer, KPointer } from "./InteropTypes" +import { wrapCallback } from "./InteropOps" +import { InteropNativeModule } from "./InteropNativeModule" +import { ResourceHolder, ResourceId } from "../arkts/ResourceManager" + +// imports required interfaces (now generation is disabled) +// import { Resource } from "@arkoala/arkui" +/** + * Value representing possible JS runtime object type. + * Must be synced with "enum RuntimeType" in C++. + */ +export enum RuntimeType { + UNEXPECTED = -1, + NUMBER = 1, + STRING = 2, + OBJECT = 3, + BOOLEAN = 4, + UNDEFINED = 5, + BIGINT = 6, + FUNCTION = 7, + SYMBOL = 8, + MATERIALIZED = 9, +} + +/** + * Value representing object type in serialized data. + * Must be synced with "enum Tags" in C++. + */ +export enum Tags { + UNDEFINED = 101, + INT32 = 102, + FLOAT32 = 103, + STRING = 104, + LENGTH = 105, + RESOURCE = 106, + OBJECT = 107, +} + +export function runtimeType(value: any): int32 { + let type = typeof value + if (type == "number") return RuntimeType.NUMBER + if (type == "string") return RuntimeType.STRING + if (type == "undefined") return RuntimeType.UNDEFINED + if (type == "object") return RuntimeType.OBJECT + if (type == "boolean") return RuntimeType.BOOLEAN + if (type == "bigint") return RuntimeType.BIGINT + if (type == "function") return RuntimeType.FUNCTION + if (type == "symbol") return RuntimeType.SYMBOL + + throw new Error(`bug: ${value} is ${type}`) +} + +export function isResource(value: unknown): boolean { + return value !== undefined + && typeof value === 'object' + && value !== null + && value.hasOwnProperty("bundleName") + && value.hasOwnProperty("moduleName") +} + +// Poor man's instanceof, fails on subclasses +export function isInstanceOf(className: string, value: object | undefined): boolean { + return value?.constructor.name === className +} + +export function registerCallback(value: object|undefined): int32 { + return wrapCallback((args: Uint8Array, length: int32) => { + // TBD: deserialize the callback arguments and call the callback + return 42 + }) +} + +export function registerMaterialized(value: object|undefined): number { + // TODO: fix me! + return 42 +} + +export interface CallbackResource { + resourceId: int32 + hold: pointer + release: pointer +} + +/* Serialization extension point */ +export abstract class CustomSerializer { + constructor(protected supported: Array) {} + supports(kind: string): boolean { return this.supported.includes(kind) } + abstract serialize(serializer: SerializerBase, value: any, kind: string): void + next: CustomSerializer | undefined = undefined +} + +export class SerializerBase { + private position = 0 + private buffer: ArrayBuffer + private view: DataView + + private static customSerializers: CustomSerializer | undefined = undefined + static registerCustomSerializer(serializer: CustomSerializer) { + if (SerializerBase.customSerializers == undefined) { + SerializerBase.customSerializers = serializer + } else { + let current = SerializerBase.customSerializers + while (current.next != undefined) { current = current.next } + current.next = serializer + } + } + constructor() { + this.buffer = new ArrayBuffer(96) + this.view = new DataView(this.buffer) + } + public release() { + this.releaseResources() + this.position = 0 + } + asArray(): Uint8Array { + return new Uint8Array(this.buffer) + } + length(): int32 { + return this.position + } + currentPosition(): int32 { return this.position } + + private checkCapacity(value: int32) { + if (value < 1) { + throw new Error(`${value} is less than 1`) + } + let buffSize = this.buffer.byteLength + if (this.position > buffSize - value) { + const minSize = this.position + value + const resizedSize = Math.max(minSize, Math.round(3 * buffSize / 2)) + let resizedBuffer = new ArrayBuffer(resizedSize) + // TODO: can we grow without new? + new Uint8Array(resizedBuffer).set(new Uint8Array(this.buffer)) + this.buffer = resizedBuffer + this.view = new DataView(resizedBuffer) + } + } + private heldResources: ResourceId[] = [] + holdAndWriteCallback(callback: object, hold: KPointer = 0, release: KPointer = 0, call: KPointer = 0, callSync: KPointer = 0): ResourceId { + const resourceId = ResourceHolder.instance().registerAndHold(callback) + this.heldResources.push(resourceId) + this.writeInt32(resourceId) + this.writePointer(hold) + this.writePointer(release) + this.writePointer(call) + this.writePointer(callSync) + return resourceId + } + holdAndWriteCallbackForPromiseVoid(hold: KPointer = 0, release: KPointer = 0, call: KPointer = 0, callSync = 0): [Promise, ResourceId] { + let resourceId: ResourceId + const promise = new Promise((resolve, reject) => { + const callback = (err: string[]|undefined) => { + if (err !== undefined) + reject(err) + else + resolve() + } + resourceId = this.holdAndWriteCallback(callback, hold, release, call, callSync) + }) + return [promise, resourceId] + } + holdAndWriteCallbackForPromise(hold: KPointer = 0, release: KPointer = 0, call: KPointer = 0): [Promise, ResourceId] { + let resourceId: ResourceId + const promise = new Promise((resolve, reject) => { + const callback = (value: T|undefined, err: string[]|undefined) => { + if (err !== undefined) + reject(err) + else + resolve(value!) + } + resourceId = this.holdAndWriteCallback(callback, hold, release, call) + }) + return [promise, resourceId] + } + writeCallbackResource(resource: CallbackResource) { + this.writeInt32(resource.resourceId) + this.writePointer(resource.hold) + this.writePointer(resource.release) + } + private releaseResources() { + for (const resourceId of this.heldResources) + InteropNativeModule._ReleaseCallbackResource(resourceId) + // todo think about effective array clearing/pushing + this.heldResources = [] + } + writeCustomObject(kind: string, value: any) { + let current = SerializerBase.customSerializers + while (current) { + if (current.supports(kind)) { + current.serialize(this, value, kind) + return + } + current = current.next + } + console.log(`Unsupported custom serialization for ${kind}, write undefined`) + this.writeInt8(Tags.UNDEFINED) + } + writeNumber(value: number|undefined) { + this.checkCapacity(5) + if (value == undefined) { + this.view.setInt8(this.position, Tags.UNDEFINED) + this.position++ + return + } + if (value == Math.round(value)) { + this.view.setInt8(this.position, Tags.INT32) + this.view.setInt32(this.position + 1, value, true) + this.position += 5 + return + } + this.view.setInt8(this.position, Tags.FLOAT32) + this.view.setFloat32(this.position + 1, value, true) + this.position += 5 + } + writeInt8(value: int32) { + this.checkCapacity(1) + this.view.setInt8(this.position, value) + this.position += 1 + } + writeInt32(value: int32) { + this.checkCapacity(4) + this.view.setInt32(this.position, value, true) + this.position += 4 + } + writeInt64(value: int64) { + this.checkCapacity(8) + this.view.setBigInt64(this.position, BigInt(value), true) + this.position += 8 + } + writePointer(value: pointer) { + this.checkCapacity(8) + this.view.setBigInt64(this.position, BigInt(value ?? 0), true) + this.position += 8 + } + writeFloat32(value: float32) { + this.checkCapacity(4) + this.view.setFloat32(this.position, value, true) + this.position += 4 + } + writeBoolean(value: boolean|undefined) { + this.checkCapacity(1) + this.view.setInt8(this.position, value == undefined ? RuntimeType.UNDEFINED : +value) + this.position++ + } + writeFunction(value: object | undefined) { + this.writeInt32(registerCallback(value)) + } + writeString(value: string) { + this.checkCapacity(4 + value.length * 4) // length, data + let encodedLength = + InteropNativeModule._ManagedStringWrite(value, new Uint8Array(this.view.buffer, 0), this.position + 4) + this.view.setInt32(this.position, encodedLength, true) + this.position += encodedLength + 4 + } + writeBuffer(buffer: ArrayBuffer) { + const resourceId = ResourceHolder.instance().registerAndHold(buffer) + this.writeCallbackResource({ + resourceId, + hold: 0, + release: 0 + }) + const ptr = InteropNativeModule._GetNativeBufferPointer(buffer) + this.writePointer(ptr) + this.writeInt64(buffer.byteLength) + } +} + +class DateSerializer extends CustomSerializer { + constructor() { + super(["Date"]) + } + + serialize(serializer: SerializerBase, value: object, kind: string): void { + serializer.writeString((value as Date).toISOString()) + } +} +SerializerBase.registerCustomSerializer(new DateSerializer()) + +export function unsafeCast(value: unknown) { + return value as unknown as T +} diff --git a/koala-wrapper/koalaui/interop/src/interop/Wrapper.ts b/koala-wrapper/koalaui/interop/src/interop/Wrapper.ts new file mode 100644 index 000000000..4b7dbc124 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/Wrapper.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022-2025 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 { ptrToString, nullptr, isSamePtr } from "#common/wrappers/Wrapper" +import { className } from "@koalaui/common" +import { KPointer } from "./InteropTypes" + +export { isNullPtr, nullptr, ptrToBits, bitsToPtr, isSamePtr, ptrToString } from "#common/wrappers/Wrapper" + +/** + * An object holding reference to the native pointer. + */ +export class Wrapper { + ptr: KPointer + constructor(ptr: KPointer) { + if (ptr == null) + throw new Error(`Init <${className(this)}> with null native peer`) + this.ptr = ptr + } + toString(): string { + return `[native object <${className(this)}> at ${ptrToString(this.ptr)}]` + } +} + +export function getPtr(value: Wrapper|undefined): KPointer { + return value?.ptr ?? nullptr +} + +export function ptrEqual(a: Wrapper|undefined, b: Wrapper|undefined): boolean { + if (a === b) return true + if (a == undefined || b == undefined) return false + return isSamePtr(a.ptr, b.ptr) +} diff --git a/koala-wrapper/koalaui/interop/src/interop/arrays.ts b/koala-wrapper/koalaui/interop/src/interop/arrays.ts new file mode 100644 index 000000000..2699de10b --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/arrays.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/common" + +export enum Access { + READ = 1, // 1 << 0, + WRITE = 2, // 1 << 1, + READWRITE = 3, // READ | WRITE +} +export function isRead(access: Access) { + return access & Access.READ +} +export function isWrite(access: Access) { + return access & Access.WRITE +} + +export type Exec = (pointer: P) => R +export type ExecWithLength = (pointer: P, length: int32) => R + +export type TypedArray = + Uint8Array + | Int8Array + | Uint16Array + | Int16Array + | Uint32Array + | Int32Array + | Float32Array + | Float64Array + +export type PtrArray = Uint32Array | BigUint64Array \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/interop/buffer.ts b/koala-wrapper/koalaui/interop/src/interop/buffer.ts new file mode 100644 index 000000000..5bf60ad3e --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/buffer.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022-2025 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 class KBuffer { + private readonly _buffer: Uint8Array + public get buffer(): ArrayBuffer { + return this._buffer + } + public get length(): number { + return this._buffer.length + } + + constructor(length: number) { + this._buffer = new Uint8Array(length) + } + + set(index: number, value: number): void { + this._buffer[index] = value + } + + get(index: number): number { + return this._buffer[index] + } +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/interop/index.ts b/koala-wrapper/koalaui/interop/src/interop/index.ts new file mode 100644 index 000000000..5966b160a --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/index.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2022-2025 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 { + withFloat32Array, + withFloat64Array, + withInt16Array, + withInt32Array, + withInt8Array, + withUint16Array, + withUint32Array, + withUint8Array, + wasmHeap as wasmHeapArrayBuffer +} from "#common/wrappers/arrays" + +export { registerCallback, setCallbackRegistry } from "#common/wrappers/Callback" + +export { Access, Exec } from "./arrays" +export { Finalizable, NativeThunk } from "./Finalizable" +export { nullable } from "./nullable" +export { getPtr, isNullPtr, nullptr, ptrEqual, Wrapper, ptrToBits, bitsToPtr } from "./Wrapper" + +export { + decodeToString, + encodeToData, + withString, + withStringArray, + withPtrArray, + fromPtrArray, + toPtrArray +} from "#common/wrappers/arrays" + +export const withFloatArray = withFloat32Array +export const withByteArray = withUint8Array +export const withIntArray = withInt32Array + +export const wasmHeap = wasmHeapArrayBuffer + +export { + withFloat32Array, + withFloat64Array, + withInt8Array, + withInt16Array, + withInt32Array, + withUint8Array, + withUint16Array, + withUint32Array, +} + +export * from "./Platform" +export * from "./InteropTypes" + +export * from "./InteropOps" +export * from "./NativeString" +export * from "./buffer" +export * from "../arkts/ResourceManager" +export * from "./NativeBuffer" +export { InteropNativeModule, loadInteropNativeModule } from "./InteropNativeModule" +export { SerializerBase, RuntimeType, Tags, runtimeType, CallbackResource, unsafeCast, isResource, isInstanceOf } from "./SerializerBase" +export { DeserializerBase } from "./DeserializerBase" +export { loadNativeModuleLibrary, loadNativeLibrary, registerNativeModuleLibraryName } from "./loadLibraries" +export * from "./MaterializedBase" diff --git a/koala-wrapper/koalaui/interop/src/interop/java/CallbackRecord.java b/koala-wrapper/koalaui/interop/src/interop/java/CallbackRecord.java new file mode 100644 index 000000000..4c866822d --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/java/CallbackRecord.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 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. + */ +package org.koalaui.interop; + +class CallbackRecord { + public CallbackType callback; + public boolean autoDisposable; + + public CallbackRecord(CallbackType callback, boolean autoDisposable) { + this.callback = callback; + this.autoDisposable = autoDisposable; + } +} diff --git a/koala-wrapper/koalaui/interop/src/interop/java/CallbackRegistry.java b/koala-wrapper/koalaui/interop/src/interop/java/CallbackRegistry.java new file mode 100644 index 000000000..59dceae85 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/java/CallbackRegistry.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 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. + */ +package org.koalaui.interop; + +import java.util.Arrays; +import java.util.HashMap; + +class CallbackRegistry { + + private static HashMap callbacks = new HashMap(); + private static Integer id = 0; + + static { + CallbackRegistry.callbacks.put(id, new CallbackRecord( + new CallbackType() { + @Override + public int apply(byte[] args, int length) { + System.out.printf("Callback 0 called with args = %s and length = %d\n", Arrays.toString(args), length); + throw new Error("Null callback called"); + } + }, false) + ); + CallbackRegistry.id++; + } + + private CallbackRegistry() { + + } + + public static Integer wrap(CallbackType callback) { + Integer id = CallbackRegistry.id++; + CallbackRegistry.callbacks.put(id, new CallbackRecord(callback, true)); + return id; + } + + public static Integer wrap(CallbackType callback, boolean autoDisposable) { + Integer id = CallbackRegistry.id++; + CallbackRegistry.callbacks.put(id, new CallbackRecord(callback, autoDisposable)); + return id; + } + + public static int call(Integer id, byte[] args, int length) { + if (!CallbackRegistry.callbacks.containsKey(id)) { + System.out.printf("Callback %d is not known\n", id); + throw new Error(String.format("Disposed or unwrapped callback called (id = %d)", id)); + } + CallbackRecord record = CallbackRegistry.callbacks.get(id); + if (record.autoDisposable) { + CallbackRegistry.dispose(id); + } + return record.callback.apply(args, length); + } + + public static void dispose(Integer id) { + CallbackRegistry.callbacks.remove(id); + } +} diff --git a/koala-wrapper/koalaui/interop/src/interop/java/CallbackTests.java b/koala-wrapper/koalaui/interop/src/interop/java/CallbackTests.java new file mode 100644 index 000000000..04573b937 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/java/CallbackTests.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2025 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. + */ +package org.koalaui.interop; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.IntBuffer; +import java.util.function.Function; + +import org.koalaui.arkoala.NativeModule; + +public class CallbackTests { + // Todo: where tests will be located? + + public class TestUtils { + // Todo: where test utils will be located? + public static void assertEquals(String name, T expected, T actual) { + if (!expected.equals(actual)) { + System.out.printf("TEST %s FAIL:\n EXPECTED \"%s\"\n ACTUAL \"%s\"\n", name, expected.toString(), actual.toString()); + } else { + System.out.printf("TEST %s PASS\n", name); + } + } + + public static void assertThrows(String name, Function fn) { + boolean caught = false; + try { + fn.apply(null); + } catch (Throwable e) { + caught = true; + } + if (!caught) { + System.out.printf("TEST %s FAIL:\n No exception thrown\n", name); + } else { + System.out.printf("TEST %s PASS\n", name); + } + } + } + + public static void checkCallback() { + Integer id1 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + return 2024; + } + }); + Integer id2 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + return 2025; + } + }); + + TestUtils.assertEquals("Call callback 1", 2024, CallbackRegistry.call(id1, new byte[] {}, 0)); + TestUtils.assertEquals("Call callback 2", 2025, CallbackRegistry.call(id2, new byte[] {}, 0)); + TestUtils.assertThrows("Call disposed callback 1", new Function() { + @Override + public Integer apply(Void v) { + return CallbackRegistry.call(id1, new byte[] { }, 0); + } + }); + TestUtils.assertThrows("Call callback 0", new Function() { + @Override + public Integer apply(Void v) { + return CallbackRegistry.call(0, new byte[] { 2, 4, 6, 8 }, 4); + } + }); + } + + public static void checkNativeCallback() { + Integer id1 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + return 123456; + } + }); + TestUtils.assertEquals("NativeCallback without args", 123456, NativeModule._TestCallIntNoArgs(id1)); + TestUtils.assertThrows("NativeCallback without args called again", new Function() { + @Override + public Integer apply(Void v) { + return CallbackRegistry.call(id1, new byte[] { }, 0); + } + }); + TestUtils.assertThrows("NativeCallback without args called again from native", new Function() { + @Override + public Integer apply(Void v) { + return NativeModule._TestCallIntNoArgs(id1); + } + }); + + Integer id2 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + ByteBuffer buffer = ByteBuffer.wrap(args); + buffer.order(ByteOrder.LITTLE_ENDIAN); + IntBuffer intBuffer = buffer.asIntBuffer(); + int sum = 0; + for (int i = 0; i < length / 4; i++) { + sum += intBuffer.get(i); + } + return sum; + } + }); + int[] arr2 = new int[] { 100, 200, 300, -1000 }; + TestUtils.assertEquals("NativeCallback Int32Array sum", -400, NativeModule._TestCallIntIntArraySum(id2, arr2, arr2.length)); + + Integer id3 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + ByteBuffer buffer = ByteBuffer.wrap(args); + buffer.order(ByteOrder.LITTLE_ENDIAN); + IntBuffer intBuffer = buffer.asIntBuffer(); + for (int i = 1; i < length / 4; i++) { + intBuffer.put(i, intBuffer.get(i) + intBuffer.get(i - 1)); + } + return 0; + } + }); + int[] arr3 = new int[] { 100, 200, 300, -1000 }; + NativeModule._TestCallVoidIntArrayPrefixSum(id3, arr3, arr3.length); + TestUtils.assertEquals("NativeCallback Int32Array PrefixSum [0]", 100, arr3[0]); + TestUtils.assertEquals("NativeCallback Int32Array PrefixSum [1]", 300, arr3[1]); + TestUtils.assertEquals("NativeCallback Int32Array PrefixSum [2]", 600, arr3[2]); + TestUtils.assertEquals("NativeCallback Int32Array PrefixSum [3]", -400, arr3[3]); + + long start = System.currentTimeMillis(); + Integer id4 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + ByteBuffer buffer = ByteBuffer.wrap(args); + buffer.order(ByteOrder.LITTLE_ENDIAN); + IntBuffer intBuffer = buffer.asIntBuffer(); + intBuffer.put(1, intBuffer.get(1) + 1); + if (intBuffer.get(0) + intBuffer.get(1) < intBuffer.get(2)) { + return NativeModule._TestCallIntRecursiveCallback(id3 + 1, args, args.length); + } + return 1; + } + }, false); + TestUtils.assertEquals("NativeCallback prepare recursive callback test", id4, id3 + 1); + int depth = 500; + int count = 100; + for (int i = 0; i < count; i++) { + int length = 12; + byte[] args = new byte[length]; + IntBuffer args32 = ByteBuffer.wrap(args).order(ByteOrder.LITTLE_ENDIAN).asIntBuffer(); + args32.put(2, depth); + NativeModule._TestCallIntRecursiveCallback(id4, args, args.length); + if (i == 0) { + TestUtils.assertEquals("NativeCallback Recursive [0]", (depth + 1) / 2, args32.get(0)); + TestUtils.assertEquals("NativeCallback Recursive [1]", depth / 2, args32.get(1)); + } + } + long passed = System.currentTimeMillis() - start; + System.out.println("recursive native callback: " + String.valueOf(passed) + "ms for " + depth * count + " callbacks, " + Math.round((double)passed / (depth * count) * 1000000) + "ms per 1M callbacks"); + + Integer id5 = CallbackRegistry.wrap(new CallbackType() { + @Override + public int apply(byte[] args, int length) { + int sum = 0; + for (int i = 0; i < length; i++) { + sum += args[i]; + } + return sum; + } + }, false); + NativeModule._TestCallIntMemory(id5, 1000); + } +} diff --git a/koala-wrapper/koalaui/interop/src/interop/java/CallbackType.java b/koala-wrapper/koalaui/interop/src/interop/java/CallbackType.java new file mode 100644 index 000000000..188faacd2 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/java/CallbackType.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 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. + */ +package org.koalaui.interop; + +public interface CallbackType { + public int apply(byte[] args, int length); +} diff --git a/koala-wrapper/koalaui/interop/src/interop/loadLibraries.ts b/koala-wrapper/koalaui/interop/src/interop/loadLibraries.ts new file mode 100644 index 000000000..79c8bdd9c --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/loadLibraries.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +const nativeModuleLibraries: Map = new Map() + +export function loadNativeLibrary(name: string): Record { + if ((globalThis as any).requireNapi) + return (globalThis as any).requireNapi(name, true) + else { + const suffixedName = name.endsWith(".node") ? name : `${name}.node` + return require(suffixedName) + } +} + +export function registerNativeModuleLibraryName(nativeModule: string, libraryName: string) { + nativeModuleLibraries.set(nativeModule, libraryName) +} + +export function loadNativeModuleLibrary(moduleName: string, module?: object) { + if (!module) + throw new Error(" argument is required and optional only for compatibility with ArkTS") + const library = loadNativeLibrary(nativeModuleLibraries.get(moduleName) ?? moduleName) + if (!library || !library[moduleName]) { + console.error(`Failed to load library for module ${moduleName}`) + return + } + Object.assign(module, library[moduleName]) +} diff --git a/koala-wrapper/koalaui/interop/src/interop/nullable.ts b/koala-wrapper/koalaui/interop/src/interop/nullable.ts new file mode 100644 index 000000000..546eb9cab --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/interop/nullable.ts @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2025 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 { isNullPtr } from "./Wrapper" +import { KPointer } from "./InteropTypes" + +export function nullable(value: KPointer, body: (arg: KPointer) => T | undefined): T | undefined { + if (isNullPtr(value)) { + return undefined + } else { + return body(value) + } +} diff --git a/koala-wrapper/koalaui/interop/src/napi/wrappers/Callback.ts b/koala-wrapper/koalaui/interop/src/napi/wrappers/Callback.ts new file mode 100644 index 000000000..4d9193a13 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/napi/wrappers/Callback.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2025 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 { KPointer } from "../../interop/InteropTypes" +import { CallbackRegistry } from "../../interop/Platform" + +export function registerCallback(callback: any, obj: any = null): KPointer { + return theRegistry!.registerCallback(callback, obj) +} + +let theRegistry: CallbackRegistry|undefined = undefined + +export function setCallbackRegistry(registry: CallbackRegistry) { + theRegistry = registry +} diff --git a/koala-wrapper/koalaui/interop/src/napi/wrappers/Wrapper.ts b/koala-wrapper/koalaui/interop/src/napi/wrappers/Wrapper.ts new file mode 100644 index 000000000..0f688601b --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/napi/wrappers/Wrapper.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/common" +import { KPointer } from "../../interop/InteropTypes" + +export const nullptr = BigInt(0) + +export function isNullPtr(value: KPointer): boolean { + return value === nullptr +} + +export function ptrToString(ptr: KPointer) { + return `0x${ptr!.toString(16).padStart(8, "0")}` +} + +export function isSamePtr(a: KPointer, b: KPointer) { + return (a === b) +} + +// TODO rethink me +export function ptrToBits(ptr: KPointer): Uint32Array | null { + let result = new Uint32Array(2) + let ptrBigInt = ptr as bigint + result[0] = Number(ptrBigInt & BigInt(0xFFFFFFFF)) + result[1] = Number((ptrBigInt >> BigInt(32)) & BigInt(0xFFFFFFFF)) + return result +} + +export function bitsToPtr(array: Int32Array, offset: int32): KPointer { + let ptrBigInt: bigint = BigInt(array[offset + 1]) & BigInt(0xFFFFFFFF) + ptrBigInt = (ptrBigInt << BigInt(32)) | (BigInt(array[offset]) & BigInt(0xFFFFFFFF)) + return ptrBigInt +} diff --git a/koala-wrapper/koalaui/interop/src/napi/wrappers/arrays.ts b/koala-wrapper/koalaui/interop/src/napi/wrappers/arrays.ts new file mode 100644 index 000000000..36cefa696 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/napi/wrappers/arrays.ts @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2022-2025 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 { CustomTextDecoder, CustomTextEncoder } from "@koalaui/common" +import { Access, Exec, ExecWithLength, PtrArray, TypedArray } from "../../interop/arrays" +import { nullptr } from "./Wrapper" +import { Wrapper } from "../../interop/Wrapper" +import { KPointer, KStringArrayPtr } from "../../interop" + +const encoder = new CustomTextEncoder() +const decoder = new CustomTextDecoder() + +export function decodeToString(array: Uint8Array): string { + return decoder.decode(array) +} + +export function encodeToData(string: string): Uint8Array { + return encoder.encode(string, false) +} + +export function withString(data: string | undefined, exec: Exec): R { + return exec(data === undefined ? null : data) +} + +export function withStringArray(strings: Array | undefined, exec: Exec): R { + if (strings === undefined || strings.length === 0) { + return exec(null) + } + + let array = encoder.encodeArray(strings) + return exec(array) +} + +function withArray( + data: C | undefined, + exec: ExecWithLength +): R { + return exec(data ?? null, data?.length ?? 0) +} + +export function withPtrArray(data: BigUint64Array, access: Access, exec: ExecWithLength) { + return exec(data ?? null, data?.length ?? 0) // TODO rethink +} + +export function toPtrArray(data: Array | undefined): BigUint64Array { + if (data == undefined || data.length === 0) { + return new BigUint64Array(0) + } + const array = new BigUint64Array(data.length) + for (let i = 0; i < data.length; i++) { + let item = data[i] + array[i] = item != undefined ? item.ptr as bigint : nullptr + } + return array +} + +export function fromPtrArray(array: PtrArray, factory: (ptr: KPointer) => T) : Array { + if (array.length === 0) { + return new Array(0) + } + const result = new Array(array.length) + for (let i = 0; i < array.length; i++) { + let ptr = array[i] + if (ptr == nullptr) { + result[i] = undefined + } else { + result[i] = factory(ptr) + } + } + return result +} + +export function withUint8Array(data: Uint8Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withInt8Array(data: Int8Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withUint16Array(data: Uint16Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withInt16Array(data: Int16Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withUint32Array(data: Uint32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withInt32Array(data: Int32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withFloat32Array(data: Float32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function withFloat64Array(data: Float64Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, exec) +} +export function wasmHeap(): ArrayBuffer { + throw new Error("Unused") +} \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/wasm/wrappers/Callback.ts b/koala-wrapper/koalaui/interop/src/wasm/wrappers/Callback.ts new file mode 100644 index 000000000..5f4de87e8 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/wasm/wrappers/Callback.ts @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2022-2025 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 { KPointer } from "../../interop/InteropTypes" +import { CallbackRegistry } from "../../interop/Platform" + +class CallbackInfo { + cb: any + recv: any + constructor(callback: any, obj: any = null) { + this.cb = callback + this.recv = obj + } +} + +const GLOBAL_SCOPE = new class CallbackScope { + static readonly CB_NULL = new CallbackInfo( + () => { throw new Error("attempted to call a callback at NULL") }, + null + ) + static readonly CB_UNDEFINED = new CallbackInfo( + () => { throw new Error("attempted to call an uninitialized callback") }, + null + ) + static readonly CB_NULL_ID = 0 + nextId: number + callbackMap: Map | null + + constructor() { + this.nextId = 1 + this.callbackMap = new Map() + this.callbackMap.set(CallbackScope.CB_NULL_ID, CallbackScope.CB_NULL) + } + + addCallback(cb: any, obj: any): number { + let id = this.nextId++ + this.callbackMap?.set(id, new CallbackInfo(cb, obj)) + return id + } + + getCallback(id: number): CallbackInfo { + return this.callbackMap?.get(id) || CallbackScope.CB_UNDEFINED + } + + deleteCallback(id: number): void { + if (id > CallbackScope.CB_NULL_ID) { + this.callbackMap?.delete(id) + } + } + + release(): void { + this.callbackMap = null + } +} + +function callCallback(callbackId: number): any { + let CallbackInfo = GLOBAL_SCOPE.getCallback(callbackId) + try { + let cb = CallbackInfo.cb + if (CallbackInfo.recv !== null) { + cb = cb.bind(CallbackInfo.recv) + } + return cb() + } catch (e) { + console.error(e) + } +} + +export function registerCallback(callback: any, obj: any = null): KPointer { + return GLOBAL_SCOPE.addCallback(callback, obj) +} + +function releaseCallback(callbackId: number): void { + return GLOBAL_SCOPE.deleteCallback(callbackId) +} + +declare namespace globalThis { + function callCallback(callbackId: number): any + function releaseCallback(callbackId: number): any +} + +globalThis.callCallback = callCallback +globalThis.releaseCallback = releaseCallback + +export function setCallbackRegistry(_ignoredRegistry: CallbackRegistry) { + // On WASM we don't need registry in current implementation. +} diff --git a/koala-wrapper/koalaui/interop/src/wasm/wrappers/Wrapper.ts b/koala-wrapper/koalaui/interop/src/wasm/wrappers/Wrapper.ts new file mode 100644 index 000000000..52c2a1a58 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/wasm/wrappers/Wrapper.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/common" +import { KPointer } from "../../interop/InteropTypes" + +export const nullptr: number = 0 + +export function isNullPtr(value: KPointer): boolean { + return (value == nullptr) +} + +export function ptrToString(ptr: KPointer) { + if (ptr === 0) return "0x0" + + const hex = (ptr as number).toString(16).padStart(8, "0") + return `0x${hex}` +} + +export function isSamePtr(a: KPointer, b: KPointer) { + return a === b +} + +export function ptrToBits(ptr: KPointer): Uint32Array { + let result = new Uint32Array(2) + result[0] = ptr as int32 + return result +} + +export function bitsToPtr(array: Int32Array, offset: int32): KPointer { + return array[offset] +} diff --git a/koala-wrapper/koalaui/interop/src/wasm/wrappers/arrays.ts b/koala-wrapper/koalaui/interop/src/wasm/wrappers/arrays.ts new file mode 100644 index 000000000..9aa189d07 --- /dev/null +++ b/koala-wrapper/koalaui/interop/src/wasm/wrappers/arrays.ts @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2022-2025 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 { CustomTextEncoder, CustomTextDecoder, int32 } from "@koalaui/common" + +import { KPointer } from "../../interop/InteropTypes" +import { Wrapper } from "../../interop/Wrapper" +import { Access, isRead, isWrite, Exec, TypedArray, ExecWithLength } from "../../interop/arrays" + +const encoder = new CustomTextEncoder() +const decoder = new CustomTextDecoder() + +export function decodeToString(array: Uint8Array): string { + return decoder.decode(array) +} + +export function encodeToData(string: string): Uint8Array { + return encoder.encode(string, false) +} + +type Heap = { readonly buffer: ArrayBuffer } + +// TODO actually memory allocation primitives are defined for a specific intance instance, +// refactor me +declare const _heaps: { + HEAP8(): Heap; + HEAP16(): Heap; + HEAP32(): Heap; + HEAPU8(): Heap; + HEAPU16(): Heap; + HEAPU32(): Heap; + HEAPF32(): Heap; + HEAPF64(): Heap; +} +declare function _malloc(size: number): number; +declare function _free(ptr: number): void; + +const nullptr: number = 0 + +// with string as array of utf8 data headed by length +export function withString(data: string | undefined, exec: Exec): R { + if (data === undefined) return exec(nullptr) + + let array = encoder.encode(data, true) + return withUint8Array(array, Access.READ, exec) +} + +export function withStringArray(strings: Array | undefined, exec: Exec): R { + if (strings === undefined || strings.length === 0) { + return exec(nullptr) + } + + let array = encoder.encodeArray(strings) + return withUint8Array(array, Access.READ, exec) +} + +function withArray( + data: C | undefined, + access: Access, + exec: ExecWithLength, + bytesPerElement: int32, + ctor: (ptr: number, length: number) => C +): R { + if (data === undefined || data.length === 0) { + return exec(nullptr, 0) + } + + let ptr = _malloc(data.length * bytesPerElement) + let wasmArray = ctor(ptr, data.length) + + if (isRead(access)) { + wasmArray.set(data) + } + + let result = exec(ptr, data.length) + + if (isWrite(access)) { + data.set(wasmArray) + } + + _free(ptr) + + return result +} + +export function withPtrArray(data: Uint32Array, access: Access, exec: ExecWithLength) { + return withArray(data as Uint32Array, access, exec, Uint32Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Uint32Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} + +export function toPtrArray(data: Array | undefined): Uint32Array { + if (data === undefined || data.length === 0) { + return new Uint32Array(0) + } + const array = new Uint32Array(data.length) + for (let i = 0; i < data.length; i++) { + array[i] = data[i]?.ptr as number + } + return array +} + +export function fromPtrArray(array: Uint32Array, factory: (ptr: KPointer) => T) : Array { + const result = new Array(array.length) + for (let i = 0; i < array.length; i++) { + let v = array[i] + if (v == 0) { + result[i] = undefined + } else { + result[i] = factory(v) + } + } + return result +} + +export function withUint8Array(data: Uint8Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Uint8Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Uint8Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withInt8Array(data: Int8Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Int8Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Int8Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withUint16Array(data: Uint16Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Uint16Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Uint16Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withInt16Array(data: Int16Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Int16Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Int16Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withUint32Array(data: Uint32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Uint32Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Uint32Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withInt32Array(data: Int32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Int32Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Int32Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withFloat32Array(data: Float32Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Float32Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Float32Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} +export function withFloat64Array(data: Float64Array | undefined, access: Access, exec: ExecWithLength) { + return withArray(data, access, exec, Float64Array.BYTES_PER_ELEMENT, (ptr: number, length: number) => { + return new Float64Array(_heaps.HEAPU8().buffer, ptr, length) + }) +} + +export function wasmHeap(): ArrayBuffer { + return _heaps.HEAP32().buffer +} diff --git a/koala-wrapper/native/BUILD.gn b/koala-wrapper/native/BUILD.gn new file mode 100644 index 000000000..1f7e783fa --- /dev/null +++ b/koala-wrapper/native/BUILD.gn @@ -0,0 +1,162 @@ +# Copyright (c) 2025 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("//build/ohos.gni") + +group("build_es2panda_lib") { + external_deps = [ "ets_frontend:ets2panda" ] +} + +shared_library("es2panda") { + deps = [ ":build_es2panda_lib" ] + sources = [ + "../koalaui/interop/src/cpp/common-interop.cc", + "../koalaui/interop/src/cpp/interop-logging.cc", + "../koalaui/interop/src/cpp/napi/convertors-napi.cc", + "./src/bridges.cc", + "./src/common.cc", + "./src/generated/bridges.cc", + ] + + include_dirs = [ + "../koalaui/interop/src/cpp", + "../koalaui/interop/src/cpp/types", + "../koalaui/interop/src/cpp/napi", + "../node_modules/node-api-headers/include", + "../node_modules/node-addon-api", + "./include", + "//arkcompiler/ets_frontend/ets2panda/public/", + "//third_party/node/src", + rebase_path("$root_gen_dir/arkcompiler/ets_frontend/ets2panda/"), + ] + + defines = [ + "KOALA_INTEROP_MODULE=NativeModule", + "INTEROP_LIBRARY_NAME=es2panda", + "KOALA_USE_NODE_VM", + "KOALA_NAPI", + "NODE_ADDON_API_DISABLE_CPP_EXCEPTIONS", + ] + + configs -= [ "//build/config/compiler:compiler" ] + + if (is_mac) { + cflags_cc = [ + "-std=c++17", + "-Wall", + "-Werror", + "-Wno-unused-variable", + "-fPIC", + ] + + ldflags = [ + "-fPIC", + "-Wl,-undefined,dynamic_lookup", + "-fuse-ld=lld", + "-Wl,--icf=all", + "-Wl,--color-diagnostics", + "-m64" + ] + defines += [ "KOALA_MACOS" ] + output_extension = "node" + } + + if (current_os == "linux") { + cflags_cc = [ + "-std=c++17", + "-Wall", + "-Werror", + "-Wno-unused-variable", + "-fPIC", + ] + + ldflags = [ + "-Wl,--allow-shlib-undefined", + "-Wl,--fatal-warnings", + "-Wl,--build-id=md5", + "-fPIC", + "-Wl,-z,noexecstack", + "-Wl,-z,now", + "-Wl,-z,relro", + + # "-Wl,-z,defs", # must no use this option + "-Wl,--as-needed", + "-fuse-ld=lld", + "-Wl,--icf=all", + "-Wl,--color-diagnostics", + "-m64", + ] + defines += [ "KOALA_LINUX" ] + output_extension = "node" + } else if (current_os == "mingw") { + output_extension = "dll" + cflags_cc = [ + "-std=c++17", + "-Wall", + "-Werror", + "-Wno-unused-variable", + "-fPIC", + "-Wno-error=deprecated-copy", + "-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang", + "-ftrivial-auto-var-init=zero", + "-fcolor-diagnostics", + "-fmerge-all-constants", + "-Xclang", + "-mllvm", + "-Xclang", + "-instcombine-lower-dbg-declare=0", + "-no-canonical-prefixes", + "-static", + "-rtlib=compiler-rt", + "-stdlib=libc++", + "-lunwind", + "-lpthread", + "-Qunused-arguments", + "-fuse-ld=lld", + "-fno-stack-protector", + "-fno-strict-aliasing", + "-Wno-builtin-macro-redefined", + "-fms-extensions", + "-static", + "-rtlib=compiler-rt", + "-stdlib=libc++", + "-std=c++17", + "-lunwind", + "-lpthread", + "-Qunused-arguments", + "-target", + "x86_64-pc-windows-gnu", + "-D__CUSTOM_SECURITY_LIBRARY", + ] + + ldflags = [ + "-Wl,--fatal-warnings", + "-fPIC", + "-Wl,--as-needed", + "-fuse-ld=lld", + "-Wl,--icf=all", + "-m64", + "-static", + "-rtlib=compiler-rt", + "-stdlib=libc++", + "-std=c++17", + "-lunwind", + "-lpthread", + "-Qunused-arguments", + "-target", + "x86_64-pc-windows-gnu", + ] + defines += [ "KOALA_WINDOWS" ] + sources += [ "../koalaui/interop/src/cpp/napi/win-dynamic-node.cc" ] + } +} diff --git a/koala-wrapper/native/include/common.h b/koala-wrapper/native/include/common.h new file mode 100644 index 000000000..77ed29cf8 --- /dev/null +++ b/koala-wrapper/native/include/common.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022-2025 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 COMMON_H +#define COMMON_H + +#include "dynamic-loader.h" +#include "es2panda_lib.h" +#include "common-interop.h" +#include "stdexcept" +#include +#include +#include + +using std::string, std::cout, std::endl, std::vector; + +es2panda_Impl *GetImpl(); + +string getString(KStringPtr ptr); + +char* getStringCopy(KStringPtr& ptr); + +inline KUInt unpackUInt(const KByte* bytes); + +es2panda_ContextState intToState(KInt state); + +#endif // COMMON_H \ No newline at end of file diff --git a/koala-wrapper/native/meson.build b/koala-wrapper/native/meson.build new file mode 100644 index 000000000..5286b471b --- /dev/null +++ b/koala-wrapper/native/meson.build @@ -0,0 +1,63 @@ +project( + 'es2panda_interop', + 'cpp', + version: '1.0', + default_options: [ + 'cpp_std=c++17', + 'buildtype=debug', + ], +) + +sources = [ + './src/common.cc', + './src/bridges.cc', + './src/generated/bridges.cc', + get_option('interop_src_dir') / 'common-interop.cc', + get_option('interop_src_dir') / 'callback-resource.cc', + get_option('interop_src_dir') / 'interop-logging.cc', + get_option('interop_src_dir') / 'napi/convertors-napi.cc', +] + +cflags = [ + '-DKOALA_INTEROP_MODULE=NativeModule', + '-DINTEROP_LIBRARY_NAME=' + get_option('lib_name'), + '-DKOALA_USE_NODE_VM', + '-DKOALA_NAPI', +] + +if (target_machine.system() == 'windows') + cflags += ['-DKOALA_WINDOWS'] + if (meson.get_compiler('cpp').get_id() == 'msvc') + # apply node.exe symbol loading hook + sources += [ + get_option('interop_src_dir') / 'napi/win-dynamic-node.cc' + ] + endif +else + cflags += ['-DKOALA_LINUX'] +endif + +shared_library( + get_option('lib_name'), + sources, + override_options: [ + 'b_lundef=false', + ], + install: true, + name_prefix: '', + name_suffix: 'node', + include_directories: [ + './src/', + './include/', + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda/public', + get_option('panda_sdk_dir') / 'ohos_arm64/include/tools/es2panda', + get_option('interop_src_dir'), + get_option('interop_src_dir') / 'types', + get_option('interop_src_dir') / 'napi', + get_option('node_modules_dir') / 'node-api-headers/include', + get_option('node_modules_dir') / 'node-addon-api', + ], + cpp_args: cflags, + link_args: [], + dependencies: [] +) diff --git a/koala-wrapper/native/meson_options.txt b/koala-wrapper/native/meson_options.txt new file mode 100644 index 000000000..cc5b1cd09 --- /dev/null +++ b/koala-wrapper/native/meson_options.txt @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +option('node_modules_dir', type : 'string', value : '../node_modules/', + description : 'path to node_modules') +option('panda_sdk_dir', type : 'string', value : '../node_modules/@panda/sdk/', + description : 'path to panda sdk') +option('interop_src_dir', type : 'string', value : '../node_modules/@koalaui/interop/src/cpp/', + description : 'path to interop') +option('lib_name', type : 'string', value : 'es2panda', + description : 'name of shared library') diff --git a/koala-wrapper/native/src/bridges.cc b/koala-wrapper/native/src/bridges.cc new file mode 100644 index 000000000..5c177990e --- /dev/null +++ b/koala-wrapper/native/src/bridges.cc @@ -0,0 +1,373 @@ +/* + * Copyright (c) 2022-2025 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 "common.h" + +KBoolean impl_ClassDefinitionIsFromStructConst(KNativePointer contextPtr, KNativePointer instancePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(instancePtr); + return GetImpl()->ClassDefinitionIsFromStructConst(context, node); +} +KOALA_INTEROP_2(ClassDefinitionIsFromStructConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetFromStructModifier(KNativePointer contextPtr, KNativePointer instancePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(instancePtr); + return GetImpl()->ClassDefinitionSetFromStructModifier(context, node); +} +KOALA_INTEROP_V2(ClassDefinitionSetFromStructModifier, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeRecheck(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + GetImpl()->AstNodeRecheck(context, node); + return nullptr; +} +KOALA_INTEROP_2(AstNodeRecheck, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AstNodeRebind(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + GetImpl()->AstNodeRebind(context, node); + return nullptr; +} +KOALA_INTEROP_2(AstNodeRebind, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AnnotationAllowedAnnotations(KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer returnLen) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + std::size_t params_len = 0; + auto annotations = GetImpl()->AnnotationAllowedAnnotations(context, node, ¶ms_len); + return new std::vector(annotations, annotations + params_len); +} +KOALA_INTEROP_3(AnnotationAllowedAnnotations, KNativePointer, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AnnotationAllowedAnnotationsConst(KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer returnLen) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + std::size_t params_len = 0; + auto annotations = GetImpl()->AnnotationAllowedAnnotationsConst(context, node, ¶ms_len); + return new std::vector(annotations, annotations + params_len); +} +KOALA_INTEROP_3(AnnotationAllowedAnnotationsConst, KNativePointer, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AstNodeVariableConst(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + + return GetImpl()->AstNodeVariableConst(context, node); +} +KOALA_INTEROP_2(AstNodeVariableConst, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_VariableDeclaration(KNativePointer contextPtr, KNativePointer variablePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto variable = reinterpret_cast(variablePtr); + + return GetImpl()->VariableDeclaration(context, variable); +} +KOALA_INTEROP_2(VariableDeclaration, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_DeclNode(KNativePointer contextPtr, KNativePointer declPtr) +{ + auto context = reinterpret_cast(contextPtr); + auto decl = reinterpret_cast(declPtr); + + return GetImpl()->DeclNode(context, decl); +} +KOALA_INTEROP_2(DeclNode, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AstNodeScopeConst(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + return GetImpl()->AstNodeScopeConst(context, node); +} +KOALA_INTEROP_2(AstNodeScopeConst, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_ScopeSetParent(KNativePointer contextPtr, KNativePointer nodePtr, KNativePointer parentPtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + auto parent = reinterpret_cast(parentPtr); + GetImpl()->ScopeSetParent(context, node, parent); + return node; +} +KOALA_INTEROP_3(ScopeSetParent, KNativePointer, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_CreateNumberLiteral(KNativePointer contextPtr, KDouble value) +{ + auto context = reinterpret_cast(contextPtr); + + return GetImpl()->CreateNumberLiteral(context, value); +} +KOALA_INTEROP_2(CreateNumberLiteral, KNativePointer, KNativePointer, KDouble) + +KNativePointer impl_ETSParserCreateExpression(KNativePointer contextPtr, KStringPtr& sourceCodePtr, KInt flagsT) +{ + auto context = reinterpret_cast(contextPtr); + auto flags = static_cast(flagsT); + + return GetImpl()->ETSParserCreateExpression(context, getStringCopy(sourceCodePtr), flags); +} +KOALA_INTEROP_3(ETSParserCreateExpression, KNativePointer, KNativePointer, KStringPtr, KInt) + +KBoolean impl_IsProgram(KNativePointer contextPtr, KNativePointer nodePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + return GetImpl()->AstNodeIsProgramConst(context, node); +} +KOALA_INTEROP_2(IsProgram, KBoolean, KNativePointer, KNativePointer) + +KBoolean impl_IsBlockStatement(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsBlockStatement(node); +} +KOALA_INTEROP_1(IsBlockStatement, KBoolean, KNativePointer) + +KNativePointer impl_ProceedToState(KNativePointer contextPtr, KInt state) +{ + auto context = reinterpret_cast(contextPtr); + return GetImpl()->ProceedToState(context, intToState(state)); +} +KOALA_INTEROP_2(ProceedToState, KNativePointer, KNativePointer, KInt) + +KNativePointer impl_ContextProgram(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + return GetImpl()->ContextProgram(context); +} +KOALA_INTEROP_1(ContextProgram, KNativePointer, KNativePointer) + +KNativePointer impl_ProgramAst(KNativePointer contextPtr, KNativePointer programPtr) +{ + auto context = reinterpret_cast(programPtr); + auto program = reinterpret_cast(programPtr); + return GetImpl()->ProgramAst(context, program); +} +KOALA_INTEROP_2(ProgramAst, KNativePointer, KNativePointer, KNativePointer) + +KBoolean impl_IsIdentifier(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsIdentifier(node); +} +KOALA_INTEROP_1(IsIdentifier, KBoolean, KNativePointer) + +KNativePointer impl_CreateContextFromString(KNativePointer configPtr, KStringPtr& sourcePtr, KStringPtr& filenamePtr) +{ + auto config = reinterpret_cast(configPtr); + return GetImpl()->CreateContextFromString(config, sourcePtr.data(), filenamePtr.data()); +} +KOALA_INTEROP_3(CreateContextFromString, KNativePointer, KNativePointer, KStringPtr, KStringPtr) + +KNativePointer impl_CreateContextFromFile(KNativePointer configPtr, KStringPtr& filenamePtr) +{ + auto config = reinterpret_cast(configPtr); + return GetImpl()->CreateContextFromFile(config, getStringCopy(filenamePtr)); +} +KOALA_INTEROP_2(CreateContextFromFile, KNativePointer, KNativePointer, KStringPtr) + +KInt impl_ContextState(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + + return static_cast(GetImpl()->ContextState(context)); +} +KOALA_INTEROP_1(ContextState, KInt, KNativePointer) + +KNativePointer impl_ContextErrorMessage(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + + return new string(GetImpl()->ContextErrorMessage(context)); +} +KOALA_INTEROP_1(ContextErrorMessage, KNativePointer, KNativePointer) + +KNativePointer impl_CallExpressionSignature(KNativePointer context, KNativePointer classInstance) +{ + const auto _context = reinterpret_cast(context); + const auto _classInstance = reinterpret_cast(classInstance); + const auto result = GetImpl()->CallExpressionSignature(_context, _classInstance); + return result; +} +KOALA_INTEROP_2(CallExpressionSignature, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_SignatureFunction(KNativePointer context, KNativePointer classInstance) +{ + const auto _context = reinterpret_cast(context); + const auto _classInstance = reinterpret_cast(classInstance); + const auto result = GetImpl()->SignatureFunction(_context, _classInstance); + return result; +} +KOALA_INTEROP_2(SignatureFunction, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_DeclarationFromIdentifier(KNativePointer context, KNativePointer identifier) +{ + const auto _context = reinterpret_cast(context); + const auto _identifier = reinterpret_cast(identifier); + const auto result = GetImpl()->DeclarationFromIdentifier(_context, _identifier); + return result; +} +KOALA_INTEROP_2(DeclarationFromIdentifier, KNativePointer, KNativePointer, KNativePointer) + +static KNativePointer impl_ProgramExternalSources(KNativePointer contextPtr, KNativePointer instancePtr) +{ + auto context = reinterpret_cast(contextPtr); + auto&& instance = reinterpret_cast(instancePtr); + std::size_t source_len = 0; + auto external_sources = GetImpl()->ProgramExternalSources(context, instance, &source_len); + return new std::vector(external_sources, external_sources + source_len); +} +KOALA_INTEROP_2(ProgramExternalSources, KNativePointer, KNativePointer, KNativePointer); + +static KNativePointer impl_ExternalSourceName(KNativePointer instance) +{ + auto&& _instance_ = reinterpret_cast(instance); + auto&& _result_ = GetImpl()->ExternalSourceName(_instance_); + return new std::string(_result_); +} +KOALA_INTEROP_1(ExternalSourceName, KNativePointer, KNativePointer); + +static KNativePointer impl_ExternalSourcePrograms(KNativePointer instance) +{ + auto&& _instance_ = reinterpret_cast(instance); + std::size_t program_len = 0; + auto programs = GetImpl()->ExternalSourcePrograms(_instance_, &program_len); + return new std::vector(programs, programs + program_len); +} +KOALA_INTEROP_1(ExternalSourcePrograms, KNativePointer, KNativePointer); + +KBoolean impl_IsClassProperty(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsClassProperty(node); +} +KOALA_INTEROP_1(IsClassProperty, KBoolean, KNativePointer) + +KBoolean impl_IsETSUnionType(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsETSUnionType(node); +} +KOALA_INTEROP_1(IsETSUnionType, KBoolean, KNativePointer) + +KBoolean impl_IsETSFunctionType(KNativePointer nodePtr) +{ + auto node = reinterpret_cast(nodePtr); + return GetImpl()->IsETSFunctionType(node); +} +KOALA_INTEROP_1(IsETSFunctionType, KBoolean, KNativePointer) + +KInt impl_GenerateTsDeclarationsFromContext(KNativePointer contextPtr, KStringPtr &outputDeclEts, KStringPtr &outputEts, + KBoolean exportAll) +{ + auto context = reinterpret_cast(contextPtr); + return GetImpl()->GenerateTsDeclarationsFromContext(context, outputDeclEts.data(), outputEts.data(), exportAll); +} +KOALA_INTEROP_4(GenerateTsDeclarationsFromContext, KInt, KNativePointer, KStringPtr, KStringPtr, KBoolean) + +void impl_InsertETSImportDeclarationAndParse(KNativePointer context, KNativePointer program, + KNativePointer importDeclaration) +{ + const auto _context = reinterpret_cast(context); + const auto _program = reinterpret_cast(program); + const auto _ast = reinterpret_cast(importDeclaration); + GetImpl()->InsertETSImportDeclarationAndParse(_context, _program, _ast); + return ; +} +KOALA_INTEROP_V3(InsertETSImportDeclarationAndParse, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParserGetImportPathManager(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + return GetImpl()->ETSParserGetImportPathManager(context); +} +KOALA_INTEROP_1(ETSParserGetImportPathManager, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSourcePosition(KNativePointer context, KInt index, KInt line) +{ + auto&& _context_ = reinterpret_cast(context); + return GetImpl()->CreateSourcePosition(_context_, index, line); +} +KOALA_INTEROP_3(CreateSourcePosition, KNativePointer, KNativePointer, KInt, KInt); + +KInt impl_SourcePositionIndex(KNativePointer context, KNativePointer instance) +{ + auto&& _context_ = reinterpret_cast(context); + auto&& _instance_ = reinterpret_cast(instance); + return GetImpl()->SourcePositionIndex(_context_, _instance_); +} +KOALA_INTEROP_2(SourcePositionIndex, KInt, KNativePointer, KNativePointer); + +KInt impl_SourcePositionLine(KNativePointer context, KNativePointer instance) +{ + auto&& _context_ = reinterpret_cast(context); + auto&& _instance_ = reinterpret_cast(instance); + return GetImpl()->SourcePositionLine(_context_, _instance_); +} +KOALA_INTEROP_2(SourcePositionLine, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSourceRange(KNativePointer context, KNativePointer start, KNativePointer end) +{ + auto&& _context_ = reinterpret_cast(context); + auto&& _start_ = reinterpret_cast(start); + auto&& _end_ = reinterpret_cast(end); + return GetImpl()->CreateSourceRange(_context_, _start_, _end_); +} +KOALA_INTEROP_3(CreateSourceRange, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSStringLiteralType(KNativePointer contextPtr, KStringPtr& str) +{ + auto context = reinterpret_cast(contextPtr); + const auto _str = getStringCopy(str); + return GetImpl()->CreateETSStringLiteralType(context, _str); +} +KOALA_INTEROP_2(CreateETSStringLiteralType, KNativePointer, KNativePointer, KStringPtr) + +KNativePointer impl_ProgramFileNameConst(KNativePointer contextPtr, KNativePointer programPtr) +{ + auto context = reinterpret_cast(contextPtr); + auto program = reinterpret_cast(programPtr); + auto result = GetImpl()->ProgramFileNameConst(context, program); + return new std::string(result); +} +KOALA_INTEROP_2(ProgramFileNameConst, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_ProgramFileNameWithExtensionConst(KNativePointer contextPtr, KNativePointer programPtr) +{ + auto context = reinterpret_cast(contextPtr); + auto program = reinterpret_cast(programPtr); + auto result = GetImpl()->ProgramFileNameWithExtensionConst(context, program); + return new std::string(result); +} +KOALA_INTEROP_2(ProgramFileNameWithExtensionConst, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_ETSParserGetGlobalProgramAbsName(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + auto result = GetImpl()->ETSParserGetGlobalProgramAbsName(context); + return new std::string(result); +} +KOALA_INTEROP_1(ETSParserGetGlobalProgramAbsName, KNativePointer, KNativePointer) \ No newline at end of file diff --git a/koala-wrapper/native/src/common.cc b/koala-wrapper/native/src/common.cc new file mode 100644 index 000000000..eb7a6acb5 --- /dev/null +++ b/koala-wrapper/native/src/common.cc @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2022-2025 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 + +using std::string, std::cout, std::endl, std::vector; + +static es2panda_Impl *impl = nullptr; + +#ifdef KOALA_WINDOWS + #include + #define PLUGIN_DIR "windows_host_tools" + #define LIB_PREFIX "lib" + #define LIB_SUFFIX ".dll" +#endif + +#if defined(KOALA_LINUX) || defined(KOALA_MACOS) + #include + + #ifdef __x86_64__ + #define PLUGIN_DIR "linux_host_tools" + #else + #define PLUGIN_DIR "linux_arm64_host_tools" + #endif + + #define LIB_PREFIX "lib" + #define LIB_SUFFIX ".so" +#endif + +const char* LIB_ES2PANDA_PUBLIC = LIB_PREFIX "es2panda_public" LIB_SUFFIX; + +void* FindLibrary() { + std::string libraryName; + char* envValue = getenv("PANDA_SDK_PATH"); + if (envValue) { + libraryName = std::string(envValue) + ("/" PLUGIN_DIR "/lib/") + LIB_ES2PANDA_PUBLIC; + } else { + libraryName = LIB_ES2PANDA_PUBLIC; + } + return loadLibrary(libraryName); +} + +es2panda_Impl *GetImpl() { + if (impl) { + return impl; + } + auto library = FindLibrary(); + if (!library) { + std::cout << "Cannot find " << LIB_ES2PANDA_PUBLIC << endl; + } + auto symbol = findSymbol(library, "es2panda_GetImpl"); + if (!symbol) { + std::cout << "Cannot find Impl Entry point" << endl; + } + impl = reinterpret_cast(symbol)(ES2PANDA_LIB_VERSION); + return impl; +} + +es2panda_ContextState intToState(KInt state) +{ + return es2panda_ContextState(state); +} + +string getString(KStringPtr ptr) { + return ptr.data(); +} + +char* getStringCopy(KStringPtr& ptr) { + return strdup(ptr.c_str()); +} + +inline KUInt unpackUInt(const KByte* bytes) { + const KUInt BYTE_0 = 0; + const KUInt BYTE_1 = 1; + const KUInt BYTE_2 = 2; + const KUInt BYTE_3 = 3; + + const KUInt BYTE_1_SHIFT = 8; + const KUInt BYTE_2_SHIFT = 16; + const KUInt BYTE_3_SHIFT = 24; + return ( + bytes[BYTE_0] + | (bytes[BYTE_1] << BYTE_1_SHIFT) + | (bytes[BYTE_2] << BYTE_2_SHIFT) + | (bytes[BYTE_3] << BYTE_3_SHIFT) + ); +} + +KNativePointer impl_CreateConfig(KInt argc, KStringArray argvPtr) { + const std::size_t headerLen = 4; + + const char** argv = new const char*[argc]; + std::size_t position = headerLen; + std::size_t strLen; + for (std::size_t i = 0; i < static_cast(argc); ++i) { + strLen = unpackUInt(argvPtr + position); + position += headerLen; + argv[i] = strdup(std::string(reinterpret_cast(argvPtr + position), strLen).c_str()); + position += strLen; + } + return GetImpl()->CreateConfig(argc, argv); +} +KOALA_INTEROP_2(CreateConfig, KNativePointer, KInt, KStringArray) + +KNativePointer impl_DestroyConfig(KNativePointer configPtr) { + auto config = reinterpret_cast(configPtr); + GetImpl()->DestroyConfig(config); + return nullptr; +} +KOALA_INTEROP_1(DestroyConfig, KNativePointer, KNativePointer) + +KNativePointer impl_DestroyContext(KNativePointer contextPtr) { + auto context = reinterpret_cast(contextPtr); + GetImpl()->DestroyContext(context); + return nullptr; +} +KOALA_INTEROP_1(DestroyContext, KNativePointer, KNativePointer) + +KNativePointer impl_UpdateCallExpression( + KNativePointer contextPtr, + KNativePointer nodePtr, + KNativePointer calleePtr, + KNativePointerArray argumentsPtr, + KInt argumentsLen, + KNativePointer typeParamsPtr, + KBoolean optionalT, + KBoolean trailingCommaT +) { + auto node = reinterpret_cast(nodePtr); + auto context = reinterpret_cast(contextPtr); + auto callee = reinterpret_cast(calleePtr); + auto arguments = reinterpret_cast(argumentsPtr); + auto typeParams = reinterpret_cast(typeParamsPtr); + auto optional = static_cast(optionalT); + auto trailingComma = static_cast(trailingCommaT); + + auto nn = GetImpl()->CreateCallExpression( + context, callee, arguments, argumentsLen, typeParams, optional, trailingComma + ); + GetImpl()->AstNodeSetOriginalNode(context, nn, node); + return nn; +} +KOALA_INTEROP_8(UpdateCallExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KInt, KNativePointer, KBoolean, KBoolean) + +KInt impl_IdentifierIdentifierFlags(KNativePointer contextPtr, KNativePointer nodePtr) { + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + + return + (GetImpl()->IdentifierIsOptionalConst(context, node) ? (1 << 0) : 0) | + (GetImpl()->IdentifierIsReferenceConst(context, node) ? (1 << 1) : 0) | + (GetImpl()->IdentifierIsTdzConst(context, node) ? (1 << 2) : 0); +} +KOALA_INTEROP_2(IdentifierIdentifierFlags, KInt, KNativePointer, KNativePointer) + +/* +TODO: NOT FROM API (shouldn't be there) +----------------------------------------------------------------------------------------------------------------------------- +*/ + +es2panda_AstNode * cachedParentNode; +es2panda_Context * cachedContext; + +static void changeParent(es2panda_AstNode *child) +{ + GetImpl()->AstNodeSetParent(cachedContext, child, cachedParentNode); +} + +static void SetRightParent(es2panda_AstNode *node, void *arg) +{ + es2panda_Context *ctx = static_cast(arg); + cachedContext = ctx; + cachedParentNode = node; + + GetImpl()->AstNodeIterateConst(ctx, node, changeParent); +} + +KNativePointer impl_AstNodeUpdateAll(KNativePointer contextPtr, KNativePointer programPtr) { + auto context = reinterpret_cast(contextPtr); + auto program = reinterpret_cast(programPtr); + + GetImpl()->AstNodeForEach(program, SetRightParent, context); + return program; +} +KOALA_INTEROP_2(AstNodeUpdateAll, KNativePointer, KNativePointer, KNativePointer) + +KNativePointer impl_AstNodeUpdateChildren(KNativePointer contextPtr, KNativePointer nodePtr) { + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + cachedParentNode = node; + + GetImpl()->AstNodeIterateConst(context, node, changeParent); + return node; +} +KOALA_INTEROP_2(AstNodeUpdateChildren, KNativePointer, KNativePointer, KNativePointer) + +std::vector cachedChildren; + +static void visitChild(es2panda_AstNode *node) { + cachedChildren.emplace_back(node); +} + +KNativePointer impl_AstNodeChildren( + KNativePointer contextPtr, + KNativePointer nodePtr +) { + auto context = reinterpret_cast(contextPtr); + auto node = reinterpret_cast(nodePtr); + cachedContext = context; + cachedChildren.clear(); + + GetImpl()->AstNodeIterateConst(context, node, visitChild); + return new std::vector(cachedChildren); +} +KOALA_INTEROP_2(AstNodeChildren, KNativePointer, KNativePointer, KNativePointer) + +/* +----------------------------------------------------------------------------------------------------------------------------- +*/ diff --git a/koala-wrapper/native/src/generated/bridges.cc b/koala-wrapper/native/src/generated/bridges.cc new file mode 100644 index 000000000..f1ca609eb --- /dev/null +++ b/koala-wrapper/native/src/generated/bridges.cc @@ -0,0 +1,11764 @@ +/* + * Copyright (c) 2022-2025 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 + +KNativePointer impl_CreateLabelledStatement(KNativePointer context, KNativePointer ident, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateLabelledStatement(_context, _ident, _body); + return result; +} +KOALA_INTEROP_3(CreateLabelledStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateLabelledStatement(KNativePointer context, KNativePointer original, KNativePointer ident, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->UpdateLabelledStatement(_context, _original, _ident, _body); + return result; +} +KOALA_INTEROP_4(UpdateLabelledStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_LabelledStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LabelledStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(LabelledStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_LabelledStatementIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LabelledStatementIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(LabelledStatementIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_LabelledStatementIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LabelledStatementIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(LabelledStatementIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_LabelledStatementGetReferencedStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->LabelledStatementGetReferencedStatementConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(LabelledStatementGetReferencedStatementConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateThrowStatement(KNativePointer context, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateThrowStatement(_context, _argument); + return result; +} +KOALA_INTEROP_2(CreateThrowStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateThrowStatement(KNativePointer context, KNativePointer original, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateThrowStatement(_context, _original, _argument); + return result; +} +KOALA_INTEROP_3(UpdateThrowStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ThrowStatementArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ThrowStatementArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ThrowStatementArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateClassProperty(KNativePointer context, KNativePointer key, KNativePointer value, KNativePointer typeAnnotation, KInt modifiers, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _modifiers = static_cast(modifiers); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->CreateClassProperty(_context, _key, _value, _typeAnnotation, _modifiers, _isComputed); + return result; +} +KOALA_INTEROP_6(CreateClassProperty, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean); + +KNativePointer impl_UpdateClassProperty(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer value, KNativePointer typeAnnotation, KInt modifiers, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _modifiers = static_cast(modifiers); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->UpdateClassProperty(_context, _original, _key, _value, _typeAnnotation, _modifiers, _isComputed); + return result; +} +KOALA_INTEROP_7(UpdateClassProperty, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean); + +KNativePointer impl_ClassPropertyTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassPropertyTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassPropertyTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassPropertySetTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->ClassPropertySetTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(ClassPropertySetTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassPropertyAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassPropertyAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassPropertyAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassPropertyAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassPropertyAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassPropertyAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassPropertySetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ClassPropertySetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ClassPropertySetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateTSVoidKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSVoidKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSVoidKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSVoidKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSVoidKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSVoidKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSFunctionTypeIr(KNativePointer context, KNativePointer signature, KInt funcFlags) +{ + const auto _context = reinterpret_cast(context); + const auto _signature = reinterpret_cast(signature); + const auto _funcFlags = static_cast(funcFlags); + auto result = GetImpl()->CreateETSFunctionTypeIr(_context, _signature, _funcFlags); + return result; +} +KOALA_INTEROP_3(CreateETSFunctionTypeIr, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateETSFunctionTypeIr(KNativePointer context, KNativePointer original, KNativePointer signature, KInt funcFlags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _signature = reinterpret_cast(signature); + const auto _funcFlags = static_cast(funcFlags); + auto result = GetImpl()->UpdateETSFunctionTypeIr(_context, _original, _signature, _funcFlags); + return result; +} +KOALA_INTEROP_4(UpdateETSFunctionTypeIr, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_ETSFunctionTypeIrTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeIrTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeIrParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSFunctionTypeIrParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSFunctionTypeIrParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeIrReturnTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrReturnTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrReturnTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeIrReturnType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrReturnType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrReturnType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeIrFunctionalInterface(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrFunctionalInterface(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrFunctionalInterface, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSFunctionTypeIrFunctionalInterfaceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrFunctionalInterfaceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrFunctionalInterfaceConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSFunctionTypeIrSetFunctionalInterface(KNativePointer context, KNativePointer receiver, KNativePointer functionalInterface) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _functionalInterface = reinterpret_cast(functionalInterface); + GetImpl()->ETSFunctionTypeIrSetFunctionalInterface(_context, _receiver, _functionalInterface); + return ; +} +KOALA_INTEROP_V3(ETSFunctionTypeIrSetFunctionalInterface, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_ETSFunctionTypeIrFlags(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrFlags(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrFlags, KInt, KNativePointer, KNativePointer); + +KBoolean impl_ETSFunctionTypeIrIsThrowingConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrIsThrowingConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrIsThrowingConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ETSFunctionTypeIrIsRethrowingConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrIsRethrowingConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrIsRethrowingConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ETSFunctionTypeIrIsExtensionFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSFunctionTypeIrIsExtensionFunctionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSFunctionTypeIrIsExtensionFunctionConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeOperator(KNativePointer context, KNativePointer type, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _type = reinterpret_cast(type); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->CreateTSTypeOperator(_context, _type, _operatorType); + return result; +} +KOALA_INTEROP_3(CreateTSTypeOperator, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateTSTypeOperator(KNativePointer context, KNativePointer original, KNativePointer type, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _type = reinterpret_cast(type); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->UpdateTSTypeOperator(_context, _original, _type, _operatorType); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeOperator, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_TSTypeOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeOperatorTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeOperatorTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSTypeOperatorIsReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeOperatorIsReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeOperatorIsReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSTypeOperatorIsKeyofConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeOperatorIsKeyofConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeOperatorIsKeyofConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSTypeOperatorIsUniqueConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeOperatorIsUniqueConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeOperatorIsUniqueConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateIfStatement(KNativePointer context, KNativePointer test, KNativePointer consequent, KNativePointer alternate) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _alternate = reinterpret_cast(alternate); + auto result = GetImpl()->CreateIfStatement(_context, _test, _consequent, _alternate); + return result; +} +KOALA_INTEROP_4(CreateIfStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateIfStatement(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointer consequent, KNativePointer alternate) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _alternate = reinterpret_cast(alternate); + auto result = GetImpl()->UpdateIfStatement(_context, _original, _test, _consequent, _alternate); + return result; +} +KOALA_INTEROP_5(UpdateIfStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(IfStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IfStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementConsequentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementConsequentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(IfStatementConsequentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementConsequent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementConsequent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IfStatementConsequent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementAlternate(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementAlternate(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IfStatementAlternate, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IfStatementAlternateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IfStatementAlternateConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(IfStatementAlternateConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSConstructorType(KNativePointer context, KNativePointer signature, KBoolean abstract) +{ + const auto _context = reinterpret_cast(context); + const auto _signature = reinterpret_cast(signature); + const auto _abstract = static_cast(abstract); + auto result = GetImpl()->CreateTSConstructorType(_context, _signature, _abstract); + return result; +} +KOALA_INTEROP_3(CreateTSConstructorType, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSConstructorType(KNativePointer context, KNativePointer original, KNativePointer signature, KBoolean abstract) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _signature = reinterpret_cast(signature); + const auto _abstract = static_cast(abstract); + auto result = GetImpl()->UpdateTSConstructorType(_context, _original, _signature, _abstract); + return result; +} +KOALA_INTEROP_4(UpdateTSConstructorType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSConstructorTypeTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConstructorTypeTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConstructorTypeTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSConstructorTypeTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConstructorTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSConstructorTypeParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSConstructorTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConstructorTypeReturnTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeReturnTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConstructorTypeReturnTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConstructorTypeReturnType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeReturnType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSConstructorTypeReturnType, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSConstructorTypeAbstractConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConstructorTypeAbstractConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSConstructorTypeAbstractConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateDecorator(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateDecorator(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateDecorator, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateDecorator(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateDecorator(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateDecorator, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DecoratorExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DecoratorExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(DecoratorExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSEnumDeclaration(KNativePointer context, KNativePointer key, KNativePointerArray members, KUInt membersSequenceLength, KBoolean isConst, KBoolean isStatic, KBoolean isDeclare) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _members = reinterpret_cast(members); + const auto _membersSequenceLength = static_cast(membersSequenceLength); + const auto _isConst = static_cast(isConst); + const auto _isStatic = static_cast(isStatic); + const auto _isDeclare = static_cast(isDeclare); + auto result = GetImpl()->CreateTSEnumDeclaration(_context, _key, _members, _membersSequenceLength, _isConst, _isStatic, _isDeclare); + return result; +} +KOALA_INTEROP_7(CreateTSEnumDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSEnumDeclaration(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointerArray members, KUInt membersSequenceLength, KBoolean isConst, KBoolean isStatic, KBoolean isDeclare) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _members = reinterpret_cast(members); + const auto _membersSequenceLength = static_cast(membersSequenceLength); + const auto _isConst = static_cast(isConst); + const auto _isStatic = static_cast(isStatic); + const auto _isDeclare = static_cast(isDeclare); + auto result = GetImpl()->UpdateTSEnumDeclaration(_context, _original, _key, _members, _membersSequenceLength, _isConst, _isStatic, _isDeclare); + return result; +} +KOALA_INTEROP_8(UpdateTSEnumDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_TSEnumDeclarationKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSEnumDeclarationKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumDeclarationKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumDeclarationKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumDeclarationMembersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSEnumDeclarationMembersConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSEnumDeclarationMembersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumDeclarationInternalNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationInternalNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TSEnumDeclarationInternalNameConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSEnumDeclarationSetInternalName(KNativePointer context, KNativePointer receiver, KStringPtr& internalName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _internalName = getStringCopy(internalName); + GetImpl()->TSEnumDeclarationSetInternalName(_context, _receiver, _internalName); + return ; +} +KOALA_INTEROP_V3(TSEnumDeclarationSetInternalName, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_TSEnumDeclarationBoxedClassConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationBoxedClassConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSEnumDeclarationBoxedClassConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSEnumDeclarationSetBoxedClass(KNativePointer context, KNativePointer receiver, KNativePointer wrapperClass) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _wrapperClass = reinterpret_cast(wrapperClass); + GetImpl()->TSEnumDeclarationSetBoxedClass(_context, _receiver, _wrapperClass); + return ; +} +KOALA_INTEROP_V3(TSEnumDeclarationSetBoxedClass, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSEnumDeclarationIsConstConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumDeclarationIsConstConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumDeclarationIsConstConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSEnumDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSEnumDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNeverKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSNeverKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSNeverKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSNeverKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSNeverKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSNeverKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportDefaultSpecifier(KNativePointer context, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->CreateImportDefaultSpecifier(_context, _local); + return result; +} +KOALA_INTEROP_2(CreateImportDefaultSpecifier, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateImportDefaultSpecifier(KNativePointer context, KNativePointer original, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->UpdateImportDefaultSpecifier(_context, _original, _local); + return result; +} +KOALA_INTEROP_3(UpdateImportDefaultSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDefaultSpecifierLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDefaultSpecifierLocalConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportDefaultSpecifierLocalConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDefaultSpecifierLocal(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDefaultSpecifierLocal(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportDefaultSpecifierLocal, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateObjectExpression(KNativePointer context, KInt nodeType, KNativePointerArray properties, KUInt propertiesSequenceLength, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _nodeType = static_cast(nodeType); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->CreateObjectExpression(_context, _nodeType, _properties, _propertiesSequenceLength, _trailingComma); + return result; +} +KOALA_INTEROP_5(CreateObjectExpression, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_UpdateObjectExpression(KNativePointer context, KNativePointer original, KInt nodeType, KNativePointerArray properties, KUInt propertiesSequenceLength, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _nodeType = static_cast(nodeType); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->UpdateObjectExpression(_context, _original, _nodeType, _properties, _propertiesSequenceLength, _trailingComma); + return result; +} +KOALA_INTEROP_6(UpdateObjectExpression, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_ObjectExpressionPropertiesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ObjectExpressionPropertiesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ObjectExpressionPropertiesConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ObjectExpressionIsDeclarationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionIsDeclarationConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ObjectExpressionIsDeclarationConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ObjectExpressionIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ObjectExpressionIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ObjectExpressionDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ObjectExpressionDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ObjectExpressionDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ObjectExpressionValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ObjectExpressionValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ObjectExpressionConvertibleToObjectPattern(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionConvertibleToObjectPattern(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ObjectExpressionConvertibleToObjectPattern, KBoolean, KNativePointer, KNativePointer); + +void impl_ObjectExpressionSetDeclaration(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ObjectExpressionSetDeclaration(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ObjectExpressionSetDeclaration, KNativePointer, KNativePointer); + +void impl_ObjectExpressionSetOptional(KNativePointer context, KNativePointer receiver, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _optional_arg = static_cast(optional_arg); + GetImpl()->ObjectExpressionSetOptional(_context, _receiver, _optional_arg); + return ; +} +KOALA_INTEROP_V3(ObjectExpressionSetOptional, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ObjectExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ObjectExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ObjectExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ObjectExpressionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->ObjectExpressionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(ObjectExpressionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportSpecifier(KNativePointer context, KNativePointer imported, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _imported = reinterpret_cast(imported); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->CreateImportSpecifier(_context, _imported, _local); + return result; +} +KOALA_INTEROP_3(CreateImportSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateImportSpecifier(KNativePointer context, KNativePointer original, KNativePointer imported, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _imported = reinterpret_cast(imported); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->UpdateImportSpecifier(_context, _original, _imported, _local); + return result; +} +KOALA_INTEROP_4(UpdateImportSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportSpecifierImported(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportSpecifierImported(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportSpecifierImported, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportSpecifierImportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportSpecifierImportedConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportSpecifierImportedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportSpecifierLocal(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportSpecifierLocal(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportSpecifierLocal, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportSpecifierLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportSpecifierLocalConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportSpecifierLocalConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateConditionalExpression(KNativePointer context, KNativePointer test, KNativePointer consequent, KNativePointer alternate) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _alternate = reinterpret_cast(alternate); + auto result = GetImpl()->CreateConditionalExpression(_context, _test, _consequent, _alternate); + return result; +} +KOALA_INTEROP_4(CreateConditionalExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateConditionalExpression(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointer consequent, KNativePointer alternate) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _alternate = reinterpret_cast(alternate); + auto result = GetImpl()->UpdateConditionalExpression(_context, _original, _test, _consequent, _alternate); + return result; +} +KOALA_INTEROP_5(UpdateConditionalExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ConditionalExpressionTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ConditionalExpressionTest, KNativePointer, KNativePointer, KNativePointer); + +void impl_ConditionalExpressionSetTest(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ConditionalExpressionSetTest(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ConditionalExpressionSetTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionConsequentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionConsequentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ConditionalExpressionConsequentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionConsequent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionConsequent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ConditionalExpressionConsequent, KNativePointer, KNativePointer, KNativePointer); + +void impl_ConditionalExpressionSetConsequent(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ConditionalExpressionSetConsequent(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ConditionalExpressionSetConsequent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionAlternateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionAlternateConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ConditionalExpressionAlternateConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ConditionalExpressionAlternate(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ConditionalExpressionAlternate(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ConditionalExpressionAlternate, KNativePointer, KNativePointer, KNativePointer); + +void impl_ConditionalExpressionSetAlternate(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ConditionalExpressionSetAlternate(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ConditionalExpressionSetAlternate, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateCallExpression(KNativePointer context, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength, KNativePointer typeParams, KBoolean optional_arg, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _optional_arg = static_cast(optional_arg); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->CreateCallExpression(_context, _callee, __arguments, __argumentsSequenceLength, _typeParams, _optional_arg, _trailingComma); + return result; +} +KOALA_INTEROP_7(CreateCallExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_CreateCallExpression1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateCallExpression1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateCallExpression1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateCallExpression1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateCallExpression1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateCallExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionCalleeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionCalleeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CallExpressionCalleeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionCallee(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionCallee(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionCallee, KNativePointer, KNativePointer, KNativePointer); + +void impl_CallExpressionSetCallee(KNativePointer context, KNativePointer receiver, KNativePointer callee) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _callee = reinterpret_cast(callee); + GetImpl()->CallExpressionSetCallee(_context, _receiver, _callee); + return ; +} +KOALA_INTEROP_V3(CallExpressionSetCallee, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CallExpressionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionArgumentsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->CallExpressionArgumentsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(CallExpressionArgumentsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionArguments(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->CallExpressionArguments(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(CallExpressionArguments, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_CallExpressionHasTrailingCommaConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionHasTrailingCommaConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionHasTrailingCommaConst, KBoolean, KNativePointer, KNativePointer); + +void impl_CallExpressionSetTypeParams(KNativePointer context, KNativePointer receiver, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeParams = reinterpret_cast(typeParams); + GetImpl()->CallExpressionSetTypeParams(_context, _receiver, _typeParams); + return ; +} +KOALA_INTEROP_V3(CallExpressionSetTypeParams, KNativePointer, KNativePointer, KNativePointer); + +void impl_CallExpressionSetTrailingBlock(KNativePointer context, KNativePointer receiver, KNativePointer block) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _block = reinterpret_cast(block); + GetImpl()->CallExpressionSetTrailingBlock(_context, _receiver, _block); + return ; +} +KOALA_INTEROP_V3(CallExpressionSetTrailingBlock, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_CallExpressionIsExtensionAccessorCall(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionIsExtensionAccessorCall(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionIsExtensionAccessorCall, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CallExpressionTrailingBlockConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionTrailingBlockConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CallExpressionTrailingBlockConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_CallExpressionSetIsTrailingBlockInNewLine(KNativePointer context, KNativePointer receiver, KBoolean isNewLine) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isNewLine = static_cast(isNewLine); + GetImpl()->CallExpressionSetIsTrailingBlockInNewLine(_context, _receiver, _isNewLine); + return ; +} +KOALA_INTEROP_V3(CallExpressionSetIsTrailingBlockInNewLine, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_CallExpressionIsTrailingBlockInNewLineConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionIsTrailingBlockInNewLineConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionIsTrailingBlockInNewLineConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_CallExpressionIsETSConstructorCallConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CallExpressionIsETSConstructorCallConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CallExpressionIsETSConstructorCallConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBigIntLiteral(KNativePointer context, KStringPtr& src) +{ + const auto _context = reinterpret_cast(context); + const auto _src = getStringCopy(src); + auto result = GetImpl()->CreateBigIntLiteral(_context, _src); + return result; +} +KOALA_INTEROP_2(CreateBigIntLiteral, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_UpdateBigIntLiteral(KNativePointer context, KNativePointer original, KStringPtr& src) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _src = getStringCopy(src); + auto result = GetImpl()->UpdateBigIntLiteral(_context, _original, _src); + return result; +} +KOALA_INTEROP_3(UpdateBigIntLiteral, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_BigIntLiteralStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BigIntLiteralStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(BigIntLiteralStrConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassElementIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassElementKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementValue(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementValue(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementValue, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassElementSetValue(KNativePointer context, KNativePointer receiver, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _value = reinterpret_cast(value); + GetImpl()->ClassElementSetValue(_context, _receiver, _value); + return ; +} +KOALA_INTEROP_V3(ClassElementSetValue, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementValueConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementValueConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassElementValueConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ClassElementIsPrivateElementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementIsPrivateElementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementIsPrivateElementConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ClassElementDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassElementDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassElementDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ClassElementIsComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassElementIsComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassElementIsComputedConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ClassElementAddDecorator(KNativePointer context, KNativePointer receiver, KNativePointer decorator) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _decorator = reinterpret_cast(decorator); + GetImpl()->ClassElementAddDecorator(_context, _receiver, _decorator); + return ; +} +KOALA_INTEROP_V3(ClassElementAddDecorator, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_ClassElementToPrivateFieldKindConst(KNativePointer context, KNativePointer receiver, KBoolean isStatic) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isStatic = static_cast(isStatic); + auto result = GetImpl()->ClassElementToPrivateFieldKindConst(_context, _receiver, _isStatic); + return result; +} +KOALA_INTEROP_3(ClassElementToPrivateFieldKindConst, KInt, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_CreateTSImportType(KNativePointer context, KNativePointer param, KNativePointer typeParams, KNativePointer qualifier, KBoolean isTypeof) +{ + const auto _context = reinterpret_cast(context); + const auto _param = reinterpret_cast(param); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _qualifier = reinterpret_cast(qualifier); + const auto _isTypeof = static_cast(isTypeof); + auto result = GetImpl()->CreateTSImportType(_context, _param, _typeParams, _qualifier, _isTypeof); + return result; +} +KOALA_INTEROP_5(CreateTSImportType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSImportType(KNativePointer context, KNativePointer original, KNativePointer param, KNativePointer typeParams, KNativePointer qualifier, KBoolean isTypeof) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _param = reinterpret_cast(param); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _qualifier = reinterpret_cast(qualifier); + const auto _isTypeof = static_cast(isTypeof); + auto result = GetImpl()->UpdateTSImportType(_context, _original, _param, _typeParams, _qualifier, _isTypeof); + return result; +} +KOALA_INTEROP_6(UpdateTSImportType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSImportTypeParamConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportTypeParamConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportTypeParamConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSImportTypeTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportTypeTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportTypeTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSImportTypeQualifierConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportTypeQualifierConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportTypeQualifierConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSImportTypeIsTypeofConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportTypeIsTypeofConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSImportTypeIsTypeofConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTaggedTemplateExpression(KNativePointer context, KNativePointer tag, KNativePointer quasi, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _tag = reinterpret_cast(tag); + const auto _quasi = reinterpret_cast(quasi); + const auto _typeParams = reinterpret_cast(typeParams); + auto result = GetImpl()->CreateTaggedTemplateExpression(_context, _tag, _quasi, _typeParams); + return result; +} +KOALA_INTEROP_4(CreateTaggedTemplateExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTaggedTemplateExpression(KNativePointer context, KNativePointer original, KNativePointer tag, KNativePointer quasi, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _tag = reinterpret_cast(tag); + const auto _quasi = reinterpret_cast(quasi); + const auto _typeParams = reinterpret_cast(typeParams); + auto result = GetImpl()->UpdateTaggedTemplateExpression(_context, _original, _tag, _quasi, _typeParams); + return result; +} +KOALA_INTEROP_5(UpdateTaggedTemplateExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TaggedTemplateExpressionTagConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TaggedTemplateExpressionTagConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TaggedTemplateExpressionTagConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TaggedTemplateExpressionQuasiConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TaggedTemplateExpressionQuasiConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TaggedTemplateExpressionQuasiConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TaggedTemplateExpressionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TaggedTemplateExpressionTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TaggedTemplateExpressionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateFunctionDeclaration(KNativePointer context, KNativePointer func, KNativePointerArray annotations, KUInt annotationsSequenceLength, KBoolean isAnonymous) +{ + const auto _context = reinterpret_cast(context); + const auto _func = reinterpret_cast(func); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + const auto _isAnonymous = static_cast(isAnonymous); + auto result = GetImpl()->CreateFunctionDeclaration(_context, _func, _annotations, _annotationsSequenceLength, _isAnonymous); + return result; +} +KOALA_INTEROP_5(CreateFunctionDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_UpdateFunctionDeclaration(KNativePointer context, KNativePointer original, KNativePointer func, KNativePointerArray annotations, KUInt annotationsSequenceLength, KBoolean isAnonymous) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _func = reinterpret_cast(func); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + const auto _isAnonymous = static_cast(isAnonymous); + auto result = GetImpl()->UpdateFunctionDeclaration(_context, _original, _func, _annotations, _annotationsSequenceLength, _isAnonymous); + return result; +} +KOALA_INTEROP_6(UpdateFunctionDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_CreateFunctionDeclaration1(KNativePointer context, KNativePointer func, KBoolean isAnonymous) +{ + const auto _context = reinterpret_cast(context); + const auto _func = reinterpret_cast(func); + const auto _isAnonymous = static_cast(isAnonymous); + auto result = GetImpl()->CreateFunctionDeclaration1(_context, _func, _isAnonymous); + return result; +} +KOALA_INTEROP_3(CreateFunctionDeclaration1, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateFunctionDeclaration1(KNativePointer context, KNativePointer original, KNativePointer func, KBoolean isAnonymous) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _func = reinterpret_cast(func); + const auto _isAnonymous = static_cast(isAnonymous); + auto result = GetImpl()->UpdateFunctionDeclaration1(_context, _original, _func, _isAnonymous); + return result; +} +KOALA_INTEROP_4(UpdateFunctionDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_FunctionDeclarationFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionDeclarationFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionDeclarationFunction, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_FunctionDeclarationIsAnonymousConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionDeclarationIsAnonymousConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionDeclarationIsAnonymousConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionDeclarationFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionDeclarationFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(FunctionDeclarationFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->FunctionDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(FunctionDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->FunctionDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(FunctionDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_FunctionDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->FunctionDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(FunctionDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateETSTypeReference(KNativePointer context, KNativePointer part) +{ + const auto _context = reinterpret_cast(context); + const auto _part = reinterpret_cast(part); + auto result = GetImpl()->CreateETSTypeReference(_context, _part); + return result; +} +KOALA_INTEROP_2(CreateETSTypeReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSTypeReference(KNativePointer context, KNativePointer original, KNativePointer part) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _part = reinterpret_cast(part); + auto result = GetImpl()->UpdateETSTypeReference(_context, _original, _part); + return result; +} +KOALA_INTEROP_3(UpdateETSTypeReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePart(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePart(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTypeReferencePart, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSTypeReferencePartConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferenceBaseNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferenceBaseNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSTypeReferenceBaseNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeReference(KNativePointer context, KNativePointer typeName, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _typeName = reinterpret_cast(typeName); + const auto _typeParams = reinterpret_cast(typeParams); + auto result = GetImpl()->CreateTSTypeReference(_context, _typeName, _typeParams); + return result; +} +KOALA_INTEROP_3(CreateTSTypeReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeReference(KNativePointer context, KNativePointer original, KNativePointer typeName, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeName = reinterpret_cast(typeName); + const auto _typeParams = reinterpret_cast(typeParams); + auto result = GetImpl()->UpdateTSTypeReference(_context, _original, _typeName, _typeParams); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeReferenceTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeReferenceTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeReferenceTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeReferenceTypeNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeReferenceTypeNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeReferenceTypeNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeReferenceBaseNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeReferenceBaseNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeReferenceBaseNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateNamedType(KNativePointer context, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->CreateNamedType(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateNamedType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateNamedType(KNativePointer context, KNativePointer original, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->UpdateNamedType(_context, _original, _name); + return result; +} +KOALA_INTEROP_3(UpdateNamedType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_NamedTypeNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NamedTypeNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(NamedTypeNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_NamedTypeTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NamedTypeTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(NamedTypeTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_NamedTypeIsNullableConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NamedTypeIsNullableConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(NamedTypeIsNullableConst, KBoolean, KNativePointer, KNativePointer); + +void impl_NamedTypeSetNullable(KNativePointer context, KNativePointer receiver, KBoolean nullable) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _nullable = static_cast(nullable); + GetImpl()->NamedTypeSetNullable(_context, _receiver, _nullable); + return ; +} +KOALA_INTEROP_V3(NamedTypeSetNullable, KNativePointer, KNativePointer, KBoolean); + +void impl_NamedTypeSetNext(KNativePointer context, KNativePointer receiver, KNativePointer next) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _next = reinterpret_cast(next); + GetImpl()->NamedTypeSetNext(_context, _receiver, _next); + return ; +} +KOALA_INTEROP_V3(NamedTypeSetNext, KNativePointer, KNativePointer, KNativePointer); + +void impl_NamedTypeSetTypeParams(KNativePointer context, KNativePointer receiver, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeParams = reinterpret_cast(typeParams); + GetImpl()->NamedTypeSetTypeParams(_context, _receiver, _typeParams); + return ; +} +KOALA_INTEROP_V3(NamedTypeSetTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_NumberLiteralStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NumberLiteralStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(NumberLiteralStrConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSFunctionType(KNativePointer context, KNativePointer signature) +{ + const auto _context = reinterpret_cast(context); + const auto _signature = reinterpret_cast(signature); + auto result = GetImpl()->CreateTSFunctionType(_context, _signature); + return result; +} +KOALA_INTEROP_2(CreateTSFunctionType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSFunctionType(KNativePointer context, KNativePointer original, KNativePointer signature) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _signature = reinterpret_cast(signature); + auto result = GetImpl()->UpdateTSFunctionType(_context, _original, _signature); + return result; +} +KOALA_INTEROP_3(UpdateTSFunctionType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSFunctionTypeTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSFunctionTypeTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSFunctionTypeTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSFunctionTypeTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSFunctionTypeParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSFunctionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeReturnTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSFunctionTypeReturnTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSFunctionTypeReturnTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSFunctionTypeReturnType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSFunctionTypeReturnType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSFunctionTypeReturnType, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSFunctionTypeSetNullable(KNativePointer context, KNativePointer receiver, KBoolean nullable) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _nullable = static_cast(nullable); + GetImpl()->TSFunctionTypeSetNullable(_context, _receiver, _nullable); + return ; +} +KOALA_INTEROP_V3(TSFunctionTypeSetNullable, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_CreateTemplateElement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTemplateElement(_context); + return result; +} +KOALA_INTEROP_1(CreateTemplateElement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTemplateElement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTemplateElement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTemplateElement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTemplateElement1(KNativePointer context, KStringPtr& raw, KStringPtr& cooked) +{ + const auto _context = reinterpret_cast(context); + const auto _raw = getStringCopy(raw); + const auto _cooked = getStringCopy(cooked); + auto result = GetImpl()->CreateTemplateElement1(_context, _raw, _cooked); + return result; +} +KOALA_INTEROP_3(CreateTemplateElement1, KNativePointer, KNativePointer, KStringPtr, KStringPtr); + +KNativePointer impl_UpdateTemplateElement1(KNativePointer context, KNativePointer original, KStringPtr& raw, KStringPtr& cooked) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _raw = getStringCopy(raw); + const auto _cooked = getStringCopy(cooked); + auto result = GetImpl()->UpdateTemplateElement1(_context, _original, _raw, _cooked); + return result; +} +KOALA_INTEROP_4(UpdateTemplateElement1, KNativePointer, KNativePointer, KNativePointer, KStringPtr, KStringPtr); + +KNativePointer impl_TemplateElementRawConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TemplateElementRawConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TemplateElementRawConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TemplateElementCookedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TemplateElementCookedConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TemplateElementCookedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSInterfaceDeclaration(KNativePointer context, KNativePointerArray _extends, KUInt _extendsSequenceLength, KNativePointer id, KNativePointer typeParams, KNativePointer body, KBoolean isStatic, KBoolean isExternal) +{ + const auto _context = reinterpret_cast(context); + const auto __extends = reinterpret_cast(_extends); + const auto __extendsSequenceLength = static_cast(_extendsSequenceLength); + const auto _id = reinterpret_cast(id); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _body = reinterpret_cast(body); + const auto _isStatic = static_cast(isStatic); + const auto _isExternal = static_cast(isExternal); + auto result = GetImpl()->CreateTSInterfaceDeclaration(_context, __extends, __extendsSequenceLength, _id, _typeParams, _body, _isStatic, _isExternal); + return result; +} +KOALA_INTEROP_8(CreateTSInterfaceDeclaration, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSInterfaceDeclaration(KNativePointer context, KNativePointer original, KNativePointerArray _extends, KUInt _extendsSequenceLength, KNativePointer id, KNativePointer typeParams, KNativePointer body, KBoolean isStatic, KBoolean isExternal) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto __extends = reinterpret_cast(_extends); + const auto __extendsSequenceLength = static_cast(_extendsSequenceLength); + const auto _id = reinterpret_cast(id); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _body = reinterpret_cast(body); + const auto _isStatic = static_cast(isStatic); + const auto _isExternal = static_cast(isExternal); + auto result = GetImpl()->UpdateTSInterfaceDeclaration(_context, _original, __extends, __extendsSequenceLength, _id, _typeParams, _body, _isStatic, _isExternal); + return result; +} +KOALA_INTEROP_9(UpdateTSInterfaceDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_TSInterfaceDeclarationBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationInternalNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationInternalNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TSInterfaceDeclarationInternalNameConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSInterfaceDeclarationSetInternalName(KNativePointer context, KNativePointer receiver, KStringPtr& internalName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _internalName = getStringCopy(internalName); + GetImpl()->TSInterfaceDeclarationSetInternalName(_context, _receiver, _internalName); + return ; +} +KOALA_INTEROP_V3(TSInterfaceDeclarationSetInternalName, KNativePointer, KNativePointer, KStringPtr); + +KBoolean impl_TSInterfaceDeclarationIsStaticConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationIsStaticConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationIsStaticConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSInterfaceDeclarationIsFromExternalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationIsFromExternalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationIsFromExternalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationExtends(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationExtends(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationExtends, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationExtendsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationExtendsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationExtendsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationGetAnonClass(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationGetAnonClass(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationGetAnonClass, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationGetAnonClassConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceDeclarationGetAnonClassConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceDeclarationGetAnonClassConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSInterfaceDeclarationSetAnonClass(KNativePointer context, KNativePointer receiver, KNativePointer anonClass) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _anonClass = reinterpret_cast(anonClass); + GetImpl()->TSInterfaceDeclarationSetAnonClass(_context, _receiver, _anonClass); + return ; +} +KOALA_INTEROP_V3(TSInterfaceDeclarationSetAnonClass, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSInterfaceDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->TSInterfaceDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(TSInterfaceDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateVariableDeclaration(KNativePointer context, KInt kind, KNativePointerArray declarators, KUInt declaratorsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + const auto _declarators = reinterpret_cast(declarators); + const auto _declaratorsSequenceLength = static_cast(declaratorsSequenceLength); + auto result = GetImpl()->CreateVariableDeclaration(_context, _kind, _declarators, _declaratorsSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateVariableDeclaration, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateVariableDeclaration(KNativePointer context, KNativePointer original, KInt kind, KNativePointerArray declarators, KUInt declaratorsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + const auto _declarators = reinterpret_cast(declarators); + const auto _declaratorsSequenceLength = static_cast(declaratorsSequenceLength); + auto result = GetImpl()->UpdateVariableDeclaration(_context, _original, _kind, _declarators, _declaratorsSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateVariableDeclaration, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt); + +KNativePointer impl_VariableDeclarationDeclaratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->VariableDeclarationDeclaratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(VariableDeclarationDeclaratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_VariableDeclarationKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclarationKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(VariableDeclarationKindConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->VariableDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(VariableDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclarationGetDeclaratorByNameConst(KNativePointer context, KNativePointer receiver, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _name = getStringCopy(name); + auto result = GetImpl()->VariableDeclarationGetDeclaratorByNameConst(_context, _receiver, _name); + return (void*)result; +} +KOALA_INTEROP_3(VariableDeclarationGetDeclaratorByNameConst, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_VariableDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->VariableDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(VariableDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->VariableDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(VariableDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_VariableDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->VariableDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(VariableDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateUndefinedLiteral(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateUndefinedLiteral(_context); + return result; +} +KOALA_INTEROP_1(CreateUndefinedLiteral, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateUndefinedLiteral(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateUndefinedLiteral(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateUndefinedLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateMemberExpression(KNativePointer context, KNativePointer object_arg, KNativePointer property, KInt kind, KBoolean computed, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _object_arg = reinterpret_cast(object_arg); + const auto _property = reinterpret_cast(property); + const auto _kind = static_cast(kind); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->CreateMemberExpression(_context, _object_arg, _property, _kind, _computed, _optional_arg); + return result; +} +KOALA_INTEROP_6(CreateMemberExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean, KBoolean); + +KNativePointer impl_UpdateMemberExpression(KNativePointer context, KNativePointer original, KNativePointer object_arg, KNativePointer property, KInt kind, KBoolean computed, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _object_arg = reinterpret_cast(object_arg); + const auto _property = reinterpret_cast(property); + const auto _kind = static_cast(kind); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->UpdateMemberExpression(_context, _original, _object_arg, _property, _kind, _computed, _optional_arg); + return result; +} +KOALA_INTEROP_7(UpdateMemberExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean, KBoolean); + +KNativePointer impl_MemberExpressionObject(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionObject(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionObject, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MemberExpressionObjectConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionObjectConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MemberExpressionObjectConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_MemberExpressionSetObject(KNativePointer context, KNativePointer receiver, KNativePointer object_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _object_arg = reinterpret_cast(object_arg); + GetImpl()->MemberExpressionSetObject(_context, _receiver, _object_arg); + return ; +} +KOALA_INTEROP_V3(MemberExpressionSetObject, KNativePointer, KNativePointer, KNativePointer); + +void impl_MemberExpressionSetProperty(KNativePointer context, KNativePointer receiver, KNativePointer prop) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _prop = reinterpret_cast(prop); + GetImpl()->MemberExpressionSetProperty(_context, _receiver, _prop); + return ; +} +KOALA_INTEROP_V3(MemberExpressionSetProperty, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MemberExpressionProperty(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionProperty(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionProperty, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MemberExpressionPropertyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionPropertyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MemberExpressionPropertyConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_MemberExpressionIsComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionIsComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionIsComputedConst, KBoolean, KNativePointer, KNativePointer); + +KInt impl_MemberExpressionKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionKindConst, KInt, KNativePointer, KNativePointer); + +void impl_MemberExpressionAddMemberKind(KNativePointer context, KNativePointer receiver, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _kind = static_cast(kind); + GetImpl()->MemberExpressionAddMemberKind(_context, _receiver, _kind); + return ; +} +KOALA_INTEROP_V3(MemberExpressionAddMemberKind, KNativePointer, KNativePointer, KInt); + +KBoolean impl_MemberExpressionHasMemberKindConst(KNativePointer context, KNativePointer receiver, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _kind = static_cast(kind); + auto result = GetImpl()->MemberExpressionHasMemberKindConst(_context, _receiver, _kind); + return result; +} +KOALA_INTEROP_3(MemberExpressionHasMemberKindConst, KBoolean, KNativePointer, KNativePointer, KInt); + +void impl_MemberExpressionRemoveMemberKind(KNativePointer context, KNativePointer receiver, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _kind = static_cast(kind); + GetImpl()->MemberExpressionRemoveMemberKind(_context, _receiver, _kind); + return ; +} +KOALA_INTEROP_V3(MemberExpressionRemoveMemberKind, KNativePointer, KNativePointer, KInt); + +KBoolean impl_MemberExpressionIsIgnoreBoxConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionIsIgnoreBoxConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionIsIgnoreBoxConst, KBoolean, KNativePointer, KNativePointer); + +void impl_MemberExpressionSetIgnoreBox(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->MemberExpressionSetIgnoreBox(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(MemberExpressionSetIgnoreBox, KNativePointer, KNativePointer); + +KBoolean impl_MemberExpressionIsPrivateReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MemberExpressionIsPrivateReferenceConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MemberExpressionIsPrivateReferenceConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSClassImplements(KNativePointer context, KNativePointer expression, KNativePointer typeParameters) +{ + const auto _context = reinterpret_cast(context); + const auto _expression = reinterpret_cast(expression); + const auto _typeParameters = reinterpret_cast(typeParameters); + auto result = GetImpl()->CreateTSClassImplements(_context, _expression, _typeParameters); + return result; +} +KOALA_INTEROP_3(CreateTSClassImplements, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSClassImplements(KNativePointer context, KNativePointer original, KNativePointer expression, KNativePointer typeParameters) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expression = reinterpret_cast(expression); + const auto _typeParameters = reinterpret_cast(typeParameters); + auto result = GetImpl()->UpdateTSClassImplements(_context, _original, _expression, _typeParameters); + return result; +} +KOALA_INTEROP_4(UpdateTSClassImplements, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSClassImplements1(KNativePointer context, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->CreateTSClassImplements1(_context, _expression); + return result; +} +KOALA_INTEROP_2(CreateTSClassImplements1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSClassImplements1(KNativePointer context, KNativePointer original, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->UpdateTSClassImplements1(_context, _original, _expression); + return result; +} +KOALA_INTEROP_3(UpdateTSClassImplements1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSClassImplementsExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSClassImplementsExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSClassImplementsExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSClassImplementsExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSClassImplementsExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSClassImplementsExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSClassImplementsTypeParametersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSClassImplementsTypeParametersConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSClassImplementsTypeParametersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSObjectKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSObjectKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSObjectKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSObjectKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSObjectKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSObjectKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSUnionTypeIr(KNativePointer context, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->CreateETSUnionTypeIr(_context, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateETSUnionTypeIr, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateETSUnionTypeIr(KNativePointer context, KNativePointer original, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->UpdateETSUnionTypeIr(_context, _original, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateETSUnionTypeIr, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_ETSUnionTypeIrTypesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSUnionTypeIrTypesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSUnionTypeIrTypesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSPropertySignature(KNativePointer context, KNativePointer key, KNativePointer typeAnnotation, KBoolean computed, KBoolean optional_arg, KBoolean readonly_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + const auto _readonly_arg = static_cast(readonly_arg); + auto result = GetImpl()->CreateTSPropertySignature(_context, _key, _typeAnnotation, _computed, _optional_arg, _readonly_arg); + return result; +} +KOALA_INTEROP_6(CreateTSPropertySignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSPropertySignature(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer typeAnnotation, KBoolean computed, KBoolean optional_arg, KBoolean readonly_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + const auto _readonly_arg = static_cast(readonly_arg); + auto result = GetImpl()->UpdateTSPropertySignature(_context, _original, _key, _typeAnnotation, _computed, _optional_arg, _readonly_arg); + return result; +} +KOALA_INTEROP_7(UpdateTSPropertySignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_TSPropertySignatureKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSPropertySignatureKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSPropertySignatureKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSPropertySignatureKey, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSPropertySignatureComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSPropertySignatureComputedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSPropertySignatureOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSPropertySignatureOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSPropertySignatureReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSPropertySignatureReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSPropertySignatureTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSPropertySignatureTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSPropertySignatureTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSPropertySignatureSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->TSPropertySignatureSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(TSPropertySignatureSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSConditionalType(KNativePointer context, KNativePointer checkType, KNativePointer extendsType, KNativePointer trueType, KNativePointer falseType) +{ + const auto _context = reinterpret_cast(context); + const auto _checkType = reinterpret_cast(checkType); + const auto _extendsType = reinterpret_cast(extendsType); + const auto _trueType = reinterpret_cast(trueType); + const auto _falseType = reinterpret_cast(falseType); + auto result = GetImpl()->CreateTSConditionalType(_context, _checkType, _extendsType, _trueType, _falseType); + return result; +} +KOALA_INTEROP_5(CreateTSConditionalType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSConditionalType(KNativePointer context, KNativePointer original, KNativePointer checkType, KNativePointer extendsType, KNativePointer trueType, KNativePointer falseType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _checkType = reinterpret_cast(checkType); + const auto _extendsType = reinterpret_cast(extendsType); + const auto _trueType = reinterpret_cast(trueType); + const auto _falseType = reinterpret_cast(falseType); + auto result = GetImpl()->UpdateTSConditionalType(_context, _original, _checkType, _extendsType, _trueType, _falseType); + return result; +} +KOALA_INTEROP_6(UpdateTSConditionalType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConditionalTypeCheckTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConditionalTypeCheckTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConditionalTypeCheckTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConditionalTypeExtendsTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConditionalTypeExtendsTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConditionalTypeExtendsTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConditionalTypeTrueTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConditionalTypeTrueTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConditionalTypeTrueTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSConditionalTypeFalseTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSConditionalTypeFalseTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSConditionalTypeFalseTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSLiteralType(KNativePointer context, KNativePointer literal) +{ + const auto _context = reinterpret_cast(context); + const auto _literal = reinterpret_cast(literal); + auto result = GetImpl()->CreateTSLiteralType(_context, _literal); + return result; +} +KOALA_INTEROP_2(CreateTSLiteralType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSLiteralType(KNativePointer context, KNativePointer original, KNativePointer literal) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _literal = reinterpret_cast(literal); + auto result = GetImpl()->UpdateTSLiteralType(_context, _original, _literal); + return result; +} +KOALA_INTEROP_3(UpdateTSLiteralType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSLiteralTypeLiteralConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSLiteralTypeLiteralConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSLiteralTypeLiteralConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeAliasDeclaration(KNativePointer context, KNativePointer id, KNativePointer typeParams, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _id = reinterpret_cast(id); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + auto result = GetImpl()->CreateTSTypeAliasDeclaration(_context, _id, _typeParams, _typeAnnotation); + return result; +} +KOALA_INTEROP_4(CreateTSTypeAliasDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeAliasDeclaration(KNativePointer context, KNativePointer original, KNativePointer id, KNativePointer typeParams, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _id = reinterpret_cast(id); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + auto result = GetImpl()->UpdateTSTypeAliasDeclaration(_context, _original, _id, _typeParams, _typeAnnotation); + return result; +} +KOALA_INTEROP_5(UpdateTSTypeAliasDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeAliasDeclaration1(KNativePointer context, KNativePointer id) +{ + const auto _context = reinterpret_cast(context); + const auto _id = reinterpret_cast(id); + auto result = GetImpl()->CreateTSTypeAliasDeclaration1(_context, _id); + return result; +} +KOALA_INTEROP_2(CreateTSTypeAliasDeclaration1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeAliasDeclaration1(KNativePointer context, KNativePointer original, KNativePointer id) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _id = reinterpret_cast(id); + auto result = GetImpl()->UpdateTSTypeAliasDeclaration1(_context, _original, _id); + return result; +} +KOALA_INTEROP_3(UpdateTSTypeAliasDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAliasDeclarationId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeAliasDeclarationId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAliasDeclarationIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAliasDeclarationIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAliasDeclarationTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAliasDeclarationTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeAliasDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeAliasDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeAliasDeclarationSetTypeParameters(KNativePointer context, KNativePointer receiver, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeParams = reinterpret_cast(typeParams); + GetImpl()->TSTypeAliasDeclarationSetTypeParameters(_context, _receiver, _typeParams); + return ; +} +KOALA_INTEROP_V3(TSTypeAliasDeclarationSetTypeParameters, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeAliasDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeAliasDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAliasDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeAliasDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeAliasDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeAliasDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->TSTypeAliasDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(TSTypeAliasDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSTypeAliasDeclarationTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAliasDeclarationTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAliasDeclarationTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeAliasDeclarationSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->TSTypeAliasDeclarationSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(TSTypeAliasDeclarationSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateDebuggerStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateDebuggerStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateDebuggerStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateDebuggerStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateDebuggerStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateDebuggerStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateReturnStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateReturnStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateReturnStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateReturnStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateReturnStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateReturnStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateReturnStatement1(KNativePointer context, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateReturnStatement1(_context, _argument); + return result; +} +KOALA_INTEROP_2(CreateReturnStatement1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateReturnStatement1(KNativePointer context, KNativePointer original, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateReturnStatement1(_context, _original, _argument); + return result; +} +KOALA_INTEROP_3(UpdateReturnStatement1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ReturnStatementArgument(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ReturnStatementArgument(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ReturnStatementArgument, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ReturnStatementArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ReturnStatementArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ReturnStatementArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ReturnStatementSetArgument(KNativePointer context, KNativePointer receiver, KNativePointer arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _arg = reinterpret_cast(arg); + GetImpl()->ReturnStatementSetArgument(_context, _receiver, _arg); + return ; +} +KOALA_INTEROP_V3(ReturnStatementSetArgument, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateExportDefaultDeclaration(KNativePointer context, KNativePointer decl, KBoolean exportEquals) +{ + const auto _context = reinterpret_cast(context); + const auto _decl = reinterpret_cast(decl); + const auto _exportEquals = static_cast(exportEquals); + auto result = GetImpl()->CreateExportDefaultDeclaration(_context, _decl, _exportEquals); + return result; +} +KOALA_INTEROP_3(CreateExportDefaultDeclaration, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateExportDefaultDeclaration(KNativePointer context, KNativePointer original, KNativePointer decl, KBoolean exportEquals) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _decl = reinterpret_cast(decl); + const auto _exportEquals = static_cast(exportEquals); + auto result = GetImpl()->UpdateExportDefaultDeclaration(_context, _original, _decl, _exportEquals); + return result; +} +KOALA_INTEROP_4(UpdateExportDefaultDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ExportDefaultDeclarationDecl(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportDefaultDeclarationDecl(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExportDefaultDeclarationDecl, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportDefaultDeclarationDeclConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportDefaultDeclarationDeclConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportDefaultDeclarationDeclConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ExportDefaultDeclarationIsExportEqualsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportDefaultDeclarationIsExportEqualsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExportDefaultDeclarationIsExportEqualsConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateScriptFunction(KNativePointer context, KNativePointer databody, KNativePointer datasignature, KInt datafuncFlags, KInt dataflags) +{ + const auto _context = reinterpret_cast(context); + const auto _databody = reinterpret_cast(databody); + const auto _datasignature = reinterpret_cast(datasignature); + const auto _datafuncFlags = static_cast(datafuncFlags); + const auto _dataflags = static_cast(dataflags); + auto result = GetImpl()->CreateScriptFunction(_context, _databody, _datasignature, _datafuncFlags, _dataflags); + return result; +} +KOALA_INTEROP_5(CreateScriptFunction, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_UpdateScriptFunction(KNativePointer context, KNativePointer original, KNativePointer databody, KNativePointer datasignature, KInt datafuncFlags, KInt dataflags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _databody = reinterpret_cast(databody); + const auto _datasignature = reinterpret_cast(datasignature); + const auto _datafuncFlags = static_cast(datafuncFlags); + const auto _dataflags = static_cast(dataflags); + auto result = GetImpl()->UpdateScriptFunction(_context, _original, _databody, _datasignature, _datafuncFlags, _dataflags); + return result; +} +KOALA_INTEROP_6(UpdateScriptFunction, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_ScriptFunctionIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ScriptFunctionIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionParams(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionReturnStatementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionReturnStatementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionReturnStatementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionReturnStatements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionReturnStatements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionReturnStatements, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ScriptFunctionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ScriptFunctionBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionBody, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionAddReturnStatement(KNativePointer context, KNativePointer receiver, KNativePointer returnStatement) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _returnStatement = reinterpret_cast(returnStatement); + GetImpl()->ScriptFunctionAddReturnStatement(_context, _receiver, _returnStatement); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionAddReturnStatement, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionSetBody(KNativePointer context, KNativePointer receiver, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _body = reinterpret_cast(body); + GetImpl()->ScriptFunctionSetBody(_context, _receiver, _body); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionSetBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionReturnTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionReturnTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ScriptFunctionReturnTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionReturnTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionReturnTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionReturnTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionSetReturnTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer node) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _node = reinterpret_cast(node); + GetImpl()->ScriptFunctionSetReturnTypeAnnotation(_context, _receiver, _node); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionSetReturnTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsEntryPointConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsEntryPointConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsEntryPointConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsGeneratorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsGeneratorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsGeneratorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsAsyncFuncConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsAsyncFuncConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsAsyncFuncConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsAsyncImplFuncConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsAsyncImplFuncConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsAsyncImplFuncConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsArrowConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsArrowConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsArrowConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsOverloadConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsOverloadConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsOverloadConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsExternalOverloadConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsExternalOverloadConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsExternalOverloadConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsConstructorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsConstructorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsConstructorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsGetterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsGetterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsGetterConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsSetterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsSetterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsSetterConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsExtensionAccessorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsExtensionAccessorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsExtensionAccessorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsMethodConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsProxyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsProxyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsProxyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsStaticBlockConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsStaticBlockConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsStaticBlockConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsEnumConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsEnumConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsEnumConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsHiddenConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsHiddenConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsHiddenConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsExternalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsExternalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsExternalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsImplicitSuperCallNeededConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsImplicitSuperCallNeededConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsImplicitSuperCallNeededConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasBodyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasBodyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasRestParameterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasRestParameterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasRestParameterConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasReturnStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasReturnStatementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasReturnStatementConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasThrowStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasThrowStatementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasThrowStatementConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsThrowingConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsThrowingConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsThrowingConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsRethrowingConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsRethrowingConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsRethrowingConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsDynamicConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsDynamicConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsDynamicConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionIsExtensionMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionIsExtensionMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionIsExtensionMethodConst, KBoolean, KNativePointer, KNativePointer); + +KInt impl_ScriptFunctionFlagsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionFlagsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionFlagsConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_ScriptFunctionHasReceiverConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionHasReceiverConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionHasReceiverConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ScriptFunctionSetIdent(KNativePointer context, KNativePointer receiver, KNativePointer id) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _id = reinterpret_cast(id); + GetImpl()->ScriptFunctionSetIdent(_context, _receiver, _id); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionSetIdent, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionAddFlag(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + GetImpl()->ScriptFunctionAddFlag(_context, _receiver, _flags); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionAddFlag, KNativePointer, KNativePointer, KInt); + +void impl_ScriptFunctionAddModifier(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + GetImpl()->ScriptFunctionAddModifier(_context, _receiver, _flags); + return ; +} +KOALA_INTEROP_V3(ScriptFunctionAddModifier, KNativePointer, KNativePointer, KInt); + +KUInt impl_ScriptFunctionFormalParamsLengthConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ScriptFunctionFormalParamsLengthConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ScriptFunctionFormalParamsLengthConst, KUInt, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ScriptFunctionAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ScriptFunctionAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ScriptFunctionAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ScriptFunctionSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ScriptFunctionSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ScriptFunctionSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateClassDefinition(KNativePointer context, KNativePointer ident, KNativePointer typeParams, KNativePointer superTypeParams, KNativePointerArray _implements, KUInt _implementsSequenceLength, KNativePointer ctor, KNativePointer superClass, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _superTypeParams = reinterpret_cast(superTypeParams); + const auto __implements = reinterpret_cast(_implements); + const auto __implementsSequenceLength = static_cast(_implementsSequenceLength); + const auto _ctor = reinterpret_cast(ctor); + const auto _superClass = reinterpret_cast(superClass); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateClassDefinition(_context, _ident, _typeParams, _superTypeParams, __implements, __implementsSequenceLength, _ctor, _superClass, _body, _bodySequenceLength, _modifiers, _flags); + return result; +} +KOALA_INTEROP_12(CreateClassDefinition, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt); + +KNativePointer impl_UpdateClassDefinition(KNativePointer context, KNativePointer original, KNativePointer ident, KNativePointer typeParams, KNativePointer superTypeParams, KNativePointerArray _implements, KUInt _implementsSequenceLength, KNativePointer ctor, KNativePointer superClass, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _superTypeParams = reinterpret_cast(superTypeParams); + const auto __implements = reinterpret_cast(_implements); + const auto __implementsSequenceLength = static_cast(_implementsSequenceLength); + const auto _ctor = reinterpret_cast(ctor); + const auto _superClass = reinterpret_cast(superClass); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateClassDefinition(_context, _original, _ident, _typeParams, _superTypeParams, __implements, __implementsSequenceLength, _ctor, _superClass, _body, _bodySequenceLength, _modifiers, _flags); + return result; +} +KOALA_INTEROP_13(UpdateClassDefinition, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt); + +KNativePointer impl_CreateClassDefinition1(KNativePointer context, KNativePointer ident, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateClassDefinition1(_context, _ident, _body, _bodySequenceLength, _modifiers, _flags); + return result; +} +KOALA_INTEROP_6(CreateClassDefinition1, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt); + +KNativePointer impl_UpdateClassDefinition1(KNativePointer context, KNativePointer original, KNativePointer ident, KNativePointerArray body, KUInt bodySequenceLength, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateClassDefinition1(_context, _original, _ident, _body, _bodySequenceLength, _modifiers, _flags); + return result; +} +KOALA_INTEROP_7(UpdateClassDefinition1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt, KInt); + +KNativePointer impl_CreateClassDefinition2(KNativePointer context, KNativePointer ident, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateClassDefinition2(_context, _ident, _modifiers, _flags); + return result; +} +KOALA_INTEROP_4(CreateClassDefinition2, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_UpdateClassDefinition2(KNativePointer context, KNativePointer original, KNativePointer ident, KInt modifiers, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + const auto _modifiers = static_cast(modifiers); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateClassDefinition2(_context, _original, _ident, _modifiers, _flags); + return result; +} +KOALA_INTEROP_5(UpdateClassDefinition2, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_ClassDefinitionIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIdent, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetIdent(KNativePointer context, KNativePointer receiver, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _ident = reinterpret_cast(ident); + GetImpl()->ClassDefinitionSetIdent(_context, _receiver, _ident); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionInternalNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionInternalNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ClassDefinitionInternalNameConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetInternalName(KNativePointer context, KNativePointer receiver, KStringPtr& internalName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _internalName = getStringCopy(internalName); + GetImpl()->ClassDefinitionSetInternalName(_context, _receiver, _internalName); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetInternalName, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_ClassDefinitionSuper(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionSuper(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionSuper, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionSuperConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionSuperConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionSuperConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetSuper(KNativePointer context, KNativePointer receiver, KNativePointer superClass) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _superClass = reinterpret_cast(superClass); + GetImpl()->ClassDefinitionSetSuper(_context, _receiver, _superClass); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetSuper, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsGlobalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsGlobalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsGlobalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsLocalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsLocalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsExternConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsExternConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsExternConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsFromExternalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsFromExternalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsFromExternalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsInnerConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsInnerConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsInnerConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsGlobalInitializedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsGlobalInitializedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsGlobalInitializedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsClassDefinitionCheckedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsClassDefinitionCheckedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsClassDefinitionCheckedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsAnonymousConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsAnonymousConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsAnonymousConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsNamespaceTransformedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsNamespaceTransformedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsNamespaceTransformedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionIsModuleConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionIsModuleConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionIsModuleConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetGlobalInitialized(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetGlobalInitialized(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetGlobalInitialized, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetInnerModifier(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetInnerModifier(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetInnerModifier, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetClassDefinitionChecked(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetClassDefinitionChecked(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetClassDefinitionChecked, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetAnonymousModifier(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetAnonymousModifier(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetAnonymousModifier, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetNamespaceTransformed(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ClassDefinitionSetNamespaceTransformed(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ClassDefinitionSetNamespaceTransformed, KNativePointer, KNativePointer); + +KInt impl_ClassDefinitionModifiersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionModifiersConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionModifiersConst, KInt, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetModifiers(KNativePointer context, KNativePointer receiver, KInt modifiers) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _modifiers = static_cast(modifiers); + GetImpl()->ClassDefinitionSetModifiers(_context, _receiver, _modifiers); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetModifiers, KNativePointer, KNativePointer, KInt); + +void impl_ClassDefinitionAddProperties(KNativePointer context, KNativePointer receiver, KNativePointerArray body, KUInt bodySequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + GetImpl()->ClassDefinitionAddProperties(_context, _receiver, _body, _bodySequenceLength); + return ; +} +KOALA_INTEROP_V4(ClassDefinitionAddProperties, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_ClassDefinitionBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionBody(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionBodyConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionCtor(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionCtor(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionCtor, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetCtor(KNativePointer context, KNativePointer receiver, KNativePointer ctor) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _ctor = reinterpret_cast(ctor); + GetImpl()->ClassDefinitionSetCtor(_context, _receiver, _ctor); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetCtor, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionImplements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionImplements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionImplements, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionImplementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionImplementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionImplementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionTypeParams, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetTypeParams(KNativePointer context, KNativePointer receiver, KNativePointer typeParams) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeParams = reinterpret_cast(typeParams); + GetImpl()->ClassDefinitionSetTypeParams(_context, _receiver, _typeParams); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionSuperTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionSuperTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionSuperTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionSuperTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionSuperTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionSuperTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_ClassDefinitionLocalTypeCounter(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionLocalTypeCounter(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionLocalTypeCounter, KInt, KNativePointer, KNativePointer); + +KInt impl_ClassDefinitionLocalIndexConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionLocalIndexConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionLocalIndexConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionLocalPrefixConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionLocalPrefixConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ClassDefinitionLocalPrefixConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetOrigEnumDecl(KNativePointer context, KNativePointer receiver, KNativePointer enumDecl) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _enumDecl = reinterpret_cast(enumDecl); + GetImpl()->ClassDefinitionSetOrigEnumDecl(_context, _receiver, _enumDecl); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetOrigEnumDecl, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionOrigEnumDeclConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionOrigEnumDeclConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionOrigEnumDeclConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionGetAnonClass(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionGetAnonClass(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionGetAnonClass, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetAnonClass(KNativePointer context, KNativePointer receiver, KNativePointer anonClass) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _anonClass = reinterpret_cast(anonClass); + GetImpl()->ClassDefinitionSetAnonClass(_context, _receiver, _anonClass); + return ; +} +KOALA_INTEROP_V3(ClassDefinitionSetAnonClass, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionCtorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionCtorConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDefinitionCtorConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionHasPrivateMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionHasPrivateMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionHasPrivateMethodConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionHasComputedInstanceFieldConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDefinitionHasComputedInstanceFieldConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDefinitionHasComputedInstanceFieldConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ClassDefinitionHasMatchingPrivateKeyConst(KNativePointer context, KNativePointer receiver, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _name = getStringCopy(name); + auto result = GetImpl()->ClassDefinitionHasMatchingPrivateKeyConst(_context, _receiver, _name); + return result; +} +KOALA_INTEROP_3(ClassDefinitionHasMatchingPrivateKeyConst, KBoolean, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_ClassDefinitionAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDefinitionAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDefinitionAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDefinitionAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ClassDefinitionSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ClassDefinitionSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ClassDefinitionSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateArrayExpression(KNativePointer context, KNativePointerArray elements, KUInt elementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + auto result = GetImpl()->CreateArrayExpression(_context, _elements, _elementsSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateArrayExpression, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateArrayExpression(KNativePointer context, KNativePointer original, KNativePointerArray elements, KUInt elementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + auto result = GetImpl()->UpdateArrayExpression(_context, _original, _elements, _elementsSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateArrayExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateArrayExpression1(KNativePointer context, KInt nodeType, KNativePointerArray elements, KUInt elementsSequenceLength, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _nodeType = static_cast(nodeType); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->CreateArrayExpression1(_context, _nodeType, _elements, _elementsSequenceLength, _trailingComma); + return result; +} +KOALA_INTEROP_5(CreateArrayExpression1, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_UpdateArrayExpression1(KNativePointer context, KNativePointer original, KInt nodeType, KNativePointerArray elements, KUInt elementsSequenceLength, KBoolean trailingComma) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _nodeType = static_cast(nodeType); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + const auto _trailingComma = static_cast(trailingComma); + auto result = GetImpl()->UpdateArrayExpression1(_context, _original, _nodeType, _elements, _elementsSequenceLength, _trailingComma); + return result; +} +KOALA_INTEROP_6(UpdateArrayExpression1, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointerArray, KUInt, KBoolean); + +KNativePointer impl_ArrayExpressionElementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrayExpressionElementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrayExpressionElementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrayExpressionElements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrayExpressionElements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrayExpressionElements, KNativePointer, KNativePointer, KNativePointer); + +void impl_ArrayExpressionSetElements(KNativePointer context, KNativePointer receiver, KNativePointerArray elements, KUInt elementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _elements = reinterpret_cast(elements); + const auto _elementsSequenceLength = static_cast(elementsSequenceLength); + GetImpl()->ArrayExpressionSetElements(_context, _receiver, _elements, _elementsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ArrayExpressionSetElements, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KBoolean impl_ArrayExpressionIsDeclarationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionIsDeclarationConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrayExpressionIsDeclarationConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ArrayExpressionIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrayExpressionIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ArrayExpressionSetDeclaration(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ArrayExpressionSetDeclaration(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ArrayExpressionSetDeclaration, KNativePointer, KNativePointer); + +void impl_ArrayExpressionSetOptional(KNativePointer context, KNativePointer receiver, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _optional_arg = static_cast(optional_arg); + GetImpl()->ArrayExpressionSetOptional(_context, _receiver, _optional_arg); + return ; +} +KOALA_INTEROP_V3(ArrayExpressionSetOptional, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ArrayExpressionDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrayExpressionDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrayExpressionDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ArrayExpressionConvertibleToArrayPattern(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionConvertibleToArrayPattern(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrayExpressionConvertibleToArrayPattern, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ArrayExpressionValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrayExpressionValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrayExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrayExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ArrayExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ArrayExpressionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->ArrayExpressionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(ArrayExpressionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSInterfaceBody(KNativePointer context, KNativePointerArray body, KUInt bodySequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + auto result = GetImpl()->CreateTSInterfaceBody(_context, _body, _bodySequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSInterfaceBody, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSInterfaceBody(KNativePointer context, KNativePointer original, KNativePointerArray body, KUInt bodySequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _body = reinterpret_cast(body); + const auto _bodySequenceLength = static_cast(bodySequenceLength); + auto result = GetImpl()->UpdateTSInterfaceBody(_context, _original, _body, _bodySequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSInterfaceBody, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSInterfaceBodyBodyPtr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceBodyBodyPtr(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceBodyBodyPtr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceBodyBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceBodyBody(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceBodyBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceBodyBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSInterfaceBodyBodyConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSInterfaceBodyBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeQuery(KNativePointer context, KNativePointer exprName) +{ + const auto _context = reinterpret_cast(context); + const auto _exprName = reinterpret_cast(exprName); + auto result = GetImpl()->CreateTSTypeQuery(_context, _exprName); + return result; +} +KOALA_INTEROP_2(CreateTSTypeQuery, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeQuery(KNativePointer context, KNativePointer original, KNativePointer exprName) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _exprName = reinterpret_cast(exprName); + auto result = GetImpl()->UpdateTSTypeQuery(_context, _original, _exprName); + return result; +} +KOALA_INTEROP_3(UpdateTSTypeQuery, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeQueryExprNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeQueryExprNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeQueryExprNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSBigintKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSBigintKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSBigintKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSBigintKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSBigintKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSBigintKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateProperty(KNativePointer context, KNativePointer key, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + auto result = GetImpl()->CreateProperty(_context, _key, _value); + return result; +} +KOALA_INTEROP_3(CreateProperty, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateProperty(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + auto result = GetImpl()->UpdateProperty(_context, _original, _key, _value); + return result; +} +KOALA_INTEROP_4(UpdateProperty, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateProperty1(KNativePointer context, KInt kind, KNativePointer key, KNativePointer value, KBoolean isMethod, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _isMethod = static_cast(isMethod); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->CreateProperty1(_context, _kind, _key, _value, _isMethod, _isComputed); + return result; +} +KOALA_INTEROP_6(CreateProperty1, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_UpdateProperty1(KNativePointer context, KNativePointer original, KInt kind, KNativePointer key, KNativePointer value, KBoolean isMethod, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _isMethod = static_cast(isMethod); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->UpdateProperty1(_context, _original, _kind, _key, _value, _isMethod, _isComputed); + return result; +} +KOALA_INTEROP_7(UpdateProperty1, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_PropertyKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PropertyKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(PropertyKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PropertyValueConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyValueConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(PropertyValueConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PropertyValue(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyValue(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyValue, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_PropertyKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyKindConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyIsMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyIsMethodConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsShorthandConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyIsShorthandConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyIsShorthandConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyIsComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyIsComputedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsAccessorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyIsAccessorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyIsAccessorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_PropertyIsAccessorKind(KNativePointer context, KNativePointer receiver, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _kind = static_cast(kind); + auto result = GetImpl()->PropertyIsAccessorKind(_context, _receiver, _kind); + return result; +} +KOALA_INTEROP_3(PropertyIsAccessorKind, KBoolean, KNativePointer, KNativePointer, KInt); + +KBoolean impl_PropertyConvertibleToPatternProperty(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyConvertibleToPatternProperty(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyConvertibleToPatternProperty, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_PropertyValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PropertyValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(PropertyValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateVariableDeclarator(KNativePointer context, KInt flag, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _flag = static_cast(flag); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->CreateVariableDeclarator(_context, _flag, _ident); + return result; +} +KOALA_INTEROP_3(CreateVariableDeclarator, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_UpdateVariableDeclarator(KNativePointer context, KNativePointer original, KInt flag, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _flag = static_cast(flag); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->UpdateVariableDeclarator(_context, _original, _flag, _ident); + return result; +} +KOALA_INTEROP_4(UpdateVariableDeclarator, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_CreateVariableDeclarator1(KNativePointer context, KInt flag, KNativePointer ident, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _flag = static_cast(flag); + const auto _ident = reinterpret_cast(ident); + const auto _init = reinterpret_cast(init); + auto result = GetImpl()->CreateVariableDeclarator1(_context, _flag, _ident, _init); + return result; +} +KOALA_INTEROP_4(CreateVariableDeclarator1, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateVariableDeclarator1(KNativePointer context, KNativePointer original, KInt flag, KNativePointer ident, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _flag = static_cast(flag); + const auto _ident = reinterpret_cast(ident); + const auto _init = reinterpret_cast(init); + auto result = GetImpl()->UpdateVariableDeclarator1(_context, _original, _flag, _ident, _init); + return result; +} +KOALA_INTEROP_5(UpdateVariableDeclarator1, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclaratorInit(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorInit(_context, _receiver); + return result; +} +KOALA_INTEROP_2(VariableDeclaratorInit, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclaratorInitConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorInitConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(VariableDeclaratorInitConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_VariableDeclaratorSetInit(KNativePointer context, KNativePointer receiver, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _init = reinterpret_cast(init); + GetImpl()->VariableDeclaratorSetInit(_context, _receiver, _init); + return ; +} +KOALA_INTEROP_V3(VariableDeclaratorSetInit, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclaratorId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(VariableDeclaratorId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_VariableDeclaratorIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(VariableDeclaratorIdConst, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_VariableDeclaratorFlag(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->VariableDeclaratorFlag(_context, _receiver); + return result; +} +KOALA_INTEROP_2(VariableDeclaratorFlag, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateStringLiteral(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateStringLiteral(_context); + return result; +} +KOALA_INTEROP_1(CreateStringLiteral, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateStringLiteral(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateStringLiteral(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateStringLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateStringLiteral1(KNativePointer context, KStringPtr& str) +{ + const auto _context = reinterpret_cast(context); + const auto _str = getStringCopy(str); + auto result = GetImpl()->CreateStringLiteral1(_context, _str); + return result; +} +KOALA_INTEROP_2(CreateStringLiteral1, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_UpdateStringLiteral1(KNativePointer context, KNativePointer original, KStringPtr& str) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _str = getStringCopy(str); + auto result = GetImpl()->UpdateStringLiteral1(_context, _original, _str); + return result; +} +KOALA_INTEROP_3(UpdateStringLiteral1, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_StringLiteralStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->StringLiteralStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(StringLiteralStrConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeAssertion(KNativePointer context, KNativePointer typeAnnotation, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->CreateTSTypeAssertion(_context, _typeAnnotation, _expression); + return result; +} +KOALA_INTEROP_3(CreateTSTypeAssertion, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeAssertion(KNativePointer context, KNativePointer original, KNativePointer typeAnnotation, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->UpdateTSTypeAssertion(_context, _original, _typeAnnotation, _expression); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeAssertion, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAssertionGetExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAssertionGetExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAssertionGetExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeAssertionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeAssertionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeAssertionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeAssertionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->TSTypeAssertionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(TSTypeAssertionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSExternalModuleReference(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateTSExternalModuleReference(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateTSExternalModuleReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSExternalModuleReference(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateTSExternalModuleReference(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateTSExternalModuleReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSExternalModuleReferenceExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSExternalModuleReferenceExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSExternalModuleReferenceExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSUndefinedKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSUndefinedKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSUndefinedKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSUndefinedKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSUndefinedKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSUndefinedKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSTuple(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateETSTuple(_context); + return result; +} +KOALA_INTEROP_1(CreateETSTuple, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSTuple(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateETSTuple(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateETSTuple, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSTuple1(KNativePointer context, KUInt size) +{ + const auto _context = reinterpret_cast(context); + const auto _size = static_cast(size); + auto result = GetImpl()->CreateETSTuple1(_context, _size); + return result; +} +KOALA_INTEROP_2(CreateETSTuple1, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_UpdateETSTuple1(KNativePointer context, KNativePointer original, KUInt size) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _size = static_cast(size); + auto result = GetImpl()->UpdateETSTuple1(_context, _original, _size); + return result; +} +KOALA_INTEROP_3(UpdateETSTuple1, KNativePointer, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_CreateETSTuple2(KNativePointer context, KNativePointerArray typeList, KUInt typeListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _typeList = reinterpret_cast(typeList); + const auto _typeListSequenceLength = static_cast(typeListSequenceLength); + auto result = GetImpl()->CreateETSTuple2(_context, _typeList, _typeListSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateETSTuple2, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateETSTuple2(KNativePointer context, KNativePointer original, KNativePointerArray typeList, KUInt typeListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeList = reinterpret_cast(typeList); + const auto _typeListSequenceLength = static_cast(typeListSequenceLength); + auto result = GetImpl()->UpdateETSTuple2(_context, _original, _typeList, _typeListSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateETSTuple2, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KUInt impl_ETSTupleGetTupleSizeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTupleGetTupleSizeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTupleGetTupleSizeConst, KUInt, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTupleGetTupleTypeAnnotationsListConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSTupleGetTupleTypeAnnotationsListConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSTupleGetTupleTypeAnnotationsListConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSTupleSetTypeAnnotationsList(KNativePointer context, KNativePointer receiver, KNativePointerArray typeNodeList, KUInt typeNodeListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeNodeList = reinterpret_cast(typeNodeList); + const auto _typeNodeListSequenceLength = static_cast(typeNodeListSequenceLength); + GetImpl()->ETSTupleSetTypeAnnotationsList(_context, _receiver, _typeNodeList, _typeNodeListSequenceLength); + return ; +} +KOALA_INTEROP_V4(ETSTupleSetTypeAnnotationsList, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TryStatementFinallyBlockConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementFinallyBlockConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TryStatementFinallyBlockConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TryStatementBlockConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementBlockConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TryStatementBlockConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TryStatementHasFinalizerConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementHasFinalizerConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TryStatementHasFinalizerConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TryStatementHasDefaultCatchClauseConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementHasDefaultCatchClauseConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TryStatementHasDefaultCatchClauseConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TryStatementCatchClausesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TryStatementCatchClausesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TryStatementCatchClausesConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TryStatementFinallyCanCompleteNormallyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TryStatementFinallyCanCompleteNormallyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TryStatementFinallyCanCompleteNormallyConst, KBoolean, KNativePointer, KNativePointer); + +void impl_TryStatementSetFinallyCanCompleteNormally(KNativePointer context, KNativePointer receiver, KBoolean finallyCanCompleteNormally) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _finallyCanCompleteNormally = static_cast(finallyCanCompleteNormally); + GetImpl()->TryStatementSetFinallyCanCompleteNormally(_context, _receiver, _finallyCanCompleteNormally); + return ; +} +KOALA_INTEROP_V3(TryStatementSetFinallyCanCompleteNormally, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_AstNodeIsProgramConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsProgramConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsProgramConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsStatementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsStatementConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsExpressionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsExpressionConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsTypedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsTypedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsTypedConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsTyped(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsTyped(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeAsTyped, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsTypedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsTypedConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeAsTypedConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsBrokenStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsBrokenStatementConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsBrokenStatementConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeAsExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeAsExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsStatement(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsStatement(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeAsStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsStatementConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeAsStatementConst, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_AstNodeTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeTypeConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeParent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeParent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeParent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeParentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeParentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeParentConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeSetParent(KNativePointer context, KNativePointer receiver, KNativePointer parent) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _parent = reinterpret_cast(parent); + GetImpl()->AstNodeSetParent(_context, _receiver, _parent); + return ; +} +KOALA_INTEROP_V3(AstNodeSetParent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeDecoratorsPtrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AstNodeDecoratorsPtrConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AstNodeDecoratorsPtrConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeAddDecorators(KNativePointer context, KNativePointer receiver, KNativePointerArray decorators, KUInt decoratorsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _decorators = reinterpret_cast(decorators); + const auto _decoratorsSequenceLength = static_cast(decoratorsSequenceLength); + GetImpl()->AstNodeAddDecorators(_context, _receiver, _decorators, _decoratorsSequenceLength); + return ; +} +KOALA_INTEROP_V4(AstNodeAddDecorators, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KBoolean impl_AstNodeCanHaveDecoratorConst(KNativePointer context, KNativePointer receiver, KBoolean inTs) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _inTs = static_cast(inTs); + auto result = GetImpl()->AstNodeCanHaveDecoratorConst(_context, _receiver, _inTs); + return result; +} +KOALA_INTEROP_3(AstNodeCanHaveDecoratorConst, KBoolean, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_AstNodeIsReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsReadonlyTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsReadonlyTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsReadonlyTypeConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsOptionalDeclarationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsOptionalDeclarationConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsOptionalDeclarationConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsDefiniteConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsDefiniteConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsDefiniteConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsConstructorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsConstructorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsConstructorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsOverrideConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsOverrideConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsOverrideConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AstNodeSetOverride(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AstNodeSetOverride(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AstNodeSetOverride, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsAsyncConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsAsyncConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsAsyncConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsSynchronizedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsSynchronizedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsSynchronizedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsNativeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsNativeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsNativeConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsConstConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsConstConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsConstConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsStaticConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsStaticConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsStaticConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsFinalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsFinalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsFinalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsAbstractConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsAbstractConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsAbstractConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsPublicConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsPublicConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsPublicConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsProtectedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsProtectedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsProtectedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsPrivateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsPrivateConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsPrivateConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsInternalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsInternalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsInternalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsExportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsExportedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsExportedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsDefaultExportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsDefaultExportedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsDefaultExportedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsExportedTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsExportedTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsExportedTypeConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsDeclareConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsDeclareConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsDeclareConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsInConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsInConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsInConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsOutConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsOutConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsOutConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsSetterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsSetterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsSetterConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AstNodeAddModifier(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + GetImpl()->AstNodeAddModifier(_context, _receiver, _flags); + return ; +} +KOALA_INTEROP_V3(AstNodeAddModifier, KNativePointer, KNativePointer, KInt); + +void impl_AstNodeClearModifier(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + GetImpl()->AstNodeClearModifier(_context, _receiver, _flags); + return ; +} +KOALA_INTEROP_V3(AstNodeClearModifier, KNativePointer, KNativePointer, KInt); + +KInt impl_AstNodeModifiers(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeModifiers(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeModifiers, KInt, KNativePointer, KNativePointer); + +KInt impl_AstNodeModifiersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeModifiersConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeModifiersConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeHasExportAliasConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeHasExportAliasConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeHasExportAliasConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsClassElement(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsClassElement(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeAsClassElement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeAsClassElementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeAsClassElementConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeAsClassElementConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_AstNodeIsScopeBearerConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeIsScopeBearerConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeIsScopeBearerConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AstNodeClearScope(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AstNodeClearScope(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AstNodeClearScope, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeGetTopStatement(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeGetTopStatement(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AstNodeGetTopStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeGetTopStatementConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeGetTopStatementConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeGetTopStatementConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeClone(KNativePointer context, KNativePointer receiver, KNativePointer parent) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _parent = reinterpret_cast(parent); + auto result = GetImpl()->AstNodeClone(_context, _receiver, _parent); + return result; +} +KOALA_INTEROP_3(AstNodeClone, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeDumpJSONConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeDumpJSONConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(AstNodeDumpJSONConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeDumpEtsSrcConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeDumpEtsSrcConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(AstNodeDumpEtsSrcConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeDumpConst(KNativePointer context, KNativePointer receiver, KNativePointer dumper) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _dumper = reinterpret_cast(dumper); + GetImpl()->AstNodeDumpConst(_context, _receiver, _dumper); + return ; +} +KOALA_INTEROP_V3(AstNodeDumpConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeDumpConst1(KNativePointer context, KNativePointer receiver, KNativePointer dumper) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _dumper = reinterpret_cast(dumper); + GetImpl()->AstNodeDumpConst1(_context, _receiver, _dumper); + return ; +} +KOALA_INTEROP_V3(AstNodeDumpConst1, KNativePointer, KNativePointer, KNativePointer); + +void impl_AstNodeSetTransformedNode(KNativePointer context, KNativePointer receiver, KStringPtr& transformationName, KNativePointer transformedNode) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _transformationName = getStringCopy(transformationName); + const auto _transformedNode = reinterpret_cast(transformedNode); + GetImpl()->AstNodeSetTransformedNode(_context, _receiver, _transformationName, _transformedNode); + return ; +} +KOALA_INTEROP_V4(AstNodeSetTransformedNode, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + +void impl_AstNodeSetOriginalNode(KNativePointer context, KNativePointer receiver, KNativePointer originalNode) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _originalNode = reinterpret_cast(originalNode); + GetImpl()->AstNodeSetOriginalNode(_context, _receiver, _originalNode); + return ; +} +KOALA_INTEROP_V3(AstNodeSetOriginalNode, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AstNodeOriginalNodeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstNodeOriginalNodeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AstNodeOriginalNodeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateUnaryExpression(KNativePointer context, KNativePointer argument, KInt unaryOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + const auto _unaryOperator = static_cast(unaryOperator); + auto result = GetImpl()->CreateUnaryExpression(_context, _argument, _unaryOperator); + return result; +} +KOALA_INTEROP_3(CreateUnaryExpression, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateUnaryExpression(KNativePointer context, KNativePointer original, KNativePointer argument, KInt unaryOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + const auto _unaryOperator = static_cast(unaryOperator); + auto result = GetImpl()->UpdateUnaryExpression(_context, _original, _argument, _unaryOperator); + return result; +} +KOALA_INTEROP_4(UpdateUnaryExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KInt impl_UnaryExpressionOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UnaryExpressionOperatorTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UnaryExpressionOperatorTypeConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_UnaryExpressionArgument(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UnaryExpressionArgument(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UnaryExpressionArgument, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UnaryExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UnaryExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(UnaryExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateForInStatement(KNativePointer context, KNativePointer left, KNativePointer right, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateForInStatement(_context, _left, _right, _body); + return result; +} +KOALA_INTEROP_4(CreateForInStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateForInStatement(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->UpdateForInStatement(_context, _original, _left, _right, _body); + return result; +} +KOALA_INTEROP_5(UpdateForInStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForInStatementLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForInStatementLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForInStatementRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForInStatementRightConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForInStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForInStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForInStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForInStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateThisExpression(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateThisExpression(_context); + return result; +} +KOALA_INTEROP_1(CreateThisExpression, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateThisExpression(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateThisExpression(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateThisExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSMethodSignature(KNativePointer context, KNativePointer key, KNativePointer signature, KBoolean computed, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _signature = reinterpret_cast(signature); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->CreateTSMethodSignature(_context, _key, _signature, _computed, _optional_arg); + return result; +} +KOALA_INTEROP_5(CreateTSMethodSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSMethodSignature(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer signature, KBoolean computed, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _signature = reinterpret_cast(signature); + const auto _computed = static_cast(computed); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->UpdateTSMethodSignature(_context, _original, _key, _signature, _computed, _optional_arg); + return result; +} +KOALA_INTEROP_6(UpdateTSMethodSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_TSMethodSignatureKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSMethodSignatureKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSMethodSignatureTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSMethodSignatureParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSMethodSignatureParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureReturnTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureReturnTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSMethodSignatureReturnTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMethodSignatureReturnTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureReturnTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureReturnTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSMethodSignatureComputedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureComputedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureComputedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSMethodSignatureOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMethodSignatureOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMethodSignatureOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBinaryExpression(KNativePointer context, KNativePointer left, KNativePointer right, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->CreateBinaryExpression(_context, _left, _right, _operatorType); + return result; +} +KOALA_INTEROP_4(CreateBinaryExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateBinaryExpression(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->UpdateBinaryExpression(_context, _original, _left, _right, _operatorType); + return result; +} +KOALA_INTEROP_5(UpdateBinaryExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_BinaryExpressionLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BinaryExpressionLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BinaryExpressionRightConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionResultConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionResultConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BinaryExpressionResultConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BinaryExpressionResult(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionResult(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionResult, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_BinaryExpressionOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionOperatorTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionOperatorTypeConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_BinaryExpressionIsLogicalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionIsLogicalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionIsLogicalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_BinaryExpressionIsLogicalExtendedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionIsLogicalExtendedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionIsLogicalExtendedConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_BinaryExpressionIsBitwiseConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionIsBitwiseConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionIsBitwiseConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_BinaryExpressionIsArithmeticConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BinaryExpressionIsArithmeticConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BinaryExpressionIsArithmeticConst, KBoolean, KNativePointer, KNativePointer); + +void impl_BinaryExpressionSetLeft(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->BinaryExpressionSetLeft(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(BinaryExpressionSetLeft, KNativePointer, KNativePointer, KNativePointer); + +void impl_BinaryExpressionSetRight(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->BinaryExpressionSetRight(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(BinaryExpressionSetRight, KNativePointer, KNativePointer, KNativePointer); + +void impl_BinaryExpressionSetResult(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->BinaryExpressionSetResult(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(BinaryExpressionSetResult, KNativePointer, KNativePointer, KNativePointer); + +void impl_BinaryExpressionSetOperator(KNativePointer context, KNativePointer receiver, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _operatorType = static_cast(operatorType); + GetImpl()->BinaryExpressionSetOperator(_context, _receiver, _operatorType); + return ; +} +KOALA_INTEROP_V3(BinaryExpressionSetOperator, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_CreateSuperExpression(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateSuperExpression(_context); + return result; +} +KOALA_INTEROP_1(CreateSuperExpression, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateSuperExpression(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateSuperExpression(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateSuperExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAssertStatement(KNativePointer context, KNativePointer test, KNativePointer second) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _second = reinterpret_cast(second); + auto result = GetImpl()->CreateAssertStatement(_context, _test, _second); + return result; +} +KOALA_INTEROP_3(CreateAssertStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateAssertStatement(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointer second) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _second = reinterpret_cast(second); + auto result = GetImpl()->UpdateAssertStatement(_context, _original, _test, _second); + return result; +} +KOALA_INTEROP_4(UpdateAssertStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssertStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssertStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssertStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssertStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssertStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssertStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssertStatementSecondConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssertStatementSecondConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssertStatementSecondConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSStringKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSStringKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSStringKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSStringKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSStringKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSStringKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAssignmentExpression(KNativePointer context, KNativePointer left, KNativePointer right, KInt assignmentOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _assignmentOperator = static_cast(assignmentOperator); + auto result = GetImpl()->CreateAssignmentExpression(_context, _left, _right, _assignmentOperator); + return result; +} +KOALA_INTEROP_4(CreateAssignmentExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateAssignmentExpression(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right, KInt assignmentOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _assignmentOperator = static_cast(assignmentOperator); + auto result = GetImpl()->UpdateAssignmentExpression(_context, _original, _left, _right, _assignmentOperator); + return result; +} +KOALA_INTEROP_5(UpdateAssignmentExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_CreateAssignmentExpression1(KNativePointer context, KInt type, KNativePointer left, KNativePointer right, KInt assignmentOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _type = static_cast(type); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _assignmentOperator = static_cast(assignmentOperator); + auto result = GetImpl()->CreateAssignmentExpression1(_context, _type, _left, _right, _assignmentOperator); + return result; +} +KOALA_INTEROP_5(CreateAssignmentExpression1, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateAssignmentExpression1(KNativePointer context, KNativePointer original, KInt type, KNativePointer left, KNativePointer right, KInt assignmentOperator) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _type = static_cast(type); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _assignmentOperator = static_cast(assignmentOperator); + auto result = GetImpl()->UpdateAssignmentExpression1(_context, _original, _type, _left, _right, _assignmentOperator); + return result; +} +KOALA_INTEROP_6(UpdateAssignmentExpression1, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_AssignmentExpressionLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssignmentExpressionLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssignmentExpressionRightConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AssignmentExpressionSetRight(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->AssignmentExpressionSetRight(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(AssignmentExpressionSetRight, KNativePointer, KNativePointer, KNativePointer); + +void impl_AssignmentExpressionSetLeft(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->AssignmentExpressionSetLeft(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(AssignmentExpressionSetLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionResultConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionResultConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AssignmentExpressionResultConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AssignmentExpressionResult(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionResult(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionResult, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_AssignmentExpressionOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionOperatorTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionOperatorTypeConst, KInt, KNativePointer, KNativePointer); + +KInt impl_AssignmentExpressionSetOperatorType(KNativePointer context, KNativePointer receiver, KInt tokenType) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _tokenType = static_cast(tokenType); + auto result = GetImpl()->AssignmentExpressionSetOperatorType(_context, _receiver, _tokenType); + return result; +} +KOALA_INTEROP_3(AssignmentExpressionSetOperatorType, KInt, KNativePointer, KNativePointer, KInt); + +void impl_AssignmentExpressionSetResult(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->AssignmentExpressionSetResult(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(AssignmentExpressionSetResult, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_AssignmentExpressionIsLogicalExtendedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionIsLogicalExtendedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionIsLogicalExtendedConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AssignmentExpressionSetIgnoreConstAssign(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AssignmentExpressionSetIgnoreConstAssign(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AssignmentExpressionSetIgnoreConstAssign, KNativePointer, KNativePointer); + +KBoolean impl_AssignmentExpressionIsIgnoreConstAssignConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionIsIgnoreConstAssignConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionIsIgnoreConstAssignConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AssignmentExpressionConvertibleToAssignmentPatternLeft(KNativePointer context, KNativePointer receiver, KBoolean mustBePattern) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _mustBePattern = static_cast(mustBePattern); + auto result = GetImpl()->AssignmentExpressionConvertibleToAssignmentPatternLeft(_context, _receiver, _mustBePattern); + return result; +} +KOALA_INTEROP_3(AssignmentExpressionConvertibleToAssignmentPatternLeft, KBoolean, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_AssignmentExpressionConvertibleToAssignmentPatternRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AssignmentExpressionConvertibleToAssignmentPatternRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AssignmentExpressionConvertibleToAssignmentPatternRight, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AssignmentExpressionConvertibleToAssignmentPattern(KNativePointer context, KNativePointer receiver, KBoolean mustBePattern) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _mustBePattern = static_cast(mustBePattern); + auto result = GetImpl()->AssignmentExpressionConvertibleToAssignmentPattern(_context, _receiver, _mustBePattern); + return result; +} +KOALA_INTEROP_3(AssignmentExpressionConvertibleToAssignmentPattern, KBoolean, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_CreateExpressionStatement(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateExpressionStatement(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateExpressionStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExpressionStatement(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateExpressionStatement(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateExpressionStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionStatementGetExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionStatementGetExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExpressionStatementGetExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionStatementGetExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionStatementGetExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionStatementGetExpression, KNativePointer, KNativePointer, KNativePointer); + +void impl_ExpressionStatementSetExpression(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ExpressionStatementSetExpression(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ExpressionStatementSetExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSModuleIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSModuleIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSModuleIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSModuleIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ETSModuleIsETSScriptConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIsETSScriptConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSModuleIsETSScriptConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ETSModuleIsNamespaceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIsNamespaceConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSModuleIsNamespaceConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ETSModuleIsNamespaceChainLastNodeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSModuleIsNamespaceChainLastNodeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSModuleIsNamespaceChainLastNodeConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ETSModuleSetNamespaceChainLastNode(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ETSModuleSetNamespaceChainLastNode(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ETSModuleSetNamespaceChainLastNode, KNativePointer, KNativePointer); + +KNativePointer impl_ETSModuleAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSModuleAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSModuleAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSModuleAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSModuleAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSModuleAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSModuleSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ETSModuleSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ETSModuleSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateMetaProperty(KNativePointer context, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + auto result = GetImpl()->CreateMetaProperty(_context, _kind); + return result; +} +KOALA_INTEROP_2(CreateMetaProperty, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateMetaProperty(KNativePointer context, KNativePointer original, KInt kind) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + auto result = GetImpl()->UpdateMetaProperty(_context, _original, _kind); + return result; +} +KOALA_INTEROP_3(UpdateMetaProperty, KNativePointer, KNativePointer, KNativePointer, KInt); + +KInt impl_MetaPropertyKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MetaPropertyKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MetaPropertyKindConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSArrayType(KNativePointer context, KNativePointer elementType) +{ + const auto _context = reinterpret_cast(context); + const auto _elementType = reinterpret_cast(elementType); + auto result = GetImpl()->CreateTSArrayType(_context, _elementType); + return result; +} +KOALA_INTEROP_2(CreateTSArrayType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSArrayType(KNativePointer context, KNativePointer original, KNativePointer elementType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _elementType = reinterpret_cast(elementType); + auto result = GetImpl()->UpdateTSArrayType(_context, _original, _elementType); + return result; +} +KOALA_INTEROP_3(UpdateTSArrayType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSArrayTypeElementTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSArrayTypeElementTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSArrayTypeElementTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSSignatureDeclaration(KNativePointer context, KInt kind, KNativePointer signature) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + const auto _signature = reinterpret_cast(signature); + auto result = GetImpl()->CreateTSSignatureDeclaration(_context, _kind, _signature); + return result; +} +KOALA_INTEROP_3(CreateTSSignatureDeclaration, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_UpdateTSSignatureDeclaration(KNativePointer context, KNativePointer original, KInt kind, KNativePointer signature) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + const auto _signature = reinterpret_cast(signature); + auto result = GetImpl()->UpdateTSSignatureDeclaration(_context, _original, _kind, _signature); + return result; +} +KOALA_INTEROP_4(UpdateTSSignatureDeclaration, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSSignatureDeclarationTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSSignatureDeclarationTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSSignatureDeclarationParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSSignatureDeclarationParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationReturnTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationReturnTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSSignatureDeclarationReturnTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSSignatureDeclarationReturnTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationReturnTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSSignatureDeclarationReturnTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_TSSignatureDeclarationKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSSignatureDeclarationKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSSignatureDeclarationKindConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateExportAllDeclaration(KNativePointer context, KNativePointer source, KNativePointer exported) +{ + const auto _context = reinterpret_cast(context); + const auto _source = reinterpret_cast(source); + const auto _exported = reinterpret_cast(exported); + auto result = GetImpl()->CreateExportAllDeclaration(_context, _source, _exported); + return result; +} +KOALA_INTEROP_3(CreateExportAllDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExportAllDeclaration(KNativePointer context, KNativePointer original, KNativePointer source, KNativePointer exported) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _source = reinterpret_cast(source); + const auto _exported = reinterpret_cast(exported); + auto result = GetImpl()->UpdateExportAllDeclaration(_context, _original, _source, _exported); + return result; +} +KOALA_INTEROP_4(UpdateExportAllDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportAllDeclarationSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportAllDeclarationSourceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportAllDeclarationSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportAllDeclarationExportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportAllDeclarationExportedConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportAllDeclarationExportedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateExportSpecifier(KNativePointer context, KNativePointer local, KNativePointer exported) +{ + const auto _context = reinterpret_cast(context); + const auto _local = reinterpret_cast(local); + const auto _exported = reinterpret_cast(exported); + auto result = GetImpl()->CreateExportSpecifier(_context, _local, _exported); + return result; +} +KOALA_INTEROP_3(CreateExportSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExportSpecifier(KNativePointer context, KNativePointer original, KNativePointer local, KNativePointer exported) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _local = reinterpret_cast(local); + const auto _exported = reinterpret_cast(exported); + auto result = GetImpl()->UpdateExportSpecifier(_context, _original, _local, _exported); + return result; +} +KOALA_INTEROP_4(UpdateExportSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportSpecifierLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportSpecifierLocalConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportSpecifierLocalConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportSpecifierExportedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportSpecifierExportedConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportSpecifierExportedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTupleType(KNativePointer context, KNativePointerArray elementTypes, KUInt elementTypesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _elementTypes = reinterpret_cast(elementTypes); + const auto _elementTypesSequenceLength = static_cast(elementTypesSequenceLength); + auto result = GetImpl()->CreateTSTupleType(_context, _elementTypes, _elementTypesSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSTupleType, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSTupleType(KNativePointer context, KNativePointer original, KNativePointerArray elementTypes, KUInt elementTypesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _elementTypes = reinterpret_cast(elementTypes); + const auto _elementTypesSequenceLength = static_cast(elementTypesSequenceLength); + auto result = GetImpl()->UpdateTSTupleType(_context, _original, _elementTypes, _elementTypesSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSTupleType, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSTupleTypeElementTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTupleTypeElementTypeConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTupleTypeElementTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateFunctionExpression(KNativePointer context, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->CreateFunctionExpression(_context, _func); + return result; +} +KOALA_INTEROP_2(CreateFunctionExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateFunctionExpression(KNativePointer context, KNativePointer original, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->UpdateFunctionExpression(_context, _original, _func); + return result; +} +KOALA_INTEROP_3(UpdateFunctionExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateFunctionExpression1(KNativePointer context, KNativePointer namedExpr, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _namedExpr = reinterpret_cast(namedExpr); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->CreateFunctionExpression1(_context, _namedExpr, _func); + return result; +} +KOALA_INTEROP_3(CreateFunctionExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateFunctionExpression1(KNativePointer context, KNativePointer original, KNativePointer namedExpr, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _namedExpr = reinterpret_cast(namedExpr); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->UpdateFunctionExpression1(_context, _original, _namedExpr, _func); + return result; +} +KOALA_INTEROP_4(UpdateFunctionExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionExpressionFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionExpressionFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(FunctionExpressionFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionExpressionFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionExpressionFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionExpressionFunction, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_FunctionExpressionIsAnonymousConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionExpressionIsAnonymousConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionExpressionIsAnonymousConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionExpressionId(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionExpressionId(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionExpressionId, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSIndexSignature(KNativePointer context, KNativePointer param, KNativePointer typeAnnotation, KBoolean readonly_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _param = reinterpret_cast(param); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _readonly_arg = static_cast(readonly_arg); + auto result = GetImpl()->CreateTSIndexSignature(_context, _param, _typeAnnotation, _readonly_arg); + return result; +} +KOALA_INTEROP_4(CreateTSIndexSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSIndexSignature(KNativePointer context, KNativePointer original, KNativePointer param, KNativePointer typeAnnotation, KBoolean readonly_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _param = reinterpret_cast(param); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _readonly_arg = static_cast(readonly_arg); + auto result = GetImpl()->UpdateTSIndexSignature(_context, _original, _param, _typeAnnotation, _readonly_arg); + return result; +} +KOALA_INTEROP_5(UpdateTSIndexSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSIndexSignatureParamConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexSignatureParamConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSIndexSignatureParamConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSIndexSignatureTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexSignatureTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSIndexSignatureTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSIndexSignatureReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexSignatureReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSIndexSignatureReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KInt impl_TSIndexSignatureKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexSignatureKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSIndexSignatureKindConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSModuleDeclaration(KNativePointer context, KNativePointer name, KNativePointer body, KBoolean declare, KBoolean _global) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + const auto _body = reinterpret_cast(body); + const auto _declare = static_cast(declare); + const auto __global = static_cast(_global); + auto result = GetImpl()->CreateTSModuleDeclaration(_context, _name, _body, _declare, __global); + return result; +} +KOALA_INTEROP_5(CreateTSModuleDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSModuleDeclaration(KNativePointer context, KNativePointer original, KNativePointer name, KNativePointer body, KBoolean declare, KBoolean _global) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + const auto _body = reinterpret_cast(body); + const auto _declare = static_cast(declare); + const auto __global = static_cast(_global); + auto result = GetImpl()->UpdateTSModuleDeclaration(_context, _original, _name, _body, _declare, __global); + return result; +} +KOALA_INTEROP_6(UpdateTSModuleDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_TSModuleDeclarationNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSModuleDeclarationNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSModuleDeclarationNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSModuleDeclarationBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSModuleDeclarationBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSModuleDeclarationBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSModuleDeclarationGlobalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSModuleDeclarationGlobalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSModuleDeclarationGlobalConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSModuleDeclarationIsExternalOrAmbientConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSModuleDeclarationIsExternalOrAmbientConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSModuleDeclarationIsExternalOrAmbientConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportDeclaration(KNativePointer context, KNativePointer source, KNativePointerArray specifiers, KUInt specifiersSequenceLength, KInt importKind) +{ + const auto _context = reinterpret_cast(context); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + const auto _importKind = static_cast(importKind); + auto result = GetImpl()->CreateImportDeclaration(_context, _source, _specifiers, _specifiersSequenceLength, _importKind); + return result; +} +KOALA_INTEROP_5(CreateImportDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt); + +KNativePointer impl_UpdateImportDeclaration(KNativePointer context, KNativePointer original, KNativePointer source, KNativePointerArray specifiers, KUInt specifiersSequenceLength, KInt importKind) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + const auto _importKind = static_cast(importKind); + auto result = GetImpl()->UpdateImportDeclaration(_context, _original, _source, _specifiers, _specifiersSequenceLength, _importKind); + return result; +} +KOALA_INTEROP_6(UpdateImportDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt); + +KNativePointer impl_ImportDeclarationSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDeclarationSourceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportDeclarationSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDeclarationSource(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDeclarationSource(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportDeclarationSource, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDeclarationSpecifiersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ImportDeclarationSpecifiersConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ImportDeclarationSpecifiersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportDeclarationSpecifiers(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ImportDeclarationSpecifiers(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ImportDeclarationSpecifiers, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ImportDeclarationIsTypeKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportDeclarationIsTypeKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportDeclarationIsTypeKindConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSParenthesizedType(KNativePointer context, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->CreateTSParenthesizedType(_context, _type); + return result; +} +KOALA_INTEROP_2(CreateTSParenthesizedType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSParenthesizedType(KNativePointer context, KNativePointer original, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->UpdateTSParenthesizedType(_context, _original, _type); + return result; +} +KOALA_INTEROP_3(UpdateTSParenthesizedType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSParenthesizedTypeTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParenthesizedTypeTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSParenthesizedTypeTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateCharLiteral(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateCharLiteral(_context); + return result; +} +KOALA_INTEROP_1(CreateCharLiteral, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateCharLiteral(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateCharLiteral(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateCharLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSPackageDeclaration(KNativePointer context, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->CreateETSPackageDeclaration(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateETSPackageDeclaration, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSPackageDeclaration(KNativePointer context, KNativePointer original, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->UpdateETSPackageDeclaration(_context, _original, _name); + return result; +} +KOALA_INTEROP_3(UpdateETSPackageDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSImportDeclaration(KNativePointer context, KNativePointer source , KNativePointerArray specifiers, KUInt specifiersSequenceLength, KInt importKind) +{ + const auto _context = reinterpret_cast(context); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + const auto _importKind = static_cast(importKind); + auto result = GetImpl()->ETSParserBuildImportDeclaration(_context, _importKind, _specifiers, _specifiersSequenceLength, _source); + return result; +} +KOALA_INTEROP_5(CreateETSImportDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt); + +KNativePointer impl_UpdateETSImportDeclaration(KNativePointer context, KNativePointer original, KNativePointer source, KNativePointerArray specifiers, KUInt specifiersSequenceLength, KInt importKind) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + const auto _importKind = static_cast(importKind); + auto result = GetImpl()->UpdateETSImportDeclaration(_context, _original, _source, _specifiers, _specifiersSequenceLength, _importKind); + return result; +} +KOALA_INTEROP_6(UpdateETSImportDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KInt); + +KNativePointer impl_ETSImportDeclarationAssemblerName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationAssemblerName(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSImportDeclarationAssemblerName, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSImportDeclarationAssemblerNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationAssemblerNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSImportDeclarationAssemblerNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSImportDeclarationResolvedSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSImportDeclarationResolvedSourceConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSImportDeclarationResolvedSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSStructDeclaration(KNativePointer context, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->CreateETSStructDeclaration(_context, _def); + return result; +} +KOALA_INTEROP_2(CreateETSStructDeclaration, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSStructDeclaration(KNativePointer context, KNativePointer original, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->UpdateETSStructDeclaration(_context, _original, _def); + return result; +} +KOALA_INTEROP_3(UpdateETSStructDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSModuleBlock(KNativePointer context, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + auto result = GetImpl()->CreateTSModuleBlock(_context, _statements, _statementsSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSModuleBlock, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSModuleBlock(KNativePointer context, KNativePointer original, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + auto result = GetImpl()->UpdateTSModuleBlock(_context, _original, _statements, _statementsSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSModuleBlock, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSModuleBlockStatementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSModuleBlockStatementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSModuleBlockStatementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSNewArrayInstanceExpression(KNativePointer context, KNativePointer typeReference, KNativePointer dimension) +{ + const auto _context = reinterpret_cast(context); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _dimension = reinterpret_cast(dimension); + auto result = GetImpl()->CreateETSNewArrayInstanceExpression(_context, _typeReference, _dimension); + return result; +} +KOALA_INTEROP_3(CreateETSNewArrayInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSNewArrayInstanceExpression(KNativePointer context, KNativePointer original, KNativePointer typeReference, KNativePointer dimension) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _dimension = reinterpret_cast(dimension); + auto result = GetImpl()->UpdateETSNewArrayInstanceExpression(_context, _original, _typeReference, _dimension); + return result; +} +KOALA_INTEROP_4(UpdateETSNewArrayInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewArrayInstanceExpressionTypeReference(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewArrayInstanceExpressionTypeReference(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSNewArrayInstanceExpressionTypeReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewArrayInstanceExpressionTypeReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewArrayInstanceExpressionTypeReferenceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSNewArrayInstanceExpressionTypeReferenceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewArrayInstanceExpressionDimension(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewArrayInstanceExpressionDimension(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSNewArrayInstanceExpressionDimension, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewArrayInstanceExpressionDimensionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewArrayInstanceExpressionDimensionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSNewArrayInstanceExpressionDimensionConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSNewArrayInstanceExpressionSetDimension(KNativePointer context, KNativePointer receiver, KNativePointer dimension) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _dimension = reinterpret_cast(dimension); + GetImpl()->ETSNewArrayInstanceExpressionSetDimension(_context, _receiver, _dimension); + return ; +} +KOALA_INTEROP_V3(ETSNewArrayInstanceExpressionSetDimension, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAnnotationDeclaration(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateAnnotationDeclaration(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateAnnotationDeclaration, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateAnnotationDeclaration(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateAnnotationDeclaration(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateAnnotationDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAnnotationDeclaration1(KNativePointer context, KNativePointer expr, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + auto result = GetImpl()->CreateAnnotationDeclaration1(_context, _expr, _properties, _propertiesSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateAnnotationDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateAnnotationDeclaration1(KNativePointer context, KNativePointer original, KNativePointer expr, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + auto result = GetImpl()->UpdateAnnotationDeclaration1(_context, _original, _expr, _properties, _propertiesSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateAnnotationDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_AnnotationDeclarationInternalNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationInternalNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(AnnotationDeclarationInternalNameConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetInternalName(KNativePointer context, KNativePointer receiver, KStringPtr& internalName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _internalName = getStringCopy(internalName); + GetImpl()->AnnotationDeclarationSetInternalName(_context, _receiver, _internalName); + return ; +} +KOALA_INTEROP_V3(AnnotationDeclarationSetInternalName, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_AnnotationDeclarationExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AnnotationDeclarationExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationDeclarationExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationProperties(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationDeclarationProperties(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationDeclarationProperties, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationPropertiesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationDeclarationPropertiesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationDeclarationPropertiesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationPropertiesPtrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationDeclarationPropertiesPtrConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationDeclarationPropertiesPtrConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationAddProperties(KNativePointer context, KNativePointer receiver, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + GetImpl()->AnnotationDeclarationAddProperties(_context, _receiver, _properties, _propertiesSequenceLength); + return ; +} +KOALA_INTEROP_V4(AnnotationDeclarationAddProperties, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KBoolean impl_AnnotationDeclarationIsSourceRetentionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationIsSourceRetentionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationDeclarationIsSourceRetentionConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AnnotationDeclarationIsBytecodeRetentionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationIsBytecodeRetentionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationDeclarationIsBytecodeRetentionConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_AnnotationDeclarationIsRuntimeRetentionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationIsRuntimeRetentionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationDeclarationIsRuntimeRetentionConst, KBoolean, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetSourceRetention(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AnnotationDeclarationSetSourceRetention(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AnnotationDeclarationSetSourceRetention, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetBytecodeRetention(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AnnotationDeclarationSetBytecodeRetention(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AnnotationDeclarationSetBytecodeRetention, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetRuntimeRetention(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->AnnotationDeclarationSetRuntimeRetention(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(AnnotationDeclarationSetRuntimeRetention, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationGetBaseNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationDeclarationGetBaseNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AnnotationDeclarationGetBaseNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationDeclarationAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationDeclarationAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationDeclarationAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationDeclarationAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationDeclarationAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationDeclarationSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->AnnotationDeclarationSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(AnnotationDeclarationSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateAnnotationUsageIr(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateAnnotationUsageIr(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateAnnotationUsageIr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateAnnotationUsageIr(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateAnnotationUsageIr(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateAnnotationUsageIr, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAnnotationUsageIr1(KNativePointer context, KNativePointer expr, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + auto result = GetImpl()->CreateAnnotationUsageIr1(_context, _expr, _properties, _propertiesSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateAnnotationUsageIr1, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateAnnotationUsageIr1(KNativePointer context, KNativePointer original, KNativePointer expr, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + auto result = GetImpl()->UpdateAnnotationUsageIr1(_context, _original, _expr, _properties, _propertiesSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateAnnotationUsageIr1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_AnnotationUsageIrExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationUsageIrExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(AnnotationUsageIrExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationUsageIrProperties(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationUsageIrProperties(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationUsageIrProperties, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationUsageIrPropertiesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationUsageIrPropertiesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationUsageIrPropertiesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotationUsageIrPropertiesPtrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->AnnotationUsageIrPropertiesPtrConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(AnnotationUsageIrPropertiesPtrConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationUsageIrAddProperty(KNativePointer context, KNativePointer receiver, KNativePointer property) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _property = reinterpret_cast(property); + GetImpl()->AnnotationUsageIrAddProperty(_context, _receiver, _property); + return ; +} +KOALA_INTEROP_V3(AnnotationUsageIrAddProperty, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotationUsageIrSetProperties(KNativePointer context, KNativePointer receiver, KNativePointerArray properties, KUInt propertiesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _properties = reinterpret_cast(properties); + const auto _propertiesSequenceLength = static_cast(propertiesSequenceLength); + GetImpl()->AnnotationUsageIrSetProperties(_context, _receiver, _properties, _propertiesSequenceLength); + return ; +} +KOALA_INTEROP_V4(AnnotationUsageIrSetProperties, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_AnnotationUsageIrGetBaseNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotationUsageIrGetBaseNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AnnotationUsageIrGetBaseNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateEmptyStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateEmptyStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateEmptyStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateEmptyStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateEmptyStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateEmptyStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSLaunchExpression(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateETSLaunchExpression(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateETSLaunchExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSLaunchExpression(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateETSLaunchExpression(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateETSLaunchExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ETSLaunchExpressionIsStaticCallConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSLaunchExpressionIsStaticCallConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSLaunchExpressionIsStaticCallConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ETSLaunchExpressionCallConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSLaunchExpressionCallConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSLaunchExpressionCallConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateWhileStatement(KNativePointer context, KNativePointer test, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateWhileStatement(_context, _test, _body); + return result; +} +KOALA_INTEROP_3(CreateWhileStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateWhileStatement(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->UpdateWhileStatement(_context, _original, _test, _body); + return result; +} +KOALA_INTEROP_4(UpdateWhileStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_WhileStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->WhileStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(WhileStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_WhileStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->WhileStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(WhileStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_WhileStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->WhileStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(WhileStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_WhileStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->WhileStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(WhileStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateFunctionSignature(KNativePointer context, KNativePointer typeParams, KNativePointerArray params, KUInt paramsSequenceLength, KNativePointer returnTypeAnnotation, KBoolean hasReceiver) +{ + const auto _context = reinterpret_cast(context); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + const auto _returnTypeAnnotation = reinterpret_cast(returnTypeAnnotation); + const auto _hasReceiver = static_cast(hasReceiver); + auto result = GetImpl()->CreateFunctionSignature(_context, _typeParams, _params, _paramsSequenceLength, _returnTypeAnnotation, _hasReceiver); + return result; +} +KOALA_INTEROP_6(CreateFunctionSignature, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KBoolean); + +KNativePointer impl_FunctionSignatureParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->FunctionSignatureParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(FunctionSignatureParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->FunctionSignatureParams(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(FunctionSignatureParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionSignatureTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureTypeParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureTypeParamsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(FunctionSignatureTypeParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureReturnType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureReturnType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionSignatureReturnType, KNativePointer, KNativePointer, KNativePointer); + +void impl_FunctionSignatureSetReturnType(KNativePointer context, KNativePointer receiver, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _type = reinterpret_cast(type); + GetImpl()->FunctionSignatureSetReturnType(_context, _receiver, _type); + return ; +} +KOALA_INTEROP_V3(FunctionSignatureSetReturnType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureReturnTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureReturnTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(FunctionSignatureReturnTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_FunctionSignatureClone(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureClone(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionSignatureClone, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_FunctionSignatureHasReceiverConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->FunctionSignatureHasReceiverConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(FunctionSignatureHasReceiverConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateChainExpression(KNativePointer context, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->CreateChainExpression(_context, _expression); + return result; +} +KOALA_INTEROP_2(CreateChainExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateChainExpression(KNativePointer context, KNativePointer original, KNativePointer expression) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expression = reinterpret_cast(expression); + auto result = GetImpl()->UpdateChainExpression(_context, _original, _expression); + return result; +} +KOALA_INTEROP_3(UpdateChainExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ChainExpressionGetExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ChainExpressionGetExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ChainExpressionGetExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ChainExpressionGetExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ChainExpressionGetExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ChainExpressionGetExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSIntersectionType(KNativePointer context, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->CreateTSIntersectionType(_context, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSIntersectionType, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSIntersectionType(KNativePointer context, KNativePointer original, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->UpdateTSIntersectionType(_context, _original, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSIntersectionType, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSIntersectionTypeTypesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSIntersectionTypeTypesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSIntersectionTypeTypesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateUpdateExpression(KNativePointer context, KNativePointer argument, KInt updateOperator, KBoolean isPrefix) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + const auto _updateOperator = static_cast(updateOperator); + const auto _isPrefix = static_cast(isPrefix); + auto result = GetImpl()->CreateUpdateExpression(_context, _argument, _updateOperator, _isPrefix); + return result; +} +KOALA_INTEROP_4(CreateUpdateExpression, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean); + +KNativePointer impl_UpdateUpdateExpression(KNativePointer context, KNativePointer original, KNativePointer argument, KInt updateOperator, KBoolean isPrefix) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + const auto _updateOperator = static_cast(updateOperator); + const auto _isPrefix = static_cast(isPrefix); + auto result = GetImpl()->UpdateUpdateExpression(_context, _original, _argument, _updateOperator, _isPrefix); + return result; +} +KOALA_INTEROP_5(UpdateUpdateExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KBoolean); + +KInt impl_UpdateExpressionOperatorTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UpdateExpressionOperatorTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UpdateExpressionOperatorTypeConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExpressionArgument(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UpdateExpressionArgument(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UpdateExpressionArgument, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UpdateExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(UpdateExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_UpdateExpressionIsPrefixConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->UpdateExpressionIsPrefixConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(UpdateExpressionIsPrefixConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBlockExpression(KNativePointer context, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + auto result = GetImpl()->CreateBlockExpression(_context, _statements, _statementsSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateBlockExpression, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateBlockExpression(KNativePointer context, KNativePointer original, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + auto result = GetImpl()->UpdateBlockExpression(_context, _original, _statements, _statementsSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateBlockExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_BlockExpressionStatementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->BlockExpressionStatementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(BlockExpressionStatementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BlockExpressionStatements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->BlockExpressionStatements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(BlockExpressionStatements, KNativePointer, KNativePointer, KNativePointer); + +void impl_BlockExpressionAddStatements(KNativePointer context, KNativePointer receiver, KNativePointerArray statements, KUInt statementsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _statements = reinterpret_cast(statements); + const auto _statementsSequenceLength = static_cast(statementsSequenceLength); + GetImpl()->BlockExpressionAddStatements(_context, _receiver, _statements, _statementsSequenceLength); + return ; +} +KOALA_INTEROP_V4(BlockExpressionAddStatements, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +void impl_BlockExpressionAddStatement(KNativePointer context, KNativePointer receiver, KNativePointer statement) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _statement = reinterpret_cast(statement); + GetImpl()->BlockExpressionAddStatement(_context, _receiver, _statement); + return ; +} +KOALA_INTEROP_V3(BlockExpressionAddStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeLiteral(KNativePointer context, KNativePointerArray members, KUInt membersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _members = reinterpret_cast(members); + const auto _membersSequenceLength = static_cast(membersSequenceLength); + auto result = GetImpl()->CreateTSTypeLiteral(_context, _members, _membersSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSTypeLiteral, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSTypeLiteral(KNativePointer context, KNativePointer original, KNativePointerArray members, KUInt membersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _members = reinterpret_cast(members); + const auto _membersSequenceLength = static_cast(membersSequenceLength); + auto result = GetImpl()->UpdateTSTypeLiteral(_context, _original, _members, _membersSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeLiteral, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSTypeLiteralMembersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeLiteralMembersConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeLiteralMembersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeParameter(KNativePointer context, KNativePointer name, KNativePointer constraint, KNativePointer defaultType) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + const auto _constraint = reinterpret_cast(constraint); + const auto _defaultType = reinterpret_cast(defaultType); + auto result = GetImpl()->CreateTSTypeParameter(_context, _name, _constraint, _defaultType); + return result; +} +KOALA_INTEROP_4(CreateTSTypeParameter, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSTypeParameter(KNativePointer context, KNativePointer original, KNativePointer name, KNativePointer constraint, KNativePointer defaultType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + const auto _constraint = reinterpret_cast(constraint); + const auto _defaultType = reinterpret_cast(defaultType); + auto result = GetImpl()->UpdateTSTypeParameter(_context, _original, _name, _constraint, _defaultType); + return result; +} +KOALA_INTEROP_5(UpdateTSTypeParameter, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypeParameter1(KNativePointer context, KNativePointer name, KNativePointer constraint, KNativePointer defaultType, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + const auto _constraint = reinterpret_cast(constraint); + const auto _defaultType = reinterpret_cast(defaultType); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateTSTypeParameter1(_context, _name, _constraint, _defaultType, _flags); + return result; +} +KOALA_INTEROP_5(CreateTSTypeParameter1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateTSTypeParameter1(KNativePointer context, KNativePointer original, KNativePointer name, KNativePointer constraint, KNativePointer defaultType, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + const auto _constraint = reinterpret_cast(constraint); + const auto _defaultType = reinterpret_cast(defaultType); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateTSTypeParameter1(_context, _original, _name, _constraint, _defaultType, _flags); + return result; +} +KOALA_INTEROP_6(UpdateTSTypeParameter1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_TSTypeParameterNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeParameterNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterName(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeParameterName, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterConstraint(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterConstraint(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeParameterConstraint, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterConstraintConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterConstraintConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeParameterConstraintConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeParameterSetConstraint(KNativePointer context, KNativePointer receiver, KNativePointer constraint) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _constraint = reinterpret_cast(constraint); + GetImpl()->TSTypeParameterSetConstraint(_context, _receiver, _constraint); + return ; +} +KOALA_INTEROP_V3(TSTypeParameterSetConstraint, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterDefaultTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterDefaultTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypeParameterDefaultTypeConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeParameterSetDefaultType(KNativePointer context, KNativePointer receiver, KNativePointer defaultType) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _defaultType = reinterpret_cast(defaultType); + GetImpl()->TSTypeParameterSetDefaultType(_context, _receiver, _defaultType); + return ; +} +KOALA_INTEROP_V3(TSTypeParameterSetDefaultType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeParameterAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeParameterAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypeParameterAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeParameterAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeParameterAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeParameterSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->TSTypeParameterSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(TSTypeParameterSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateTSBooleanKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSBooleanKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSBooleanKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSBooleanKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSBooleanKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSBooleanKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSpreadElement(KNativePointer context, KInt nodeType, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _nodeType = static_cast(nodeType); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateSpreadElement(_context, _nodeType, _argument); + return result; +} +KOALA_INTEROP_3(CreateSpreadElement, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_UpdateSpreadElement(KNativePointer context, KNativePointer original, KInt nodeType, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _nodeType = static_cast(nodeType); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateSpreadElement(_context, _original, _nodeType, _argument); + return result; +} +KOALA_INTEROP_4(UpdateSpreadElement, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer); + +KNativePointer impl_SpreadElementArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(SpreadElementArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SpreadElementArgument(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementArgument(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SpreadElementArgument, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_SpreadElementIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SpreadElementIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_SpreadElementDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SpreadElementDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(SpreadElementDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_SpreadElementSetOptional(KNativePointer context, KNativePointer receiver, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _optional_arg = static_cast(optional_arg); + GetImpl()->SpreadElementSetOptional(_context, _receiver, _optional_arg); + return ; +} +KOALA_INTEROP_V3(SpreadElementSetOptional, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_SpreadElementValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SpreadElementValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_SpreadElementConvertibleToRest(KNativePointer context, KNativePointer receiver, KBoolean isDeclaration, KBoolean allowPattern) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isDeclaration = static_cast(isDeclaration); + const auto _allowPattern = static_cast(allowPattern); + auto result = GetImpl()->SpreadElementConvertibleToRest(_context, _receiver, _isDeclaration, _allowPattern); + return result; +} +KOALA_INTEROP_4(SpreadElementConvertibleToRest, KBoolean, KNativePointer, KNativePointer, KBoolean, KBoolean); + +KNativePointer impl_SpreadElementTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SpreadElementTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(SpreadElementTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_SpreadElementSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->SpreadElementSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(SpreadElementSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSTypePredicate(KNativePointer context, KNativePointer parameterName, KNativePointer typeAnnotation, KBoolean asserts) +{ + const auto _context = reinterpret_cast(context); + const auto _parameterName = reinterpret_cast(parameterName); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _asserts = static_cast(asserts); + auto result = GetImpl()->CreateTSTypePredicate(_context, _parameterName, _typeAnnotation, _asserts); + return result; +} +KOALA_INTEROP_4(CreateTSTypePredicate, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSTypePredicate(KNativePointer context, KNativePointer original, KNativePointer parameterName, KNativePointer typeAnnotation, KBoolean asserts) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _parameterName = reinterpret_cast(parameterName); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _asserts = static_cast(asserts); + auto result = GetImpl()->UpdateTSTypePredicate(_context, _original, _parameterName, _typeAnnotation, _asserts); + return result; +} +KOALA_INTEROP_5(UpdateTSTypePredicate, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSTypePredicateParameterNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypePredicateParameterNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypePredicateParameterNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSTypePredicateTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypePredicateTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSTypePredicateTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSTypePredicateAssertsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypePredicateAssertsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypePredicateAssertsConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportNamespaceSpecifier(KNativePointer context, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->CreateImportNamespaceSpecifier(_context, _local); + return result; +} +KOALA_INTEROP_2(CreateImportNamespaceSpecifier, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateImportNamespaceSpecifier(KNativePointer context, KNativePointer original, KNativePointer local) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _local = reinterpret_cast(local); + auto result = GetImpl()->UpdateImportNamespaceSpecifier(_context, _original, _local); + return result; +} +KOALA_INTEROP_3(UpdateImportNamespaceSpecifier, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportNamespaceSpecifierLocal(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportNamespaceSpecifierLocal(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportNamespaceSpecifierLocal, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportNamespaceSpecifierLocalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportNamespaceSpecifierLocalConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportNamespaceSpecifierLocalConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateExportNamedDeclaration(KNativePointer context, KNativePointer source, KNativePointerArray specifiers, KUInt specifiersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + auto result = GetImpl()->CreateExportNamedDeclaration(_context, _source, _specifiers, _specifiersSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateExportNamedDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateExportNamedDeclaration(KNativePointer context, KNativePointer original, KNativePointer source, KNativePointerArray specifiers, KUInt specifiersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _source = reinterpret_cast(source); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + auto result = GetImpl()->UpdateExportNamedDeclaration(_context, _original, _source, _specifiers, _specifiersSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateExportNamedDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateExportNamedDeclaration1(KNativePointer context, KNativePointer decl, KNativePointerArray specifiers, KUInt specifiersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _decl = reinterpret_cast(decl); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + auto result = GetImpl()->CreateExportNamedDeclaration1(_context, _decl, _specifiers, _specifiersSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateExportNamedDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateExportNamedDeclaration1(KNativePointer context, KNativePointer original, KNativePointer decl, KNativePointerArray specifiers, KUInt specifiersSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _decl = reinterpret_cast(decl); + const auto _specifiers = reinterpret_cast(specifiers); + const auto _specifiersSequenceLength = static_cast(specifiersSequenceLength); + auto result = GetImpl()->UpdateExportNamedDeclaration1(_context, _original, _decl, _specifiers, _specifiersSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateExportNamedDeclaration1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateExportNamedDeclaration2(KNativePointer context, KNativePointer decl) +{ + const auto _context = reinterpret_cast(context); + const auto _decl = reinterpret_cast(decl); + auto result = GetImpl()->CreateExportNamedDeclaration2(_context, _decl); + return result; +} +KOALA_INTEROP_2(CreateExportNamedDeclaration2, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateExportNamedDeclaration2(KNativePointer context, KNativePointer original, KNativePointer decl) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _decl = reinterpret_cast(decl); + auto result = GetImpl()->UpdateExportNamedDeclaration2(_context, _original, _decl); + return result; +} +KOALA_INTEROP_3(UpdateExportNamedDeclaration2, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportNamedDeclarationDeclConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportNamedDeclarationDeclConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportNamedDeclarationDeclConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportNamedDeclarationSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExportNamedDeclarationSourceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExportNamedDeclarationSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExportNamedDeclarationSpecifiersConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ExportNamedDeclarationSpecifiersConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ExportNamedDeclarationSpecifiersConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSParameterExpression(KNativePointer context, KNativePointer identOrSpread, KBoolean isOptional) +{ + const auto _context = reinterpret_cast(context); + const auto _identOrSpread = reinterpret_cast(identOrSpread); + const auto _isOptional = static_cast(isOptional); + auto result = GetImpl()->CreateETSParameterExpression(_context, _identOrSpread, _isOptional); + return result; +} +KOALA_INTEROP_3(CreateETSParameterExpression, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateETSParameterExpression(KNativePointer context, KNativePointer original, KNativePointer identOrSpread, KBoolean isOptional) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _identOrSpread = reinterpret_cast(identOrSpread); + const auto _isOptional = static_cast(isOptional); + auto result = GetImpl()->UpdateETSParameterExpression(_context, _original, _identOrSpread, _isOptional); + return result; +} +KOALA_INTEROP_4(UpdateETSParameterExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_CreateETSParameterExpression1(KNativePointer context, KNativePointer identOrSpread, KNativePointer initializer) +{ + const auto _context = reinterpret_cast(context); + const auto _identOrSpread = reinterpret_cast(identOrSpread); + const auto _initializer = reinterpret_cast(initializer); + auto result = GetImpl()->CreateETSParameterExpression1(_context, _identOrSpread, _initializer); + return result; +} +KOALA_INTEROP_3(CreateETSParameterExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSParameterExpression1(KNativePointer context, KNativePointer original, KNativePointer identOrSpread, KNativePointer initializer) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _identOrSpread = reinterpret_cast(identOrSpread); + const auto _initializer = reinterpret_cast(initializer); + auto result = GetImpl()->UpdateETSParameterExpression1(_context, _original, _identOrSpread, _initializer); + return result; +} +KOALA_INTEROP_4(UpdateETSParameterExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSParameterExpressionNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSParameterExpressionIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionIdent, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetIdent(KNativePointer context, KNativePointer receiver, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _ident = reinterpret_cast(ident); + GetImpl()->ETSParameterExpressionSetIdent(_context, _receiver, _ident); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionRestParameterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionRestParameterConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSParameterExpressionRestParameterConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionRestParameter(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionRestParameter(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionRestParameter, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionInitializerConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionInitializerConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSParameterExpressionInitializerConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionInitializer(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionInitializer(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionInitializer, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetLexerSaved(KNativePointer context, KNativePointer receiver, KStringPtr& s) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _s = getStringCopy(s); + GetImpl()->ETSParameterExpressionSetLexerSaved(_context, _receiver, _s); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetLexerSaved, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_ETSParameterExpressionLexerSavedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionLexerSavedConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSParameterExpressionLexerSavedConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSParameterExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeNode) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeNode = reinterpret_cast(typeNode); + GetImpl()->ETSParameterExpressionSetTypeAnnotation(_context, _receiver, _typeNode); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ETSParameterExpressionIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetOptional(KNativePointer context, KNativePointer receiver, KBoolean value) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _value = static_cast(value); + GetImpl()->ETSParameterExpressionSetOptional(_context, _receiver, _value); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetOptional, KNativePointer, KNativePointer, KBoolean); + +void impl_ETSParameterExpressionSetInitializer(KNativePointer context, KNativePointer receiver, KNativePointer initExpr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _initExpr = reinterpret_cast(initExpr); + GetImpl()->ETSParameterExpressionSetInitializer(_context, _receiver, _initExpr); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetInitializer, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ETSParameterExpressionIsRestParameterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionIsRestParameterConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionIsRestParameterConst, KBoolean, KNativePointer, KNativePointer); + +KUInt impl_ETSParameterExpressionGetRequiredParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSParameterExpressionGetRequiredParamsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSParameterExpressionGetRequiredParamsConst, KUInt, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetRequiredParams(KNativePointer context, KNativePointer receiver, KUInt value) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _value = static_cast(value); + GetImpl()->ETSParameterExpressionSetRequiredParams(_context, _receiver, _value); + return ; +} +KOALA_INTEROP_V3(ETSParameterExpressionSetRequiredParams, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_ETSParameterExpressionAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSParameterExpressionAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSParameterExpressionAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSParameterExpressionAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSParameterExpressionAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSParameterExpressionAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSParameterExpressionSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ETSParameterExpressionSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ETSParameterExpressionSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateTSTypeParameterInstantiation(KNativePointer context, KNativePointerArray params, KUInt paramsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + auto result = GetImpl()->CreateTSTypeParameterInstantiation(_context, _params, _paramsSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSTypeParameterInstantiation, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSTypeParameterInstantiation(KNativePointer context, KNativePointer original, KNativePointerArray params, KUInt paramsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + auto result = GetImpl()->UpdateTSTypeParameterInstantiation(_context, _original, _params, _paramsSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSTypeParameterInstantiation, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSTypeParameterInstantiationParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeParameterInstantiationParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeParameterInstantiationParamsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateNullLiteral(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateNullLiteral(_context); + return result; +} +KOALA_INTEROP_1(CreateNullLiteral, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateNullLiteral(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateNullLiteral(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateNullLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSInferType(KNativePointer context, KNativePointer typeParam) +{ + const auto _context = reinterpret_cast(context); + const auto _typeParam = reinterpret_cast(typeParam); + auto result = GetImpl()->CreateTSInferType(_context, _typeParam); + return result; +} +KOALA_INTEROP_2(CreateTSInferType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSInferType(KNativePointer context, KNativePointer original, KNativePointer typeParam) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeParam = reinterpret_cast(typeParam); + auto result = GetImpl()->UpdateTSInferType(_context, _original, _typeParam); + return result; +} +KOALA_INTEROP_3(UpdateTSInferType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInferTypeTypeParamConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInferTypeTypeParamConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInferTypeTypeParamConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSwitchCaseStatement(KNativePointer context, KNativePointer test, KNativePointerArray consequent, KUInt consequentSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _consequentSequenceLength = static_cast(consequentSequenceLength); + auto result = GetImpl()->CreateSwitchCaseStatement(_context, _test, _consequent, _consequentSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateSwitchCaseStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateSwitchCaseStatement(KNativePointer context, KNativePointer original, KNativePointer test, KNativePointerArray consequent, KUInt consequentSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _test = reinterpret_cast(test); + const auto _consequent = reinterpret_cast(consequent); + const auto _consequentSequenceLength = static_cast(consequentSequenceLength); + auto result = GetImpl()->UpdateSwitchCaseStatement(_context, _original, _test, _consequent, _consequentSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateSwitchCaseStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_SwitchCaseStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SwitchCaseStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SwitchCaseStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchCaseStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SwitchCaseStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(SwitchCaseStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchCaseStatementConsequentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SwitchCaseStatementConsequentConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(SwitchCaseStatementConsequentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateYieldExpression(KNativePointer context, KNativePointer argument, KBoolean isDelegate) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + const auto _isDelegate = static_cast(isDelegate); + auto result = GetImpl()->CreateYieldExpression(_context, _argument, _isDelegate); + return result; +} +KOALA_INTEROP_3(CreateYieldExpression, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateYieldExpression(KNativePointer context, KNativePointer original, KNativePointer argument, KBoolean isDelegate) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + const auto _isDelegate = static_cast(isDelegate); + auto result = GetImpl()->UpdateYieldExpression(_context, _original, _argument, _isDelegate); + return result; +} +KOALA_INTEROP_4(UpdateYieldExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_YieldExpressionHasDelegateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->YieldExpressionHasDelegateConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(YieldExpressionHasDelegateConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_YieldExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->YieldExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(YieldExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSImportEqualsDeclaration(KNativePointer context, KNativePointer id, KNativePointer moduleReference, KBoolean isExport) +{ + const auto _context = reinterpret_cast(context); + const auto _id = reinterpret_cast(id); + const auto _moduleReference = reinterpret_cast(moduleReference); + const auto _isExport = static_cast(isExport); + auto result = GetImpl()->CreateTSImportEqualsDeclaration(_context, _id, _moduleReference, _isExport); + return result; +} +KOALA_INTEROP_4(CreateTSImportEqualsDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSImportEqualsDeclaration(KNativePointer context, KNativePointer original, KNativePointer id, KNativePointer moduleReference, KBoolean isExport) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _id = reinterpret_cast(id); + const auto _moduleReference = reinterpret_cast(moduleReference); + const auto _isExport = static_cast(isExport); + auto result = GetImpl()->UpdateTSImportEqualsDeclaration(_context, _original, _id, _moduleReference, _isExport); + return result; +} +KOALA_INTEROP_5(UpdateTSImportEqualsDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSImportEqualsDeclarationIdConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportEqualsDeclarationIdConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportEqualsDeclarationIdConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSImportEqualsDeclarationModuleReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportEqualsDeclarationModuleReferenceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSImportEqualsDeclarationModuleReferenceConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSImportEqualsDeclarationIsExportConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSImportEqualsDeclarationIsExportConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSImportEqualsDeclarationIsExportConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBooleanLiteral(KNativePointer context, KBoolean value) +{ + const auto _context = reinterpret_cast(context); + const auto _value = static_cast(value); + auto result = GetImpl()->CreateBooleanLiteral(_context, _value); + return result; +} +KOALA_INTEROP_2(CreateBooleanLiteral, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateBooleanLiteral(KNativePointer context, KNativePointer original, KBoolean value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _value = static_cast(value); + auto result = GetImpl()->UpdateBooleanLiteral(_context, _original, _value); + return result; +} +KOALA_INTEROP_3(UpdateBooleanLiteral, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_BooleanLiteralValueConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BooleanLiteralValueConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BooleanLiteralValueConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNumberKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSNumberKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSNumberKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSNumberKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSNumberKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSNumberKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateClassStaticBlock(KNativePointer context, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _value = reinterpret_cast(value); + auto result = GetImpl()->CreateClassStaticBlock(_context, _value); + return result; +} +KOALA_INTEROP_2(CreateClassStaticBlock, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateClassStaticBlock(KNativePointer context, KNativePointer original, KNativePointer value) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _value = reinterpret_cast(value); + auto result = GetImpl()->UpdateClassStaticBlock(_context, _original, _value); + return result; +} +KOALA_INTEROP_3(UpdateClassStaticBlock, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassStaticBlockFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassStaticBlockFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassStaticBlockFunction, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassStaticBlockFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassStaticBlockFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassStaticBlockFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassStaticBlockNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassStaticBlockNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ClassStaticBlockNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNonNullExpression(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateTSNonNullExpression(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateTSNonNullExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSNonNullExpression(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateTSNonNullExpression(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateTSNonNullExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSNonNullExpressionExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNonNullExpressionExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSNonNullExpressionExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSNonNullExpressionExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNonNullExpressionExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSNonNullExpressionExpr, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSNonNullExpressionSetExpr(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->TSNonNullExpressionSetExpr(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(TSNonNullExpressionSetExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreatePrefixAssertionExpression(KNativePointer context, KNativePointer expr, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->CreatePrefixAssertionExpression(_context, _expr, _type); + return result; +} +KOALA_INTEROP_3(CreatePrefixAssertionExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdatePrefixAssertionExpression(KNativePointer context, KNativePointer original, KNativePointer expr, KNativePointer type) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + const auto _type = reinterpret_cast(type); + auto result = GetImpl()->UpdatePrefixAssertionExpression(_context, _original, _expr, _type); + return result; +} +KOALA_INTEROP_4(UpdatePrefixAssertionExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PrefixAssertionExpressionExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PrefixAssertionExpressionExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(PrefixAssertionExpressionExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_PrefixAssertionExpressionTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->PrefixAssertionExpressionTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(PrefixAssertionExpressionTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateClassExpression(KNativePointer context, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->CreateClassExpression(_context, _def); + return result; +} +KOALA_INTEROP_2(CreateClassExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateClassExpression(KNativePointer context, KNativePointer original, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->UpdateClassExpression(_context, _original, _def); + return result; +} +KOALA_INTEROP_3(UpdateClassExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassExpressionDefinitionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassExpressionDefinitionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassExpressionDefinitionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateForOfStatement(KNativePointer context, KNativePointer left, KNativePointer right, KNativePointer body, KBoolean isAwait) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _body = reinterpret_cast(body); + const auto _isAwait = static_cast(isAwait); + auto result = GetImpl()->CreateForOfStatement(_context, _left, _right, _body, _isAwait); + return result; +} +KOALA_INTEROP_5(CreateForOfStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateForOfStatement(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right, KNativePointer body, KBoolean isAwait) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + const auto _body = reinterpret_cast(body); + const auto _isAwait = static_cast(isAwait); + auto result = GetImpl()->UpdateForOfStatement(_context, _original, _left, _right, _body, _isAwait); + return result; +} +KOALA_INTEROP_6(UpdateForOfStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_ForOfStatementLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForOfStatementLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForOfStatementLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForOfStatementRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForOfStatementRightConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForOfStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForOfStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForOfStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ForOfStatementIsAwaitConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForOfStatementIsAwaitConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForOfStatementIsAwaitConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTemplateLiteral(KNativePointer context, KNativePointerArray quasis, KUInt quasisSequenceLength, KNativePointerArray expressions, KUInt expressionsSequenceLength, KStringPtr& multilineString) +{ + const auto _context = reinterpret_cast(context); + const auto _quasis = reinterpret_cast(quasis); + const auto _quasisSequenceLength = static_cast(quasisSequenceLength); + const auto _expressions = reinterpret_cast(expressions); + const auto _expressionsSequenceLength = static_cast(expressionsSequenceLength); + const auto _multilineString = getStringCopy(multilineString); + auto result = GetImpl()->CreateTemplateLiteral(_context, _quasis, _quasisSequenceLength, _expressions, _expressionsSequenceLength, _multilineString); + return result; +} +KOALA_INTEROP_6(CreateTemplateLiteral, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointerArray, KUInt, KStringPtr); + +KNativePointer impl_UpdateTemplateLiteral(KNativePointer context, KNativePointer original, KNativePointerArray quasis, KUInt quasisSequenceLength, KNativePointerArray expressions, KUInt expressionsSequenceLength, KStringPtr& multilineString) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _quasis = reinterpret_cast(quasis); + const auto _quasisSequenceLength = static_cast(quasisSequenceLength); + const auto _expressions = reinterpret_cast(expressions); + const auto _expressionsSequenceLength = static_cast(expressionsSequenceLength); + const auto _multilineString = getStringCopy(multilineString); + auto result = GetImpl()->UpdateTemplateLiteral(_context, _original, _quasis, _quasisSequenceLength, _expressions, _expressionsSequenceLength, _multilineString); + return result; +} +KOALA_INTEROP_7(UpdateTemplateLiteral, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointerArray, KUInt, KStringPtr); + +KNativePointer impl_TemplateLiteralQuasisConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TemplateLiteralQuasisConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TemplateLiteralQuasisConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TemplateLiteralExpressionsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TemplateLiteralExpressionsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TemplateLiteralExpressionsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TemplateLiteralGetMultilineStringConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TemplateLiteralGetMultilineStringConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TemplateLiteralGetMultilineStringConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSUnionType(KNativePointer context, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->CreateTSUnionType(_context, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateTSUnionType, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateTSUnionType(KNativePointer context, KNativePointer original, KNativePointerArray types, KUInt typesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _types = reinterpret_cast(types); + const auto _typesSequenceLength = static_cast(typesSequenceLength); + auto result = GetImpl()->UpdateTSUnionType(_context, _original, _types, _typesSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateTSUnionType, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_TSUnionTypeTypesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSUnionTypeTypesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSUnionTypeTypesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSUnknownKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSUnknownKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSUnknownKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSUnknownKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSUnknownKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSUnknownKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateIdentifier(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateIdentifier(_context); + return result; +} +KOALA_INTEROP_1(CreateIdentifier, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateIdentifier(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateIdentifier(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateIdentifier, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateIdentifier1(KNativePointer context, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + auto result = GetImpl()->CreateIdentifier1(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateIdentifier1, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_UpdateIdentifier1(KNativePointer context, KNativePointer original, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = getStringCopy(name); + auto result = GetImpl()->UpdateIdentifier1(_context, _original, _name); + return result; +} +KOALA_INTEROP_3(UpdateIdentifier1, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_CreateIdentifier2(KNativePointer context, KStringPtr& name, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + auto result = GetImpl()->CreateIdentifier2(_context, _name, _typeAnnotation); + return result; +} +KOALA_INTEROP_3(CreateIdentifier2, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + +KNativePointer impl_UpdateIdentifier2(KNativePointer context, KNativePointer original, KStringPtr& name, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = getStringCopy(name); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + auto result = GetImpl()->UpdateIdentifier2(_context, _original, _name, _typeAnnotation); + return result; +} +KOALA_INTEROP_4(UpdateIdentifier2, KNativePointer, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + +KNativePointer impl_IdentifierNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(IdentifierNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IdentifierName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierName(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(IdentifierName, KNativePointer, KNativePointer, KNativePointer); + +void impl_IdentifierSetName(KNativePointer context, KNativePointer receiver, KStringPtr& newName) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _newName = getStringCopy(newName); + GetImpl()->IdentifierSetName(_context, _receiver, _newName); + return ; +} +KOALA_INTEROP_V3(IdentifierSetName, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_IdentifierDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->IdentifierDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(IdentifierDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsErrorPlaceHolderConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsErrorPlaceHolderConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsErrorPlaceHolderConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetOptional(KNativePointer context, KNativePointer receiver, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _optional_arg = static_cast(optional_arg); + GetImpl()->IdentifierSetOptional(_context, _receiver, _optional_arg); + return ; +} +KOALA_INTEROP_V3(IdentifierSetOptional, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_IdentifierIsReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsReferenceConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsReferenceConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsTdzConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsTdzConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsTdzConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetTdz(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetTdz(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetTdz, KNativePointer, KNativePointer); + +void impl_IdentifierSetAccessor(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetAccessor(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetAccessor, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsAccessorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsAccessorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsAccessorConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetMutator(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetMutator(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetMutator, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsMutatorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsMutatorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsMutatorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsReceiverConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsReceiverConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsReceiverConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsPrivateIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsPrivateIdentConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsPrivateIdentConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetPrivate(KNativePointer context, KNativePointer receiver, KBoolean isPrivate) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isPrivate = static_cast(isPrivate); + GetImpl()->IdentifierSetPrivate(_context, _receiver, _isPrivate); + return ; +} +KOALA_INTEROP_V3(IdentifierSetPrivate, KNativePointer, KNativePointer, KBoolean); + +KBoolean impl_IdentifierIsIgnoreBoxConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsIgnoreBoxConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsIgnoreBoxConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetIgnoreBox(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetIgnoreBox(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetIgnoreBox, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsAnnotationDeclConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsAnnotationDeclConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsAnnotationDeclConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetAnnotationDecl(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetAnnotationDecl(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetAnnotationDecl, KNativePointer, KNativePointer); + +KBoolean impl_IdentifierIsAnnotationUsageConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierIsAnnotationUsageConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierIsAnnotationUsageConst, KBoolean, KNativePointer, KNativePointer); + +void impl_IdentifierSetAnnotationUsage(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->IdentifierSetAnnotationUsage(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(IdentifierSetAnnotationUsage, KNativePointer, KNativePointer); + +KNativePointer impl_IdentifierCloneReference(KNativePointer context, KNativePointer receiver, KNativePointer parent) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _parent = reinterpret_cast(parent); + auto result = GetImpl()->IdentifierCloneReference(_context, _receiver, _parent); + return result; +} +KOALA_INTEROP_3(IdentifierCloneReference, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IdentifierValidateExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierValidateExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(IdentifierValidateExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_IdentifierTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->IdentifierTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(IdentifierTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_IdentifierSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->IdentifierSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(IdentifierSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateOpaqueTypeNode1(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateOpaqueTypeNode1(_context); + return result; +} +KOALA_INTEROP_1(CreateOpaqueTypeNode1, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateOpaqueTypeNode1(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateOpaqueTypeNode1(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateOpaqueTypeNode1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBlockStatement(KNativePointer context, KNativePointerArray statementList, KUInt statementListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _statementList = reinterpret_cast(statementList); + const auto _statementListSequenceLength = static_cast(statementListSequenceLength); + auto result = GetImpl()->CreateBlockStatement(_context, _statementList, _statementListSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateBlockStatement, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateBlockStatement(KNativePointer context, KNativePointer original, KNativePointerArray statementList, KUInt statementListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _statementList = reinterpret_cast(statementList); + const auto _statementListSequenceLength = static_cast(statementListSequenceLength); + auto result = GetImpl()->UpdateBlockStatement(_context, _original, _statementList, _statementListSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateBlockStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_BlockStatementStatementsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->BlockStatementStatementsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(BlockStatementStatementsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BlockStatementStatements(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->BlockStatementStatements(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(BlockStatementStatements, KNativePointer, KNativePointer, KNativePointer); + +void impl_BlockStatementSetStatements(KNativePointer context, KNativePointer receiver, KNativePointerArray statementList, KUInt statementListSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _statementList = reinterpret_cast(statementList); + const auto _statementListSequenceLength = static_cast(statementListSequenceLength); + GetImpl()->BlockStatementSetStatements(_context, _receiver, _statementList, _statementListSequenceLength); + return ; +} +KOALA_INTEROP_V4(BlockStatementSetStatements, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +void impl_BlockStatementAddTrailingBlock(KNativePointer context, KNativePointer receiver, KNativePointer stmt, KNativePointer trailingBlock) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _stmt = reinterpret_cast(stmt); + const auto _trailingBlock = reinterpret_cast(trailingBlock); + GetImpl()->BlockStatementAddTrailingBlock(_context, _receiver, _stmt, _trailingBlock); + return ; +} +KOALA_INTEROP_V4(BlockStatementAddTrailingBlock, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateDirectEvalExpression(KNativePointer context, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength, KNativePointer typeParams, KBoolean optional_arg, KUInt parserStatus) +{ + const auto _context = reinterpret_cast(context); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _optional_arg = static_cast(optional_arg); + const auto _parserStatus = static_cast(parserStatus); + auto result = GetImpl()->CreateDirectEvalExpression(_context, _callee, __arguments, __argumentsSequenceLength, _typeParams, _optional_arg, _parserStatus); + return result; +} +KOALA_INTEROP_7(CreateDirectEvalExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KBoolean, KUInt); + +KNativePointer impl_UpdateDirectEvalExpression(KNativePointer context, KNativePointer original, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength, KNativePointer typeParams, KBoolean optional_arg, KUInt parserStatus) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _optional_arg = static_cast(optional_arg); + const auto _parserStatus = static_cast(parserStatus); + auto result = GetImpl()->UpdateDirectEvalExpression(_context, _original, _callee, __arguments, __argumentsSequenceLength, _typeParams, _optional_arg, _parserStatus); + return result; +} +KOALA_INTEROP_8(UpdateDirectEvalExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KNativePointer, KBoolean, KUInt); + +KNativePointer impl_CreateTSTypeParameterDeclaration(KNativePointer context, KNativePointerArray params, KUInt paramsSequenceLength, KUInt requiredParams) +{ + const auto _context = reinterpret_cast(context); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + const auto _requiredParams = static_cast(requiredParams); + auto result = GetImpl()->CreateTSTypeParameterDeclaration(_context, _params, _paramsSequenceLength, _requiredParams); + return result; +} +KOALA_INTEROP_4(CreateTSTypeParameterDeclaration, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KUInt); + +KNativePointer impl_UpdateTSTypeParameterDeclaration(KNativePointer context, KNativePointer original, KNativePointerArray params, KUInt paramsSequenceLength, KUInt requiredParams) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _params = reinterpret_cast(params); + const auto _paramsSequenceLength = static_cast(paramsSequenceLength); + const auto _requiredParams = static_cast(requiredParams); + auto result = GetImpl()->UpdateTSTypeParameterDeclaration(_context, _original, _params, _paramsSequenceLength, _requiredParams); + return result; +} +KOALA_INTEROP_5(UpdateTSTypeParameterDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt, KUInt); + +KNativePointer impl_TSTypeParameterDeclarationParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TSTypeParameterDeclarationParamsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TSTypeParameterDeclarationParamsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSTypeParameterDeclarationAddParam(KNativePointer context, KNativePointer receiver, KNativePointer param) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _param = reinterpret_cast(param); + GetImpl()->TSTypeParameterDeclarationAddParam(_context, _receiver, _param); + return ; +} +KOALA_INTEROP_V3(TSTypeParameterDeclarationAddParam, KNativePointer, KNativePointer, KNativePointer); + +KUInt impl_TSTypeParameterDeclarationRequiredParamsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSTypeParameterDeclarationRequiredParamsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSTypeParameterDeclarationRequiredParamsConst, KUInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateMethodDefinition(KNativePointer context, KInt kind, KNativePointer key, KNativePointer value, KInt modifiers, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _kind = static_cast(kind); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _modifiers = static_cast(modifiers); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->CreateMethodDefinition(_context, _kind, _key, _value, _modifiers, _isComputed); + return result; +} +KOALA_INTEROP_6(CreateMethodDefinition, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KInt, KBoolean); + +KNativePointer impl_UpdateMethodDefinition(KNativePointer context, KNativePointer original, KInt kind, KNativePointer key, KNativePointer value, KInt modifiers, KBoolean isComputed) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _kind = static_cast(kind); + const auto _key = reinterpret_cast(key); + const auto _value = reinterpret_cast(value); + const auto _modifiers = static_cast(modifiers); + const auto _isComputed = static_cast(isComputed); + auto result = GetImpl()->UpdateMethodDefinition(_context, _original, _kind, _key, _value, _modifiers, _isComputed); + return result; +} +KOALA_INTEROP_7(UpdateMethodDefinition, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KNativePointer, KInt, KBoolean); + +KInt impl_MethodDefinitionKindConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionKindConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionKindConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionIsConstructorConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionIsConstructorConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionIsConstructorConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionIsExtensionMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionIsExtensionMethodConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionIsExtensionMethodConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionOverloadsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->MethodDefinitionOverloadsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(MethodDefinitionOverloadsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionBaseOverloadMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionBaseOverloadMethodConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MethodDefinitionBaseOverloadMethodConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionBaseOverloadMethod(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionBaseOverloadMethod(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionBaseOverloadMethod, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionAsyncPairMethodConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionAsyncPairMethodConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MethodDefinitionAsyncPairMethodConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionAsyncPairMethod(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionAsyncPairMethod(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionAsyncPairMethod, KNativePointer, KNativePointer, KNativePointer); + +void impl_MethodDefinitionSetOverloads(KNativePointer context, KNativePointer receiver, KNativePointerArray overloads, KUInt overloadsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _overloads = reinterpret_cast(overloads); + const auto _overloadsSequenceLength = static_cast(overloadsSequenceLength); + GetImpl()->MethodDefinitionSetOverloads(_context, _receiver, _overloads, _overloadsSequenceLength); + return ; +} +KOALA_INTEROP_V4(MethodDefinitionSetOverloads, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +void impl_MethodDefinitionClearOverloads(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->MethodDefinitionClearOverloads(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(MethodDefinitionClearOverloads, KNativePointer, KNativePointer); + +void impl_MethodDefinitionAddOverload(KNativePointer context, KNativePointer receiver, KNativePointer overload) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _overload = reinterpret_cast(overload); + GetImpl()->MethodDefinitionAddOverload(_context, _receiver, _overload); + return ; +} +KOALA_INTEROP_V3(MethodDefinitionAddOverload, KNativePointer, KNativePointer, KNativePointer); + +void impl_MethodDefinitionSetBaseOverloadMethod(KNativePointer context, KNativePointer receiver, KNativePointer baseOverloadMethod) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _baseOverloadMethod = reinterpret_cast(baseOverloadMethod); + GetImpl()->MethodDefinitionSetBaseOverloadMethod(_context, _receiver, _baseOverloadMethod); + return ; +} +KOALA_INTEROP_V3(MethodDefinitionSetBaseOverloadMethod, KNativePointer, KNativePointer, KNativePointer); + +void impl_MethodDefinitionSetAsyncPairMethod(KNativePointer context, KNativePointer receiver, KNativePointer method) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _method = reinterpret_cast(method); + GetImpl()->MethodDefinitionSetAsyncPairMethod(_context, _receiver, _method); + return ; +} +KOALA_INTEROP_V3(MethodDefinitionSetAsyncPairMethod, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_MethodDefinitionHasOverload(KNativePointer context, KNativePointer receiver, KNativePointer overload) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _overload = reinterpret_cast(overload); + auto result = GetImpl()->MethodDefinitionHasOverload(_context, _receiver, _overload); + return result; +} +KOALA_INTEROP_3(MethodDefinitionHasOverload, KBoolean, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MethodDefinitionFunction, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_MethodDefinitionFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MethodDefinitionFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(MethodDefinitionFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNullKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSNullKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSNullKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSNullKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSNullKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSNullKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSInterfaceHeritage(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateTSInterfaceHeritage(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateTSInterfaceHeritage, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSInterfaceHeritage(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateTSInterfaceHeritage(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateTSInterfaceHeritage, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceHeritageExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceHeritageExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSInterfaceHeritageExpr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSInterfaceHeritageExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSInterfaceHeritageExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSInterfaceHeritageExprConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsGroupedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsGroupedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsGroupedConst, KBoolean, KNativePointer, KNativePointer); + +void impl_ExpressionSetGrouped(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->ExpressionSetGrouped(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(ExpressionSetGrouped, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsLiteralConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsLiteralConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExpressionAsLiteralConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsLiteral(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsLiteral(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionAsLiteral, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsLiteralConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsLiteralConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsLiteralConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsTypeNodeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsTypeNodeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsTypeNodeConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsAnnotatedExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsAnnotatedExpressionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsAnnotatedExpressionConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsTypeNode(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsTypeNode(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionAsTypeNode, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsTypeNodeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsTypeNodeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExpressionAsTypeNodeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsAnnotatedExpression(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsAnnotatedExpression(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionAsAnnotatedExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionAsAnnotatedExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionAsAnnotatedExpressionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ExpressionAsAnnotatedExpressionConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_ExpressionIsBrokenExpressionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionIsBrokenExpressionConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ExpressionIsBrokenExpressionConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_ExpressionToStringConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ExpressionToStringConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ExpressionToStringConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AnnotatedExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AnnotatedExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AnnotatedExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_AnnotatedExpressionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->AnnotatedExpressionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(AnnotatedExpressionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_MaybeOptionalExpressionIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->MaybeOptionalExpressionIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(MaybeOptionalExpressionIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +void impl_MaybeOptionalExpressionClearOptional(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->MaybeOptionalExpressionClearOptional(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(MaybeOptionalExpressionClearOptional, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSrcDumper(KNativePointer context, KNativePointer node) +{ + const auto _context = reinterpret_cast(context); + const auto _node = reinterpret_cast(node); + auto result = GetImpl()->CreateSrcDumper(_context, _node); + return result; +} +KOALA_INTEROP_2(CreateSrcDumper, KNativePointer, KNativePointer, KNativePointer); + +void impl_SrcDumperAdd(KNativePointer context, KNativePointer receiver, KStringPtr& str) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _str = getStringCopy(str); + GetImpl()->SrcDumperAdd(_context, _receiver, _str); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd, KNativePointer, KNativePointer, KStringPtr); + +void impl_SrcDumperAdd1(KNativePointer context, KNativePointer receiver, KInt i) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _i = static_cast(i); + GetImpl()->SrcDumperAdd1(_context, _receiver, _i); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd1, KNativePointer, KNativePointer, KInt); + +void impl_SrcDumperAdd2(KNativePointer context, KNativePointer receiver, KLong l) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _l = static_cast(l); + GetImpl()->SrcDumperAdd2(_context, _receiver, _l); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd2, KNativePointer, KNativePointer, KLong); + +void impl_SrcDumperAdd3(KNativePointer context, KNativePointer receiver, KFloat f) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _f = static_cast(f); + GetImpl()->SrcDumperAdd3(_context, _receiver, _f); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd3, KNativePointer, KNativePointer, KFloat); + +void impl_SrcDumperAdd4(KNativePointer context, KNativePointer receiver, KDouble d) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _d = static_cast(d); + GetImpl()->SrcDumperAdd4(_context, _receiver, _d); + return ; +} +KOALA_INTEROP_V3(SrcDumperAdd4, KNativePointer, KNativePointer, KDouble); + +KNativePointer impl_SrcDumperStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SrcDumperStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(SrcDumperStrConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_SrcDumperIncrIndent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->SrcDumperIncrIndent(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(SrcDumperIncrIndent, KNativePointer, KNativePointer); + +void impl_SrcDumperDecrIndent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + GetImpl()->SrcDumperDecrIndent(_context, _receiver); + return ; +} +KOALA_INTEROP_V2(SrcDumperDecrIndent, KNativePointer, KNativePointer); + +void impl_SrcDumperEndl(KNativePointer context, KNativePointer receiver, KUInt num) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _num = static_cast(num); + GetImpl()->SrcDumperEndl(_context, _receiver, _num); + return ; +} +KOALA_INTEROP_V3(SrcDumperEndl, KNativePointer, KNativePointer, KUInt); + +KNativePointer impl_CreateETSClassLiteral(KNativePointer context, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->CreateETSClassLiteral(_context, _expr); + return result; +} +KOALA_INTEROP_2(CreateETSClassLiteral, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSClassLiteral(KNativePointer context, KNativePointer original, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expr = reinterpret_cast(expr); + auto result = GetImpl()->UpdateETSClassLiteral(_context, _original, _expr); + return result; +} +KOALA_INTEROP_3(UpdateETSClassLiteral, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSClassLiteralExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSClassLiteralExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSClassLiteralExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBreakStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateBreakStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateBreakStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateBreakStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateBreakStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateBreakStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateBreakStatement1(KNativePointer context, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->CreateBreakStatement1(_context, _ident); + return result; +} +KOALA_INTEROP_2(CreateBreakStatement1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateBreakStatement1(KNativePointer context, KNativePointer original, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->UpdateBreakStatement1(_context, _original, _ident); + return result; +} +KOALA_INTEROP_3(UpdateBreakStatement1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BreakStatementIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BreakStatementIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BreakStatementIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BreakStatementIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BreakStatementIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(BreakStatementIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_BreakStatementTargetConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->BreakStatementTargetConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(BreakStatementTargetConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_BreakStatementSetTarget(KNativePointer context, KNativePointer receiver, KNativePointer target) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _target = reinterpret_cast(target); + GetImpl()->BreakStatementSetTarget(_context, _receiver, _target); + return ; +} +KOALA_INTEROP_V3(BreakStatementSetTarget, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateRegExpLiteral(KNativePointer context, KStringPtr& pattern, KInt flags, KStringPtr& flagsStr) +{ + const auto _context = reinterpret_cast(context); + const auto _pattern = getStringCopy(pattern); + const auto _flags = static_cast(flags); + const auto _flagsStr = getStringCopy(flagsStr); + auto result = GetImpl()->CreateRegExpLiteral(_context, _pattern, _flags, _flagsStr); + return result; +} +KOALA_INTEROP_4(CreateRegExpLiteral, KNativePointer, KNativePointer, KStringPtr, KInt, KStringPtr); + +KNativePointer impl_UpdateRegExpLiteral(KNativePointer context, KNativePointer original, KStringPtr& pattern, KInt flags, KStringPtr& flagsStr) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _pattern = getStringCopy(pattern); + const auto _flags = static_cast(flags); + const auto _flagsStr = getStringCopy(flagsStr); + auto result = GetImpl()->UpdateRegExpLiteral(_context, _original, _pattern, _flags, _flagsStr); + return result; +} +KOALA_INTEROP_5(UpdateRegExpLiteral, KNativePointer, KNativePointer, KNativePointer, KStringPtr, KInt, KStringPtr); + +KNativePointer impl_RegExpLiteralPatternConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->RegExpLiteralPatternConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(RegExpLiteralPatternConst, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_RegExpLiteralFlagsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->RegExpLiteralFlagsConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(RegExpLiteralFlagsConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSMappedType(KNativePointer context, KNativePointer typeParameter, KNativePointer typeAnnotation, KInt readonly_arg, KInt optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _typeParameter = reinterpret_cast(typeParameter); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _readonly_arg = static_cast(readonly_arg); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->CreateTSMappedType(_context, _typeParameter, _typeAnnotation, _readonly_arg, _optional_arg); + return result; +} +KOALA_INTEROP_5(CreateTSMappedType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_UpdateTSMappedType(KNativePointer context, KNativePointer original, KNativePointer typeParameter, KNativePointer typeAnnotation, KInt readonly_arg, KInt optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeParameter = reinterpret_cast(typeParameter); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _readonly_arg = static_cast(readonly_arg); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->UpdateTSMappedType(_context, _original, _typeParameter, _typeAnnotation, _readonly_arg, _optional_arg); + return result; +} +KOALA_INTEROP_6(UpdateTSMappedType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt, KInt); + +KNativePointer impl_TSMappedTypeTypeParameter(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMappedTypeTypeParameter(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMappedTypeTypeParameter, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSMappedTypeTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMappedTypeTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMappedTypeTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KInt impl_TSMappedTypeReadonly(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMappedTypeReadonly(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMappedTypeReadonly, KInt, KNativePointer, KNativePointer); + +KInt impl_TSMappedTypeOptional(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSMappedTypeOptional(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSMappedTypeOptional, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSAnyKeyword(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSAnyKeyword(_context); + return result; +} +KOALA_INTEROP_1(CreateTSAnyKeyword, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSAnyKeyword(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSAnyKeyword(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSAnyKeyword, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateClassDeclaration(KNativePointer context, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->CreateClassDeclaration(_context, _def); + return result; +} +KOALA_INTEROP_2(CreateClassDeclaration, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateClassDeclaration(KNativePointer context, KNativePointer original, KNativePointer def) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _def = reinterpret_cast(def); + auto result = GetImpl()->UpdateClassDeclaration(_context, _original, _def); + return result; +} +KOALA_INTEROP_3(UpdateClassDeclaration, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDeclarationDefinition(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDeclarationDefinition(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ClassDeclarationDefinition, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDeclarationDefinitionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ClassDeclarationDefinitionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ClassDeclarationDefinitionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ClassDeclarationDecoratorsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ClassDeclarationDecoratorsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ClassDeclarationDecoratorsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSIndexedAccessType(KNativePointer context, KNativePointer objectType, KNativePointer indexType) +{ + const auto _context = reinterpret_cast(context); + const auto _objectType = reinterpret_cast(objectType); + const auto _indexType = reinterpret_cast(indexType); + auto result = GetImpl()->CreateTSIndexedAccessType(_context, _objectType, _indexType); + return result; +} +KOALA_INTEROP_3(CreateTSIndexedAccessType, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSIndexedAccessType(KNativePointer context, KNativePointer original, KNativePointer objectType, KNativePointer indexType) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _objectType = reinterpret_cast(objectType); + const auto _indexType = reinterpret_cast(indexType); + auto result = GetImpl()->UpdateTSIndexedAccessType(_context, _original, _objectType, _indexType); + return result; +} +KOALA_INTEROP_4(UpdateTSIndexedAccessType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSIndexedAccessTypeObjectTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexedAccessTypeObjectTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSIndexedAccessTypeObjectTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSIndexedAccessTypeIndexTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSIndexedAccessTypeIndexTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSIndexedAccessTypeIndexTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSQualifiedName(KNativePointer context, KNativePointer left, KNativePointer right) +{ + const auto _context = reinterpret_cast(context); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + auto result = GetImpl()->CreateTSQualifiedName(_context, _left, _right); + return result; +} +KOALA_INTEROP_3(CreateTSQualifiedName, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSQualifiedName(KNativePointer context, KNativePointer original, KNativePointer left, KNativePointer right) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _left = reinterpret_cast(left); + const auto _right = reinterpret_cast(right); + auto result = GetImpl()->UpdateTSQualifiedName(_context, _original, _left, _right); + return result; +} +KOALA_INTEROP_4(UpdateTSQualifiedName, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameLeftConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameLeftConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSQualifiedNameLeftConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameLeft(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameLeft(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSQualifiedNameLeft, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameRightConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameRightConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSQualifiedNameRightConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameRight(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameRight(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSQualifiedNameRight, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TSQualifiedNameNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameResolveLeftMostQualifiedName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameResolveLeftMostQualifiedName(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSQualifiedNameResolveLeftMostQualifiedName, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSQualifiedNameResolveLeftMostQualifiedNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSQualifiedNameResolveLeftMostQualifiedNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSQualifiedNameResolveLeftMostQualifiedNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAwaitExpression(KNativePointer context, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateAwaitExpression(_context, _argument); + return result; +} +KOALA_INTEROP_2(CreateAwaitExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateAwaitExpression(KNativePointer context, KNativePointer original, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateAwaitExpression(_context, _original, _argument); + return result; +} +KOALA_INTEROP_3(UpdateAwaitExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_AwaitExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AwaitExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(AwaitExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateValidationInfo(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateValidationInfo(_context); + return result; +} +KOALA_INTEROP_1(CreateValidationInfo, KNativePointer, KNativePointer); + +KBoolean impl_ValidationInfoFailConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ValidationInfoFailConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ValidationInfoFailConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateContinueStatement(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateContinueStatement(_context); + return result; +} +KOALA_INTEROP_1(CreateContinueStatement, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateContinueStatement(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateContinueStatement(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateContinueStatement, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateContinueStatement1(KNativePointer context, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->CreateContinueStatement1(_context, _ident); + return result; +} +KOALA_INTEROP_2(CreateContinueStatement1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateContinueStatement1(KNativePointer context, KNativePointer original, KNativePointer ident) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _ident = reinterpret_cast(ident); + auto result = GetImpl()->UpdateContinueStatement1(_context, _original, _ident); + return result; +} +KOALA_INTEROP_3(UpdateContinueStatement1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ContinueStatementIdentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ContinueStatementIdentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ContinueStatementIdentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ContinueStatementIdent(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ContinueStatementIdent(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ContinueStatementIdent, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ContinueStatementTargetConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ContinueStatementTargetConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ContinueStatementTargetConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ContinueStatementSetTarget(KNativePointer context, KNativePointer receiver, KNativePointer target) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _target = reinterpret_cast(target); + GetImpl()->ContinueStatementSetTarget(_context, _receiver, _target); + return ; +} +KOALA_INTEROP_V3(ContinueStatementSetTarget, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSNewMultiDimArrayInstanceExpression(KNativePointer context, KNativePointer typeReference, KNativePointerArray dimensions, KUInt dimensionsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _dimensions = reinterpret_cast(dimensions); + const auto _dimensionsSequenceLength = static_cast(dimensionsSequenceLength); + auto result = GetImpl()->CreateETSNewMultiDimArrayInstanceExpression(_context, _typeReference, _dimensions, _dimensionsSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateETSNewMultiDimArrayInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateETSNewMultiDimArrayInstanceExpression(KNativePointer context, KNativePointer original, KNativePointer typeReference, KNativePointerArray dimensions, KUInt dimensionsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _dimensions = reinterpret_cast(dimensions); + const auto _dimensionsSequenceLength = static_cast(dimensionsSequenceLength); + auto result = GetImpl()->UpdateETSNewMultiDimArrayInstanceExpression(_context, _original, _typeReference, _dimensions, _dimensionsSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateETSNewMultiDimArrayInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateETSNewMultiDimArrayInstanceExpression1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateETSNewMultiDimArrayInstanceExpression1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateETSNewMultiDimArrayInstanceExpression1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSNewMultiDimArrayInstanceExpression1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateETSNewMultiDimArrayInstanceExpression1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateETSNewMultiDimArrayInstanceExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewMultiDimArrayInstanceExpressionTypeReference(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewMultiDimArrayInstanceExpressionTypeReference(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSNewMultiDimArrayInstanceExpressionTypeReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewMultiDimArrayInstanceExpressionDimensions(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSNewMultiDimArrayInstanceExpressionDimensions(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSNewMultiDimArrayInstanceExpressionDimensions, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewMultiDimArrayInstanceExpressionDimensionsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSNewMultiDimArrayInstanceExpressionDimensionsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSNewMultiDimArrayInstanceExpressionDimensionsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSNamedTupleMember(KNativePointer context, KNativePointer label, KNativePointer elementType, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _label = reinterpret_cast(label); + const auto _elementType = reinterpret_cast(elementType); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->CreateTSNamedTupleMember(_context, _label, _elementType, _optional_arg); + return result; +} +KOALA_INTEROP_4(CreateTSNamedTupleMember, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSNamedTupleMember(KNativePointer context, KNativePointer original, KNativePointer label, KNativePointer elementType, KBoolean optional_arg) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _label = reinterpret_cast(label); + const auto _elementType = reinterpret_cast(elementType); + const auto _optional_arg = static_cast(optional_arg); + auto result = GetImpl()->UpdateTSNamedTupleMember(_context, _original, _label, _elementType, _optional_arg); + return result; +} +KOALA_INTEROP_5(UpdateTSNamedTupleMember, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSNamedTupleMemberLabelConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNamedTupleMemberLabelConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSNamedTupleMemberLabelConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSNamedTupleMemberElementType(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNamedTupleMemberElementType(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSNamedTupleMemberElementType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSNamedTupleMemberElementTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNamedTupleMemberElementTypeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSNamedTupleMemberElementTypeConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSNamedTupleMemberIsOptionalConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSNamedTupleMemberIsOptionalConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSNamedTupleMemberIsOptionalConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateImportExpression(KNativePointer context, KNativePointer source) +{ + const auto _context = reinterpret_cast(context); + const auto _source = reinterpret_cast(source); + auto result = GetImpl()->CreateImportExpression(_context, _source); + return result; +} +KOALA_INTEROP_2(CreateImportExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateImportExpression(KNativePointer context, KNativePointer original, KNativePointer source) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _source = reinterpret_cast(source); + auto result = GetImpl()->UpdateImportExpression(_context, _original, _source); + return result; +} +KOALA_INTEROP_3(UpdateImportExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportExpressionSource(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportExpressionSource(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ImportExpressionSource, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ImportExpressionSourceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ImportExpressionSourceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ImportExpressionSourceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateAstDumper(KNativePointer context, KNativePointer node, KStringPtr& sourceCode) +{ + const auto _context = reinterpret_cast(context); + const auto _node = reinterpret_cast(node); + const auto _sourceCode = getStringCopy(sourceCode); + auto result = GetImpl()->CreateAstDumper(_context, _node, _sourceCode); + return result; +} +KOALA_INTEROP_3(CreateAstDumper, KNativePointer, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_AstDumperModifierToString(KNativePointer context, KNativePointer receiver, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _flags = static_cast(flags); + auto result = GetImpl()->AstDumperModifierToString(_context, _receiver, _flags); + return new std::string(result); +} +KOALA_INTEROP_3(AstDumperModifierToString, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_AstDumperTypeOperatorToString(KNativePointer context, KNativePointer receiver, KInt operatorType) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _operatorType = static_cast(operatorType); + auto result = GetImpl()->AstDumperTypeOperatorToString(_context, _receiver, _operatorType); + return new std::string(result); +} +KOALA_INTEROP_3(AstDumperTypeOperatorToString, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_AstDumperStrConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->AstDumperStrConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(AstDumperStrConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSNullTypeIr(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateETSNullTypeIr(_context); + return result; +} +KOALA_INTEROP_1(CreateETSNullTypeIr, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSNullTypeIr(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateETSNullTypeIr(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateETSNullTypeIr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSUndefinedTypeIr(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateETSUndefinedTypeIr(_context); + return result; +} +KOALA_INTEROP_1(CreateETSUndefinedTypeIr, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSUndefinedTypeIr(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateETSUndefinedTypeIr(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateETSUndefinedTypeIr, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTypeofExpression(KNativePointer context, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->CreateTypeofExpression(_context, _argument); + return result; +} +KOALA_INTEROP_2(CreateTypeofExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTypeofExpression(KNativePointer context, KNativePointer original, KNativePointer argument) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _argument = reinterpret_cast(argument); + auto result = GetImpl()->UpdateTypeofExpression(_context, _original, _argument); + return result; +} +KOALA_INTEROP_3(UpdateTypeofExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TypeofExpressionArgumentConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TypeofExpressionArgumentConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TypeofExpressionArgumentConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSEnumMember(KNativePointer context, KNativePointer key, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _init = reinterpret_cast(init); + auto result = GetImpl()->CreateTSEnumMember(_context, _key, _init); + return result; +} +KOALA_INTEROP_3(CreateTSEnumMember, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSEnumMember(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer init) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _init = reinterpret_cast(init); + auto result = GetImpl()->UpdateTSEnumMember(_context, _original, _key, _init); + return result; +} +KOALA_INTEROP_4(UpdateTSEnumMember, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSEnumMember1(KNativePointer context, KNativePointer key, KNativePointer init, KBoolean isGenerated) +{ + const auto _context = reinterpret_cast(context); + const auto _key = reinterpret_cast(key); + const auto _init = reinterpret_cast(init); + const auto _isGenerated = static_cast(isGenerated); + auto result = GetImpl()->CreateTSEnumMember1(_context, _key, _init, _isGenerated); + return result; +} +KOALA_INTEROP_4(CreateTSEnumMember1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSEnumMember1(KNativePointer context, KNativePointer original, KNativePointer key, KNativePointer init, KBoolean isGenerated) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _key = reinterpret_cast(key); + const auto _init = reinterpret_cast(init); + const auto _isGenerated = static_cast(isGenerated); + auto result = GetImpl()->UpdateTSEnumMember1(_context, _original, _key, _init, _isGenerated); + return result; +} +KOALA_INTEROP_5(UpdateTSEnumMember1, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSEnumMemberKeyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberKeyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSEnumMemberKeyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumMemberKey(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberKey(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumMemberKey, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumMemberInitConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberInitConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSEnumMemberInitConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumMemberInit(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberInit(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumMemberInit, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSEnumMemberIsGeneratedConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberIsGeneratedConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSEnumMemberIsGeneratedConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSEnumMemberNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSEnumMemberNameConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(TSEnumMemberNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSwitchStatement(KNativePointer context, KNativePointer discriminant, KNativePointerArray cases, KUInt casesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _discriminant = reinterpret_cast(discriminant); + const auto _cases = reinterpret_cast(cases); + const auto _casesSequenceLength = static_cast(casesSequenceLength); + auto result = GetImpl()->CreateSwitchStatement(_context, _discriminant, _cases, _casesSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateSwitchStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateSwitchStatement(KNativePointer context, KNativePointer original, KNativePointer discriminant, KNativePointerArray cases, KUInt casesSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _discriminant = reinterpret_cast(discriminant); + const auto _cases = reinterpret_cast(cases); + const auto _casesSequenceLength = static_cast(casesSequenceLength); + auto result = GetImpl()->UpdateSwitchStatement(_context, _original, _discriminant, _cases, _casesSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateSwitchStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_SwitchStatementDiscriminantConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SwitchStatementDiscriminantConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(SwitchStatementDiscriminantConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchStatementDiscriminant(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->SwitchStatementDiscriminant(_context, _receiver); + return result; +} +KOALA_INTEROP_2(SwitchStatementDiscriminant, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchStatementCasesConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SwitchStatementCasesConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(SwitchStatementCasesConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SwitchStatementCases(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SwitchStatementCases(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(SwitchStatementCases, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateDoWhileStatement(KNativePointer context, KNativePointer body, KNativePointer test) +{ + const auto _context = reinterpret_cast(context); + const auto _body = reinterpret_cast(body); + const auto _test = reinterpret_cast(test); + auto result = GetImpl()->CreateDoWhileStatement(_context, _body, _test); + return result; +} +KOALA_INTEROP_3(CreateDoWhileStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateDoWhileStatement(KNativePointer context, KNativePointer original, KNativePointer body, KNativePointer test) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _body = reinterpret_cast(body); + const auto _test = reinterpret_cast(test); + auto result = GetImpl()->UpdateDoWhileStatement(_context, _original, _body, _test); + return result; +} +KOALA_INTEROP_4(UpdateDoWhileStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DoWhileStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DoWhileStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(DoWhileStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DoWhileStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DoWhileStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(DoWhileStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DoWhileStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DoWhileStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(DoWhileStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_DoWhileStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->DoWhileStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(DoWhileStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateCatchClause(KNativePointer context, KNativePointer param, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _param = reinterpret_cast(param); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateCatchClause(_context, _param, _body); + return result; +} +KOALA_INTEROP_3(CreateCatchClause, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateCatchClause(KNativePointer context, KNativePointer original, KNativePointer param, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _param = reinterpret_cast(param); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->UpdateCatchClause(_context, _original, _param, _body); + return result; +} +KOALA_INTEROP_4(UpdateCatchClause, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CatchClauseParam(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseParam(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CatchClauseParam, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CatchClauseParamConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseParamConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CatchClauseParamConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CatchClauseBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CatchClauseBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CatchClauseBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(CatchClauseBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_CatchClauseIsDefaultCatchClauseConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->CatchClauseIsDefaultCatchClauseConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(CatchClauseIsDefaultCatchClauseConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_CreateSequenceExpression(KNativePointer context, KNativePointerArray sequence_arg, KUInt sequence_argSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _sequence_arg = reinterpret_cast(sequence_arg); + const auto _sequence_argSequenceLength = static_cast(sequence_argSequenceLength); + auto result = GetImpl()->CreateSequenceExpression(_context, _sequence_arg, _sequence_argSequenceLength); + return result; +} +KOALA_INTEROP_3(CreateSequenceExpression, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateSequenceExpression(KNativePointer context, KNativePointer original, KNativePointerArray sequence_arg, KUInt sequence_argSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _sequence_arg = reinterpret_cast(sequence_arg); + const auto _sequence_argSequenceLength = static_cast(sequence_argSequenceLength); + auto result = GetImpl()->UpdateSequenceExpression(_context, _original, _sequence_arg, _sequence_argSequenceLength); + return result; +} +KOALA_INTEROP_4(UpdateSequenceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_SequenceExpressionSequenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SequenceExpressionSequenceConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(SequenceExpressionSequenceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_SequenceExpressionSequence(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->SequenceExpressionSequence(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(SequenceExpressionSequence, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateArrowFunctionExpression(KNativePointer context, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->CreateArrowFunctionExpression(_context, _func); + return result; +} +KOALA_INTEROP_2(CreateArrowFunctionExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateArrowFunctionExpression(KNativePointer context, KNativePointer original, KNativePointer func) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _func = reinterpret_cast(func); + auto result = GetImpl()->UpdateArrowFunctionExpression(_context, _original, _func); + return result; +} +KOALA_INTEROP_3(UpdateArrowFunctionExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateArrowFunctionExpression1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateArrowFunctionExpression1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateArrowFunctionExpression1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateArrowFunctionExpression1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateArrowFunctionExpression1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateArrowFunctionExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionFunctionConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrowFunctionExpressionFunctionConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ArrowFunctionExpressionFunctionConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionFunction(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrowFunctionExpressionFunction(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrowFunctionExpressionFunction, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionCreateTypeAnnotation(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ArrowFunctionExpressionCreateTypeAnnotation(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ArrowFunctionExpressionCreateTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrowFunctionExpressionAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrowFunctionExpressionAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ArrowFunctionExpressionAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ArrowFunctionExpressionAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ArrowFunctionExpressionAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ArrowFunctionExpressionSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->ArrowFunctionExpressionSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ArrowFunctionExpressionSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateOmittedExpression(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateOmittedExpression(_context); + return result; +} +KOALA_INTEROP_1(CreateOmittedExpression, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateOmittedExpression(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateOmittedExpression(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateOmittedExpression, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSNewClassInstanceExpression(KNativePointer context, KNativePointer typeReference, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _typeReference = reinterpret_cast(typeReference); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + auto result = GetImpl()->CreateETSNewClassInstanceExpression(_context, _typeReference, __arguments, __argumentsSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateETSNewClassInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateETSNewClassInstanceExpression(KNativePointer context, KNativePointer original, KNativePointer typeReference, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeReference = reinterpret_cast(typeReference); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + auto result = GetImpl()->UpdateETSNewClassInstanceExpression(_context, _original, _typeReference, __arguments, __argumentsSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateETSNewClassInstanceExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateETSNewClassInstanceExpression1(KNativePointer context, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->CreateETSNewClassInstanceExpression1(_context, _other); + return result; +} +KOALA_INTEROP_2(CreateETSNewClassInstanceExpression1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSNewClassInstanceExpression1(KNativePointer context, KNativePointer original, KNativePointer other) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _other = reinterpret_cast(other); + auto result = GetImpl()->UpdateETSNewClassInstanceExpression1(_context, _original, _other); + return result; +} +KOALA_INTEROP_3(UpdateETSNewClassInstanceExpression1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewClassInstanceExpressionGetTypeRefConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSNewClassInstanceExpressionGetTypeRefConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSNewClassInstanceExpressionGetTypeRefConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewClassInstanceExpressionGetArguments(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSNewClassInstanceExpressionGetArguments(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSNewClassInstanceExpressionGetArguments, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSNewClassInstanceExpressionGetArgumentsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->ETSNewClassInstanceExpressionGetArgumentsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(ETSNewClassInstanceExpressionGetArgumentsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_ETSNewClassInstanceExpressionSetArguments(KNativePointer context, KNativePointer receiver, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + GetImpl()->ETSNewClassInstanceExpressionSetArguments(_context, _receiver, __arguments, __argumentsSequenceLength); + return ; +} +KOALA_INTEROP_V4(ETSNewClassInstanceExpressionSetArguments, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +void impl_ETSNewClassInstanceExpressionAddToArgumentsFront(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->ETSNewClassInstanceExpressionAddToArgumentsFront(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(ETSNewClassInstanceExpressionAddToArgumentsFront, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSAsExpression(KNativePointer context, KNativePointer expression, KNativePointer typeAnnotation, KBoolean isConst) +{ + const auto _context = reinterpret_cast(context); + const auto _expression = reinterpret_cast(expression); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _isConst = static_cast(isConst); + auto result = GetImpl()->CreateTSAsExpression(_context, _expression, _typeAnnotation, _isConst); + return result; +} +KOALA_INTEROP_4(CreateTSAsExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_UpdateTSAsExpression(KNativePointer context, KNativePointer original, KNativePointer expression, KNativePointer typeAnnotation, KBoolean isConst) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _expression = reinterpret_cast(expression); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + const auto _isConst = static_cast(isConst); + auto result = GetImpl()->UpdateTSAsExpression(_context, _original, _expression, _typeAnnotation, _isConst); + return result; +} +KOALA_INTEROP_5(UpdateTSAsExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSAsExpressionExprConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSAsExpressionExprConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSAsExpressionExprConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TSAsExpressionExpr(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSAsExpressionExpr(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSAsExpressionExpr, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSAsExpressionSetExpr(KNativePointer context, KNativePointer receiver, KNativePointer expr) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _expr = reinterpret_cast(expr); + GetImpl()->TSAsExpressionSetExpr(_context, _receiver, _expr); + return ; +} +KOALA_INTEROP_V3(TSAsExpressionSetExpr, KNativePointer, KNativePointer, KNativePointer); + +KBoolean impl_TSAsExpressionIsConstConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSAsExpressionIsConstConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSAsExpressionIsConstConst, KBoolean, KNativePointer, KNativePointer); + +void impl_TSAsExpressionSetUncheckedCast(KNativePointer context, KNativePointer receiver, KBoolean isUncheckedCast) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _isUncheckedCast = static_cast(isUncheckedCast); + GetImpl()->TSAsExpressionSetUncheckedCast(_context, _receiver, _isUncheckedCast); + return ; +} +KOALA_INTEROP_V3(TSAsExpressionSetUncheckedCast, KNativePointer, KNativePointer, KBoolean); + +KNativePointer impl_TSAsExpressionTypeAnnotationConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSAsExpressionTypeAnnotationConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSAsExpressionTypeAnnotationConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TSAsExpressionSetTsTypeAnnotation(KNativePointer context, KNativePointer receiver, KNativePointer typeAnnotation) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _typeAnnotation = reinterpret_cast(typeAnnotation); + GetImpl()->TSAsExpressionSetTsTypeAnnotation(_context, _receiver, _typeAnnotation); + return ; +} +KOALA_INTEROP_V3(TSAsExpressionSetTsTypeAnnotation, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateForUpdateStatement(KNativePointer context, KNativePointer init, KNativePointer test, KNativePointer update, KNativePointer body) +{ + const auto _context = reinterpret_cast(context); + const auto _init = reinterpret_cast(init); + const auto _test = reinterpret_cast(test); + const auto _update = reinterpret_cast(update); + const auto _body = reinterpret_cast(body); + auto result = GetImpl()->CreateForUpdateStatement(_context, _init, _test, _update, _body); + return result; +} +KOALA_INTEROP_5(CreateForUpdateStatement, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementInit(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementInit(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForUpdateStatementInit, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementInitConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementInitConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForUpdateStatementInitConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementTest(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementTest(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForUpdateStatementTest, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementTestConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementTestConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForUpdateStatementTestConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementUpdateConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementUpdateConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForUpdateStatementUpdateConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementBody(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementBody(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ForUpdateStatementBody, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ForUpdateStatementBodyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ForUpdateStatementBodyConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ForUpdateStatementBodyConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSTypeReferencePart(KNativePointer context, KNativePointer name, KNativePointer typeParams, KNativePointer prev) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _prev = reinterpret_cast(prev); + auto result = GetImpl()->CreateETSTypeReferencePart(_context, _name, _typeParams, _prev); + return result; +} +KOALA_INTEROP_4(CreateETSTypeReferencePart, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSTypeReferencePart(KNativePointer context, KNativePointer original, KNativePointer name, KNativePointer typeParams, KNativePointer prev) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + const auto _typeParams = reinterpret_cast(typeParams); + const auto _prev = reinterpret_cast(prev); + auto result = GetImpl()->UpdateETSTypeReferencePart(_context, _original, _name, _typeParams, _prev); + return result; +} +KOALA_INTEROP_5(UpdateETSTypeReferencePart, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSTypeReferencePart1(KNativePointer context, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->CreateETSTypeReferencePart1(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateETSTypeReferencePart1, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateETSTypeReferencePart1(KNativePointer context, KNativePointer original, KNativePointer name) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _name = reinterpret_cast(name); + auto result = GetImpl()->UpdateETSTypeReferencePart1(_context, _original, _name); + return result; +} +KOALA_INTEROP_3(UpdateETSTypeReferencePart1, KNativePointer, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartPrevious(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartPrevious(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTypeReferencePartPrevious, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartPreviousConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartPreviousConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSTypeReferencePartPreviousConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartName(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartName(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTypeReferencePartName, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartTypeParams(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartTypeParams(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSTypeReferencePartTypeParams, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSTypeReferencePartNameConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSTypeReferencePartNameConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSTypeReferencePartNameConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSReExportDeclarationGetETSImportDeclarationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSReExportDeclarationGetETSImportDeclarationsConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSReExportDeclarationGetETSImportDeclarationsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSReExportDeclarationGetETSImportDeclarations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSReExportDeclarationGetETSImportDeclarations(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSReExportDeclarationGetETSImportDeclarations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSReExportDeclarationGetProgramPathConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSReExportDeclarationGetProgramPathConst(_context, _receiver); + return new std::string(result); +} +KOALA_INTEROP_2(ETSReExportDeclarationGetProgramPathConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSPrimitiveType(KNativePointer context, KInt type) +{ + const auto _context = reinterpret_cast(context); + const auto _type = static_cast(type); + auto result = GetImpl()->CreateETSPrimitiveType(_context, _type); + return result; +} +KOALA_INTEROP_2(CreateETSPrimitiveType, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateETSPrimitiveType(KNativePointer context, KNativePointer original, KInt type) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _type = static_cast(type); + auto result = GetImpl()->UpdateETSPrimitiveType(_context, _original, _type); + return result; +} +KOALA_INTEROP_3(UpdateETSPrimitiveType, KNativePointer, KNativePointer, KNativePointer, KInt); + +KInt impl_ETSPrimitiveTypeGetPrimitiveTypeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSPrimitiveTypeGetPrimitiveTypeConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSPrimitiveTypeGetPrimitiveTypeConst, KInt, KNativePointer, KNativePointer); + +KNativePointer impl_TypeNodeAnnotations(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TypeNodeAnnotations(_context, _receiver, &length); + return new std::vector(result, result + length); +} +KOALA_INTEROP_2(TypeNodeAnnotations, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_TypeNodeAnnotationsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->TypeNodeAnnotationsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(TypeNodeAnnotationsConst, KNativePointer, KNativePointer, KNativePointer); + +void impl_TypeNodeSetAnnotations(KNativePointer context, KNativePointer receiver, KNativePointerArray annotations, KUInt annotationsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + const auto _annotations = reinterpret_cast(annotations); + const auto _annotationsSequenceLength = static_cast(annotationsSequenceLength); + GetImpl()->TypeNodeSetAnnotations(_context, _receiver, _annotations, _annotationsSequenceLength); + return ; +} +KOALA_INTEROP_V4(TypeNodeSetAnnotations, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_CreateNewExpression(KNativePointer context, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + auto result = GetImpl()->CreateNewExpression(_context, _callee, __arguments, __argumentsSequenceLength); + return result; +} +KOALA_INTEROP_4(CreateNewExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_UpdateNewExpression(KNativePointer context, KNativePointer original, KNativePointer callee, KNativePointerArray _arguments, KUInt _argumentsSequenceLength) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _callee = reinterpret_cast(callee); + const auto __arguments = reinterpret_cast(_arguments); + const auto __argumentsSequenceLength = static_cast(_argumentsSequenceLength); + auto result = GetImpl()->UpdateNewExpression(_context, _original, _callee, __arguments, __argumentsSequenceLength); + return result; +} +KOALA_INTEROP_5(UpdateNewExpression, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KNativePointerArray, KUInt); + +KNativePointer impl_NewExpressionCalleeConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->NewExpressionCalleeConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(NewExpressionCalleeConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_NewExpressionArgumentsConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + std::size_t length; + auto result = GetImpl()->NewExpressionArgumentsConst(_context, _receiver, &length); + return (void*)new std::vector(result, result + length); +} +KOALA_INTEROP_2(NewExpressionArgumentsConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSParameterProperty(KNativePointer context, KInt accessibility, KNativePointer parameter, KBoolean readonly_arg, KBoolean isStatic, KBoolean isExport) +{ + const auto _context = reinterpret_cast(context); + const auto _accessibility = static_cast(accessibility); + const auto _parameter = reinterpret_cast(parameter); + const auto _readonly_arg = static_cast(readonly_arg); + const auto _isStatic = static_cast(isStatic); + const auto _isExport = static_cast(isExport); + auto result = GetImpl()->CreateTSParameterProperty(_context, _accessibility, _parameter, _readonly_arg, _isStatic, _isExport); + return result; +} +KOALA_INTEROP_6(CreateTSParameterProperty, KNativePointer, KNativePointer, KInt, KNativePointer, KBoolean, KBoolean, KBoolean); + +KNativePointer impl_UpdateTSParameterProperty(KNativePointer context, KNativePointer original, KInt accessibility, KNativePointer parameter, KBoolean readonly_arg, KBoolean isStatic, KBoolean isExport) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _accessibility = static_cast(accessibility); + const auto _parameter = reinterpret_cast(parameter); + const auto _readonly_arg = static_cast(readonly_arg); + const auto _isStatic = static_cast(isStatic); + const auto _isExport = static_cast(isExport); + auto result = GetImpl()->UpdateTSParameterProperty(_context, _original, _accessibility, _parameter, _readonly_arg, _isStatic, _isExport); + return result; +} +KOALA_INTEROP_7(UpdateTSParameterProperty, KNativePointer, KNativePointer, KNativePointer, KInt, KNativePointer, KBoolean, KBoolean, KBoolean); + +KInt impl_TSParameterPropertyAccessibilityConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyAccessibilityConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSParameterPropertyAccessibilityConst, KInt, KNativePointer, KNativePointer); + +KBoolean impl_TSParameterPropertyReadonlyConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyReadonlyConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSParameterPropertyReadonlyConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSParameterPropertyIsStaticConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyIsStaticConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSParameterPropertyIsStaticConst, KBoolean, KNativePointer, KNativePointer); + +KBoolean impl_TSParameterPropertyIsExportConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyIsExportConst(_context, _receiver); + return result; +} +KOALA_INTEROP_2(TSParameterPropertyIsExportConst, KBoolean, KNativePointer, KNativePointer); + +KNativePointer impl_TSParameterPropertyParameterConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->TSParameterPropertyParameterConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(TSParameterPropertyParameterConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateETSWildcardType(KNativePointer context, KNativePointer typeReference, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _flags = static_cast(flags); + auto result = GetImpl()->CreateETSWildcardType(_context, _typeReference, _flags); + return result; +} +KOALA_INTEROP_3(CreateETSWildcardType, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_UpdateETSWildcardType(KNativePointer context, KNativePointer original, KNativePointer typeReference, KInt flags) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + const auto _typeReference = reinterpret_cast(typeReference); + const auto _flags = static_cast(flags); + auto result = GetImpl()->UpdateETSWildcardType(_context, _original, _typeReference, _flags); + return result; +} +KOALA_INTEROP_4(UpdateETSWildcardType, KNativePointer, KNativePointer, KNativePointer, KNativePointer, KInt); + +KNativePointer impl_ETSWildcardTypeTypeReference(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSWildcardTypeTypeReference(_context, _receiver); + return result; +} +KOALA_INTEROP_2(ETSWildcardTypeTypeReference, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_ETSWildcardTypeTypeReferenceConst(KNativePointer context, KNativePointer receiver) +{ + const auto _context = reinterpret_cast(context); + const auto _receiver = reinterpret_cast(receiver); + auto result = GetImpl()->ETSWildcardTypeTypeReferenceConst(_context, _receiver); + return (void*)result; +} +KOALA_INTEROP_2(ETSWildcardTypeTypeReferenceConst, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateTSThisType(KNativePointer context) +{ + const auto _context = reinterpret_cast(context); + auto result = GetImpl()->CreateTSThisType(_context); + return result; +} +KOALA_INTEROP_1(CreateTSThisType, KNativePointer, KNativePointer); + +KNativePointer impl_UpdateTSThisType(KNativePointer context, KNativePointer original) +{ + const auto _context = reinterpret_cast(context); + const auto _original = reinterpret_cast(original); + auto result = GetImpl()->UpdateTSThisType(_context, _original); + return result; +} +KOALA_INTEROP_2(UpdateTSThisType, KNativePointer, KNativePointer, KNativePointer); + +KNativePointer impl_CreateInterfaceDecl(KNativePointer context, KStringPtr& name) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + auto result = GetImpl()->CreateInterfaceDecl(_context, _name); + return result; +} +KOALA_INTEROP_2(CreateInterfaceDecl, KNativePointer, KNativePointer, KStringPtr); + +KNativePointer impl_CreateInterfaceDecl1(KNativePointer context, KStringPtr& name, KNativePointer declNode) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + const auto _declNode = reinterpret_cast(declNode); + auto result = GetImpl()->CreateInterfaceDecl1(_context, _name, _declNode); + return result; +} +KOALA_INTEROP_3(CreateInterfaceDecl1, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + +KNativePointer impl_CreateFunctionDecl(KNativePointer context, KStringPtr& name, KNativePointer node) +{ + const auto _context = reinterpret_cast(context); + const auto _name = getStringCopy(name); + const auto _node = reinterpret_cast(node); + auto result = GetImpl()->CreateFunctionDecl(_context, _name, _node); + return result; +} +KOALA_INTEROP_3(CreateFunctionDecl, KNativePointer, KNativePointer, KStringPtr, KNativePointer); + diff --git a/koala-wrapper/package.json b/koala-wrapper/package.json new file mode 100644 index 000000000..397203cec --- /dev/null +++ b/koala-wrapper/package.json @@ -0,0 +1,81 @@ +{ + "name": "@koalaui/libarkts", + "version": "1.0.0", + "private": true, + "main": "./build/lib/es2panda.js", + "types": "./build/src/arkts-api/index.d.ts", + "exports": { + ".": "./build/lib/arkts-api/index.js", + "./build/lib/es2panda": "./build/lib/es2panda.js" + }, + "files": [ + "./build/*" + ], + "config": { + "gen_version": "3.0.19" + }, + "devDependencies": { + "@babel/cli": "7.20.7", + "@babel/core": "7.20.12", + "@babel/plugin-proposal-class-properties": "7.18.6", + "@babel/preset-env": "7.20.2", + "@babel/preset-typescript": "7.18.6", + "@babel/runtime": "7.20.13", + "@tsconfig/recommended": "1.0.8", + "node-addon-api": "^8.3.0", + "typescript": "^5.0.0", + "@types/node": "^18.0.0" + }, + "imports": { + "#koalaui/interop": { + "default": "./koalaui/interop/dist/lib/src/interop/index.js" + }, + "#koalaui/common": { + "default": "./koalaui/common/dist/lib/src/index.js" + }, + "#koalaui/compat": { + "default": "./koalaui/compat/dist/src/index.js" + }, + "#common/wrappers": { + "browser": "./koalaui/interop/dist/lib/src/wasm/wrappers/index.js", + "node": "./koalaui/interop/dist/lib/src/napi/wrappers/index.js" + }, + "#common/wrappers/*": { + "browser": "./koalaui/interop/dist/lib/src/wasm/wrappers/*.js", + "node": "./koalaui/interop/dist/lib/src/napi/wrappers/*.js", + "default": "./koalaui/interop/dist/lib/src/napi/wrappers/*.js" + }, + "#platform": { + "ark": "./koalaui/compat/dist/src/ohos/index.js", + "ios": "./koalaui/compat/dist/src/typescript/index.js", + "browser": "./koalaui/compat/dist/src/typescript/index.js", + "node": "./koalaui/compat/dist/src/typescript/index.js", + "default": "./koalaui/compat/dist/src/typescript/index.js" + } + }, + "scripts": { + "clean": "rimraf build native/build*", + "compile:meson": "cd native && meson setup build && meson compile -C build", + "copy:.node": "mkdir -p ./build/lib/native/ && cp ./native/build/es2panda.node ./build/lib/native", + "compile:native": "npm run compile:meson && npm run copy:.node", + "compile:src": "./node_modules/.bin/babel ./src --out-dir build/lib --extensions .ts", + "compile:types": "npx tsc -p ./tsconfig.json --emitDeclarationOnly", + "compile:src:tsc": "tsc -p ./tsconfig.json", + "compile:tsc": "npm run compile:src && npm run compile:types", + "compile": "npm run compile:native && npm run compile:src && npm run compile:types", + "compile:plugins": "npx ets-tsc -p plugins/tsconfig.json", + "restart": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/main.sts --output ./build/abc/main.abc --dump-plugin-ast --arktsconfig ./arktsconfig.json --restart-stages", + "direct": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/no-import-no-struct.sts --output ./build/abc/no-import-no-struct.abc --dump-plugin-ast --arktsconfig ./arktsconfig-print-only.json", + "memo": "PANDA_SDK_PATH=../../incremental/tools/panda/node_modules/@panda/sdk node . --file ./plugins/input/memo.sts --output ./build/abc/memo.abc --dump-plugin-ast --arktsconfig ./arktsconfig-memo.json --restart-stages", + "run": "npm run compile && npm run compile:plugins && npm run restart", + "run:memo": "npm run compile && npm run compile:plugins && npm run compile --prefix ../memo-plugin && npm run memo", + "run:abc": "../../incremental/tools/panda/node_modules/@panda/sdk/linux_host_tools/bin/ark --load-runtimes=ets --boot-panda-files=../../incremental/tools/panda/node_modules/@panda/sdk/ets/etsstdlib.abc ./main.abc main.ETSGLOBAL::main", + "compile:playground": "cd playground && meson setup build && meson compile -C build", + "run:playground": "npm run compile:playground && ./playground/build/playground.out", + "panda:sdk:clean": "cd ../../incremental/tools/panda && rimraf node_modules", + "panda:sdk:install": "cd ../../incremental/tools/panda && npm run panda:sdk:install", + "panda:sdk:reinstall": "npm run panda:sdk:clean && npm run panda:sdk:install", + "regenerate": "npx @idlizer/libarkts-gen@$npm_package_config_gen_version --input-file $npm_package_config_input_file --output-dir ../ --files bridges,nativeModule", + "reinstall:regenerate": "npm run panda:sdk:reinstall && npm run regenerate" + } +} diff --git a/koala-wrapper/src/Es2pandaEnums.ts b/koala-wrapper/src/Es2pandaEnums.ts new file mode 100644 index 000000000..bf820a759 --- /dev/null +++ b/koala-wrapper/src/Es2pandaEnums.ts @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +// HANDWRITTEN (for now) + +export enum Es2pandaAstNodeType { + AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION, + AST_NODE_TYPE_ANNOTATION_DECLARATION, + AST_NODE_TYPE_ANNOTATION_USAGE, + AST_NODE_TYPE_ASSERT_STATEMENT, + AST_NODE_TYPE_AWAIT_EXPRESSION, + AST_NODE_TYPE_BIGINT_LITERAL, + AST_NODE_TYPE_BINARY_EXPRESSION, + AST_NODE_TYPE_BLOCK_STATEMENT, + AST_NODE_TYPE_BOOLEAN_LITERAL, + AST_NODE_TYPE_BREAK_STATEMENT, + AST_NODE_TYPE_CALL_EXPRESSION, + AST_NODE_TYPE_CATCH_CLAUSE, + AST_NODE_TYPE_CHAIN_EXPRESSION, + AST_NODE_TYPE_CHAR_LITERAL, + AST_NODE_TYPE_CLASS_DEFINITION, + AST_NODE_TYPE_CLASS_DECLARATION, + AST_NODE_TYPE_CLASS_EXPRESSION, + AST_NODE_TYPE_CLASS_PROPERTY, + AST_NODE_TYPE_CLASS_STATIC_BLOCK, + AST_NODE_TYPE_CONDITIONAL_EXPRESSION, + AST_NODE_TYPE_CONTINUE_STATEMENT, + AST_NODE_TYPE_DEBUGGER_STATEMENT, + AST_NODE_TYPE_DECORATOR, + AST_NODE_TYPE_DIRECT_EVAL, + AST_NODE_TYPE_DO_WHILE_STATEMENT, + AST_NODE_TYPE_EMPTY_STATEMENT, + AST_NODE_TYPE_EXPORT_ALL_DECLARATION, + AST_NODE_TYPE_EXPORT_DEFAULT_DECLARATION, + AST_NODE_TYPE_EXPORT_NAMED_DECLARATION, + AST_NODE_TYPE_EXPORT_SPECIFIER, + AST_NODE_TYPE_EXPRESSION_STATEMENT, + AST_NODE_TYPE_FOR_IN_STATEMENT, + AST_NODE_TYPE_FOR_OF_STATEMENT, + AST_NODE_TYPE_FOR_UPDATE_STATEMENT, + AST_NODE_TYPE_FUNCTION_DECLARATION, + AST_NODE_TYPE_FUNCTION_EXPRESSION, + AST_NODE_TYPE_IDENTIFIER, + AST_NODE_TYPE_DUMMYNODE, + AST_NODE_TYPE_IF_STATEMENT, + AST_NODE_TYPE_IMPORT_DECLARATION, + AST_NODE_TYPE_IMPORT_EXPRESSION, + AST_NODE_TYPE_IMPORT_DEFAULT_SPECIFIER, + AST_NODE_TYPE_IMPORT_NAMESPACE_SPECIFIER, + AST_NODE_TYPE_IMPORT_SPECIFIER, + AST_NODE_TYPE_LABELLED_STATEMENT, + AST_NODE_TYPE_MEMBER_EXPRESSION, + AST_NODE_TYPE_META_PROPERTY_EXPRESSION, + AST_NODE_TYPE_METHOD_DEFINITION, + AST_NODE_TYPE_NAMED_TYPE, + AST_NODE_TYPE_NEW_EXPRESSION, + AST_NODE_TYPE_NULL_LITERAL, + AST_NODE_TYPE_UNDEFINED_LITERAL, + AST_NODE_TYPE_NUMBER_LITERAL, + AST_NODE_TYPE_OMITTED_EXPRESSION, + AST_NODE_TYPE_PREFIX_ASSERTION_EXPRESSION, + AST_NODE_TYPE_PROPERTY, + AST_NODE_TYPE_REGEXP_LITERAL, + AST_NODE_TYPE_REEXPORT_STATEMENT, + AST_NODE_TYPE_RETURN_STATEMENT, + AST_NODE_TYPE_SCRIPT_FUNCTION, + AST_NODE_TYPE_SEQUENCE_EXPRESSION, + AST_NODE_TYPE_STRING_LITERAL, + AST_NODE_TYPE_ETS_NULL_TYPE, + AST_NODE_TYPE_ETS_UNDEFINED_TYPE, + AST_NODE_TYPE_ETS_NEVER_TYPE, + AST_NODE_TYPE_ETS_STRING_LITERAL_TYPE, + AST_NODE_TYPE_ETS_FUNCTION_TYPE, + AST_NODE_TYPE_ETS_WILDCARD_TYPE, + AST_NODE_TYPE_ETS_PRIMITIVE_TYPE, + AST_NODE_TYPE_ETS_PACKAGE_DECLARATION, + AST_NODE_TYPE_ETS_CLASS_LITERAL, + AST_NODE_TYPE_ETS_TYPE_REFERENCE, + AST_NODE_TYPE_ETS_TYPE_REFERENCE_PART, + AST_NODE_TYPE_ETS_UNION_TYPE, + AST_NODE_TYPE_ETS_KEYOF_TYPE, + AST_NODE_TYPE_ETS_LAUNCH_EXPRESSION, + AST_NODE_TYPE_ETS_NEW_ARRAY_INSTANCE_EXPRESSION, + AST_NODE_TYPE_ETS_NEW_MULTI_DIM_ARRAY_INSTANCE_EXPRESSION, + AST_NODE_TYPE_ETS_NEW_CLASS_INSTANCE_EXPRESSION, + AST_NODE_TYPE_ETS_IMPORT_DECLARATION, + AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION, + AST_NODE_TYPE_ETS_TUPLE, + AST_NODE_TYPE_ETS_MODULE, + AST_NODE_TYPE_SUPER_EXPRESSION, + AST_NODE_TYPE_STRUCT_DECLARATION, + AST_NODE_TYPE_SWITCH_CASE_STATEMENT, + AST_NODE_TYPE_SWITCH_STATEMENT, + AST_NODE_TYPE_TS_ENUM_DECLARATION, + AST_NODE_TYPE_TS_ENUM_MEMBER, + AST_NODE_TYPE_TS_EXTERNAL_MODULE_REFERENCE, + AST_NODE_TYPE_TS_NUMBER_KEYWORD, + AST_NODE_TYPE_TS_ANY_KEYWORD, + AST_NODE_TYPE_TS_STRING_KEYWORD, + AST_NODE_TYPE_TS_BOOLEAN_KEYWORD, + AST_NODE_TYPE_TS_VOID_KEYWORD, + AST_NODE_TYPE_TS_UNDEFINED_KEYWORD, + AST_NODE_TYPE_TS_UNKNOWN_KEYWORD, + AST_NODE_TYPE_TS_OBJECT_KEYWORD, + AST_NODE_TYPE_TS_BIGINT_KEYWORD, + AST_NODE_TYPE_TS_NEVER_KEYWORD, + AST_NODE_TYPE_TS_NON_NULL_EXPRESSION, + AST_NODE_TYPE_TS_NULL_KEYWORD, + AST_NODE_TYPE_TS_ARRAY_TYPE, + AST_NODE_TYPE_TS_UNION_TYPE, + AST_NODE_TYPE_TS_TYPE_LITERAL, + AST_NODE_TYPE_TS_PROPERTY_SIGNATURE, + AST_NODE_TYPE_TS_METHOD_SIGNATURE, + AST_NODE_TYPE_TS_SIGNATURE_DECLARATION, + AST_NODE_TYPE_TS_PARENT_TYPE, + AST_NODE_TYPE_TS_LITERAL_TYPE, + AST_NODE_TYPE_TS_INFER_TYPE, + AST_NODE_TYPE_TS_CONDITIONAL_TYPE, + AST_NODE_TYPE_TS_IMPORT_TYPE, + AST_NODE_TYPE_TS_INTERSECTION_TYPE, + AST_NODE_TYPE_TS_MAPPED_TYPE, + AST_NODE_TYPE_TS_MODULE_BLOCK, + AST_NODE_TYPE_TS_THIS_TYPE, + AST_NODE_TYPE_TS_TYPE_OPERATOR, + AST_NODE_TYPE_TS_TYPE_PARAMETER, + AST_NODE_TYPE_TS_TYPE_PARAMETER_DECLARATION, + AST_NODE_TYPE_TS_TYPE_PARAMETER_INSTANTIATION, + AST_NODE_TYPE_TS_TYPE_PREDICATE, + AST_NODE_TYPE_TS_PARAMETER_PROPERTY, + AST_NODE_TYPE_TS_MODULE_DECLARATION, + AST_NODE_TYPE_TS_IMPORT_EQUALS_DECLARATION, + AST_NODE_TYPE_TS_FUNCTION_TYPE, + AST_NODE_TYPE_TS_CONSTRUCTOR_TYPE, + AST_NODE_TYPE_TS_TYPE_ALIAS_DECLARATION, + AST_NODE_TYPE_TS_TYPE_REFERENCE, + AST_NODE_TYPE_TS_QUALIFIED_NAME, + AST_NODE_TYPE_TS_INDEXED_ACCESS_TYPE, + AST_NODE_TYPE_TS_INTERFACE_DECLARATION, + AST_NODE_TYPE_TS_INTERFACE_BODY, + AST_NODE_TYPE_TS_INTERFACE_HERITAGE, + AST_NODE_TYPE_TS_TUPLE_TYPE, + AST_NODE_TYPE_TS_NAMED_TUPLE_MEMBER, + AST_NODE_TYPE_TS_INDEX_SIGNATURE, + AST_NODE_TYPE_TS_TYPE_QUERY, + AST_NODE_TYPE_TS_AS_EXPRESSION, + AST_NODE_TYPE_TS_CLASS_IMPLEMENTS, + AST_NODE_TYPE_TS_TYPE_ASSERTION, + AST_NODE_TYPE_TAGGED_TEMPLATE_EXPRESSION, + AST_NODE_TYPE_TEMPLATE_ELEMENT, + AST_NODE_TYPE_TEMPLATE_LITERAL, + AST_NODE_TYPE_THIS_EXPRESSION, + AST_NODE_TYPE_TYPEOF_EXPRESSION, + AST_NODE_TYPE_THROW_STATEMENT, + AST_NODE_TYPE_TRY_STATEMENT, + AST_NODE_TYPE_UNARY_EXPRESSION, + AST_NODE_TYPE_UPDATE_EXPRESSION, + AST_NODE_TYPE_VARIABLE_DECLARATION, + AST_NODE_TYPE_VARIABLE_DECLARATOR, + AST_NODE_TYPE_WHILE_STATEMENT, + AST_NODE_TYPE_YIELD_EXPRESSION, + AST_NODE_TYPE_OPAQUE_TYPE_NODE, + AST_NODE_TYPE_BLOCK_EXPRESSION, + AST_NODE_TYPE_ERROR_TYPE_NODE, + AST_NODE_TYPE_ARRAY_EXPRESSION, + AST_NODE_TYPE_ARRAY_PATTERN, + AST_NODE_TYPE_ASSIGNMENT_EXPRESSION, + AST_NODE_TYPE_ASSIGNMENT_PATTERN, + AST_NODE_TYPE_OBJECT_EXPRESSION, + AST_NODE_TYPE_OBJECT_PATTERN, + AST_NODE_TYPE_SPREAD_ELEMENT, + AST_NODE_TYPE_REST_ELEMENT, +} diff --git a/koala-wrapper/src/Es2pandaNativeModule.ts b/koala-wrapper/src/Es2pandaNativeModule.ts new file mode 100644 index 000000000..3f271657a --- /dev/null +++ b/koala-wrapper/src/Es2pandaNativeModule.ts @@ -0,0 +1,812 @@ +/* + * Copyright (c) 2022-2025 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 { + KNativePointer as KPtr, + KInt, + KBoolean, + KNativePointer, + registerNativeModuleLibraryName, + loadNativeModuleLibrary, + KDouble, +} from '@koalaui/interop'; +import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from './generated/Es2pandaNativeModule'; +import * as path from 'path'; + +// TODO: this type should be in interop +export type KPtrArray = BigUint64Array; + +export class Es2pandaNativeModule { + _ClassDefinitionSuper(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateTSInterfaceDeclaration( + _context: KPtr, + _extends: KPtrArray, + _extendsLen: KInt, + _id: KPtr, + _typeParams: KPtr, + _body: KPtr, + _isStatic: KBoolean, + _isExternal: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _CreateTSTypeParameterInstantiation(context: KPtr, params: KPtrArray, paramsLen: KInt): KPtr { + throw new Error('Not implemented'); + } + _ClassElementKey(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ClassElementValue(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AnnotationUsageIrExpr(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AnnotationUsageIrPropertiesConst(context: KPtr, node: KPtr, returnLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AnnotationAllowedAnnotations(context: KPtr, node: KPtr, returnLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AnnotationAllowedAnnotationsConst(context: KPtr, node: KPtr, returnLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeRebind(context: KPtr, node: KPtr): void { + throw new Error('Not implemented'); + } + _AstNodeRecheck(context: KPtr, node: KPtr): void { + throw new Error('Not implemented'); + } + + _ContextState(context: KPtr): KInt { + throw new Error('Not implemented'); + } + _ContextErrorMessage(context: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeChildren(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ETSParserCreateExpression(context: KPtr, sourceCode: String, flags: KInt): KPtr { + throw new Error('Not implemented'); + } + _AstNodeDumpModifiers(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateAstDumper(context: KPtr, node: KPtr, source: String): KPtr { + throw new Error('Not implemented'); + } + _AstDumperModifierToString(context: KPtr, dumper: KPtr, flags: KInt): KPtr { + throw new Error('Not implemented'); + } + + _CreateConfig(argc: number, argv: string[]): KPtr { + throw new Error('Not implemented'); + } + _DestroyConfig(config: KPtr): void { + throw new Error('Not implemented'); + } + _CreateContextFromString(config: KPtr, source: String, filename: String): KPtr { + throw new Error('Not implemented'); + } + _CreateContextFromFile(config: KPtr, filename: String): KPtr { + throw new Error('Not implemented'); + } + _DestroyContext(context: KPtr): void { + throw new Error('Not implemented'); + } + _ProceedToState(context: KPtr, state: number): void { + throw new Error('Not implemented'); + } + _ContextProgram(context: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ProgramAst(context: KPtr, program: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CheckerStartChecker(context: KPtr): KBoolean { + throw new Error('Not implemented'); + } + _VarBinderIdentifierAnalysis(context: KPtr): void { + throw new Error('Not implemented'); + } + _VarBinderInitTopScope(context: KPtr): void { + throw new Error('Not implemented'); + } + _VarBinderSetGenStdLib(context: KPtr, genStdLibT: KBoolean): void { + throw new Error('Not implemented'); + } + _SourceFileGetChildren(node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _BlockGetStatements(node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _FunctionDeclarationIsAnonymousConst(context: KPtr, node: KPtr): KBoolean { + throw new Error('Not implemented'); + } + _ExpressionStatementGetExpression(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CallExpressionArguments(context: KPtr, node: KPtr, returnLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CallExpressionCallee(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _IdentifierGetText(node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _IdentifierIsPrivateIdentConst(context: KPtr, node: KPtr): KBoolean { + throw new Error('Not implemented'); + } + _PropertyAccessExpressionGetExpression(node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _PropertyAccessExpressionGetName(node: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _FunctionDeclarationFunction(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionSignature(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionParams(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionId(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionBody(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionAnnotations(context: KPtr, node: KPtr, returnLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionSetIdent(context: KPtr, ast: KPtr, id: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionSetSignature(context: KPtr, ast: KPtr, signature: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionSetBody(context: KPtr, ast: KPtr, body: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionSetScope(context: KPtr, ast: KPtr, scope: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionSetAnnotations(context: KPtr, ast: KPtr, annotations: KPtrArray, annotationsLen: KInt): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionDeclareConst(context: KPtr, node: KPtr): KBoolean { + throw new Error('Not implemented'); + } + _ScriptFunctionFlagsConst(context: KPtr, node: KPtr): KInt { + throw new Error('Not implemented'); + } + _ScriptFunctionTypeParams(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionReturnTypeAnnotation(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ScriptFunctionAddFlag(context: KPtr, node: KPtr, flags: KInt): void { + throw new Error('Not implemented'); + } + _ClassPropertyAnnotations(context: KPtr, node: KPtr, returnLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ClassPropertySetAnnotations(context: KPtr, ast: KPtr, annotations: KPtrArray, annotationsLen: KInt): KPtr { + throw new Error('Not implemented'); + } + _UpdateBlockStatement(context: KPtr, original: KPtr, statementList: KPtrArray, statementListLen: KInt): KPtr { + throw new Error('Not implemented'); + } + _BlockStatementSetScope(context: KPtr, node: KPtr, scope: KPtrArray): void { + throw new Error('Not implemented'); + } + _CreateIdentifier1(context: KPtr, name: String): KPtr { + throw new Error('Not implemented'); + } + _CreateIdentifier2(context: KPtr, name: String, type_annotation: KPtr): KPtr { + throw new Error('Not implemented'); + } + _IdentifierSetName(context: KPtr, node: KPtr, name: String): void { + throw new Error('Not implemented'); + } + _IdentifierIdentifierFlags(context: KPtr, node: KPtr): KInt { + throw new Error('Not implemented'); + } + _CreateFunctionDeclaration( + context: KPtr, + func: KPtr, + annotations: KPtrArray, + annotationsLen: KInt, + isAnon: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _UpdateFunctionDeclaration( + context: KPtr, + node: KPtr, + annotations: KPtrArray, + annotationsLen: KInt, + func: KPtr, + isAnon: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _CreateReturnStatement1(context: KPtr, argument: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ReturnStatementArgument(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateIfStatement(context: KPtr, test: KPtr, consequent: KPtr, alternate: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateBinaryExpression(context: KPtr, left: KPtr, right: KPtr, operatorType: KInt): KPtr { + throw new Error('Not implemented'); + } + _CreateAssignmentExpression(context: KPtr, left: KPtr, right: KPtr, assignmentOperator: KInt): KPtr { + throw new Error('Not implemented'); + } + _CreateMethodDefinition( + context: KPtr, + kind: KInt, + key: KPtr, + value: KPtr, + modifiers: KInt, + isComputed: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _CreateClassProperty( + context: KPtr, + key: KPtr, + value: KPtr, + typeAnnotation: KPtr, + modifiers: KInt, + isComputed: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _CreateETSImportDeclaration( + context: KPtr, + source: KPtr, + specifiers: KPtrArray, + specifiersLen: KInt, + importKind: KInt + ): KNativePointer { + throw new Error('Not implemented'); + } + _ETSImportDeclarationSourceConst(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ETSImportDeclarationResolvedSource(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ETSImportDeclarationHasDeclConst(context: KPtr, node: KPtr): KBoolean { + throw new Error('Not implemented'); + } + _CreateImportSource(context: KPtr, source: KPtr, resolvedSource: KPtr, hasDecl: KBoolean): KNativePointer { + throw new Error('Not implemented'); + } + _CreateImportSpecifier(context: KPtr, imported: KPtr, local: KPtr): KNativePointer { + throw new Error('Not implemented'); + } + + _CreateFunctionSignature( + context: KPtr, + typeParams: KPtr, + params: KPtrArray, + paramsLen: KInt, + returnTypeAnnotation: KPtr, + hasReceiver: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _CreateScriptFunction( + context: KPtr, + databody: KPtr, + datasignature: KPtr, + datafuncFlags: KInt, + dataflags: KInt + ): KPtr { + throw new Error('Not implemented'); + } + _UpdateScriptFunction( + context: KPtr, + original: KPtr, + databody: KPtr, + datasignature: KPtr, + datafuncFlags: KInt, + dataflags: KInt, + datadeclare: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _CreateBlockStatement(context: KPtr, statementList: KPtrArray, statementListLen: KInt): KPtr { + throw new Error('Not implemented'); + } + _AstNodeScopeConst(context: KPtr, ast: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeParent(context: KPtr, ast: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeSetParent(context: KPtr, ast: KPtr, parent: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeClone(context: KPtr, ast: KPtr, parent: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeModifiers(context: KPtr, ast: KPtr): KInt { + throw new Error('Not implemented'); + } + _AstNodeAddModifier(context: KPtr, ast: KPtr, flags: KInt): void { + throw new Error('Not implemented'); + } + _AstNodeClearModifier(context: KPtr, ast: KPtr, flags: KInt): void { + throw new Error('Not implemented'); + } + _AstNodeVariableConst(context: KPtr, ast: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeTypeConst(context: KPtr, ast: KPtr): KInt { + throw new Error('Not implemented'); + } + _FunctionSignatureTypeParams(context: KPtr, ast: KPtr): KPtr { + throw new Error('Not implemented'); + } + _FunctionSignatureReturnType(context: KPtr, ast: KPtr): KPtr { + throw new Error('Not implemented'); + } + _FunctionSignatureParamsConst(context: KPtr, ast: KPtr, returnTypeLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _UpdateIdentifier1(context: KPtr, ast: KPtr, name: string): KPtr { + throw new Error('Not implemented'); + } + _UpdateIdentifier2(context: KPtr, ast: KPtr, name: string, typeAnnotation: KPtr): KPtr { + throw new Error('Not implemented'); + } + _UpdateMethodDefinition( + context: KPtr, + node: KPtr, + kind: KInt, + key: KPtr, + value: KPtr, + modifiers: KInt, + isComputed: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _MethodDefinitionFunction(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _MethodDefinitionKindConst(context: KPtr, node: KPtr): KInt { + throw new Error('Not implemented'); + } + + _CreateMemberExpression( + context: KPtr, + object: KPtr, + property: KPtr, + kind: KInt, + computed: KBoolean, + optional: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _UpdateMemberExpression( + context: KPtr, + node: KPtr, + object: KPtr, + property: KPtr, + kind: KInt, + computed: KBoolean, + optional: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _MemberExpressionObject(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _MemberExpressionProperty(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _MemberExpressionKindConst(context: KPtr, node: KPtr): KInt { + throw new Error('Not implemented'); + } + _CreateCallExpression( + context: KPtr, + callee: KPtr, + args: KPtrArray, + argsLen: KInt, + typeParams: KPtr, + optional: KBoolean, + trailingComma: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _UpdateCallExpression( + context: KPtr, + node: KPtr, + callee: KPtr, + args: KPtrArray, + argsLen: KInt, + typeParams: KPtr, + optional: KBoolean, + trailingComma: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _CreateArrowFunctionExpression(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _FunctionExpressionFunction(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ArrowFunctionExpressionFunction(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ArrowFunctionExpressionCreateTypeAnnotation(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateFunctionExpression(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _UpdateFunctionExpression(context: KPtr, original: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _CreateExpressionStatement(context: KPtr, expr: KPtr): KPtr { + throw new Error('Not implemented'); + } + _UpdateExpressionStatement(context: KPtr, node: KPtr, expr: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateETSParameterExpression(context: KPtr, identifier: KPtr, initializer: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateETSPrimitiveType(context: KPtr, type: KInt): KPtr { + throw new Error('Not implemented'); + } + _ETSPrimitiveTypeGetPrimitiveTypeConst(context: KPtr, node: KNativePointer): KInt { + throw new Error('Not implemented'); + } + _CreateETSTypeReference(context: KPtr, part: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateETSTypeReferencePart(context: KPtr, name: KPtr, typeParams: KPtr, prev: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateETSTypeReferencePart1(context: KPtr, name: KPtr): KPtr { + throw new Error('Not implemented'); + } + _IsIdentifier(node: KPtr): KBoolean { + throw new Error('Not implemented'); + } + _IdentifierName(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ETSParameterExpressionIdent(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ETSParameterExpressionAnnotations(context: KPtr, node: KPtr, returnLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ETSParameterExpressionSetAnnotations( + context: KPtr, + ast: KPtr, + annotations: KPtrArray, + annotationsLen: KInt + ): KPtr { + throw new Error('Not implemented'); + } + _CreateTSTypeParameterDeclaration(context: KPtr, params: KPtrArray, paramsLen: KInt, requiredParams: KInt): KPtr { + throw new Error('Not implemented'); + } + _TSTypeParameterDeclarationParamsConst(context: KPtr, node: KPtr, returnTypeLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateTSTypeParameter(context: KPtr, name: KPtr, constraint: KPtr, defaultType: KPtr): KPtr { + throw new Error('Not implemented'); + } + _TSTypeParameterName(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _CreateTSUnionType(context: KPtr, types: KPtrArray, typesLen: KInt): KPtr { + throw new Error('Not implemented'); + } + _TSUnionTypeTypesConst(context: KPtr, node: KPtr, returnTypeLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateETSUnionTypeIr(context: KPtr, types: KPtrArray, typesLen: KInt): KPtr { + throw new Error('Not implemented'); + } + _ETSUnionTypeIrTypesConst(context: KPtr, node: KPtr, returnTypeLen: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _CreateVariableDeclaration(context: KPtr, kind: KInt, declarators: KPtrArray, declaratorsLen: KInt): KPtr { + throw new Error('Not implemented'); + } + _UpdateVariableDeclaration( + context: KPtr, + original: KPtr, + kind: KInt, + declarators: KPtrArray, + declaratorsLen: KInt, + declare: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + _CreateVariableDeclarator(context: KPtr, flag: KInt, ident: KPtr): KPtr { + throw new Error('Not implemented'); + } + _VariableDeclarationDeclaratorsConst(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _VariableDeclarationKindConst(context: KPtr, node: KPtr): KInt { + throw new Error('Not implemented'); + } + _VariableDeclaratorId(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _VariableDeclaratorSetInit(context: KPtr, node: KPtr, init: KPtr): void { + throw new Error('Not implemented'); + } + + _CreateStringLiteral(context: KPtr, string: string): KPtr { + throw new Error('Not implemented'); + } + _CreateNumberLiteral(context: KPtr, value: KDouble): KPtr { + throw new Error('Not implemented'); + } + _NumberLiteralStrConst(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _StringLiteralStrConst(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _BlockStatementStatements(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _BlockStatementSetStatements(context: KPtr, node: KPtr, statements: KPtrArray, statementsLen: KInt): void { + throw new Error('Not implemented'); + } + _ClassDeclarationDefinition(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ClassDefinitionBody(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ClassDefinitionIdent(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _ClassDefinitionTypeParamsConst(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateETSStructDeclaration(context: KPtr, def: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateClassDeclaration(context: KPtr, def: KPtr): KPtr { + throw new Error('Not implemented'); + } + _UpdateClassDeclaration(context: KPtr, original: KPtr, def: KPtr): KPtr { + throw new Error('Not implemented'); + } + _CreateClassDefinition1( + context: KPtr, + ident: KPtr, + body: KPtrArray, + bodyLen: KInt, + modifiers: KInt, + flags: KInt + ): KPtr { + throw new Error('Not implemented'); + } + _ClassDefinitionSetTypeParams(context: KPtr, ast: KPtr, typeParams: KPtr): void { + throw new Error('Not implemented'); + } + _ClassDefinitionSetSuper(context: KPtr, ast: KPtr, superClass: KPtr): void { + throw new Error('Not implemented'); + } + _UpdateClassDefinition1( + context: KPtr, + original: KPtr, + ident: KPtr, + body: KPtrArray, + bodyLen: KInt, + modifiers: KInt, + flags: KInt + ): KPtr { + throw new Error('Not implemented'); + } + _CreateETSFunctionTypeIr(context: KPtr, signature: KPtr, funcFlags: KInt): KPtr { + throw new Error('Not implemented'); + } + _CreateSuperExpression(context: KPtr): KPtr { + throw new Error('Not implemented'); + } + _UpdateSuperExpression(context: KPtr, original: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _IsProgram(context: KPtr, node: KPtr): KBoolean { + throw new Error('Not implemented'); + } + _AstNodeDumpJSONConst(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeDumpEtsSrcConst(context: KPtr, node: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeUpdateChildren(context: KPtr, node: KPtr): void { + throw new Error('Not implemented'); + } + _AstNodeUpdateAll(context: KPtr, node: KPtr): void { + throw new Error('Not implemented'); + } + _AstNodeSetOriginalNode(context: KPtr, ast: KPtr, originalNode: KPtr): void { + throw new Error('Not implemented'); + } + _AstNodeOriginalNodeConst(context: KPtr, ast: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _VarBinderSetProgram(context: KPtr): void { + throw new Error('Not implemented'); + } + _VarBinderSetContext(context: KPtr): void { + throw new Error('Not implemented'); + } + + _VariableDeclaration(context: KPtr, variable: KPtr): KPtr { + throw new Error('Not implemented'); + } + _DeclNode(context: KPtr, decl: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _ScopeSetParent(context: KPtr, ast: KPtr, scope: KPtr): void { + throw new Error('Not implemented'); + } + + _CallExpressionSignature(context: KPtr, classInstance: KPtr): KPtr { + throw new Error('Not implemented'); + } + _SignatureFunction(context: KPtr, classInstance: KPtr): KPtr { + throw new Error('Not implemented'); + } + _DeclarationFromIdentifier(context: KPtr, identifier: KPtr): KPtr { + throw new Error('Not implemented'); + } + _IsTSInterfaceDeclaration(ast: KNativePointer): KBoolean { + throw new Error('Not implemented'); + } + + _IsAnnotationDeclaration(ast: KNativePointer): KBoolean { + throw new Error('Not implemented'); + } + + _IsAnnotationUsage(ast: KNativePointer): KBoolean { + throw new Error('Not implemented'); + } + + _IsClassProperty(ast: KNativePointer): KBoolean { + throw new Error('Not implemented'); + } + + _CreateAnnotationUsageIr(context: KPtr, ast: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _IsETSUnionType(ast: KPtr): KBoolean { + throw new Error('Not implemented'); + } + + _IsETSFunctionType(ast: KPtr): KBoolean { + throw new Error('Not implemented'); + } + _ProgramExternalSources(context: KNativePointer, instance: KNativePointer): KNativePointer { + throw new Error('Not implemented'); + } + + _ExternalSourceName(instance: KNativePointer): KNativePointer { + throw new Error('Not implemented'); + } + + _ExternalSourcePrograms(instance: KNativePointer): KNativePointer { + throw new Error('Not implemented'); + } + + _GenerateTsDeclarationsFromContext( + config: KPtr, + outputDeclEts: String, + outputEts: String, + exportAll: KBoolean + ): KPtr { + throw new Error('Not implemented'); + } + + _InsertETSImportDeclarationAndParse( + context: KNativePointer, + program: KNativePointer, + importDeclaration: KNativePointer + ): void { + throw new Error('Not implemented'); + } + + _ETSParserGetImportPathManager(context: KNativePointer): KPtr { + throw new Error('Not implemented'); + } + + _CreateSourcePosition(context: KNativePointer, index: KInt, line: KInt): KNativePointer { + throw new Error('Not implemented'); + } + _SourcePositionIndex(context: KNativePointer, instance: KNativePointer): KInt { + throw new Error('Not implemented'); + } + _SourcePositionLine(context: KNativePointer, instance: KNativePointer): KInt { + throw new Error('Not implemented'); + } + _CreateETSStringLiteralType(context: KNativePointer, str: String): KNativePointer { + throw new Error('Not implemented'); + } + + _ClassDefinitionIsFromStructConst(context: KNativePointer, instance: KNativePointer): KBoolean { + throw new Error('Not implemented'); + } + + _ClassDefinitionSetFromStructModifier(context: KNativePointer, instance: KNativePointer): void { + throw new Error('Not implemented'); + } + + _ProgramFileNameConst(context: KPtr, program: KPtr): KNativePointer { + throw new Error('Not implemented'); + } + + _ProgramFileNameWithExtensionConst(context: KPtr, program: KPtr): KNativePointer { + throw new Error('Not implemented'); + } + + _ETSParserGetGlobalProgramAbsName(context: KNativePointer): KNativePointer { + throw new Error('Not implemented'); + } +} + +export function initEs2panda(): Es2pandaNativeModule { + registerNativeModuleLibraryName('NativeModule', path.resolve(__dirname, '../native/es2panda.node')); + const instance = new Es2pandaNativeModule(); + loadNativeModuleLibrary('NativeModule', instance); + return instance; +} + +export function initGeneratedEs2panda(): GeneratedEs2pandaNativeModule { + registerNativeModuleLibraryName('NativeModule', path.resolve(__dirname, '../native/es2panda.node')); + const instance = new GeneratedEs2pandaNativeModule(); + // registerNativeModule("InteropNativeModule", NativeModule) + loadNativeModuleLibrary('NativeModule', instance); + return instance; +} diff --git a/koala-wrapper/src/InteropNativeModule.ts b/koala-wrapper/src/InteropNativeModule.ts new file mode 100644 index 000000000..2018b318c --- /dev/null +++ b/koala-wrapper/src/InteropNativeModule.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022-2025 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 { + KNativePointer as KPtr, + KInt, + registerNativeModuleLibraryName, + loadNativeModuleLibrary +} from "@koalaui/interop" +import * as path from "path" + +export class InteropNativeModule { + _StringLength(ptr: KPtr): KInt { + throw new Error("Not implemented") + } + _StringData(ptr: KPtr, buffer: KPtr, length: KInt): void { + throw new Error("Not implemented") + } + _GetStringFinalizer(): KPtr { + throw new Error("Not implemented") + } + _InvokeFinalizer(ptr: KPtr, finalizer: KPtr): void { + throw new Error("Not implemented") + } + _GetPtrVectorSize(ptr: KPtr): KInt { + throw new Error("Not implemented") + } + _GetPtrVectorElement(ptr: KPtr, index: KInt): KPtr { + throw new Error("Not implemented") + } +} + +export function initInterop(): InteropNativeModule { + registerNativeModuleLibraryName("InteropNativeModule", path.join(__dirname, "../native/es2panda.node")) + const instance = new InteropNativeModule() + loadNativeModuleLibrary("InteropNativeModule", instance) + return instance +} diff --git a/koala-wrapper/src/arkts-api/class-by-peer.ts b/koala-wrapper/src/arkts-api/class-by-peer.ts new file mode 100644 index 000000000..f8d79996c --- /dev/null +++ b/koala-wrapper/src/arkts-api/class-by-peer.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 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 { Es2pandaAstNodeType } from '../Es2pandaEnums'; +import { throwError } from '../utils'; +import { global } from './static/global'; +import { KNativePointer, nullptr } from '@koalaui/interop'; +import { AstNode, UnsupportedNode } from './peers/AstNode'; + +export const nodeByType = new Map([]); + +const cache = new Map(); +export function clearNodeCache(): void { + cache.clear(); +} + +function getOrPut(peer: KNativePointer, create: (peer: KNativePointer) => AstNode): AstNode { + if (cache.has(peer)) { + return cache.get(peer)!; + } + + const newNode = create(peer); + cache.set(peer, newNode); + return newNode; +} + +export function classByPeer(peer: KNativePointer): T { + if (peer === nullptr) { + throwError('classByPeer: peer is NULLPTR'); + } + const type = global.generatedEs2panda._AstNodeTypeConst(global.context, peer); + const node = nodeByType.get(type) ?? UnsupportedNode; + return getOrPut(peer, (peer) => new node(peer)) as T; +} diff --git a/koala-wrapper/src/arkts-api/factory/nodeFactory.ts b/koala-wrapper/src/arkts-api/factory/nodeFactory.ts new file mode 100644 index 000000000..5283543ac --- /dev/null +++ b/koala-wrapper/src/arkts-api/factory/nodeFactory.ts @@ -0,0 +1,441 @@ +/* + * Copyright (c) 2022-2025 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 { updateNodeByNode } from "../utilities/private" +import { + ArrowFunctionExpression, + AssignmentExpression, + CallExpression, + ETSParameterExpression, + EtsScript, + ExpressionStatement, + FunctionDeclaration, + FunctionExpression, + IfStatement, + MethodDefinition, + NumberLiteral, + StructDeclaration, + VariableDeclaration, + VariableDeclarator, + ETSStringLiteralType +} from "../types" +import { MemberExpression } from "../to-be-generated/MemberExpression" +import { AstNode } from "../peers/AstNode" +import { + AnnotationUsage, + BinaryExpression, + BlockStatement, + ClassDeclaration, + ClassDefinition, + ClassProperty, + ConditionalExpression, + ETSImportDeclaration, + ETSFunctionType, + ETSPrimitiveType, + ETSTypeReference, + ETSTypeReferencePart, + ETSUndefinedType, + ETSUnionType, + FunctionSignature, + Identifier, + ImportSpecifier, + NullLiteral, + ReturnStatement, + ScriptFunction, + StringLiteral, + SuperExpression, + ThisExpression, + TSInterfaceBody, + TSInterfaceDeclaration, + TSNonNullExpression, + TSTypeParameter, + TSTypeParameterDeclaration, + TSTypeParameterInstantiation, + TypeNode, + UndefinedLiteral, + TSAsExpression, + TSTypeAliasDeclaration, + ChainExpression, + BlockExpression, + ETSNewClassInstanceExpression +} from "../../generated" +import { + Es2pandaModifierFlags +} from "../../generated/Es2pandaEnums" +import { + classPropertySetOptional, + hasModifierFlag +} from "../utilities/public" +import { updateIdentifier } from "../node-utilities/Identifier" +import { updateCallExpression } from "../node-utilities/CallExpression" +import { updateExpressionStatement } from "../node-utilities/ExpressionStatement" +import { updateMemberExpression } from "../node-utilities/MemberExpression" +import { updateFunctionDeclaration } from "../node-utilities/FunctionDeclaration" +import { updateBlockStatement } from "../node-utilities/BlockStatement" +import { updateArrowFunctionExpression } from "../node-utilities/ArrowFunctionExpression" +import { updateScriptFunction } from "../node-utilities/ScriptFunction" +import { updateStringLiteral } from "../node-utilities/StringLiteral" +import { updateNumberLiteral } from "../node-utilities/NumberLiteral" +import { updateETSParameterExpression } from "../node-utilities/ETSParameterExpression" +import { updateTSTypeParameter } from "../node-utilities/TSTypeParameter" +import { updateTSTypeParameterDeclaration } from "../node-utilities/TSTypeParameterDeclaration" +import { updateETSPrimitiveType } from "../node-utilities/ETSPrimitiveType" +import { updateETSTypeReference } from "../node-utilities/ETSTypeReference" +import { updateETSTypeReferencePart } from "../node-utilities/ETSTypeReferencePart" +import { updateETSImportDeclaration } from "../node-utilities/ETSImportDeclaration" +import { updateImportSpecifier } from "../node-utilities/ImportSpecifier" +import { updateVariableDeclaration } from "../node-utilities/VariableDeclaration" +import { updateVariableDeclarator } from "../node-utilities/VariableDeclarator" +import { updateETSUnionType } from "../node-utilities/ETSUnionType" +import { updateReturnStatement } from "../node-utilities/ReturnStatement" +import { updateIfStatement } from "../node-utilities/IfStatement" +import { updateBinaryExpression } from "../node-utilities/BinaryExpression" +import { updateClassDeclaration } from "../node-utilities/ClassDeclaration" +import { updateStructDeclaration } from "../node-utilities/StructDeclaration" +import { updateClassDefinition } from "../node-utilities/ClassDefinition" +import { updateClassProperty } from "../node-utilities/ClassProperty" +import { updateETSFunctionType } from "../node-utilities/ETSFunctionType" +import { updateFunctionExpression } from "../node-utilities/FunctionExpression" +import { updateMethodDefinition } from "../node-utilities/MethodDefinition" +import { updateSuperExpression } from "../node-utilities/SuperExpression" +import { updateTSTypeParameterInstantiation } from "../node-utilities/TSTypeParameterInstantiation" +import { updateTSInterfaceDeclaration } from "../node-utilities/TSInterfaceDeclaration" +import { updateTSInterfaceBody } from "../node-utilities/TSInterfaceBody" +import { updateUndefinedLiteral } from "../node-utilities/UndefinedLiteral" +import { updateAnnotationUsage } from "../node-utilities/AnnotationUsage" +import { updateAssignmentExpression } from "../node-utilities/AssignmentExpression" +import { updateETSUndefinedType } from "../node-utilities/ETSUndefinedType" +import { updateConditionalExpression } from "../node-utilities/ConditionalExpression" +import { updateTSAsExpression } from "../node-utilities/TSAsExpression" +import { updateThisExpression } from "../node-utilities/ThisExpression" +import { updateTSTypeAliasDeclaration } from "../node-utilities/TSTypeAliasDeclaration" +import { updateTSNonNullExpression } from "../node-utilities/TSNonNullExpression" +import { updateChainExpression } from "../node-utilities/ChainExpression" +import { updateBlockExpression } from "../node-utilities/BlockExpression" +import { updateNullLiteral } from "../node-utilities/NullLiteral" +import { updateETSNewClassInstanceExpression } from "../node-utilities/ETSNewClassInstanceExpression" + +export const factory = { + get createIdentifier() { + return Identifier.create2Identifier + }, + get updateIdentifier() { + return updateIdentifier + }, + get createCallExpression() { + return CallExpression.create + }, + get updateCallExpression() { + return updateCallExpression + }, + get createExpressionStatement() { + return ExpressionStatement.create + }, + get updateExpressionStatement() { + return updateExpressionStatement + }, + get createMemberExpression() { + return MemberExpression.create + }, + get updateMemberExpression() { + return updateMemberExpression + }, + get createEtsScript() { + return EtsScript.createFromSource + }, + get updateEtsScript() { + return EtsScript.updateByStatements + }, + get createFunctionDeclaration() { + return FunctionDeclaration.create + }, + get updateFunctionDeclaration() { + return updateFunctionDeclaration + }, + get createBlock() { + return BlockStatement.createBlockStatement + }, + get updateBlock() { + return updateBlockStatement + }, + get createArrowFunction() { + return ArrowFunctionExpression.create + }, + get updateArrowFunction() { + return updateArrowFunctionExpression + }, + get createScriptFunction() { + return ScriptFunction.createScriptFunction + }, + get updateScriptFunction() { + return updateScriptFunction + }, + get createStringLiteral() { + return StringLiteral.create1StringLiteral + }, + get updateStringLiteral() { + return updateStringLiteral + }, + get create1StringLiteral() { + return StringLiteral.create1StringLiteral + }, + get update1StringLiteral() { + return updateStringLiteral + }, + get createNumericLiteral() { + return NumberLiteral.create + }, + get updateNumericLiteral() { + return updateNumberLiteral + }, + get createParameterDeclaration() { + return ETSParameterExpression.create + }, + get updateParameterDeclaration() { + return updateETSParameterExpression + }, + get createTypeParameter() { + return TSTypeParameter.createTSTypeParameter + }, + get updateTypeParameter() { + return updateTSTypeParameter + }, + get createTypeParameterDeclaration() { + return TSTypeParameterDeclaration.createTSTypeParameterDeclaration + }, + get updateTypeParameterDeclaration() { + return updateTSTypeParameterDeclaration + }, + get createPrimitiveType() { + return ETSPrimitiveType.createETSPrimitiveType + }, + get updatePrimitiveType() { + return updateETSPrimitiveType + }, + get createTypeReference() { + return ETSTypeReference.createETSTypeReference + }, + get updateTypeReference() { + return updateETSTypeReference + }, + get createTypeReferencePart() { + return ETSTypeReferencePart.createETSTypeReferencePart + }, + get updateTypeReferencePart() { + return updateETSTypeReferencePart + }, + get createImportDeclaration() { + return ETSImportDeclaration.createETSImportDeclaration + }, + get updateImportDeclaration() { + return updateETSImportDeclaration + }, + get createImportSpecifier() { + return ImportSpecifier.createImportSpecifier + }, + get updateImportSpecifier() { + return updateImportSpecifier + }, + get createVariableDeclaration() { + return VariableDeclaration.create + }, + get updateVariableDeclaration() { + return updateVariableDeclaration + }, + get createVariableDeclarator() { + return VariableDeclarator.create + }, + get updateVariableDeclarator() { + return updateVariableDeclarator + }, + get createUnionType() { + return ETSUnionType.createETSUnionType + }, + get updateUnionType() { + return updateETSUnionType + }, + get createReturnStatement() { + return ReturnStatement.create1ReturnStatement + }, + get updateReturnStatement() { + return updateReturnStatement + }, + get createIfStatement() { + return IfStatement.create + }, + get updateIfStatement() { + return updateIfStatement + }, + get createBinaryExpression() { + return BinaryExpression.createBinaryExpression + }, + get updateBinaryExpression() { + return updateBinaryExpression + }, + get createClassDeclaration() { + return ClassDeclaration.createClassDeclaration + }, + get updateClassDeclaration() { + return updateClassDeclaration + }, + get createStructDeclaration() { + return StructDeclaration.create + }, + get updateStructDeclaration() { + return updateStructDeclaration + }, + get createClassDefinition() { + return ClassDefinition.createClassDefinition + }, + get updateClassDefinition() { + return updateClassDefinition + }, + get createClassProperty() { + return ClassProperty.createClassProperty + }, + get updateClassProperty() { + return updateClassProperty + }, + get createFunctionType() { + return ETSFunctionType.createETSFunctionType + }, + get updateFunctionType() { + return updateETSFunctionType + }, + get createFunctionExpression() { + return FunctionExpression.create + }, + get updateFunctionExpression() { + return updateFunctionExpression + }, + get createMethodDefinition() { + return MethodDefinition.create + }, + get updateMethodDefinition() { + return updateMethodDefinition + }, + get createSuperExpression() { + return SuperExpression.createSuperExpression + }, + get updateSuperExpression() { + return updateSuperExpression + }, + get createTSTypeParameterInstantiation() { + return TSTypeParameterInstantiation.createTSTypeParameterInstantiation + }, + get updateTSTypeParameterInstantiation() { + return updateTSTypeParameterInstantiation + }, + get createInterfaceDeclaration() { + return TSInterfaceDeclaration.createTSInterfaceDeclaration + }, + get updateInterfaceDeclaration() { + return updateTSInterfaceDeclaration + }, + get createInterfaceBody() { + return TSInterfaceBody.createTSInterfaceBody + }, + get updateInterfaceBody() { + return updateTSInterfaceBody + }, + get createUndefinedLiteral() { + return UndefinedLiteral.createUndefinedLiteral + }, + get updateUndefinedLiteral() { + return updateUndefinedLiteral + }, + get createAnnotationUsage() { + return AnnotationUsage.createAnnotationUsage + }, + get updateAnnotationUsage() { + return updateAnnotationUsage + }, + get createAssignmentExpression() { + return AssignmentExpression.create + }, + get updateAssignmentExpression() { + return updateAssignmentExpression + }, + get createETSUndefinedType() { + return ETSUndefinedType.createETSUndefinedType + }, + get updateETSUndefinedType() { + return updateETSUndefinedType + }, + get createFunctionSignature() { + return FunctionSignature.createFunctionSignature + }, + get createConditionalExpression() { + return ConditionalExpression.createConditionalExpression + }, + get updateConditionalExpression() { + return updateConditionalExpression + }, + get createTSAsExpression() { + return TSAsExpression.createTSAsExpression + }, + get updateTSAsExpression() { + return updateTSAsExpression + }, + get createThisExpression() { + return ThisExpression.createThisExpression + }, + get updateThisExpression() { + return updateThisExpression + }, + get createTSTypeAliasDeclaration() { + return TSTypeAliasDeclaration.createTSTypeAliasDeclaration + }, + get updateTSTypeAliasDeclaration() { + return updateTSTypeAliasDeclaration + }, + get createTSNonNullExpression() { + return TSNonNullExpression.createTSNonNullExpression + }, + get updateTSNonNullExpression() { + return updateTSNonNullExpression + }, + get createChainExpression() { + return ChainExpression.createChainExpression + }, + get updateChainExpression() { + return updateChainExpression + }, + get createBlockExpression() { + return BlockExpression.createBlockExpression + }, + get updateBlockExpression() { + return updateBlockExpression + }, + get createNullLiteral() { + return NullLiteral.createNullLiteral + }, + get updateNullLiteral() { + return updateNullLiteral + }, + get createETSNewClassInstanceExpression() { + return ETSNewClassInstanceExpression.createETSNewClassInstanceExpression + }, + get updateETSNewClassInstanceExpression() { + return updateETSNewClassInstanceExpression + }, + get createETSStringLiteralType(){ + return ETSStringLiteralType.create; + }, + /** @deprecated */ + createTypeParameter1_(name: Identifier, constraint?: TypeNode, defaultType?: TypeNode) { + return TSTypeParameter.createTSTypeParameter(Identifier.create1Identifier(name.name), constraint, defaultType) + }, +} diff --git a/koala-wrapper/src/arkts-api/factory/nodeTests.ts b/koala-wrapper/src/arkts-api/factory/nodeTests.ts new file mode 100644 index 000000000..b40a1a353 --- /dev/null +++ b/koala-wrapper/src/arkts-api/factory/nodeTests.ts @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2022-2025 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 { global } from "../static/global" +import { + ArrowFunctionExpression, + CallExpression, + ETSParameterExpression, + EtsScript, + ExpressionStatement, + FunctionDeclaration, + FunctionExpression, + IfStatement, + MethodDefinition, + // ScriptFunction, + StructDeclaration, + VariableDeclaration, + VariableDeclarator, +} from "../types" +import { MemberExpression } from "../to-be-generated/MemberExpression" +import { AstNode } from "../peers/AstNode" + +export function isCallExpression(node: AstNode): node is CallExpression { + return node instanceof CallExpression +} + +export function isMemberExpression(node: AstNode): node is MemberExpression { + return node instanceof MemberExpression +} + +export function isFunctionDeclaration(node: AstNode): node is FunctionDeclaration { + return node instanceof FunctionDeclaration +} + +export function isMethodDefinition(node: AstNode): node is MethodDefinition { + return node instanceof MethodDefinition +} + +export function isEtsScript(node: AstNode): node is EtsScript { + return node instanceof EtsScript +} + +export function isExpressionStatement(node: AstNode): node is ExpressionStatement { + return node instanceof ExpressionStatement +} + +export function isArrowFunctionExpression(node: AstNode): node is ArrowFunctionExpression { + return node instanceof ArrowFunctionExpression +} + +export function isStructDeclaration(node: AstNode): node is StructDeclaration { + return node instanceof StructDeclaration +} + +export function isFunctionExpression(node: AstNode): node is FunctionExpression { + return node instanceof FunctionExpression +} + +export function isEtsParameterExpression(node: AstNode): node is ETSParameterExpression { + return node instanceof ETSParameterExpression +} + +export function isVariableDeclaration(node: AstNode): node is VariableDeclaration { + return node instanceof VariableDeclaration +} + +// export function isScriptFunction(node: AstNode): node is ScriptFunction { +// return node instanceof ScriptFunction +// } + +export function isIfStatement(node: AstNode): node is IfStatement { + return node instanceof IfStatement +} + +export function isVariableDeclarator(node: AstNode): node is VariableDeclarator { + return node instanceof VariableDeclarator +} diff --git a/koala-wrapper/src/arkts-api/index.ts b/koala-wrapper/src/arkts-api/index.ts new file mode 100644 index 000000000..463ae2730 --- /dev/null +++ b/koala-wrapper/src/arkts-api/index.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022-2025 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 * from "../Es2pandaEnums" +export * from "../generated/Es2pandaEnums" +export * from "../generated/peers/AnnotationUsage" +export * from "../generated/peers/BlockStatement" +export * from "../generated/peers/ETSPrimitiveType" +export * from "../generated/peers/TSInterfaceBody" +export * from "../generated/peers/TSInterfaceDeclaration" +export * from "../generated/peers/TSTypeParameterInstantiation" +export * from "../generated/peers/UndefinedLiteral" +export * from "../generated/peers/ETSUnionType" +export * from "../generated/peers/FunctionSignature" +export * from "../generated/peers/ETSFunctionType" +export * from "../generated/peers/StringLiteral" +export * from "../generated/peers/ThrowStatement" +export * from "../generated/peers/TypeNode" +export * from "../generated/peers/ClassDeclaration" +export * from "../generated/peers/ClassDefinition" +export * from "../generated/peers/Identifier" +export * from "../generated/peers/ETSTypeReference" +export * from "../generated/peers/ETSTypeReferencePart" +export * from "../generated/peers/ClassProperty" +export * from "../generated/peers/ReturnStatement" +export * from "../generated/peers/Expression" +export * from "../generated/peers/Statement" +export * from "../generated/peers/ImportSpecifier" +export * from "../generated/peers/TSAsExpression" +export * from "../generated/peers/ThisExpression" +export * from "../generated/peers/TSThisType" +export * from "../generated/peers/ETSImportDeclaration" +export * from "../generated/peers/ImportSource" +export * from "../generated/peers/ScriptFunction" +export * from "../generated/peers/TSTypeParameterDeclaration" +export * from "../generated/peers/TSTypeParameter" +export * from "../generated/peers/TSNonNullExpression" +export * from "../generated/peers/ChainExpression" +export * from "../generated/peers/ConditionalExpression" +export * from "../generated/peers/NullLiteral" +export * from "../generated/peers/TSTypeAliasDeclaration" +export * from "../generated/peers/ETSUndefinedType" +export * from "../generated/peers/ETSNewClassInstanceExpression" +export * from "../generated/peers/ObjectExpression" +export * from "../generated/peers/Property" +export * from "../generated/peers/BlockExpression" + +export * from "./types" +export * from "./utilities/private" +export * from "./utilities/public" +export * from "./utilities/performance" +export * from "./factory/nodeFactory" +export * from "./factory/nodeTests" +export * from "./visitor" +export * from "./peers/AstNode" +import "../generated" + +export * from "./peers/Config" +export * from "./peers/Context" +export * from "./peers/Program" +export * from "./peers/ImportPathManager" +export * from "./peers/SourcePosition" +export * from "./to-be-generated/MemberExpression" +export * from "./static/globalUtils" +export { global as arktsGlobal } from "./static/global"; diff --git a/koala-wrapper/src/arkts-api/node-utilities/AnnotationUsage.ts b/koala-wrapper/src/arkts-api/node-utilities/AnnotationUsage.ts new file mode 100644 index 000000000..e79cc04c3 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/AnnotationUsage.ts @@ -0,0 +1,27 @@ +/* + * 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 { AnnotationUsage, Expression } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateAnnotationUsage(original: AnnotationUsage, expr?: Expression): AnnotationUsage { + if (isSameNativeObject(expr, original.expr)) { + return original; + } + + const update = updateThenAttach(AnnotationUsage.updateAnnotationUsage, attachModifiers); + return update(original, expr); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ArrowFunctionExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/ArrowFunctionExpression.ts new file mode 100644 index 000000000..9ad9e11af --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ArrowFunctionExpression.ts @@ -0,0 +1,35 @@ +/* + * 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 { ScriptFunction } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { ArrowFunctionExpression } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateArrowFunctionExpression( + original: ArrowFunctionExpression, + func: ScriptFunction +): ArrowFunctionExpression { + if (isSameNativeObject(func, original.scriptFunction)) { + return original; + } + + const update = updateThenAttach( + ArrowFunctionExpression.update, + attachModifiers, + (node: ArrowFunctionExpression, original: ArrowFunctionExpression) => node.setAnnotations(original.annotations) + ); + return update(original, func); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/AssignmentExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/AssignmentExpression.ts new file mode 100644 index 000000000..de701b0ad --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/AssignmentExpression.ts @@ -0,0 +1,38 @@ +/* + * 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 { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { AssignmentExpression } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; +import { Es2pandaTokenType } from '../../generated/Es2pandaEnums'; + +export function updateAssignmentExpression( + original: AssignmentExpression, + left: AstNode, + assignmentOperator: Es2pandaTokenType, + right: AstNode +): AssignmentExpression { + if ( + isSameNativeObject(left, original.left) && + isSameNativeObject(assignmentOperator, original.operatorType) && + isSameNativeObject(right, original.right) + ) { + return original; + } + + const update = updateThenAttach(AssignmentExpression.update, attachModifiers); + return update(original, left, assignmentOperator, right); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/BinaryExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/BinaryExpression.ts new file mode 100644 index 000000000..25a182b16 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/BinaryExpression.ts @@ -0,0 +1,37 @@ +/* + * 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 { BinaryExpression, Expression } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; +import { Es2pandaTokenType } from '../../generated/Es2pandaEnums'; + +export function updateBinaryExpression( + original: BinaryExpression, + left: Expression | undefined, + right: Expression | undefined, + operatorType: Es2pandaTokenType +): BinaryExpression { + if ( + isSameNativeObject(left, original.left) && + isSameNativeObject(right, original.right) && + isSameNativeObject(operatorType, original.operatorType) + ) { + return original; + } + + const update = updateThenAttach(BinaryExpression.updateBinaryExpression, attachModifiers); + return update(original, left, right, operatorType); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/BlockExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/BlockExpression.ts new file mode 100644 index 000000000..e1489fb2e --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/BlockExpression.ts @@ -0,0 +1,27 @@ +/* + * 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 { BlockExpression, Statement } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateBlockExpression(original: BlockExpression, statements: readonly Statement[]): BlockExpression { + if (isSameNativeObject(statements, original.statements)) { + return original; + } + + const update = updateThenAttach(BlockExpression.updateBlockExpression, attachModifiers); + return update(original, statements); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/BlockStatement.ts b/koala-wrapper/src/arkts-api/node-utilities/BlockStatement.ts new file mode 100644 index 000000000..d9571384f --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/BlockStatement.ts @@ -0,0 +1,27 @@ +/* + * 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 { BlockStatement, Statement } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateBlockStatement(original: BlockStatement, statementList: readonly Statement[]): BlockStatement { + if (isSameNativeObject(statementList, original.statements)) { + return original; + } + + const update = updateThenAttach(BlockStatement.updateBlockStatement, attachModifiers); + return update(original, statementList); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/CallExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/CallExpression.ts new file mode 100644 index 000000000..d1489441a --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/CallExpression.ts @@ -0,0 +1,45 @@ +/* + * 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 { TypeNode } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { CallExpression } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateCallExpression( + original: CallExpression, + expression: AstNode, + typeArguments: readonly TypeNode[] | undefined, + args: readonly AstNode[] | undefined, + isOptional?: boolean, + trailingComma?: boolean +): CallExpression { + if ( + isSameNativeObject(expression, original.expression) && + isSameNativeObject(typeArguments, original.typeArguments) && + isSameNativeObject(args, original.arguments) + ) { + return original; + } + + const update = updateThenAttach( + CallExpression.update, + attachModifiers, + (node: CallExpression, original: CallExpression) => + !!original.trailingBlock ? node.setTralingBlock(original.trailingBlock) : node + ); + return update(original, expression, typeArguments, args, isOptional, trailingComma); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ChainExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/ChainExpression.ts new file mode 100644 index 000000000..fdadb8843 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ChainExpression.ts @@ -0,0 +1,27 @@ +/* + * 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 { ChainExpression, Expression } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateChainExpression(original: ChainExpression, expression?: Expression): ChainExpression { + if (isSameNativeObject(expression, original.getExpression)) { + return original; + } + + const update = updateThenAttach(ChainExpression.updateChainExpression, attachModifiers); + return update(original, expression); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ClassDeclaration.ts b/koala-wrapper/src/arkts-api/node-utilities/ClassDeclaration.ts new file mode 100644 index 000000000..1474e8d84 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ClassDeclaration.ts @@ -0,0 +1,27 @@ +/* + * 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 { ClassDeclaration, ClassDefinition } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateClassDeclaration(original: ClassDeclaration, def?: ClassDefinition): ClassDeclaration { + if (isSameNativeObject(def, original.definition)) { + return original; + } + + const update = updateThenAttach(ClassDeclaration.updateClassDeclaration, attachModifiers); + return update(original, def); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ClassDefinition.ts b/koala-wrapper/src/arkts-api/node-utilities/ClassDefinition.ts new file mode 100644 index 000000000..1e9ae0ffb --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ClassDefinition.ts @@ -0,0 +1,73 @@ +/* + * 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 { + ClassDefinition, + Expression, + Identifier, + TSClassImplements, + TSTypeParameterDeclaration, + TSTypeParameterInstantiation, +} from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { MethodDefinition } from '../types'; +import { updateThenAttach } from '../utilities/private'; +import { Es2pandaClassDefinitionModifiers, Es2pandaModifierFlags } from '../../generated/Es2pandaEnums'; +import { classDefinitionFlags } from '../utilities/public'; + +export function updateClassDefinition( + original: ClassDefinition, + ident: Identifier | undefined, + typeParams: TSTypeParameterDeclaration | undefined, + superTypeParams: TSTypeParameterInstantiation | undefined, + _implements: readonly TSClassImplements[], + ctor: MethodDefinition | undefined, + superClass: Expression | undefined, + body: readonly AstNode[], + modifiers: Es2pandaClassDefinitionModifiers, + flags: Es2pandaModifierFlags +): ClassDefinition { + if ( + isSameNativeObject(ident, original.ident) && + isSameNativeObject(typeParams, original.typeParams) && + isSameNativeObject(superTypeParams, original.superTypeParams) && + isSameNativeObject(_implements, original.implements) && + isSameNativeObject(superClass, original.super) && + isSameNativeObject(body, original.body) && + isSameNativeObject(modifiers, original.modifiers) && + isSameNativeObject(flags, classDefinitionFlags(original)) + /* TODO: no getter for ctor */ + ) { + return original; + } + + const update = updateThenAttach( + ClassDefinition.updateClassDefinition, + (node: ClassDefinition, original: ClassDefinition) => node.setAnnotations(original.annotations) + ); + return update( + original, + ident, + typeParams, + superTypeParams, + _implements, + undefined, + superClass, + body, + modifiers, + flags + ); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ClassProperty.ts b/koala-wrapper/src/arkts-api/node-utilities/ClassProperty.ts new file mode 100644 index 000000000..06450c0cb --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ClassProperty.ts @@ -0,0 +1,51 @@ +/* + * 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 { ClassProperty, Expression, TypeNode } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { updateThenAttach } from '../utilities/private'; +import { classPropertySetOptional, hasModifierFlag } from '../utilities/public'; +import { Es2pandaModifierFlags } from '../../generated/Es2pandaEnums'; + +export function updateClassProperty( + original: ClassProperty, + key: Expression | undefined, + value: Expression | undefined, + typeAnnotation: TypeNode | undefined, + modifiers: Es2pandaModifierFlags, + isComputed: boolean +): ClassProperty { + if ( + isSameNativeObject(key, original.key) && + isSameNativeObject(value, original.value) && + isSameNativeObject(typeAnnotation, original.typeAnnotation) && + isSameNativeObject(modifiers, original.modifiers) && + isSameNativeObject(isComputed, original.isComputed) + ) { + return original; + } + + const update = updateThenAttach( + ClassProperty.updateClassProperty, + (node: ClassProperty, original: ClassProperty) => node.setAnnotations(original.annotations), + (node: ClassProperty, original: ClassProperty) => { + if (hasModifierFlag(original, Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL)) { + return classPropertySetOptional(node, true); + } + return node; + } + ); + return update(original, key, value, typeAnnotation, modifiers, isComputed); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ConditionalExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/ConditionalExpression.ts new file mode 100644 index 000000000..e1d2d5b2f --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ConditionalExpression.ts @@ -0,0 +1,36 @@ +/* + * 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 { ConditionalExpression, Expression } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateConditionalExpression( + original: ConditionalExpression, + test?: Expression, + consequent?: Expression, + alternate?: Expression +): ConditionalExpression { + if ( + isSameNativeObject(test, original.test) && + isSameNativeObject(consequent, original.consequent) && + isSameNativeObject(alternate, original.alternate) + ) { + return original; + } + + const update = updateThenAttach(ConditionalExpression.updateConditionalExpression, attachModifiers); + return update(original, test, consequent, alternate); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ETSFunctionType.ts b/koala-wrapper/src/arkts-api/node-utilities/ETSFunctionType.ts new file mode 100644 index 000000000..a0e522040 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ETSFunctionType.ts @@ -0,0 +1,42 @@ +/* + * 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 { ETSFunctionType, FunctionSignature } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; +import { Es2pandaScriptFunctionFlags } from '../../generated/Es2pandaEnums'; + +export function updateETSFunctionType( + original: ETSFunctionType, + signature: FunctionSignature | undefined, + funcFlags: Es2pandaScriptFunctionFlags +): ETSFunctionType { + if ( + isSameNativeObject(signature?.typeParams, original.typeParams) && + isSameNativeObject(signature?.returnType, original.returnType) && + isSameNativeObject(signature?.params, original.params) && + isSameNativeObject(funcFlags, original.flags) + /* TODO: no getter for signature's hasReceiver */ + ) { + return original; + } + + const update = updateThenAttach( + ETSFunctionType.updateETSFunctionType, + attachModifiers, + (node: ETSFunctionType, original: ETSFunctionType) => node.setAnnotations(original.annotations) + ); + return update(original, signature, funcFlags); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ETSImportDeclaration.ts b/koala-wrapper/src/arkts-api/node-utilities/ETSImportDeclaration.ts new file mode 100644 index 000000000..1186fe3d4 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ETSImportDeclaration.ts @@ -0,0 +1,39 @@ +/* + * 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 { ETSImportDeclaration, StringLiteral } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; +import { Es2pandaImportKinds } from '../../generated/Es2pandaEnums'; + +export function updateETSImportDeclaration( + original: ETSImportDeclaration, + source: StringLiteral | undefined, + specifiers: readonly AstNode[], + importKind: Es2pandaImportKinds +): ETSImportDeclaration { + if ( + isSameNativeObject(source, original.source) && + isSameNativeObject(specifiers, original.specifiers) && + isSameNativeObject(importKind, Number(original.isTypeKind)) + ) { + /* TODO: probably should set importMetadata, but no getter provided yet */ + return original; + } + + const update = updateThenAttach(ETSImportDeclaration.updateETSImportDeclaration, attachModifiers); + return update(original, source, specifiers, importKind); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ETSNewClassInstanceExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/ETSNewClassInstanceExpression.ts new file mode 100644 index 000000000..512085cb0 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ETSNewClassInstanceExpression.ts @@ -0,0 +1,34 @@ +/* + * 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 { ETSNewClassInstanceExpression, Expression } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateETSNewClassInstanceExpression( + original: ETSNewClassInstanceExpression, + typeReference: Expression | undefined, + _arguments: readonly Expression[] +): ETSNewClassInstanceExpression { + if ( + isSameNativeObject(typeReference, original.getTypeRef) && + isSameNativeObject(_arguments, original.getArguments) + ) { + return original; + } + + const update = updateThenAttach(ETSNewClassInstanceExpression.updateETSNewClassInstanceExpression, attachModifiers); + return update(original, typeReference, _arguments); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ETSParameterExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/ETSParameterExpression.ts new file mode 100644 index 000000000..b9e8f0514 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ETSParameterExpression.ts @@ -0,0 +1,43 @@ +/* + * 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 { Identifier } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { ETSParameterExpression } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateETSParameterExpression( + original: ETSParameterExpression, + identifier: Identifier, + initializer: AstNode | undefined +): ETSParameterExpression { + if ( + isSameNativeObject(identifier, original.identifier) && + !initializer // TODO: get this from ETSParameterExpression + ) { + return original; + } + + const update = updateThenAttach( + ETSParameterExpression.update, + attachModifiers, + (node: ETSParameterExpression, original: ETSParameterExpression) => { + node.annotations = original.annotations; + return node; + } + ); + return update(original, identifier, initializer); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ETSPrimitiveType.ts b/koala-wrapper/src/arkts-api/node-utilities/ETSPrimitiveType.ts new file mode 100644 index 000000000..0cba48bd8 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ETSPrimitiveType.ts @@ -0,0 +1,28 @@ +/* + * 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 { ETSPrimitiveType } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; +import { Es2pandaPrimitiveType } from '../../generated/Es2pandaEnums'; + +export function updateETSPrimitiveType(original: ETSPrimitiveType, type: Es2pandaPrimitiveType): ETSPrimitiveType { + if (isSameNativeObject(type, original.getPrimitiveType)) { + return original; + } + + const update = updateThenAttach(ETSPrimitiveType.updateETSPrimitiveType, attachModifiers); + return update(original, type); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ETSTypeReference.ts b/koala-wrapper/src/arkts-api/node-utilities/ETSTypeReference.ts new file mode 100644 index 000000000..005d510bf --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ETSTypeReference.ts @@ -0,0 +1,27 @@ +/* + * 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 { ETSTypeReference, ETSTypeReferencePart } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateETSTypeReference(original: ETSTypeReference, part?: ETSTypeReferencePart): ETSTypeReference { + if (isSameNativeObject(part, original.part)) { + return original; + } + + const update = updateThenAttach(ETSTypeReference.updateETSTypeReference, attachModifiers); + return update(original, part); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ETSTypeReferencePart.ts b/koala-wrapper/src/arkts-api/node-utilities/ETSTypeReferencePart.ts new file mode 100644 index 000000000..fcc821203 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ETSTypeReferencePart.ts @@ -0,0 +1,36 @@ +/* + * 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 { ETSTypeReferencePart, Expression, TSTypeParameterInstantiation } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateETSTypeReferencePart( + original: ETSTypeReferencePart, + name?: Expression, + typeParams?: TSTypeParameterInstantiation, + prev?: ETSTypeReferencePart +): ETSTypeReferencePart { + if ( + isSameNativeObject(name, original.name) && + isSameNativeObject(typeParams, original.typeParams) && + isSameNativeObject(prev, original.previous) + ) { + return original; + } + + const update = updateThenAttach(ETSTypeReferencePart.updateETSTypeReferencePart, attachModifiers); + return update(original, name, typeParams, prev); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ETSUndefinedType.ts b/koala-wrapper/src/arkts-api/node-utilities/ETSUndefinedType.ts new file mode 100644 index 000000000..f88a53794 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ETSUndefinedType.ts @@ -0,0 +1,24 @@ +/* + * 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 { ETSUndefinedType } from '../../generated'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateETSUndefinedType(original: ETSUndefinedType): ETSUndefinedType { + /* TODO: no getter provided yet */ + + const update = updateThenAttach(ETSUndefinedType.updateETSUndefinedType, attachModifiers); + return update(original); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ETSUnionType.ts b/koala-wrapper/src/arkts-api/node-utilities/ETSUnionType.ts new file mode 100644 index 000000000..c8dc20720 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ETSUnionType.ts @@ -0,0 +1,27 @@ +/* + * 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 { ETSUnionType, TypeNode } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateETSUnionType(original: ETSUnionType, types: readonly TypeNode[]): ETSUnionType { + if (isSameNativeObject(types, original.types)) { + return original; + } + + const update = updateThenAttach(ETSUnionType.updateETSUnionType, attachModifiers); + return update(original, types); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ExpressionStatement.ts b/koala-wrapper/src/arkts-api/node-utilities/ExpressionStatement.ts new file mode 100644 index 000000000..4950ba1ff --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ExpressionStatement.ts @@ -0,0 +1,28 @@ +/* + * 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 { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { ExpressionStatement } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateExpressionStatement(original: ExpressionStatement, expression: AstNode): ExpressionStatement { + if (isSameNativeObject(expression, original.expression)) { + return original; + } + + const update = updateThenAttach(ExpressionStatement.update, attachModifiers); + return update(original, expression); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/FunctionDeclaration.ts b/koala-wrapper/src/arkts-api/node-utilities/FunctionDeclaration.ts new file mode 100644 index 000000000..7a579c288 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/FunctionDeclaration.ts @@ -0,0 +1,37 @@ +/* + * 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 { AnnotationUsage, ScriptFunction } from '../../generated'; +import { FunctionDeclaration } from '../types'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateFunctionDeclaration( + original: FunctionDeclaration, + scriptFunction: ScriptFunction, + isAnon: boolean, + annotations?: AnnotationUsage[] +): FunctionDeclaration { + if ( + isSameNativeObject(scriptFunction, original.scriptFunction) && + isSameNativeObject(isAnon, original.isAnon) && + isSameNativeObject(annotations, original.annotations) + ) { + return original; + } + + const update = updateThenAttach(FunctionDeclaration.update, attachModifiers); + return update(original, scriptFunction, isAnon, annotations); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/FunctionExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/FunctionExpression.ts new file mode 100644 index 000000000..ba2135801 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/FunctionExpression.ts @@ -0,0 +1,28 @@ +/* + * 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 { ScriptFunction } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { FunctionExpression } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateFunctionExpression(original: FunctionExpression, expression: ScriptFunction): FunctionExpression { + if (isSameNativeObject(expression, original.scriptFunction)) { + return original; + } + + const update = updateThenAttach(FunctionExpression.update, attachModifiers); + return update(original, expression); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/Identifier.ts b/koala-wrapper/src/arkts-api/node-utilities/Identifier.ts new file mode 100644 index 000000000..f31d25fc6 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/Identifier.ts @@ -0,0 +1,27 @@ +/* + * 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 { Identifier, TypeNode } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateIdentifier(original: Identifier, name: string, typeAnnotation?: TypeNode): Identifier { + if (isSameNativeObject(name, original.name) && isSameNativeObject(typeAnnotation, original.typeAnnotation)) { + return original; + } + + const update = updateThenAttach(Identifier.update2Identifier, attachModifiers); + return update(original, name, typeAnnotation); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/IfStatement.ts b/koala-wrapper/src/arkts-api/node-utilities/IfStatement.ts new file mode 100644 index 000000000..2e3e9275c --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/IfStatement.ts @@ -0,0 +1,37 @@ +/* + * 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 { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { IfStatement } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateIfStatement( + original: IfStatement, + test: AstNode, + consequent: AstNode, + alternate?: AstNode +): IfStatement { + if ( + isSameNativeObject(test, original.test) && + isSameNativeObject(consequent, original.consequent) && + isSameNativeObject(alternate, original.alternate) + ) { + return original; + } + + const update = updateThenAttach(IfStatement.update, attachModifiers); + return update(original, test, consequent, alternate); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ImportSpecifier.ts b/koala-wrapper/src/arkts-api/node-utilities/ImportSpecifier.ts new file mode 100644 index 000000000..d09684550 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ImportSpecifier.ts @@ -0,0 +1,31 @@ +/* + * 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 { Identifier, ImportSpecifier } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateImportSpecifier( + original: ImportSpecifier, + imported?: Identifier, + local?: Identifier +): ImportSpecifier { + if (isSameNativeObject(imported, original.imported) && isSameNativeObject(local, original.local)) { + return original; + } + + const update = updateThenAttach(ImportSpecifier.updateImportSpecifier, attachModifiers); + return update(original, imported, local); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/MemberExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/MemberExpression.ts new file mode 100644 index 000000000..960dacfaf --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/MemberExpression.ts @@ -0,0 +1,42 @@ +/* + * 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 { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { MemberExpression } from '../to-be-generated/MemberExpression'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; +import { Es2pandaMemberExpressionKind } from '../../generated/Es2pandaEnums'; + +export function updateMemberExpression( + original: MemberExpression, + object: AstNode, + property: AstNode, + kind: Es2pandaMemberExpressionKind, + computed: boolean, + optional: boolean +): MemberExpression { + if ( + isSameNativeObject(object, original.object) && + isSameNativeObject(property, original.property) && + isSameNativeObject(kind, original.kind) && + isSameNativeObject(computed, original.computed) && + isSameNativeObject(optional, original.optional) + ) { + return original; + } + + const update = updateThenAttach(MemberExpression.update, attachModifiers); + return update(original, object, property, kind, computed, optional); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/MethodDefinition.ts b/koala-wrapper/src/arkts-api/node-utilities/MethodDefinition.ts new file mode 100644 index 000000000..44afa1dbc --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/MethodDefinition.ts @@ -0,0 +1,45 @@ +/* + * 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 { KInt } from '@koalaui/interop'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { MethodDefinition } from '../types'; +import { updateThenAttach } from '../utilities/private'; +import { Es2pandaMethodDefinitionKind } from '../../generated/Es2pandaEnums'; + +export function updateMethodDefinition( + original: MethodDefinition, + kind: Es2pandaMethodDefinitionKind, + key: AstNode, + value: AstNode, + modifiers: KInt, + isComputed: boolean +): MethodDefinition { + if ( + isSameNativeObject(kind, original.kind) && + isSameNativeObject(key, original.name) && + isSameNativeObject(value, original.scriptFunction) && + isSameNativeObject(modifiers, original.modifiers) + /* TODO: no getter for isComputed */ + ) { + return original; + } + + const update = updateThenAttach(MethodDefinition.update, (node: MethodDefinition, original: MethodDefinition) => + node.setOverloads(original.overloads) + ); + return update(original, kind, key, value, modifiers, isComputed); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/NullLiteral.ts b/koala-wrapper/src/arkts-api/node-utilities/NullLiteral.ts new file mode 100644 index 000000000..9ab1bb363 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/NullLiteral.ts @@ -0,0 +1,24 @@ +/* + * 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 { NullLiteral } from '../../generated'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateNullLiteral(original: NullLiteral): NullLiteral { + /* TODO: no getter provided yet */ + + const update = updateThenAttach(NullLiteral.updateNullLiteral, attachModifiers); + return update(original); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/NumberLiteral.ts b/koala-wrapper/src/arkts-api/node-utilities/NumberLiteral.ts new file mode 100644 index 000000000..1dfab1450 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/NumberLiteral.ts @@ -0,0 +1,30 @@ +/* + * 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 { NumberLiteral } from '../types'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, compose, updateThenAttach } from '../utilities/private'; + +export function updateNumberLiteral(original: NumberLiteral, value: number): NumberLiteral { + if (isSameNativeObject(value, original.value)) { + return original; + } + + const update = updateThenAttach( + compose(NumberLiteral.create), // TODO: No UpdateNumberLiteral, need to change this + attachModifiers + ); + return update(original, value); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ReturnStatement.ts b/koala-wrapper/src/arkts-api/node-utilities/ReturnStatement.ts new file mode 100644 index 000000000..9fc05a371 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ReturnStatement.ts @@ -0,0 +1,27 @@ +/* + * 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 { Expression, ReturnStatement } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateReturnStatement(original: ReturnStatement, argument?: Expression): ReturnStatement { + if (isSameNativeObject(argument, original.argument)) { + return original; + } + + const update = updateThenAttach(ReturnStatement.update1ReturnStatement, attachModifiers); + return update(original, argument); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ScriptFunction.ts b/koala-wrapper/src/arkts-api/node-utilities/ScriptFunction.ts new file mode 100644 index 000000000..745a5398c --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ScriptFunction.ts @@ -0,0 +1,46 @@ +/* + * 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 { FunctionSignature, ScriptFunction } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { updateThenAttach } from '../utilities/private'; + +export function updateScriptFunction( + original: ScriptFunction, + databody: AstNode | undefined, + datasignature: FunctionSignature | undefined, + datafuncFlags: number, + dataflags: number +): ScriptFunction { + if ( + isSameNativeObject(databody, original.body) && + isSameNativeObject(datasignature?.params, original.params) && + isSameNativeObject(datasignature?.typeParams, original.typeParams) && + isSameNativeObject(datasignature?.returnType, original.returnTypeAnnotation) && + isSameNativeObject(datasignature?.hasReceiver, original.hasReceiver) && + isSameNativeObject(datafuncFlags, original.flags) && + isSameNativeObject(dataflags, original.modifiers) + ) { + return original; + } + + const update = updateThenAttach( + ScriptFunction.updateScriptFunction, + (node: ScriptFunction, original: ScriptFunction) => (!!original.id ? node.setIdent(original.id) : node), + (node: ScriptFunction, original: ScriptFunction) => node.setAnnotations(original.annotations) + ); + return update(original, databody, datasignature, datafuncFlags, dataflags); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/StringLiteral.ts b/koala-wrapper/src/arkts-api/node-utilities/StringLiteral.ts new file mode 100644 index 000000000..53f330d42 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/StringLiteral.ts @@ -0,0 +1,27 @@ +/* + * 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 { StringLiteral } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateStringLiteral(original: StringLiteral, str: string): StringLiteral { + if (isSameNativeObject(str, original.str)) { + return original; + } + + const update = updateThenAttach(StringLiteral.update1StringLiteral, attachModifiers); + return update(original, str); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/StructDeclaration.ts b/koala-wrapper/src/arkts-api/node-utilities/StructDeclaration.ts new file mode 100644 index 000000000..ee57547d2 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/StructDeclaration.ts @@ -0,0 +1,28 @@ +/* + * 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 { ClassDefinition } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { StructDeclaration } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateStructDeclaration(original: StructDeclaration, definition: ClassDefinition): StructDeclaration { + if (isSameNativeObject(definition, original.definition)) { + return original; + } + + const update = updateThenAttach(StructDeclaration.update, attachModifiers); + return update(original, definition); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/SuperExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/SuperExpression.ts new file mode 100644 index 000000000..d1bee071b --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/SuperExpression.ts @@ -0,0 +1,24 @@ +/* + * 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 { SuperExpression } from '../../generated'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateSuperExpression(original: SuperExpression): SuperExpression { + /* TODO: no getter provided yet */ + + const update = updateThenAttach(SuperExpression.updateSuperExpression, attachModifiers); + return update(original); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/TSAsExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/TSAsExpression.ts new file mode 100644 index 000000000..f82b8afc1 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/TSAsExpression.ts @@ -0,0 +1,36 @@ +/* + * 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 { Expression, TSAsExpression, TypeNode } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateTSAsExpression( + original: TSAsExpression, + expression: Expression | undefined, + typeAnnotation: TypeNode | undefined, + isConst: boolean +): TSAsExpression { + if ( + isSameNativeObject(expression, original.expr) && + isSameNativeObject(typeAnnotation, original.typeAnnotation) && + isSameNativeObject(isConst, original.isConst) + ) { + return original; + } + + const update = updateThenAttach(TSAsExpression.updateTSAsExpression, attachModifiers); + return update(original, expression, typeAnnotation, isConst); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/TSInterfaceBody.ts b/koala-wrapper/src/arkts-api/node-utilities/TSInterfaceBody.ts new file mode 100644 index 000000000..a1a6350f7 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/TSInterfaceBody.ts @@ -0,0 +1,28 @@ +/* + * 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 { TSInterfaceBody } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateTSInterfaceBody(original: TSInterfaceBody, body: readonly AstNode[]): TSInterfaceBody { + if (isSameNativeObject(body, original.body)) { + return original; + } + + const update = updateThenAttach(TSInterfaceBody.updateTSInterfaceBody, attachModifiers); + return update(original, body); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts b/koala-wrapper/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts new file mode 100644 index 000000000..d268c5d82 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/TSInterfaceDeclaration.ts @@ -0,0 +1,43 @@ +/* + * 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 { TSInterfaceDeclaration, TSInterfaceHeritage } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { AstNode } from '../peers/AstNode'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateTSInterfaceDeclaration( + original: TSInterfaceDeclaration, + _extends: readonly TSInterfaceHeritage[], + id: AstNode | undefined, + typeParams: AstNode | undefined, + body: AstNode | undefined, + isStatic: boolean, + isExternal: boolean +): TSInterfaceDeclaration { + if ( + isSameNativeObject(_extends, original.extends) && + isSameNativeObject(id, original.id) && + isSameNativeObject(typeParams, original.typeParams) && + isSameNativeObject(body, original.body) && + isSameNativeObject(isStatic, original.isStatic) && + isSameNativeObject(isExternal, original.isFromExternal) + ) { + return original; + } + + const update = updateThenAttach(TSInterfaceDeclaration.updateTSInterfaceDeclaration, attachModifiers); + return update(original, _extends, id, typeParams, body, isStatic, isExternal); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/TSNonNullExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/TSNonNullExpression.ts new file mode 100644 index 000000000..d387e39f9 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/TSNonNullExpression.ts @@ -0,0 +1,27 @@ +/* + * 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 { Expression, TSNonNullExpression } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateTSNonNullExpression(original: TSNonNullExpression, expr?: Expression): TSNonNullExpression { + if (isSameNativeObject(expr, original.expr)) { + return original; + } + + const update = updateThenAttach(TSNonNullExpression.updateTSNonNullExpression, attachModifiers); + return update(original, expr); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts b/koala-wrapper/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts new file mode 100644 index 000000000..3531ee3a9 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/TSTypeAliasDeclaration.ts @@ -0,0 +1,40 @@ +/* + * 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 { Identifier, TSTypeAliasDeclaration, TSTypeParameterDeclaration, TypeNode } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateTSTypeAliasDeclaration( + original: TSTypeAliasDeclaration, + id?: Identifier, + typeParams?: TSTypeParameterDeclaration, + typeAnnotation?: TypeNode +): TSTypeAliasDeclaration { + if ( + isSameNativeObject(id, original.id) && + isSameNativeObject(typeParams, original.typeParams) && + isSameNativeObject(typeAnnotation, original.typeAnnotation) + ) { + return original; + } + + const update = updateThenAttach( + TSTypeAliasDeclaration.updateTSTypeAliasDeclaration, + attachModifiers, + (node: TSTypeAliasDeclaration, original: TSTypeAliasDeclaration) => node.setAnnotations(original.annotations) + ); + return update(original, id, typeParams, typeAnnotation); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/TSTypeParameter.ts b/koala-wrapper/src/arkts-api/node-utilities/TSTypeParameter.ts new file mode 100644 index 000000000..9a5ac75d5 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/TSTypeParameter.ts @@ -0,0 +1,36 @@ +/* + * 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 { Identifier, TSTypeParameter, TypeNode } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateTSTypeParameter( + original: TSTypeParameter, + name?: Identifier, + constraint?: TypeNode, + defaultType?: TypeNode +): TSTypeParameter { + if ( + isSameNativeObject(name, original.name) && + isSameNativeObject(constraint, original.constraint) && + isSameNativeObject(defaultType, original.defaultType) + ) { + return original; + } + + const update = updateThenAttach(TSTypeParameter.updateTSTypeParameter, attachModifiers); + return update(original, name, constraint, defaultType); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/TSTypeParameterDeclaration.ts b/koala-wrapper/src/arkts-api/node-utilities/TSTypeParameterDeclaration.ts new file mode 100644 index 000000000..3f1395049 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/TSTypeParameterDeclaration.ts @@ -0,0 +1,31 @@ +/* + * 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 { TSTypeParameter, TSTypeParameterDeclaration } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateTSTypeParameterDeclaration( + original: TSTypeParameterDeclaration, + params: readonly TSTypeParameter[], + requiredParams: number +): TSTypeParameterDeclaration { + if (isSameNativeObject(params, original.params) && isSameNativeObject(requiredParams, original.requiredParams)) { + return original; + } + + const update = updateThenAttach(TSTypeParameterDeclaration.updateTSTypeParameterDeclaration, attachModifiers); + return update(original, params, requiredParams); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/TSTypeParameterInstantiation.ts b/koala-wrapper/src/arkts-api/node-utilities/TSTypeParameterInstantiation.ts new file mode 100644 index 000000000..49d8746e4 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/TSTypeParameterInstantiation.ts @@ -0,0 +1,30 @@ +/* + * 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 { TSTypeParameterInstantiation, TypeNode } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateTSTypeParameterInstantiation( + original: TSTypeParameterInstantiation, + params: readonly TypeNode[] +): TSTypeParameterInstantiation { + if (isSameNativeObject(params, original.params)) { + return original; + } + + const update = updateThenAttach(TSTypeParameterInstantiation.updateTSTypeParameterInstantiation, attachModifiers); + return update(original, params); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/ThisExpression.ts b/koala-wrapper/src/arkts-api/node-utilities/ThisExpression.ts new file mode 100644 index 000000000..f2f04c716 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/ThisExpression.ts @@ -0,0 +1,24 @@ +/* + * 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 { ThisExpression } from '../../generated'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateThisExpression(original: ThisExpression): ThisExpression { + /* TODO: no getter provided yet */ + + const update = updateThenAttach(ThisExpression.updateThisExpression, attachModifiers); + return update(original); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/UndefinedLiteral.ts b/koala-wrapper/src/arkts-api/node-utilities/UndefinedLiteral.ts new file mode 100644 index 000000000..aaedc726c --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/UndefinedLiteral.ts @@ -0,0 +1,24 @@ +/* + * 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 { UndefinedLiteral } from '../../generated'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; + +export function updateUndefinedLiteral(original: UndefinedLiteral): UndefinedLiteral { + /* TODO: no getter provided yet */ + + const update = updateThenAttach(UndefinedLiteral.updateUndefinedLiteral, attachModifiers); + return update(original); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/VariableDeclaration.ts b/koala-wrapper/src/arkts-api/node-utilities/VariableDeclaration.ts new file mode 100644 index 000000000..24432ec6d --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/VariableDeclaration.ts @@ -0,0 +1,38 @@ +/* + * 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 { KInt } from '@koalaui/interop'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { VariableDeclaration, VariableDeclarator } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; +import { Es2pandaVariableDeclarationKind } from '../../generated/Es2pandaEnums'; + +export function updateVariableDeclaration( + original: VariableDeclaration, + modifiers: KInt, + kind: Es2pandaVariableDeclarationKind, + declarators: readonly VariableDeclarator[] +): VariableDeclaration { + if ( + isSameNativeObject(modifiers, original.modifiers) && + isSameNativeObject(kind, original.declarationKind) && + isSameNativeObject(declarators, original.declarators) + ) { + return original; + } + + const update = updateThenAttach(VariableDeclaration.update, attachModifiers); + return update(original, modifiers, kind, declarators); +} diff --git a/koala-wrapper/src/arkts-api/node-utilities/VariableDeclarator.ts b/koala-wrapper/src/arkts-api/node-utilities/VariableDeclarator.ts new file mode 100644 index 000000000..52c002fd3 --- /dev/null +++ b/koala-wrapper/src/arkts-api/node-utilities/VariableDeclarator.ts @@ -0,0 +1,39 @@ +/* + * 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 { Identifier } from '../../generated'; +import { isSameNativeObject } from '../peers/ArktsObject'; +import { VariableDeclarator } from '../types'; +import { attachModifiers, updateThenAttach } from '../utilities/private'; +import { Es2pandaVariableDeclaratorFlag } from '../../generated/Es2pandaEnums'; +import { AstNode } from '../peers/AstNode'; + +export function updateVariableDeclarator( + original: VariableDeclarator, + flag: Es2pandaVariableDeclaratorFlag, + name: Identifier, + initializer: AstNode | undefined +): VariableDeclarator { + if ( + isSameNativeObject(name, original.name) && + isSameNativeObject(initializer, original.initializer) + /* TODO: no getter for flag */ + ) { + return original; + } + + const update = updateThenAttach(VariableDeclarator.update, attachModifiers); + return update(original, flag, name, initializer); +} diff --git a/koala-wrapper/src/arkts-api/peers/ArktsObject.ts b/koala-wrapper/src/arkts-api/peers/ArktsObject.ts new file mode 100644 index 000000000..bfa1e6e09 --- /dev/null +++ b/koala-wrapper/src/arkts-api/peers/ArktsObject.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 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 { KNativePointer } from '@koalaui/interop'; + +export abstract class ArktsObject { + protected constructor(peer: KNativePointer) { + this.peer = peer; + } + + readonly peer: KNativePointer; +} + +export function isSameNativeObject( + first: T | readonly T[], + second: T | readonly T[] +): boolean { + if (Array.isArray(first) && Array.isArray(second)) { + if (first.length !== second.length) { + return false; + } + for (let i = 0; i < first.length; i++) { + if (!isSameNativeObject(first[i], second[i])) { + return false; + } + } + return true; + } + if (first instanceof ArktsObject && second instanceof ArktsObject) { + return first?.peer === second?.peer; + } + return first === second; +} diff --git a/koala-wrapper/src/arkts-api/peers/AstNode.ts b/koala-wrapper/src/arkts-api/peers/AstNode.ts new file mode 100644 index 000000000..634da8e17 --- /dev/null +++ b/koala-wrapper/src/arkts-api/peers/AstNode.ts @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2025 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 { isNullPtr, KInt, KNativePointer as KPtr, KNativePointer, nullptr } from "@koalaui/interop" +import { global } from "../static/global" +import { allFlags, nodeType, unpackNodeArray, unpackNonNullableNode, unpackString } from "../utilities/private" +import { throwError } from "../../utils" +import { Es2pandaModifierFlags } from "../../generated/Es2pandaEnums" +import { ArktsObject } from "./ArktsObject" +import { Es2pandaAstNodeType } from "../../Es2pandaEnums" + +export abstract class AstNode extends ArktsObject { + protected constructor(peer: KNativePointer) { + if (isNullPtr(peer)) { + throwError(`attempted to create AstNode from nullptr`) + } + super(peer) + this.updateChildren() + } + + public get originalPeer(): KNativePointer { + return global.generatedEs2panda._AstNodeOriginalNodeConst(global.context, this.peer) + } + + public set originalPeer(peer: KNativePointer) { + global.generatedEs2panda._AstNodeSetOriginalNode(global.context, this.peer, peer) + } + + public getChildren(): readonly AstNode[] { + return unpackNodeArray(global.es2panda._AstNodeChildren(global.context, this.peer)) + } + + public getSubtree(): readonly AstNode[] { + return this.getChildren().reduce( + (prev: readonly AstNode[], curr) => { + return prev.concat(curr.getSubtree()) + }, + [this] + ) + } + + public updateChildren(): void { + if (this.peer === nullptr) { + throwError('updateChildren called on NULLPTR') + } + global.es2panda._AstNodeUpdateChildren(global.context, this.peer) + } + + public updateModifiers(modifierFlags: KInt | undefined): this { + global.generatedEs2panda._AstNodeClearModifier(global.context, this.peer, allFlags) + global.generatedEs2panda._AstNodeAddModifier(global.context, this.peer, modifierFlags ?? Es2pandaModifierFlags.MODIFIER_FLAGS_NONE) + return this + } + + public dump(indentation: number = 0): string { + const children = this.getChildren() + .map((it) => it.dump(indentation + 1)) + const msg = + `${indentation}_` + + ` ` + + this.dumpMessage() + return "> " + " ".repeat(4 * indentation) + msg + "\n" + children.join("") + } + + protected dumpMessage(): string { + return `` + } + + public dumpJson(): string { + return unpackString(global.generatedEs2panda._AstNodeDumpJSONConst(global.context, this.peer)) + } + + public dumpSrc(): string { + return unpackString(global.generatedEs2panda._AstNodeDumpEtsSrcConst(global.context, this.peer)) + } + + public dumpModifiers(): string { + return unpackString(global.es2panda._AstNodeDumpModifiers(global.context, this.peer)) + } + + public clone(): this { + return unpackNonNullableNode(global.generatedEs2panda._AstNodeClone(global.context, this.peer, this.parent.peer)); + } + + public get parent(): AstNode { + const parent = global.generatedEs2panda._AstNodeParent(global.context, this.peer) + if (parent === nullptr) { + throwError(`no parent`) + } + return unpackNonNullableNode(parent) + } + + public set parent(node: AstNode) { + global.generatedEs2panda._AstNodeSetParent(global.context, this.peer, node.peer) + } + + public get modifiers(): KInt { + return global.generatedEs2panda._AstNodeModifiers(global.context, this.peer) + } + + public set modifiers(flags: KInt | undefined) { + global.generatedEs2panda._AstNodeClearModifier(global.context, this.peer, allFlags) + global.generatedEs2panda._AstNodeAddModifier(global.context, this.peer, flags ?? Es2pandaModifierFlags.MODIFIER_FLAGS_NONE) + } + + public get isStatic(): boolean { + return global.generatedEs2panda._AstNodeIsStaticConst(global.context, this.peer) + } +} + + +export class UnsupportedNode extends AstNode { + constructor(peer: KPtr) { + super(peer) + + } +} diff --git a/koala-wrapper/src/arkts-api/peers/Config.ts b/koala-wrapper/src/arkts-api/peers/Config.ts new file mode 100644 index 000000000..cde8c26fc --- /dev/null +++ b/koala-wrapper/src/arkts-api/peers/Config.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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 { ArktsObject } from "./ArktsObject" +import { global } from "../static/global" +import { passStringArray } from "../utilities/private" +import { KNativePointer } from "@koalaui/interop" + +export class Config extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + // TODO: wait for getter from api + this.path = `` + } + + static create( + input: readonly string[] + ): Config { + console.log("[TS WRAPPER] CREATE CONFIG"); + return new Config( + global.es2panda._CreateConfig(input.length, passStringArray(input)) + ) + } + + static createDefault(): Config { + if (global.configIsInitialized()) { + console.warn(`Config already initialized`) + return new Config( + global.config + ) + } + return new Config( + global.es2panda._CreateConfig( + 4, + passStringArray(["", "--arktsconfig", "./arktsconfig.json", global.filePath]) + ) + ) + } + + readonly path: string +} \ No newline at end of file diff --git a/koala-wrapper/src/arkts-api/peers/Context.ts b/koala-wrapper/src/arkts-api/peers/Context.ts new file mode 100644 index 000000000..81a1ec31f --- /dev/null +++ b/koala-wrapper/src/arkts-api/peers/Context.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 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 { ArktsObject } from "./ArktsObject" +import { global } from "../static/global" +import { throwError, filterSource } from "../../utils" +import { passString } from "../utilities/private" +import { KNativePointer } from "@koalaui/interop" +import { AstNode } from "./AstNode" +import { Program } from "./Program" +export class Context extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + } + + static createFromString( + source: string + ): Context { + if (!global.configIsInitialized()) { + throwError(`Config not initialized`) + } + return new Context( + global.es2panda._CreateContextFromString( + global.config, + passString(source), + passString(global.filePath) + ) + ) + } + static destroyAndRecreate( + ast: AstNode + ): Context { + console.log("[TS WRAPPER] DESTROY AND RECREATE"); + const source = filterSource(ast.dumpSrc()) + global.es2panda._DestroyContext(global.context) + global.compilerContext = Context.createFromString(source) + + return new Context(global.context); + } + + get program(): Program { + return new Program(global.es2panda._ContextProgram(this.peer)); + } +} \ No newline at end of file diff --git a/koala-wrapper/src/arkts-api/peers/ImportPathManager.ts b/koala-wrapper/src/arkts-api/peers/ImportPathManager.ts new file mode 100644 index 000000000..eeeecf1dc --- /dev/null +++ b/koala-wrapper/src/arkts-api/peers/ImportPathManager.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 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 { ArktsObject } from "./ArktsObject" +import { global } from "../static/global" +import { KNativePointer } from "@koalaui/interop" +import { passString, unpackString } from "../utilities/private"; +import { SourcePosition } from "./SourcePosition"; + +export class ImportPathManager extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + } + + static create(): ImportPathManager { + return new ImportPathManager( + global.es2panda._ETSParserGetImportPathManager(global.context) + ); + } + + resolvePath(currentModulePath: string, importPath: string): string { + return ''; // TODO: no longer support this. + } +} \ No newline at end of file diff --git a/koala-wrapper/src/arkts-api/peers/Program.ts b/koala-wrapper/src/arkts-api/peers/Program.ts new file mode 100644 index 000000000..5f3afbed2 --- /dev/null +++ b/koala-wrapper/src/arkts-api/peers/Program.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 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 { ArktsObject } from "./ArktsObject" +import { global } from "../static/global" +import { acceptNativeObjectArrayResult, unpackString } from "../utilities/private" +import { KNativePointer } from "@koalaui/interop" +import { EtsScript } from "../types" + +export class Program extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer); + } + + get astNode(): EtsScript { + return new EtsScript(global.es2panda._ProgramAst(global.context, this.peer)); + } + + get externalSources(): ExternalSource[] { + return acceptNativeObjectArrayResult( + global.es2panda._ProgramExternalSources(global.context, this.peer), + (instance: KNativePointer) => new ExternalSource(instance) + ); + } + + get programFileName(): string { + return unpackString(global.es2panda._ProgramFileNameConst(global.context, this.peer)); + } + + get programFileNameWithExtension(): string { + return unpackString(global.es2panda._ProgramFileNameWithExtensionConst(global.context, this.peer)); + } + + get programGlobalAbsName(): string { + return unpackString(global.es2panda._ETSParserGetGlobalProgramAbsName(global.context)); + } +} + +export class ExternalSource extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + } + + getName(): string { + return unpackString(global.es2panda._ExternalSourceName(this.peer)); + } + + get programs(): Program[] { + return acceptNativeObjectArrayResult( + global.es2panda._ExternalSourcePrograms(this.peer), + (instance: KNativePointer) => new Program(instance) + ); + } +} diff --git a/koala-wrapper/src/arkts-api/peers/SourcePosition.ts b/koala-wrapper/src/arkts-api/peers/SourcePosition.ts new file mode 100644 index 000000000..9d84847a6 --- /dev/null +++ b/koala-wrapper/src/arkts-api/peers/SourcePosition.ts @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 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 { ArktsObject } from "./ArktsObject" +import { global } from "../static/global" +import { KNativePointer } from "@koalaui/interop" + +export class SourcePosition extends ArktsObject { + constructor(peer: KNativePointer) { + super(peer) + } + + static create(index: number, line: number): SourcePosition { + return new SourcePosition( + global.es2panda._CreateSourcePosition(global.context, index, line) + ); + } + + index(): number { + return global.es2panda._SourcePositionIndex(global.context, this.peer); + } + + line(): number { + return global.es2panda._SourcePositionLine(global.context, this.peer); + } +} \ No newline at end of file diff --git a/koala-wrapper/src/arkts-api/static/global.ts b/koala-wrapper/src/arkts-api/static/global.ts new file mode 100644 index 000000000..551b6c83f --- /dev/null +++ b/koala-wrapper/src/arkts-api/static/global.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022-2025 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 { throwError } from "../../utils" +import { KNativePointer } from "@koalaui/interop" +import { initEs2panda, Es2pandaNativeModule, initGeneratedEs2panda } from "../../Es2pandaNativeModule" +import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from "../../generated/Es2pandaNativeModule" +import { initInterop, InteropNativeModule } from "../../InteropNativeModule" +import type { Context } from "../peers/Context" + +export class global { + public static filePath: string = "./plugins/input/main.sts" + + private static _config?: KNativePointer + public static set config(config: KNativePointer) { + if (global._config !== undefined) { + throwError('Global.config already initialized') + } + global._config = config + } + public static get config(): KNativePointer { + return global._config ?? throwError('Global.config not initialized') + } + public static configIsInitialized(): boolean { + return global._config !== undefined + } + + // TODO: rename to contextPeer + public static get context(): KNativePointer { + return global.compilerContext?.peer ?? throwError('Global.context not initialized') + } + + // unsafe - could be undefined + public static compilerContext: Context | undefined + + public static clearContext(): void { + this.compilerContext = undefined; + } + + private static _es2panda: Es2pandaNativeModule | undefined = undefined + public static get es2panda(): Es2pandaNativeModule { + if (this._es2panda === undefined) { + this._es2panda = initEs2panda() + } + return this._es2panda + } + + private static _generatedEs2panda: GeneratedEs2pandaNativeModule | undefined = undefined + public static get generatedEs2panda(): GeneratedEs2pandaNativeModule { + if (this._generatedEs2panda === undefined) { + this._generatedEs2panda = initGeneratedEs2panda() + } + return this._generatedEs2panda + } + + private static _interop: InteropNativeModule | undefined = undefined + public static get interop(): InteropNativeModule { + if (this._interop === undefined) this._interop = initInterop() + return this._interop + } + + public static resetConfig() { + global._config = undefined; + } +} diff --git a/koala-wrapper/src/arkts-api/static/globalUtils.ts b/koala-wrapper/src/arkts-api/static/globalUtils.ts new file mode 100644 index 000000000..8e3a91074 --- /dev/null +++ b/koala-wrapper/src/arkts-api/static/globalUtils.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 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 { KNativePointer } from "@koalaui/interop"; +import { Context } from "../peers/Context"; +import { global } from "./global"; +import { clearNodeCache } from "../class-by-peer"; + +export function getOrUpdateGlobalContext(peer: KNativePointer): Context { + if (!global.compilerContext || global.context !== peer) { + clearNodeCache(); + global.compilerContext = new Context(peer); + } + return global.compilerContext; +} \ No newline at end of file diff --git a/koala-wrapper/src/arkts-api/to-be-generated/MemberExpression.ts b/koala-wrapper/src/arkts-api/to-be-generated/MemberExpression.ts new file mode 100644 index 000000000..0a953323a --- /dev/null +++ b/koala-wrapper/src/arkts-api/to-be-generated/MemberExpression.ts @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2022-2025 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 { Expression } from '../../generated'; +import { + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + Es2pandaMemberExpressionKind, + KNativePointer, + passNode, + unpackNonNullableNode, + global, +} from '../../reexport-for-generated'; + +export class MemberExpression extends Expression { + constructor(peer: KNativePointer) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_MEMBER_EXPRESSION); + super(peer); + } + + static create( + object: AstNode, + property: AstNode, + kind: Es2pandaMemberExpressionKind, + computed: boolean, + optional: boolean + ): MemberExpression { + return new MemberExpression( + global.generatedEs2panda._CreateMemberExpression( + global.context, + passNode(object), + passNode(property), + kind, + computed, + optional + ) + ); + } + + static update( + node: MemberExpression, + object: AstNode, + property: AstNode, + kind: Es2pandaMemberExpressionKind, + computed: boolean, + optional: boolean + ): MemberExpression { + return new MemberExpression( + global.generatedEs2panda._UpdateMemberExpression( + global.context, + node.peer, + passNode(object), + passNode(property), + kind, + computed, + optional + ) + ); + } + + protected override dumpMessage(): string { + return ` `; + } + + get object(): AstNode { + return unpackNonNullableNode(global.generatedEs2panda._MemberExpressionObject(global.context, this.peer)); + } + + get property(): AstNode { + return unpackNonNullableNode(global.generatedEs2panda._MemberExpressionProperty(global.context, this.peer)); + } + + get kind(): Es2pandaMemberExpressionKind { + return global.generatedEs2panda._MemberExpressionKindConst(global.context, this.peer); + } + + get computed(): boolean { + return global.generatedEs2panda._MemberExpressionIsComputedConst(global.context, this.peer); + } + + get optional(): boolean { + return false; // todo: no corresponding method in es2panda + } + + /** @deprecated */ + setObject(object_arg?: Expression): this { + global.generatedEs2panda._MemberExpressionSetObject(global.context, this.peer, passNode(object_arg)); + return this; + } + /** @deprecated */ + setProperty(prop?: Expression): this { + global.generatedEs2panda._MemberExpressionSetProperty(global.context, this.peer, passNode(prop)); + return this; + } +} diff --git a/koala-wrapper/src/arkts-api/types.ts b/koala-wrapper/src/arkts-api/types.ts new file mode 100644 index 000000000..3faf2f690 --- /dev/null +++ b/koala-wrapper/src/arkts-api/types.ts @@ -0,0 +1,903 @@ +/* + * Copyright (c) 2022-2025 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 { global } from './static/global'; +import { KInt, KNativePointer, KNativePointer as KPtr, nullptr } from '@koalaui/interop'; +import { + Es2pandaContextState, + Es2pandaMethodDefinitionKind, + Es2pandaModifierFlags, + Es2pandaScriptFunctionFlags, + Es2pandaTokenType, + Es2pandaVariableDeclarationKind, + Es2pandaVariableDeclaratorFlag, +} from '../generated/Es2pandaEnums'; +import { + allFlags, + arrayOfNullptr, + assertValidPeer, + nodeType, + passNode, + passNodeArray, + passString, + unpackNode, + unpackNodeArray, + unpackNonNullableNode, + unpackString, + updatePeerByNode, +} from './utilities/private'; +import { proceedToState } from './utilities/public'; +import { Es2pandaAstNodeType } from '../Es2pandaEnums'; +import { AstNode } from './peers/AstNode'; +import { ArktsObject } from './peers/ArktsObject'; +import { Config } from './peers/Config'; +import { Context } from './peers/Context'; +import * as path from 'node:path'; +import { nodeByType } from './class-by-peer'; +import { MemberExpression } from './to-be-generated/MemberExpression'; +import { + AnnotationUsage, + BlockStatement, + ClassDefinition, + ETSTypeReference, + ETSTypeReferencePart, + Expression, + FunctionSignature, + Identifier, + ImportSpecifier, + Literal, + ObjectExpression, + ScriptFunction, + StringLiteral, + TSTypeParameterDeclaration, + TSTypeParameterInstantiation, + TypeNode, +} from '../generated'; + +export class EtsScript extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE); + super(peer); + } + + static fromContext(): EtsScript { + console.log('[TS WRAPPER] GET AST FROM CONTEXT'); + return new EtsScript( + global.es2panda._ProgramAst(global.context, global.es2panda._ContextProgram(global.context)) + ); + } + + /** + * @deprecated + */ + static createFromSource( + source: string, + state: Es2pandaContextState = Es2pandaContextState.ES2PANDA_STATE_PARSED + ): EtsScript { + if (!global.configIsInitialized()) { + global.config = Config.createDefault().peer; + } + global.compilerContext = Context.createFromString(source); + proceedToState(state); + return new EtsScript( + global.es2panda._ProgramAst(global.context, global.es2panda._ContextProgram(global.context)) + ); + } + + /** + * @deprecated + */ + static updateByStatements(node: EtsScript, statements: readonly AstNode[]): EtsScript { + global.generatedEs2panda._BlockStatementSetStatements( + global.context, + node.peer, + passNodeArray(statements), + statements.length + ); + return node; + } + + get statements(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._BlockStatementStatements(global.context, this.peer)); + } + + set statements(nodes: readonly AstNode[]) { + global.generatedEs2panda._BlockStatementSetStatements( + global.context, + this.peer, + passNodeArray(nodes), + nodes.length + ); + } +} + +export class ExpressionStatement extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_EXPRESSION_STATEMENT); + super(peer); + } + + static create(expression: AstNode): ExpressionStatement { + return new ExpressionStatement( + global.generatedEs2panda._CreateExpressionStatement(global.context, expression.peer) + ); + } + + static update(node: ExpressionStatement, expression: AstNode): ExpressionStatement { + return new ExpressionStatement( + global.generatedEs2panda._UpdateExpressionStatement(global.context, node.peer, expression.peer) + ); + } + + get expression(): AstNode { + return unpackNonNullableNode( + global.generatedEs2panda._ExpressionStatementGetExpressionConst(global.context, this.peer) + ); + } + /** @deprecated */ + setExpression(expr?: Expression): this { + global.generatedEs2panda._ExpressionStatementSetExpression(global.context, this.peer, passNode(expr)); + return this; + } +} + +// TODO: +// the CallExpression idl Create signature doesn't include the trailing block at all. +// Need to clarify with the compiler people if they will provide create signature with a trailing block argument. +export class CallExpression extends Expression { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_CALL_EXPRESSION); + super(peer); + this.expression = unpackNonNullableNode( + global.generatedEs2panda._CallExpressionCallee(global.context, this.peer) + ); + this.typeParams = unpackNode(global.generatedEs2panda._CallExpressionTypeParams(global.context, this.peer)); + this.typeArguments = this.typeParams + ? unpackNodeArray( + global.generatedEs2panda._TSTypeParameterInstantiationParamsConst( + global.context, + this.typeParams.peer + ) + ) + : undefined; + this.arguments = unpackNodeArray(global.generatedEs2panda._CallExpressionArguments(global.context, this.peer)); + } + + static create( + expression: AstNode, + typeArguments: readonly TypeNode[] | undefined, + args: readonly AstNode[] | undefined, + isOptional: boolean = false, + trailingComma: boolean = false + ): CallExpression { + const peer = global.generatedEs2panda._CreateCallExpression( + global.context, + passNode(expression), + passNodeArray(args), + args?.length ?? 0, + typeArguments + ? passNode(TSTypeParameterInstantiation.createTSTypeParameterInstantiation(typeArguments)) + : nullptr, + isOptional, + trailingComma + ); + return new CallExpression(peer); + } + + static update( + node: CallExpression, + expression: AstNode, + typeArguments: readonly TypeNode[] | undefined, + args: readonly AstNode[] | undefined, + isOptional: boolean = false, + trailingComma: boolean = false + ): CallExpression { + const peer = global.es2panda._UpdateCallExpression( + global.context, + node.peer, + passNode(expression), + passNodeArray(args), + args?.length ?? 0, + typeArguments + ? passNode(TSTypeParameterInstantiation.createTSTypeParameterInstantiation(typeArguments)) + : nullptr, + isOptional, + trailingComma + ); + return new CallExpression(peer); + } + + get trailingBlock(): BlockStatement | undefined { + return unpackNode(global.generatedEs2panda._CallExpressionTrailingBlockConst(global.context, this.peer)); + } + + setTralingBlock(trailingBlock: BlockStatement | undefined): this { + if (!trailingBlock) return this; + global.generatedEs2panda._CallExpressionSetTrailingBlock(global.context, this.peer, trailingBlock.peer); + return this; + } + + /** @deprecated */ + setCallee(callee?: Expression): this { + global.generatedEs2panda._CallExpressionSetCallee(global.context, this.peer, passNode(callee)); + return this; + } + + /** @deprecated */ + setTypeParams(typeParams?: TSTypeParameterInstantiation): this { + global.generatedEs2panda._CallExpressionSetTypeParams(global.context, this.peer, passNode(typeParams)); + return this; + } + + readonly expression: AstNode; // Expression + readonly typeArguments: readonly TypeNode[] | undefined; + readonly arguments: readonly Expression[]; + readonly typeParams: TSTypeParameterInstantiation | undefined; +} + +export class AssignmentExpression extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_ASSIGNMENT_EXPRESSION); + super(peer); + } + + static create(left: AstNode, assignmentOperator: Es2pandaTokenType, right: AstNode): AssignmentExpression { + return new AssignmentExpression( + global.generatedEs2panda._CreateAssignmentExpression( + global.context, + passNode(left), + passNode(right), + assignmentOperator + ) + ); + } + + static update( + node: AssignmentExpression, + left: AstNode, + assignmentOperator: Es2pandaTokenType, + right: AstNode + ): AssignmentExpression { + return new AssignmentExpression( + global.generatedEs2panda._UpdateAssignmentExpression( + global.context, + node.peer, + passNode(left), + passNode(right), + assignmentOperator + ) + ); + } + + get left(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssignmentExpressionLeftConst(global.context, this.peer)); + } + get right(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssignmentExpressionRightConst(global.context, this.peer)); + } + get operatorType(): Es2pandaTokenType { + return global.generatedEs2panda._AssignmentExpressionOperatorTypeConst(global.context, this.peer); + } + /** @deprecated */ + setRight(expr?: Expression): this { + global.generatedEs2panda._AssignmentExpressionSetRight(global.context, this.peer, passNode(expr)); + return this; + } + /** @deprecated */ + setLeft(expr?: Expression): this { + global.generatedEs2panda._AssignmentExpressionSetLeft(global.context, this.peer, passNode(expr)); + return this; + } + setOperatorType(operatorType: Es2pandaTokenType): this { + global.generatedEs2panda._AssignmentExpressionSetOperatorType(global.context, this.peer, operatorType); + return this; + } +} + +export class TSUnionType extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_TS_UNION_TYPE); + super(peer); + this.types = unpackNodeArray(global.generatedEs2panda._TSUnionTypeTypesConst(global.context, this.peer)); + } + + static create(node: undefined | TSUnionType, types: AstNode[]): TSUnionType { + return new TSUnionType( + updatePeerByNode( + global.generatedEs2panda._CreateTSUnionType(global.context, passNodeArray(types), types.length), + node + ) + ); + } + + readonly types: readonly AstNode[]; +} + +export class NumberLiteral extends Literal { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_NUMBER_LITERAL); + super(peer); + this.value = 0.0; + } + + static create(value: number): NumberLiteral { + return new NumberLiteral(global.es2panda._CreateNumberLiteral(global.context, value)); + } + + protected override dumpMessage(): string { + return ` `; + } + + readonly value: number = 0.0; +} + +export class ArrowFunctionExpression extends Expression { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION); + super(peer); + this.scriptFunction = unpackNonNullableNode( + global.generatedEs2panda._ArrowFunctionExpressionFunction(global.context, this.peer) + ); + } + + static create(func: ScriptFunction): ArrowFunctionExpression { + return new ArrowFunctionExpression( + global.generatedEs2panda._CreateArrowFunctionExpression(global.context, passNode(func)) + ); + } + + static update(node: ArrowFunctionExpression, func: ScriptFunction): ArrowFunctionExpression { + return new ArrowFunctionExpression( + global.generatedEs2panda._UpdateArrowFunctionExpression(global.context, node.peer, passNode(func)) + ); + } + + get annotations(): AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ArrowFunctionExpressionAnnotations(global.context, this.peer)); + } + + setAnnotations(annotations: AnnotationUsage[]): this { + global.generatedEs2panda._ArrowFunctionExpressionSetAnnotations( + global.context, + this.peer, + passNodeArray(annotations), + annotations.length + ); + + return this; + } + + readonly scriptFunction: ScriptFunction; +} + +export class FunctionDeclaration extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_FUNCTION_DECLARATION); + super(peer); + this.scriptFunction = unpackNonNullableNode( + global.generatedEs2panda._FunctionDeclarationFunction(global.context, this.peer) + ); + this.parameters = unpackNodeArray( + global.generatedEs2panda._ScriptFunctionParams(global.context, this.scriptFunction.peer) + ); + this.name = unpackNode(global.generatedEs2panda._ScriptFunctionId(global.context, this.scriptFunction.peer)); + this.body = unpackNode(global.generatedEs2panda._ScriptFunctionBody(global.context, this.scriptFunction.peer)); + this.typeParamsDecl = unpackNode( + global.generatedEs2panda._ScriptFunctionTypeParams(global.context, this.scriptFunction.peer) + ); + this.returnType = unpackNode( + global.generatedEs2panda._ScriptFunctionReturnTypeAnnotation(global.context, this.scriptFunction.peer) + ); + this.isAnon = global.generatedEs2panda._FunctionDeclarationIsAnonymousConst(global.context, this.peer); + } + + static create( + scriptFunction: ScriptFunction, + isAnon: boolean, + annotations?: AnnotationUsage[] + ): FunctionDeclaration { + const res = new FunctionDeclaration( + global.es2panda._CreateFunctionDeclaration( + global.context, + scriptFunction.peer, + // TODO: support annotations + arrayOfNullptr, + 0, + isAnon + ) + ); + // TODO: maybe wrong + res.modifiers = scriptFunction.modifiers; + if (annotations) { + res.annotations = annotations; + } + return res; + } + + static update( + node: FunctionDeclaration, + scriptFunction: ScriptFunction, + isAnon: boolean, + annotations?: AnnotationUsage[] + ): FunctionDeclaration { + const res = new FunctionDeclaration( + global.generatedEs2panda._UpdateFunctionDeclaration( + global.context, + node.peer, + scriptFunction.peer, + // TODO: support annotations + passNodeArray(annotations), + 0, + isAnon + ) + ); + if (annotations) { + res.annotations = annotations; + } + return res; + } + + get annotations(): AnnotationUsage[] { + return unpackNodeArray( + global.generatedEs2panda._FunctionDeclarationAnnotationsConst(global.context, this.peer) + ); + } + + set annotations(newAnnotations: AnnotationUsage[]) { + global.generatedEs2panda._FunctionDeclarationSetAnnotations( + global.context, + this.peer, + passNodeArray(newAnnotations), + newAnnotations.length + ); + } + + readonly scriptFunction: ScriptFunction; + readonly parameters: readonly AstNode[]; + readonly name?: Identifier; + readonly body?: BlockStatement; + readonly typeParamsDecl?: TSTypeParameterDeclaration; + readonly returnType?: AstNode; + readonly isAnon: boolean; +} + +export class FunctionExpression extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_FUNCTION_EXPRESSION); + super(peer); + this.scriptFunction = unpackNonNullableNode( + global.generatedEs2panda._FunctionExpressionFunction(global.context, this.peer) + ); + } + + static create(expression: ScriptFunction): FunctionExpression { + return new FunctionExpression( + global.generatedEs2panda._CreateFunctionExpression(global.context, passNode(expression)) + ); + } + + static update(node: FunctionExpression, expression: ScriptFunction): FunctionExpression { + return new FunctionExpression( + global.generatedEs2panda._UpdateFunctionExpression(global.context, node.peer, passNode(expression)) + ); + } + + readonly scriptFunction: ScriptFunction; +} + +export class ETSParameterExpression extends Expression { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION); + super(peer); + } + + static create(identifier: Identifier, initializer: AstNode | undefined): ETSParameterExpression { + if (initializer !== undefined) { + return new ETSParameterExpression( + global.generatedEs2panda._CreateETSParameterExpression1( + global.context, + passNode(identifier), + passNode(initializer) + ) + ); + } + return new ETSParameterExpression( + global.generatedEs2panda._CreateETSParameterExpression(global.context, passNode(identifier), false) + ); + } + + static update( + node: ETSParameterExpression, + identifier: Identifier, + initializer: AstNode | undefined + ): ETSParameterExpression { + if (initializer !== undefined) { + return new ETSParameterExpression( + global.generatedEs2panda._UpdateETSParameterExpression1( + global.context, + node.peer, + passNode(identifier), + passNode(initializer) + ) + ); + } + return new ETSParameterExpression( + global.generatedEs2panda._UpdateETSParameterExpression( + global.context, + node.peer, + passNode(identifier), + false + ) + ); + } + + get annotations(): AnnotationUsage[] { + return unpackNodeArray(global.es2panda._ETSParameterExpressionAnnotations(global.context, this.peer, nullptr)); + } + + set annotations(newAnnotations: AnnotationUsage[]) { + global.es2panda._ETSParameterExpressionSetAnnotations( + global.context, + this.peer, + passNodeArray(newAnnotations), + newAnnotations.length + ); + } + + get type(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ETSParameterExpressionTypeAnnotation(global.context, this.peer)); + } + + set type(t: AstNode | undefined) { + if (t === undefined) return; + global.generatedEs2panda._ETSParameterExpressionSetTypeAnnotation(global.context, this.peer, t.peer); + } + + get optional(): Boolean { + return global.generatedEs2panda._ETSParameterExpressionIsOptionalConst(global.context, this.peer); + } + + get initializer(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ETSParameterExpressionInitializerConst(global.context, this.peer)); + } + + /** @deprecated */ + setInitializer(initExpr?: Expression): this { + global.generatedEs2panda._ETSParameterExpressionSetInitializer(global.context, this.peer, passNode(initExpr)); + return this; + } + + setOptional(value: boolean): this { + global.generatedEs2panda._ETSParameterExpressionSetOptional(global.context, this.peer, value); + return this; + } + + get identifier(): Identifier { + return unpackNonNullableNode( + global.generatedEs2panda._ETSParameterExpressionIdentConst(global.context, this.peer) + ); + } + + /** @deprecated */ + setIdent(ident?: Identifier): this { + global.generatedEs2panda._ETSParameterExpressionSetIdent(global.context, this.peer, passNode(ident)); + return this; + } +} + +export class IfStatement extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_IF_STATEMENT); + super(peer); + this.test = unpackNonNullableNode(global.generatedEs2panda._IfStatementTest(global.context, this.peer)); + this.consequent = unpackNonNullableNode( + global.generatedEs2panda._IfStatementConsequent(global.context, this.peer) + ); + this.alternate = unpackNode(global.generatedEs2panda._IfStatementAlternate(global.context, this.peer)); + } + + static create(test: AstNode, consequent: AstNode, alternate?: AstNode): IfStatement { + return new IfStatement( + global.generatedEs2panda._CreateIfStatement( + global.context, + passNode(test), + passNode(consequent), + passNode(alternate) + ) + ); + } + + static update(node: IfStatement, test: AstNode, consequent: AstNode, alternate?: AstNode): IfStatement { + return new IfStatement( + global.generatedEs2panda._UpdateIfStatement( + global.context, + node.peer, + passNode(test), + passNode(consequent), + passNode(alternate) + ) + ); + } + + test: AstNode; + consequent: AstNode; + alternate: AstNode | undefined; +} + +export class StructDeclaration extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_STRUCT_DECLARATION); + super(peer); + // TODO: is struct definition the same as struct definition? + this.definition = unpackNonNullableNode( + global.generatedEs2panda._ClassDeclarationDefinition(global.context, this.peer) + ); + } + + static create(definition: ClassDefinition): StructDeclaration { + return new StructDeclaration( + global.generatedEs2panda._CreateETSStructDeclaration(global.context, passNode(definition)) + ); + } + + static update(node: StructDeclaration, definition: ClassDefinition): StructDeclaration { + return new StructDeclaration( + global.generatedEs2panda._UpdateETSStructDeclaration(global.context, node.peer, passNode(definition)) + ); + } + + readonly definition: ClassDefinition; +} + +export class MethodDefinition extends AstNode { + constructor(peer: KPtr, key?: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_METHOD_DEFINITION); + super(peer); + this.kind = global.generatedEs2panda._MethodDefinitionKindConst(global.context, this.peer); + this.scriptFunction = unpackNonNullableNode( + global.generatedEs2panda._MethodDefinitionFunction(global.context, this.peer) + ); + assertValidPeer(this.scriptFunction.peer, Es2pandaAstNodeType.AST_NODE_TYPE_SCRIPT_FUNCTION); + + // Somehow the scriptFunction cannot attach method's key to its ident after checker + if (key) { + assertValidPeer(key, Es2pandaAstNodeType.AST_NODE_TYPE_IDENTIFIER); + const _name = unpackNonNullableNode(key); + this.scriptFunction = this.scriptFunction.setIdent(_name as Identifier); + } + + this.name = unpackNonNullableNode( + global.generatedEs2panda._ScriptFunctionId(global.context, this.scriptFunction.peer) + ); + this.kind = global.generatedEs2panda._MethodDefinitionKindConst(global.context, this.peer); + } + + static create( + kind: Es2pandaMethodDefinitionKind, + key: AstNode, + value: AstNode, + modifiers: KInt, + isComputed: boolean + ): MethodDefinition { + return new MethodDefinition( + global.generatedEs2panda._CreateMethodDefinition( + global.context, + kind, + passNode(key), + passNode(value), + modifiers, + isComputed + ), + key.peer + ); + } + + static update( + node: MethodDefinition, + kind: Es2pandaMethodDefinitionKind, + key: AstNode, + value: AstNode, + modifiers: KInt, + isComputed: boolean + ): MethodDefinition { + return new MethodDefinition( + global.generatedEs2panda._UpdateMethodDefinition( + global.context, + node.peer, + kind, + passNode(key), + passNode(value), + modifiers, + isComputed + ), + key.peer + ); + } + + // TODO: does not work + isConstructor(): boolean { + return global.generatedEs2panda._MethodDefinitionIsConstructorConst(global.context, this.peer); + } + + get overloads(): readonly MethodDefinition[] { + return unpackNodeArray(global.generatedEs2panda._MethodDefinitionOverloadsConst(global.context, this.peer)); + } + + setOverloads(overloads: readonly MethodDefinition[]): this { + global.generatedEs2panda._MethodDefinitionSetOverloads( + global.context, + this.peer, + passNodeArray(overloads), + overloads.length + ); + return this; + } + + readonly kind: Es2pandaMethodDefinitionKind; + readonly scriptFunction: ScriptFunction; + readonly name: Identifier; +} + +export class VariableDeclaration extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATION); + super(peer); + this.declarationKind = global.generatedEs2panda._VariableDeclarationKindConst(global.context, this.peer); + this.declarators = unpackNodeArray( + global.generatedEs2panda._VariableDeclarationDeclaratorsConst(global.context, this.peer) + ); + } + + static create( + modifiers: KInt, + kind: Es2pandaVariableDeclarationKind, + declarators: readonly VariableDeclarator[] + ): VariableDeclaration { + const peer = global.generatedEs2panda._CreateVariableDeclaration( + global.context, + kind, + passNodeArray(declarators), + declarators.length + ); + global.generatedEs2panda._AstNodeClearModifier(global.context, peer, allFlags); + global.generatedEs2panda._AstNodeAddModifier(global.context, peer, modifiers); + return new VariableDeclaration(peer); + } + + static update( + node: VariableDeclaration, + modifiers: KInt, + kind: Es2pandaVariableDeclarationKind, + declarators: readonly VariableDeclarator[] + ): VariableDeclaration { + const peer = global.generatedEs2panda._UpdateVariableDeclaration( + global.context, + node.peer, + kind, + passNodeArray(declarators), + declarators.length + ); + global.generatedEs2panda._AstNodeClearModifier(global.context, peer, allFlags); + global.generatedEs2panda._AstNodeAddModifier(global.context, peer, modifiers); + return new VariableDeclaration(peer); + } + + readonly declarationKind: Es2pandaVariableDeclarationKind; + readonly declarators: readonly VariableDeclarator[]; +} + +export class VariableDeclarator extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATOR); + super(peer); + this.name = unpackNonNullableNode(global.generatedEs2panda._VariableDeclaratorId(global.context, this.peer)); + } + + static create( + flag: Es2pandaVariableDeclaratorFlag, + name: Identifier, + initializer: AstNode | undefined + ): VariableDeclarator { + const peer = global.generatedEs2panda._CreateVariableDeclarator(global.context, flag, passNode(name)); + if (initializer !== undefined) { + global.generatedEs2panda._VariableDeclaratorSetInit(global.context, peer, initializer.peer); + } + return new VariableDeclarator(peer); + } + + static update( + node: VariableDeclarator, + flag: Es2pandaVariableDeclaratorFlag, + name: Identifier, + initializer: AstNode | undefined + ): VariableDeclarator { + const peer = global.generatedEs2panda._UpdateVariableDeclarator( + global.context, + node.peer, + flag, + passNode(name) + ); + if (initializer !== undefined) { + global.generatedEs2panda._VariableDeclaratorSetInit(global.context, peer, initializer.peer); + } + return new VariableDeclarator(peer); + } + + get initializer(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._VariableDeclaratorInit(global.context, this.peer)); + } + + /** @deprecated */ + setInit(init?: Expression): this { + global.generatedEs2panda._VariableDeclaratorSetInit(global.context, this.peer, passNode(init)); + return this; + } + + get flag(): Es2pandaVariableDeclaratorFlag { + return global.generatedEs2panda._VariableDeclaratorFlag(global.context, this.peer); + } + + readonly name: Identifier; +} + +export class SuperExpression extends AstNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_SUPER_EXPRESSION); + super(peer); + this.id = unpackNode(global.generatedEs2panda._TSInterfaceDeclarationId(global.context, this.peer)); + } + + static create(): SuperExpression { + return new SuperExpression(global.generatedEs2panda._CreateSuperExpression(global.context)); + } + + readonly id?: Identifier; +} + +export class ETSStringLiteralType extends TypeNode { + constructor(peer: KPtr) { + assertValidPeer(peer, Es2pandaAstNodeType.AST_NODE_TYPE_ETS_STRING_LITERAL_TYPE); + super(peer); + } + + static create(str: string): ETSStringLiteralType { + return new ETSStringLiteralType(global.es2panda._CreateETSStringLiteralType(global.context, passString(str))); + } +} + +const pairs: [Es2pandaAstNodeType, { new (peer: KNativePointer): AstNode }][] = [ + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_MODULE, EtsScript], + [Es2pandaAstNodeType.AST_NODE_TYPE_IDENTIFIER, Identifier], + [Es2pandaAstNodeType.AST_NODE_TYPE_NUMBER_LITERAL, NumberLiteral], + [Es2pandaAstNodeType.AST_NODE_TYPE_EXPRESSION_STATEMENT, ExpressionStatement], + [Es2pandaAstNodeType.AST_NODE_TYPE_FUNCTION_DECLARATION, FunctionDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_SCRIPT_FUNCTION, ScriptFunction], + [Es2pandaAstNodeType.AST_NODE_TYPE_BLOCK_STATEMENT, BlockStatement], + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION, ETSParameterExpression], + [Es2pandaAstNodeType.AST_NODE_TYPE_TS_TYPE_PARAMETER_DECLARATION, TSTypeParameterDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_CALL_EXPRESSION, CallExpression], + [Es2pandaAstNodeType.AST_NODE_TYPE_MEMBER_EXPRESSION, MemberExpression], + [Es2pandaAstNodeType.AST_NODE_TYPE_IF_STATEMENT, IfStatement], + [Es2pandaAstNodeType.AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION, ArrowFunctionExpression], + [Es2pandaAstNodeType.AST_NODE_TYPE_STRUCT_DECLARATION, StructDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_METHOD_DEFINITION, MethodDefinition], + [Es2pandaAstNodeType.AST_NODE_TYPE_ASSIGNMENT_EXPRESSION, AssignmentExpression], + [Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATION, VariableDeclaration], + [Es2pandaAstNodeType.AST_NODE_TYPE_VARIABLE_DECLARATOR, VariableDeclarator], + [Es2pandaAstNodeType.AST_NODE_TYPE_FUNCTION_EXPRESSION, FunctionExpression], + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_TYPE_REFERENCE, ETSTypeReference], + [Es2pandaAstNodeType.AST_NODE_TYPE_ETS_TYPE_REFERENCE_PART, ETSTypeReferencePart], + [Es2pandaAstNodeType.AST_NODE_TYPE_OBJECT_EXPRESSION, ObjectExpression], +]; +pairs.forEach(([nodeType, astNode]) => nodeByType.set(nodeType, astNode)); diff --git a/koala-wrapper/src/arkts-api/utilities/nativePtrDecoder.ts b/koala-wrapper/src/arkts-api/utilities/nativePtrDecoder.ts new file mode 100644 index 000000000..809b13e72 --- /dev/null +++ b/koala-wrapper/src/arkts-api/utilities/nativePtrDecoder.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022-2025 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 { int32 } from "@koalaui/common" +import { + Access, + ArrayDecoder, + CallbackRegistry, + NativeStringBase, + nullptr, + pointer, + providePlatformDefinedData, + withByteArray +} from "@koalaui/interop" +import { global } from "../static/global" + +class NativeString extends NativeStringBase { + constructor(ptr: pointer) { + super(ptr) + } + protected bytesLength(): int32 { + return global.interop._StringLength(this.ptr) + } + protected getData(data: Uint8Array): void { + withByteArray(data, Access.WRITE, (dataPtr: pointer) => { + global.interop._StringData(this.ptr, dataPtr, data.length) + }) + } + close(): void { + global.interop._InvokeFinalizer(this.ptr, global.interop._GetStringFinalizer()) + this.ptr = nullptr + } +} + +providePlatformDefinedData({ + nativeString(ptr: pointer): NativeStringBase { + return new NativeString(ptr) + }, + nativeStringArrayDecoder(): ArrayDecoder { + throw new Error("Not yet implemented") + }, + callbackRegistry(): CallbackRegistry | undefined { + return undefined + } +}) + +export class NativePtrDecoder extends ArrayDecoder { + getArraySize(blob: pointer) { + return global.interop._GetPtrVectorSize(blob) + } + disposeArray(blob: pointer): void { + // TODO + } + getArrayElement(blob: pointer, index: int32): pointer { + return global.interop._GetPtrVectorElement(blob, index) + } +} \ No newline at end of file diff --git a/koala-wrapper/src/arkts-api/utilities/performance.ts b/koala-wrapper/src/arkts-api/utilities/performance.ts new file mode 100644 index 000000000..bafe9df5d --- /dev/null +++ b/koala-wrapper/src/arkts-api/utilities/performance.ts @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +interface Event { + name: string, + startTime: number, + endTime?: number, + parentEvent?: string, + duration?: number +} + +function formatTime(ms: number): string { + const milliseconds = Math.floor(ms % 1000); + const seconds = Math.floor((ms / 1000) % 60); + const minutes = Math.floor((ms / (1000 * 60)) % 60); + const hours = Math.floor(ms / (1000 * 60 * 60)); + + return `${pad(hours, 2)}:${pad(minutes, 2)}:${pad(seconds, 2)}:${pad(milliseconds, 3)}`; +} + +function pad(value: number, length: number): string { + return value.toString().padStart(length, '0'); +} + +export class Performance { + private static instance: Performance; + private events: Map; + private scopes: string[]; + private shouldSkip: boolean; + private totalDuration: number; + + private constructor() { + this.events = new Map(); + this.scopes = []; + this.shouldSkip = true; + this.totalDuration = 0; + } + + public static getInstance(): Performance { + if (!this.instance) { + this.instance = new Performance(); + } + return this.instance; + } + + skip(shouldSkip: boolean = true): void { + this.shouldSkip = shouldSkip; + } + + createEvent(name: string): Event { + if (this.shouldSkip) return { name: '', startTime: 0 }; + const startTime: number = performance.now(); + const newEvent: Event = { name, startTime }; + this.events.set(name, newEvent); + this.scopes.push(name); + return newEvent; + } + + stopEvent(name: string, shouldLog: boolean = false): Event { + if (this.shouldSkip) return { name: '', startTime: 0 }; + if (!this.events.has(name) || this.scopes.length === 0) { + throw new Error(`Event ${name} is not created.`); + } + if (this.scopes[this.scopes.length - 1] !== name) { + console.warn(`[PERFORMANCE WARNING] Event ${name} early exit.`); + } + this.scopes.pop(); + + const event: Event = this.events.get(name)!; + const endTime: number = performance.now(); + const parentEvent: string = this.scopes[this.scopes.length - 1]; + const duration: number = endTime - event.startTime; + this.totalDuration += duration; + + if (shouldLog) { + console.log( + `[PERFORMANCE] name: ${event.name}, parent: ${parentEvent}, duration: ${formatTime(duration)}, total: ${formatTime(this.totalDuration)}` + ); + } + + return { ...event, endTime, parentEvent, duration }; + } + + stopLastEvent(shouldLog: boolean = false): Event { + if (this.shouldSkip) return { name: '', startTime: 0 }; + if (this.scopes.length === 0) { + throw new Error("No last event"); + } + const name: string = this.scopes.pop()!; + if (!this.events.has(name)) { + throw new Error(`Event ${name} is not created.`); + } + + const event: Event = this.events.get(name)!; + const endTime: number = performance.now(); + const parentEvent: string = this.scopes[this.scopes.length - 1]; + const duration: number = endTime - event.startTime; + this.totalDuration += duration; + + if (shouldLog) { + console.log( + `[PERFORMANCE] name: ${event.name}, parent: ${parentEvent}, duration: ${formatTime(duration)}, total: ${formatTime(this.totalDuration)}` + ); + } + + return { ...event, endTime, parentEvent, duration }; + } + + clearAllEvents(shouldLog: boolean = false): void { + if (this.shouldSkip) return; + for (let i = 0; i < this.scopes.length; i ++) { + this.stopLastEvent(shouldLog); + } + this.events = new Map(); + } + + clearTotalDuration(): void { + this.totalDuration = 0; + } +} \ No newline at end of file diff --git a/koala-wrapper/src/arkts-api/utilities/private.ts b/koala-wrapper/src/arkts-api/utilities/private.ts new file mode 100644 index 000000000..30db3e472 --- /dev/null +++ b/koala-wrapper/src/arkts-api/utilities/private.ts @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2022-2025 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 { global } from '../static/global'; +import { isNumber, throwError } from '../../utils'; +import { + KInt, + KNativePointer as KPtr, + KNativePointer, + nullptr, + withString, + withStringArray, + withStringResult, +} from '@koalaui/interop'; +import { NativePtrDecoder } from './nativePtrDecoder'; +import { Es2pandaModifierFlags, Es2pandaScriptFunctionFlags } from '../../generated/Es2pandaEnums'; +import { classByPeer } from '../class-by-peer'; +import type { AstNode } from '../peers/AstNode'; +import { ArktsObject } from '../peers/ArktsObject'; +import { Es2pandaAstNodeType } from '../../Es2pandaEnums'; + +export const arrayOfNullptr = new BigUint64Array([nullptr]); + +export const allFlags = Object.values(Es2pandaModifierFlags) + .filter(isNumber) + .reduce((prev, next) => prev | next, 0); + +export function assertValidPeer(peer: KPtr, expectedKind: Es2pandaAstNodeType): void { + if (peer === nullptr) { + throwError(`invalid peer`); + } + const peerType = global.generatedEs2panda._AstNodeTypeConst(global.context, peer); + if (peerType !== expectedKind) { + throwError(`expected: ${Es2pandaAstNodeType[expectedKind]}, got: ${Es2pandaAstNodeType[peerType]}`); + } +} + +export function acceptNativeObjectArrayResult( + arrayObject: KNativePointer, + factory: (instance: KNativePointer) => T +): T[] { + return new NativePtrDecoder().decode(arrayObject).map(factory); +} + +export function unpackNonNullableNode(peer: KNativePointer): T { + if (peer === nullptr) { + throwError('peer is NULLPTR (maybe you should use unpackNode)'); + } + return classByPeer(peer) as T; +} + +export function unpackNode(peer: KNativePointer): T | undefined { + if (peer === nullptr) { + return undefined; + } + return classByPeer(peer) as T; +} + +export function passNode(node: ArktsObject | undefined): KNativePointer { + return node?.peer ?? nullptr; +} + +// meaning unpackNonNullableNodeArray +export function unpackNodeArray(nodesPtr: KNativePointer): T[] { + if (nodesPtr === nullptr) { + throwError('nodesPtr is NULLPTR (maybe you should use unpackNodeArray)'); + } + return new NativePtrDecoder().decode(nodesPtr).map((peer: KNativePointer) => unpackNonNullableNode(peer)); +} + +export function passNodeArray(nodes: readonly AstNode[] | undefined): BigUint64Array { + return new BigUint64Array(nodes?.map((node) => BigInt(node.peer)) ?? []); +} + +export function unpackNonNullableObject( + Type: { new (peer: KNativePointer): T }, + peer: KNativePointer +): T { + if (peer === nullptr) { + throwError('peer is NULLPTR (maybe you should use unpackObject)'); + } + return new Type(peer); +} + +export function unpackObject( + Type: { new (peer: KNativePointer): T }, + peer: KNativePointer +): T | undefined { + if (peer === nullptr) { + return undefined; + } + return new Type(peer); +} + +export function unpackString(peer: KNativePointer): string { + return withStringResult(peer) ?? throwError(`failed to unpack (peer shouldn't be NULLPTR)`); +} + +export function passString(str: string | undefined): string { + if (str === undefined) { + return ''; + } + return withString(str, (it: string) => it); +} + +export function passStringArray(strings: readonly string[]): string[] { + return withStringArray(strings, (it: string[]) => it); +} + +export function passNodeWithNewModifiers(node: T, modifiers: KInt): T { + return (unpackNonNullableNode(node.peer) as T).updateModifiers(modifiers); +} + +export function scriptFunctionHasBody(peer: KNativePointer): boolean { + const flags = global.generatedEs2panda._ScriptFunctionFlagsConst(global.context, peer); + return ( + (flags & Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_EXTERNAL) === 0 && + (flags & Es2pandaScriptFunctionFlags.SCRIPT_FUNCTION_FLAGS_EXTERNAL_OVERLOAD) === 0 + ); +} + +// TODO: remove this +// TODO: update scopes and other data +export function updatePeerByNode(peer: KNativePointer, original: T | undefined): KNativePointer { + if (peer === nullptr) { + throwError('updatePeerByNode called on NULLPTR'); + } + if (original === undefined) { + return peer; + } + global.generatedEs2panda._AstNodeSetOriginalNode(global.context, peer, original.peer); + global.generatedEs2panda._AstNodeSetParent( + global.context, + peer, + global.generatedEs2panda._AstNodeParent(global.context, original.peer) + ); + global.es2panda._AstNodeUpdateChildren(global.context, peer); + global.generatedEs2panda._AstNodeClearModifier(global.context, peer, allFlags); + global.generatedEs2panda._AstNodeAddModifier(global.context, peer, original.modifiers); + global.es2panda._AstNodeUpdateChildren(global.context, peer); + return peer; +} + +// TODO: update scopes and other data +export function updateNodeByNode(node: T, original: AstNode): T { + if (original.peer === nullptr) { + throwError('update called on NULLPTR'); + } + global.generatedEs2panda._AstNodeSetOriginalNode(global.context, node.peer, original.peer); + global.generatedEs2panda._AstNodeSetParent( + global.context, + node.peer, + global.generatedEs2panda._AstNodeParent(global.context, original.peer) + ); + global.es2panda._AstNodeUpdateChildren(global.context, node.peer); + return node; +} + +export function nodeType(node: AstNode): Es2pandaAstNodeType { + return global.generatedEs2panda._AstNodeTypeConst(global.context, passNode(node)); +} + +/** + * @deprecated + */ +export function compose( + create: (...args: ARGS) => T, + update: (node: T, original: T) => T = updateNodeByNode +): (node: T, ...args: ARGS) => T { + return (node: T, ...args: ARGS) => update(create(...args), node); +} + +export function updateThenAttach( + update: (original: T, ...args: ARGS) => T, + ...attachFuncs: ((node: T, original: T) => T)[] +): (node: T, ...args: ARGS) => T { + return (node: T, ...args: ARGS) => { + let _node: T = update(node, ...args); + attachFuncs.forEach((attach) => { + _node = attach(_node, node); + }); + return _node; + }; +} + +export function attachModifiers(node: T, original: T): T { + node.modifiers = original.modifiers; + return node; +} diff --git a/koala-wrapper/src/arkts-api/utilities/public.ts b/koala-wrapper/src/arkts-api/utilities/public.ts new file mode 100644 index 000000000..45888cd18 --- /dev/null +++ b/koala-wrapper/src/arkts-api/utilities/public.ts @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2022-2025 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 { global } from "../static/global" +import { isNumber, throwError, getEnumName } from "../../utils" +import { KNativePointer, KInt, nullptr, withStringResult } from "@koalaui/interop" +import { passNode, passString, unpackNodeArray, unpackNonNullableNode } from "./private" +import { isFunctionDeclaration, isMemberExpression } from "../factory/nodeTests" +import { Es2pandaContextState, Es2pandaModifierFlags } from "../../generated/Es2pandaEnums" +import type { AstNode } from "../peers/AstNode" +import { ClassDefinition, ClassProperty, ETSImportDeclaration, isClassDefinition, isScriptFunction, type AnnotationUsage } from "../../generated" +import { Program } from "../peers/Program" +import { clearNodeCache } from "../class-by-peer" + +export function proceedToState(state: Es2pandaContextState, forceDtsEmit = false): void { + console.log("[TS WRAPPER] PROCEED TO STATE: ", getEnumName(Es2pandaContextState, state)); + if (state <= global.es2panda._ContextState(global.context)) { + console.log("[TS WRAPPER] PROCEED TO STATE: SKIPPING"); + return + } + clearNodeCache() + try { + global.es2panda._ProceedToState(global.context, state) + if (global.es2panda._ContextState(global.context) === Es2pandaContextState.ES2PANDA_STATE_ERROR && !forceDtsEmit) { + const errorMessage = withStringResult(global.es2panda._ContextErrorMessage(global.context)) + if (errorMessage === undefined) { + throwError(`Could not get ContextErrorMessage`) + } + throwError( + [ + `Failed to proceed to ${Es2pandaContextState[state]}`, + errorMessage + ] + .join(`\n`) + ) + } + } catch (e) { + global.es2panda._DestroyContext(global.context) + throw e + } +} + +export function startChecker(): boolean { + return global.es2panda._CheckerStartChecker(global.context) +} + +export function recheckSubtree(node: AstNode): void { + global.es2panda._AstNodeRecheck(global.context, node.peer) +} + +export function rebindSubtree(node: AstNode): void { + global.es2panda._AstNodeRebind(global.context, node.peer) +} + +export function getDecl(node: AstNode): AstNode | undefined { + if (isMemberExpression(node)) { + return getDecl(node.property) + } + const decl = global.es2panda._DeclarationFromIdentifier(global.context, passNode(node)) + if (decl === nullptr) { + return undefined + } + return unpackNonNullableNode(decl) +} + +export function getAnnotations(node: AstNode): readonly AnnotationUsage[] { + if (!isFunctionDeclaration(node) && !isScriptFunction(node) && !isClassDefinition(node)) { + throwError('for now annotations allowed only for: functionDeclaration, scriptFunction, classDefinition') + } + return unpackNodeArray(global.es2panda._AnnotationAllowedAnnotations(global.context, node.peer, nullptr)) +} + +export function getOriginalNode(node: AstNode): AstNode { + if (node === undefined) { + // TODO: fix this + throwError('there is no arkts pair of ts node (unable to getOriginalNode)') + } + if (node.originalPeer === nullptr) { + return node + } + return unpackNonNullableNode(node.originalPeer) +} + +export function getFileName(): string { + return global.filePath +} + +export function classDefinitionSetFromStructModifier(node: ClassDefinition): void { + global.es2panda._ClassDefinitionSetFromStructModifier(global.context, node.peer); +} + +export function classDefinitionIsFromStructConst(node: ClassDefinition): boolean { + return global.es2panda._ClassDefinitionIsFromStructConst(global.context, node.peer); +} + +// TODO: It seems like Definition overrides AstNode modifiers +// with it's own modifiers which is completely unrelated set of flags. +// Use this function if you need +// the language level modifiers: public, declare, export, etc. +export function classDefinitionFlags(node: ClassDefinition): Es2pandaModifierFlags { + return global.generatedEs2panda._AstNodeModifiers(global.context, node.peer) +} + +// TODO: Import statements should be inserted to the statements +export function importDeclarationInsert(node: ETSImportDeclaration, program: Program): void { + global.es2panda._InsertETSImportDeclarationAndParse(global.context, program.peer, node.peer) +} + +export function hasModifierFlag(node: AstNode, flag: Es2pandaModifierFlags): boolean { + if (!node) return false; + + let modifiers; + if (isClassDefinition(node)) { + modifiers = classDefinitionFlags(node); + } else { + modifiers = node.modifiers + } + return (modifiers & flag) === flag; +} + +// TODO: ClassProperty's optional flag is set by AstNode's modifiers flags. +export function classPropertySetOptional(node: ClassProperty, value: boolean): ClassProperty { + if (value) { + node.modifiers |= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL; + } else { + node.modifiers &= Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL; + } + return node; +} + +export function modifiersToString(modifiers: Es2pandaModifierFlags): string { + return Object.values(Es2pandaModifierFlags) + .filter(isNumber) + .map(it => { + console.log(it.valueOf(), Es2pandaModifierFlags[it], modifiers.valueOf() & it) + return ((modifiers.valueOf() & it) === it) ? Es2pandaModifierFlags[it] : "" + }).join(" ") +} +export function destroyConfig(config: KNativePointer): void { + global.es2panda._DestroyConfig(config); + global.resetConfig(); +} + +export function setAllParents(ast: AstNode) { + global.es2panda._AstNodeUpdateAll(global.context, ast.peer) +} + +export function generateTsDeclarationsFromContext(outputDeclEts: string, outputEts: string, exportAll: boolean): KInt { + return global.es2panda._GenerateTsDeclarationsFromContext(global.context, passString(outputDeclEts), passString(outputEts), exportAll) +} \ No newline at end of file diff --git a/koala-wrapper/src/arkts-api/visitor.ts b/koala-wrapper/src/arkts-api/visitor.ts new file mode 100644 index 000000000..2d62b5a42 --- /dev/null +++ b/koala-wrapper/src/arkts-api/visitor.ts @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2022-2025 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 { global } from "./static/global" +import { factory } from "./factory/nodeFactory" +import { + Es2pandaClassDefinitionModifiers, + Es2pandaImportKinds, + Es2pandaModifierFlags, + Es2pandaVariableDeclaratorFlag +} from "../generated/Es2pandaEnums" +import { AstNode } from "./peers/AstNode" +import { + isBlockStatement, + isConditionalExpression, + isTSInterfaceBody, + isTSInterfaceDeclaration, + isClassDeclaration, + isClassDefinition, + isTSAsExpression, + isETSImportDeclaration, + ImportSource, + isScriptFunction, + FunctionSignature, + Property, + isClassProperty, + isImportDeclaration +} from "../generated" +import { + isEtsScript, + isCallExpression, + isFunctionDeclaration, + isExpressionStatement, + isStructDeclaration, + isMethodDefinition, + // isScriptFunction, + isMemberExpression, + isIfStatement, + isVariableDeclaration, + isVariableDeclarator, + isArrowFunctionExpression +} from "./factory/nodeTests" +import { + classDefinitionFlags, + hasModifierFlag, + classPropertySetOptional + } from "./utilities/public" + +type Visitor = (node: AstNode) => AstNode + +export interface StructVariableMetadata { + name: string, + properties: string[], + modifiers: Es2pandaModifierFlags, + hasStateManagementType?: boolean +} + +export class StructInfo { + metadata: Record = {}; + initializeBody: AstNode[] = []; + updateBody: AstNode[] = []; + isReusable: boolean = false; + toRecordBody: Property[] = []; +} + +export class GlobalInfo { + private _structCollection: Set; + private static instance: GlobalInfo; + private _structMap: Map; + + private constructor() { + this._structCollection = new Set(); + this._structMap = new Map(); + } + + public static getInfoInstance(): GlobalInfo { + if (!this.instance) { + this.instance = new GlobalInfo(); + } + return this.instance; + } + + public add(str: string): void { + this._structCollection.add(str); + } + + public getStructCollection(): Set { + return this._structCollection; + } + + public getStructInfo(structName: string): StructInfo { + const structInfo = this._structMap.get(structName); + if (!structInfo) { + return new StructInfo(); + } + return structInfo; + } + + public setStructInfo(structName: string, info: StructInfo): void { + this._structMap.set(structName, info); + } + + public reset(): void { + this._structMap.clear(); + this._structCollection.clear(); + } +} + +// TODO: rethink (remove as) +function nodeVisitor(node: T, visitor: Visitor): T { + if (node === undefined) { + return node + } + return visitor(node) as T +} + +// TODO: rethink (remove as) +function nodesVisitor(nodes: TIn, visitor: Visitor): T[] | TIn { + if (nodes === undefined) { + return nodes + } + return nodes.map(node => visitor(node) as T) +} + +// TODO: apply this to all nodes that does not require updating +function visitWithoutUpdate( + node: T, + visitor: Visitor +): T { + if (isImportDeclaration(node)) { + nodesVisitor(node.specifiers, visitor); + } + return node; +} + +export function visitEachChild( + node: AstNode, + visitor: Visitor +): AstNode { + if (isEtsScript(node)) { + return factory.updateEtsScript( + node, + nodesVisitor(node.statements, visitor) + ); + } + if (isCallExpression(node)) { + const call = factory.updateCallExpression( + node, + nodeVisitor(node.expression, visitor), + nodesVisitor(node.typeArguments, visitor), + nodesVisitor(node.arguments, visitor) + ); + if (!!node.trailingBlock) { + call.setTralingBlock(nodeVisitor(node.trailingBlock, visitor)); + } + return call; + } + if (isFunctionDeclaration(node)) { + return factory.updateFunctionDeclaration( + node, + nodeVisitor(node.scriptFunction, visitor), + node.isAnon, + node.annotations, + ); + } + if (isBlockStatement(node)) { + return factory.updateBlock( + node, + nodesVisitor(node.statements, visitor), + ); + } + if (isExpressionStatement(node)) { + return factory.updateExpressionStatement( + node, + nodeVisitor(node.expression, visitor) + ); + } + if (isClassDeclaration(node)) { + return factory.updateClassDeclaration( + node, + nodeVisitor(node.definition, visitor) + ); + } + if (isStructDeclaration(node)) { + return factory.updateStructDeclaration( + node, + nodeVisitor(node.definition, visitor) + ); + } + if (isClassDefinition(node)) { + // TODO: fix + return factory.updateClassDefinition( + node, + node.ident, + node.typeParams, + node.superTypeParams, + node.implements, + undefined, + node.super, + nodesVisitor(node.body, visitor), + node.modifiers, + classDefinitionFlags(node) + ); + } + if (isMethodDefinition(node)) { + // TODO: fix + return factory.updateMethodDefinition( + node, + node.kind, + node.name, + factory.createFunctionExpression( + // TODO: maybe fix + nodeVisitor(node.scriptFunction, visitor) + ), + node.modifiers, + false + ); + } + if (isScriptFunction(node)) { + return factory.updateScriptFunction( + node, + nodeVisitor(node.body, visitor), + FunctionSignature.createFunctionSignature( + nodeVisitor(node.typeParams, visitor), + nodesVisitor(node.params, visitor), + nodeVisitor(node.returnTypeAnnotation, visitor), + node.hasReceiver + ), + node.flags, + node.modifiers + ); + } + if (isMemberExpression(node)) { + return factory.updateMemberExpression( + node, + nodeVisitor(node.object, visitor), + nodeVisitor(node.property, visitor), + node.kind, + node.computed, + node.optional + ); + } + if (isTSInterfaceDeclaration(node)) { + return factory.updateInterfaceDeclaration( + node, + nodesVisitor(node.extends, visitor), + nodeVisitor(node.id, visitor), + nodeVisitor(node.typeParams, visitor), + nodeVisitor(node.body, visitor), + node.isStatic, + // TODO: how do I get it? + true + ); + } + if (isTSInterfaceBody(node)) { + return factory.updateInterfaceBody( + node, + nodesVisitor(node.body, visitor) + ); + } + if (isIfStatement(node)) { + return factory.updateIfStatement( + node, + nodeVisitor(node.test, visitor), + nodeVisitor(node.consequent, visitor), + nodeVisitor(node.alternate, visitor), + ); + } + if (isConditionalExpression(node)) { + return factory.updateConditionalExpression( + node, + nodeVisitor(node.test, visitor), + nodeVisitor(node.consequent, visitor), + nodeVisitor(node.alternate, visitor), + ); + } + if (isVariableDeclaration(node)) { + return factory.updateVariableDeclaration( + node, + 0, + node.declarationKind, + nodesVisitor(node.declarators, visitor), + ); + } + if (isVariableDeclarator(node)) { + return factory.updateVariableDeclarator( + node, + global.generatedEs2panda._VariableDeclaratorFlag(global.context, node.peer), + nodeVisitor(node.name, visitor), + nodeVisitor(node.initializer, visitor), + ); + } + if (isArrowFunctionExpression(node)) { + return factory.updateArrowFunction( + node, + nodeVisitor(node.scriptFunction, visitor), + ); + } + if (isTSAsExpression(node)) { + return factory.updateTSAsExpression( + node, + nodeVisitor(node.expr, visitor), + nodeVisitor(node.typeAnnotation, visitor), + node.isConst + ); + } + if (isClassProperty(node)) { + return factory.updateClassProperty( + node, + node.key, + nodeVisitor(node.value, visitor), + node.typeAnnotation, + node.modifiers, + node.isComputed + ); + } + if (isClassProperty(node)) { + const _node = factory.updateClassProperty( + node, + node.key, + nodeVisitor(node.value, visitor), + node.typeAnnotation, + node.modifiers, + node.isComputed + ); + if (hasModifierFlag(node, Es2pandaModifierFlags.MODIFIER_FLAGS_OPTIONAL)) { + classPropertySetOptional(_node, true); + } + _node.setAnnotations(node.annotations); + return _node; + } + // TODO + return visitWithoutUpdate(node, visitor); +} diff --git a/koala-wrapper/src/es2panda.ts b/koala-wrapper/src/es2panda.ts new file mode 100644 index 000000000..9e0e14f4e --- /dev/null +++ b/koala-wrapper/src/es2panda.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2025 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 * as fs from "node:fs" +import * as path from "node:path" +import { global } from "./arkts-api/static/global" +import { isNumber, throwError, withWarning, filterSource } from "./utils" +import { Es2pandaContextState } from "./generated/Es2pandaEnums" +import { AstNode, Config, Context, EtsScript, proceedToState } from "./arkts-api" + +import * as arkts from "./arkts-api" +export {arkts, global as arktsGlobal} diff --git a/koala-wrapper/src/generated/Es2pandaEnums.ts b/koala-wrapper/src/generated/Es2pandaEnums.ts new file mode 100644 index 000000000..cc682d5a3 --- /dev/null +++ b/koala-wrapper/src/generated/Es2pandaEnums.ts @@ -0,0 +1,1266 @@ +/* + * Copyright (c) 2022-2025 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. + */ + +// RENAMED: es2panda_ContextState -> Es2pandaContextState +export enum Es2pandaContextState { + ES2PANDA_STATE_NEW = 0, + ES2PANDA_STATE_PARSED = 1, + ES2PANDA_STATE_SCOPE_INITED = 2, + ES2PANDA_STATE_BOUND = 3, + ES2PANDA_STATE_CHECKED = 4, + ES2PANDA_STATE_LOWERED = 5, + ES2PANDA_STATE_ASM_GENERATED = 6, + ES2PANDA_STATE_BIN_GENERATED = 7, + ES2PANDA_STATE_ERROR = 8 +} +// export enum Es2pandaAstNodeType { +// AST_NODE_TYPE_ARROW_FUNCTION_EXPRESSION = 0, +// AST_NODE_TYPE_ANNOTATION_DECLARATION = 1, +// AST_NODE_TYPE_ANNOTATION_USAGE = 2, +// AST_NODE_TYPE_ASSERT_STATEMENT = 3, +// AST_NODE_TYPE_AWAIT_EXPRESSION = 4, +// AST_NODE_TYPE_BIGINT_LITERAL = 5, +// AST_NODE_TYPE_BINARY_EXPRESSION = 6, +// AST_NODE_TYPE_BLOCK_STATEMENT = 7, +// AST_NODE_TYPE_BOOLEAN_LITERAL = 8, +// AST_NODE_TYPE_BREAK_STATEMENT = 9, +// AST_NODE_TYPE_CALL_EXPRESSION = 10, +// AST_NODE_TYPE_CATCH_CLAUSE = 11, +// AST_NODE_TYPE_CHAIN_EXPRESSION = 12, +// AST_NODE_TYPE_CHAR_LITERAL = 13, +// AST_NODE_TYPE_CLASS_DEFINITION = 14, +// AST_NODE_TYPE_CLASS_DECLARATION = 15, +// AST_NODE_TYPE_CLASS_EXPRESSION = 16, +// AST_NODE_TYPE_CLASS_PROPERTY = 17, +// AST_NODE_TYPE_CLASS_STATIC_BLOCK = 18, +// AST_NODE_TYPE_CONDITIONAL_EXPRESSION = 19, +// AST_NODE_TYPE_CONTINUE_STATEMENT = 20, +// AST_NODE_TYPE_DEBUGGER_STATEMENT = 21, +// AST_NODE_TYPE_DECORATOR = 22, +// AST_NODE_TYPE_DIRECT_EVAL = 23, +// AST_NODE_TYPE_DO_WHILE_STATEMENT = 24, +// AST_NODE_TYPE_EMPTY_STATEMENT = 25, +// AST_NODE_TYPE_EXPORT_ALL_DECLARATION = 26, +// AST_NODE_TYPE_EXPORT_DEFAULT_DECLARATION = 27, +// AST_NODE_TYPE_EXPORT_NAMED_DECLARATION = 28, +// AST_NODE_TYPE_EXPORT_SPECIFIER = 29, +// AST_NODE_TYPE_EXPRESSION_STATEMENT = 30, +// AST_NODE_TYPE_FOR_IN_STATEMENT = 31, +// AST_NODE_TYPE_FOR_OF_STATEMENT = 32, +// AST_NODE_TYPE_FOR_UPDATE_STATEMENT = 33, +// AST_NODE_TYPE_FUNCTION_DECLARATION = 34, +// AST_NODE_TYPE_FUNCTION_EXPRESSION = 35, +// AST_NODE_TYPE_IDENTIFIER = 36, +// AST_NODE_TYPE_DUMMYNODE = 37, +// AST_NODE_TYPE_IF_STATEMENT = 38, +// AST_NODE_TYPE_IMPORT_DECLARATION = 39, +// AST_NODE_TYPE_IMPORT_EXPRESSION = 40, +// AST_NODE_TYPE_IMPORT_DEFAULT_SPECIFIER = 41, +// AST_NODE_TYPE_IMPORT_NAMESPACE_SPECIFIER = 42, +// AST_NODE_TYPE_IMPORT_SPECIFIER = 43, +// AST_NODE_TYPE_LABELLED_STATEMENT = 44, +// AST_NODE_TYPE_MEMBER_EXPRESSION = 45, +// AST_NODE_TYPE_META_PROPERTY_EXPRESSION = 46, +// AST_NODE_TYPE_METHOD_DEFINITION = 47, +// AST_NODE_TYPE_NAMED_TYPE = 48, +// AST_NODE_TYPE_NAMESPACE_DECLARATION = 49, +// AST_NODE_TYPE_NAMESPACE_DEFINITION = 50, +// AST_NODE_TYPE_NEW_EXPRESSION = 51, +// AST_NODE_TYPE_NULL_LITERAL = 52, +// AST_NODE_TYPE_UNDEFINED_LITERAL = 53, +// AST_NODE_TYPE_NUMBER_LITERAL = 54, +// AST_NODE_TYPE_OMITTED_EXPRESSION = 55, +// AST_NODE_TYPE_PREFIX_ASSERTION_EXPRESSION = 56, +// AST_NODE_TYPE_PROPERTY = 57, +// AST_NODE_TYPE_REGEXP_LITERAL = 58, +// AST_NODE_TYPE_REEXPORT_STATEMENT = 59, +// AST_NODE_TYPE_RETURN_STATEMENT = 60, +// AST_NODE_TYPE_SCRIPT_FUNCTION = 61, +// AST_NODE_TYPE_SEQUENCE_EXPRESSION = 62, +// AST_NODE_TYPE_STRING_LITERAL = 63, +// AST_NODE_TYPE_ETS_NULL_TYPE = 64, +// AST_NODE_TYPE_ETS_UNDEFINED_TYPE = 65, +// AST_NODE_TYPE_ETS_NEVER_TYPE = 66, +// AST_NODE_TYPE_ETS_STRING_LITERAL_TYPE = 67, +// AST_NODE_TYPE_ETS_FUNCTION_TYPE = 68, +// AST_NODE_TYPE_ETS_WILDCARD_TYPE = 69, +// AST_NODE_TYPE_ETS_PRIMITIVE_TYPE = 70, +// AST_NODE_TYPE_ETS_PACKAGE_DECLARATION = 71, +// AST_NODE_TYPE_ETS_CLASS_LITERAL = 72, +// AST_NODE_TYPE_ETS_TYPE_REFERENCE = 73, +// AST_NODE_TYPE_ETS_TYPE_REFERENCE_PART = 74, +// AST_NODE_TYPE_ETS_UNION_TYPE = 75, +// AST_NODE_TYPE_ETS_LAUNCH_EXPRESSION = 76, +// AST_NODE_TYPE_ETS_NEW_ARRAY_INSTANCE_EXPRESSION = 77, +// AST_NODE_TYPE_ETS_NEW_MULTI_DIM_ARRAY_INSTANCE_EXPRESSION = 78, +// AST_NODE_TYPE_ETS_NEW_CLASS_INSTANCE_EXPRESSION = 79, +// AST_NODE_TYPE_ETS_IMPORT_DECLARATION = 80, +// AST_NODE_TYPE_ETS_PARAMETER_EXPRESSION = 81, +// AST_NODE_TYPE_ETS_TUPLE = 82, +// AST_NODE_TYPE_ETS_SCRIPT = 83, +// AST_NODE_TYPE_SUPER_EXPRESSION = 84, +// AST_NODE_TYPE_STRUCT_DECLARATION = 85, +// AST_NODE_TYPE_SWITCH_CASE_STATEMENT = 86, +// AST_NODE_TYPE_SWITCH_STATEMENT = 87, +// AST_NODE_TYPE_TS_ENUM_DECLARATION = 88, +// AST_NODE_TYPE_TS_ENUM_MEMBER = 89, +// AST_NODE_TYPE_TS_EXTERNAL_MODULE_REFERENCE = 90, +// AST_NODE_TYPE_TS_NUMBER_KEYWORD = 91, +// AST_NODE_TYPE_TS_ANY_KEYWORD = 92, +// AST_NODE_TYPE_TS_STRING_KEYWORD = 93, +// AST_NODE_TYPE_TS_BOOLEAN_KEYWORD = 94, +// AST_NODE_TYPE_TS_VOID_KEYWORD = 95, +// AST_NODE_TYPE_TS_UNDEFINED_KEYWORD = 96, +// AST_NODE_TYPE_TS_UNKNOWN_KEYWORD = 97, +// AST_NODE_TYPE_TS_OBJECT_KEYWORD = 98, +// AST_NODE_TYPE_TS_BIGINT_KEYWORD = 99, +// AST_NODE_TYPE_TS_NEVER_KEYWORD = 100, +// AST_NODE_TYPE_TS_NON_NULL_EXPRESSION = 101, +// AST_NODE_TYPE_TS_NULL_KEYWORD = 102, +// AST_NODE_TYPE_TS_ARRAY_TYPE = 103, +// AST_NODE_TYPE_TS_UNION_TYPE = 104, +// AST_NODE_TYPE_TS_TYPE_LITERAL = 105, +// AST_NODE_TYPE_TS_PROPERTY_SIGNATURE = 106, +// AST_NODE_TYPE_TS_METHOD_SIGNATURE = 107, +// AST_NODE_TYPE_TS_SIGNATURE_DECLARATION = 108, +// AST_NODE_TYPE_TS_PARENT_TYPE = 109, +// AST_NODE_TYPE_TS_LITERAL_TYPE = 110, +// AST_NODE_TYPE_TS_INFER_TYPE = 111, +// AST_NODE_TYPE_TS_CONDITIONAL_TYPE = 112, +// AST_NODE_TYPE_TS_IMPORT_TYPE = 113, +// AST_NODE_TYPE_TS_INTERSECTION_TYPE = 114, +// AST_NODE_TYPE_TS_MAPPED_TYPE = 115, +// AST_NODE_TYPE_TS_MODULE_BLOCK = 116, +// AST_NODE_TYPE_TS_THIS_TYPE = 117, +// AST_NODE_TYPE_TS_TYPE_OPERATOR = 118, +// AST_NODE_TYPE_TS_TYPE_PARAMETER = 119, +// AST_NODE_TYPE_TS_TYPE_PARAMETER_DECLARATION = 120, +// AST_NODE_TYPE_TS_TYPE_PARAMETER_INSTANTIATION = 121, +// AST_NODE_TYPE_TS_TYPE_PREDICATE = 122, +// AST_NODE_TYPE_TS_PARAMETER_PROPERTY = 123, +// AST_NODE_TYPE_TS_MODULE_DECLARATION = 124, +// AST_NODE_TYPE_TS_IMPORT_EQUALS_DECLARATION = 125, +// AST_NODE_TYPE_TS_FUNCTION_TYPE = 126, +// AST_NODE_TYPE_TS_CONSTRUCTOR_TYPE = 127, +// AST_NODE_TYPE_TS_TYPE_ALIAS_DECLARATION = 128, +// AST_NODE_TYPE_TS_TYPE_REFERENCE = 129, +// AST_NODE_TYPE_TS_QUALIFIED_NAME = 130, +// AST_NODE_TYPE_TS_INDEXED_ACCESS_TYPE = 131, +// AST_NODE_TYPE_TS_INTERFACE_DECLARATION = 132, +// AST_NODE_TYPE_TS_INTERFACE_BODY = 133, +// AST_NODE_TYPE_TS_INTERFACE_HERITAGE = 134, +// AST_NODE_TYPE_TS_TUPLE_TYPE = 135, +// AST_NODE_TYPE_TS_NAMED_TUPLE_MEMBER = 136, +// AST_NODE_TYPE_TS_INDEX_SIGNATURE = 137, +// AST_NODE_TYPE_TS_TYPE_QUERY = 138, +// AST_NODE_TYPE_TS_AS_EXPRESSION = 139, +// AST_NODE_TYPE_TS_CLASS_IMPLEMENTS = 140, +// AST_NODE_TYPE_TS_TYPE_ASSERTION = 141, +// AST_NODE_TYPE_TAGGED_TEMPLATE_EXPRESSION = 142, +// AST_NODE_TYPE_TEMPLATE_ELEMENT = 143, +// AST_NODE_TYPE_TEMPLATE_LITERAL = 144, +// AST_NODE_TYPE_THIS_EXPRESSION = 145, +// AST_NODE_TYPE_TYPEOF_EXPRESSION = 146, +// AST_NODE_TYPE_THROW_STATEMENT = 147, +// AST_NODE_TYPE_TRY_STATEMENT = 148, +// AST_NODE_TYPE_UNARY_EXPRESSION = 149, +// AST_NODE_TYPE_UPDATE_EXPRESSION = 150, +// AST_NODE_TYPE_VARIABLE_DECLARATION = 151, +// AST_NODE_TYPE_VARIABLE_DECLARATOR = 152, +// AST_NODE_TYPE_WHILE_STATEMENT = 153, +// AST_NODE_TYPE_YIELD_EXPRESSION = 154, +// AST_NODE_TYPE_OPAQUE_TYPE_NODE = 155, +// AST_NODE_TYPE_BLOCK_EXPRESSION = 156, +// AST_NODE_TYPE_ERROR_TYPE_NODE = 157, +// AST_NODE_TYPE_ARRAY_EXPRESSION = 158, +// AST_NODE_TYPE_ARRAY_PATTERN = 159, +// AST_NODE_TYPE_ASSIGNMENT_EXPRESSION = 160, +// AST_NODE_TYPE_ASSIGNMENT_PATTERN = 161, +// AST_NODE_TYPE_OBJECT_EXPRESSION = 162, +// AST_NODE_TYPE_OBJECT_PATTERN = 163, +// AST_NODE_TYPE_SPREAD_ELEMENT = 164, +// AST_NODE_TYPE_REST_ELEMENT = 165 +// } +export enum Es2pandaScopeType { + SCOPE_TYPE_PARAM = 0, + SCOPE_TYPE_CATCH_PARAM = 1, + SCOPE_TYPE_FUNCTION_PARAM = 2, + SCOPE_TYPE_CATCH = 3, + SCOPE_TYPE_CLASS = 4, + SCOPE_TYPE_ANNOTATION = 5, + SCOPE_TYPE_ANNOTATIONPARAMSCOPE = 6, + SCOPE_TYPE_LOCAL = 7, + SCOPE_TYPE_LOCAL_WITH_ALIAS = 8, + SCOPE_TYPE_LOOP = 9, + SCOPE_TYPE_LOOP_DECL = 10, + SCOPE_TYPE_FUNCTION = 11, + SCOPE_TYPE_GLOBAL = 12, + SCOPE_TYPE_MODULE = 13 +} +export enum Es2pandaDeclType { + DECL_TYPE_NONE = 0, + DECL_TYPE_VAR = 1, + DECL_TYPE_LET = 2, + DECL_TYPE_CONST = 3, + DECL_TYPE_LABEL = 4, + DECL_TYPE_READONLY = 5, + DECL_TYPE_FUNC = 6, + DECL_TYPE_PARAM = 7, + DECL_TYPE_IMPORT = 8, + DECL_TYPE_DYNAMIC_IMPORT = 9, + DECL_TYPE_EXPORT = 10, + DECL_TYPE_ANNOTATIONDECL = 11, + DECL_TYPE_ANNOTATIONUSAGE = 12, + DECL_TYPE_TYPE_ALIAS = 13, + DECL_TYPE_NAMESPACE = 14, + DECL_TYPE_INTERFACE = 15, + DECL_TYPE_ENUM_LITERAL = 16, + DECL_TYPE_TYPE_PARAMETER = 17, + DECL_TYPE_PROPERTY = 18, + DECL_TYPE_CLASS = 19, + DECL_TYPE_METHOD = 20, + DECL_TYPE_ENUM = 21 +} +export enum Es2pandaResolveBindingOptions { + RESOLVE_BINDING_OPTIONS_BINDINGS = 0, + RESOLVE_BINDING_OPTIONS_INTERFACES = 1, + RESOLVE_BINDING_OPTIONS_VARIABLES = 2, + RESOLVE_BINDING_OPTIONS_METHODS = 4, + RESOLVE_BINDING_OPTIONS_DECLARATION = 8, + RESOLVE_BINDING_OPTIONS_STATIC_VARIABLES = 16, + RESOLVE_BINDING_OPTIONS_STATIC_METHODS = 32, + RESOLVE_BINDING_OPTIONS_STATIC_DECLARATION = 64, + RESOLVE_BINDING_OPTIONS_TYPE_ALIASES = 128, + RESOLVE_BINDING_OPTIONS_ALL = 256, + RESOLVE_BINDING_OPTIONS_ALL_NON_TYPE = 512, + RESOLVE_BINDING_OPTIONS_ALL_VARIABLES = 18, + RESOLVE_BINDING_OPTIONS_ALL_METHOD = 36, + RESOLVE_BINDING_OPTIONS_ALL_DECLARATION = 72, + RESOLVE_BINDING_OPTIONS_ALL_STATIC = 112, + RESOLVE_BINDING_OPTIONS_ALL_NON_STATIC = 14, + RESOLVE_BINDING_OPTIONS_LAST = 128 +} +export enum Es2pandaVariableKind { + VARIABLE_KIND_NONE = 0, + VARIABLE_KIND_VAR = 1, + VARIABLE_KIND_LEXICAL = 2, + VARIABLE_KIND_FUNCTION = 3, + VARIABLE_KIND_MODULE = 4 +} +export enum Es2pandaLetOrConstStatus { + LET_OR_CONST_STATUS_INITIALIZED = 0, + LET_OR_CONST_STATUS_UNINITIALIZED = 1 +} +export enum Es2pandaScopeFlags { + SCOPE_FLAGS_NONE = 0, + SCOPE_FLAGS_SET_LEXICAL_FUNCTION = 1, + SCOPE_FLAGS_USE_ARGS = 2, + SCOPE_FLAGS_USE_SUPER = 4, + SCOPE_FLAGS_INNER_ARROW = 8, + SCOPE_FLAGS_NO_REG_STORE = 16, + SCOPE_FLAGS_DECL_SCOPE = 32, + SCOPE_FLAGS_FIELD_SCOPE = 64, + SCOPE_FLAGS_METHOD_SCOPE = 128, + SCOPE_FLAGS_STATIC = 256, + SCOPE_FLAGS_TYPE_ALIAS = 512, + SCOPE_FLAGS_LOOP_SCOPE = 1024, + SCOPE_FLAGS_STATIC_DECL_SCOPE = 288, + SCOPE_FLAGS_STATIC_FIELD_SCOPE = 320, + SCOPE_FLAGS_STATIC_METHOD_SCOPE = 384 +} +export enum Es2pandaEnum { + ENUM_NODE_HAS_PARENT = 0, + ENUM_NODE_HAS_SOURCE_RANGE = 1, + ENUM_EVERY_CHILD_HAS_VALID_PARENT = 2, + ENUM_EVERY_CHILD_IN_PARENT_RANGE = 3, + ENUM_CHECK_STRUCT_DECLARATION = 4, + ENUM_VARIABLE_HAS_SCOPE = 5, + ENUM_NODE_HAS_TYPE = 6, + ENUM_NO_PRIMITIVE_TYPES = 7, + ENUM_IDENTIFIER_HAS_VARIABLE = 8, + ENUM_REFERENCE_TYPE_ANNOTATION_IS_NULL = 9, + ENUM_ARITHMETIC_OPERATION_VALID = 10, + ENUM_SEQUENCE_EXPRESSION_HAS_LAST_TYPE = 11, + ENUM_CHECK_INFINITE_LOOP = 12, + ENUM_FOR_LOOP_CORRECTLY_INITIALIZED = 13, + ENUM_VARIABLE_HAS_ENCLOSING_SCOPE = 14, + ENUM_MODIFIER_ACCESS_VALID = 15, + ENUM_VARIABLE_NAME_IDENTIFIER_NAME_SAME = 16, + ENUM_CHECK_ABSTRACT_METHOD = 17, + ENUM_GETTER_SETTER_VALIDATION = 18, + ENUM_CHECK_SCOPE_DECLARATION = 19, + ENUM_CHECK_CONST_PROPERTIES = 20, + ENUM_COUNT = 21, + ENUM_BASE_FIRST = 0, + ENUM_BASE_LAST = 3, + ENUM_AFTER_PLUGINS_AFTER_PARSE_FIRST = 4, + ENUM_AFTER_PLUGINS_AFTER_PARSE_LAST = 4, + ENUM_AFTER_SCOPES_INIT_PHASE_FIRST = 5, + ENUM_AFTER_SCOPES_INIT_PHASE_LAST = 5, + ENUM_AFTER_CHECKER_PHASE_FIRST = 6, + ENUM_AFTER_CHECKER_PHASE_LAST = 20, + ENUM_FIRST = 0, + ENUM_LAST = 20, + ENUM_INVALID = 21 +} +export enum Es2pandaRegExpFlags { + REG_EXP_FLAGS_EMPTY = 0, + REG_EXP_FLAGS_GLOBAL = 1, + REG_EXP_FLAGS_IGNORE_CASE = 2, + REG_EXP_FLAGS_MULTILINE = 4, + REG_EXP_FLAGS_DOTALL = 8, + REG_EXP_FLAGS_UNICODE = 16, + REG_EXP_FLAGS_STICKY = 32 +} +export enum Es2pandaId { + ID_AS = 0, + ID_JS = 1, + ID_TS = 2, + ID_ETS = 3, + ID_COUNT = 4 +} +export enum Es2pandaTokenType { + TOKEN_TYPE_EOS = 0, + TOKEN_TYPE_LITERAL_IDENT = 1, + TOKEN_TYPE_LITERAL_STRING = 2, + TOKEN_TYPE_LITERAL_CHAR = 3, + TOKEN_TYPE_LITERAL_NUMBER = 4, + TOKEN_TYPE_LITERAL_REGEXP = 5, + TOKEN_TYPE_PUNCTUATOR_BITWISE_AND = 6, + TOKEN_TYPE_PUNCTUATOR_BITWISE_OR = 7, + TOKEN_TYPE_PUNCTUATOR_MULTIPLY = 8, + TOKEN_TYPE_PUNCTUATOR_DIVIDE = 9, + TOKEN_TYPE_PUNCTUATOR_MINUS = 10, + TOKEN_TYPE_PUNCTUATOR_EXCLAMATION_MARK = 11, + TOKEN_TYPE_PUNCTUATOR_TILDE = 12, + TOKEN_TYPE_PUNCTUATOR_MINUS_MINUS = 13, + TOKEN_TYPE_PUNCTUATOR_LEFT_SHIFT = 14, + TOKEN_TYPE_PUNCTUATOR_RIGHT_SHIFT = 15, + TOKEN_TYPE_PUNCTUATOR_LESS_THAN_EQUAL = 16, + TOKEN_TYPE_PUNCTUATOR_GREATER_THAN_EQUAL = 17, + TOKEN_TYPE_PUNCTUATOR_MOD = 18, + TOKEN_TYPE_PUNCTUATOR_BITWISE_XOR = 19, + TOKEN_TYPE_PUNCTUATOR_EXPONENTIATION = 20, + TOKEN_TYPE_PUNCTUATOR_MULTIPLY_EQUAL = 21, + TOKEN_TYPE_PUNCTUATOR_EXPONENTIATION_EQUAL = 22, + TOKEN_TYPE_PUNCTUATOR_ARROW = 23, + TOKEN_TYPE_PUNCTUATOR_BACK_TICK = 24, + TOKEN_TYPE_PUNCTUATOR_HASH_MARK = 25, + TOKEN_TYPE_PUNCTUATOR_DIVIDE_EQUAL = 26, + TOKEN_TYPE_PUNCTUATOR_MOD_EQUAL = 27, + TOKEN_TYPE_PUNCTUATOR_MINUS_EQUAL = 28, + TOKEN_TYPE_PUNCTUATOR_LEFT_SHIFT_EQUAL = 29, + TOKEN_TYPE_PUNCTUATOR_RIGHT_SHIFT_EQUAL = 30, + TOKEN_TYPE_PUNCTUATOR_UNSIGNED_RIGHT_SHIFT = 31, + TOKEN_TYPE_PUNCTUATOR_UNSIGNED_RIGHT_SHIFT_EQUAL = 32, + TOKEN_TYPE_PUNCTUATOR_BITWISE_AND_EQUAL = 33, + TOKEN_TYPE_PUNCTUATOR_BITWISE_OR_EQUAL = 34, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_AND_EQUAL = 35, + TOKEN_TYPE_PUNCTUATOR_NULLISH_COALESCING = 36, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_OR_EQUAL = 37, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_NULLISH_EQUAL = 38, + TOKEN_TYPE_PUNCTUATOR_BITWISE_XOR_EQUAL = 39, + TOKEN_TYPE_PUNCTUATOR_PLUS = 40, + TOKEN_TYPE_PUNCTUATOR_PLUS_PLUS = 41, + TOKEN_TYPE_PUNCTUATOR_PLUS_EQUAL = 42, + TOKEN_TYPE_PUNCTUATOR_LESS_THAN = 43, + TOKEN_TYPE_PUNCTUATOR_GREATER_THAN = 44, + TOKEN_TYPE_PUNCTUATOR_EQUAL = 45, + TOKEN_TYPE_PUNCTUATOR_NOT_EQUAL = 46, + TOKEN_TYPE_PUNCTUATOR_STRICT_EQUAL = 47, + TOKEN_TYPE_PUNCTUATOR_NOT_STRICT_EQUAL = 48, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_AND = 49, + TOKEN_TYPE_PUNCTUATOR_LOGICAL_OR = 50, + TOKEN_TYPE_PUNCTUATOR_SUBSTITUTION = 51, + TOKEN_TYPE_PUNCTUATOR_QUESTION_MARK = 52, + TOKEN_TYPE_PUNCTUATOR_QUESTION_DOT = 53, + TOKEN_TYPE_PUNCTUATOR_AT = 54, + TOKEN_TYPE_PUNCTUATOR_FORMAT = 55, + TOKEN_TYPE_PUNCTUATOR_RIGHT_PARENTHESIS = 56, + TOKEN_TYPE_PUNCTUATOR_LEFT_PARENTHESIS = 57, + TOKEN_TYPE_PUNCTUATOR_RIGHT_SQUARE_BRACKET = 58, + TOKEN_TYPE_PUNCTUATOR_LEFT_SQUARE_BRACKET = 59, + TOKEN_TYPE_PUNCTUATOR_RIGHT_BRACE = 60, + TOKEN_TYPE_PUNCTUATOR_PERIOD = 61, + TOKEN_TYPE_PUNCTUATOR_PERIOD_PERIOD_PERIOD = 62, + TOKEN_TYPE_PUNCTUATOR_PERIOD_QUESTION = 63, + TOKEN_TYPE_PUNCTUATOR_LEFT_BRACE = 64, + TOKEN_TYPE_PUNCTUATOR_SEMI_COLON = 65, + TOKEN_TYPE_PUNCTUATOR_COLON = 66, + TOKEN_TYPE_PUNCTUATOR_COMMA = 67, + TOKEN_TYPE_KEYW_ABSTRACT = 68, + TOKEN_TYPE_KEYW_ANY = 69, + TOKEN_TYPE_KEYW_ANYREF = 70, + TOKEN_TYPE_KEYW_ARGUMENTS = 71, + TOKEN_TYPE_KEYW_AS = 72, + TOKEN_TYPE_KEYW_ASSERT = 73, + TOKEN_TYPE_KEYW_ASSERTS = 74, + TOKEN_TYPE_KEYW_ASYNC = 75, + TOKEN_TYPE_KEYW_AWAIT = 76, + TOKEN_TYPE_KEYW_BIGINT = 77, + TOKEN_TYPE_KEYW_BOOLEAN = 78, + TOKEN_TYPE_KEYW_BREAK = 79, + TOKEN_TYPE_KEYW_BYTE = 80, + TOKEN_TYPE_KEYW_CASE = 81, + TOKEN_TYPE_KEYW_CATCH = 82, + TOKEN_TYPE_KEYW_CHAR = 83, + TOKEN_TYPE_KEYW_CLASS = 84, + TOKEN_TYPE_KEYW_CONST = 85, + TOKEN_TYPE_KEYW_CONSTRUCTOR = 86, + TOKEN_TYPE_KEYW_CONTINUE = 87, + TOKEN_TYPE_KEYW_DATAREF = 88, + TOKEN_TYPE_KEYW_DEBUGGER = 89, + TOKEN_TYPE_KEYW_DECLARE = 90, + TOKEN_TYPE_KEYW_DEFAULT = 91, + TOKEN_TYPE_KEYW_DELETE = 92, + TOKEN_TYPE_KEYW_DO = 93, + TOKEN_TYPE_KEYW_DOUBLE = 94, + TOKEN_TYPE_KEYW_ELSE = 95, + TOKEN_TYPE_KEYW_ENUM = 96, + TOKEN_TYPE_KEYW_EQREF = 97, + TOKEN_TYPE_KEYW_EVAL = 98, + TOKEN_TYPE_KEYW_EXPORT = 99, + TOKEN_TYPE_KEYW_EXTENDS = 100, + TOKEN_TYPE_KEYW_EXTERNREF = 101, + TOKEN_TYPE_KEYW_F32 = 102, + TOKEN_TYPE_KEYW_F64 = 103, + TOKEN_TYPE_LITERAL_FALSE = 104, + TOKEN_TYPE_KEYW_FINALLY = 105, + TOKEN_TYPE_KEYW_FLOAT = 106, + TOKEN_TYPE_KEYW_FOR = 107, + TOKEN_TYPE_KEYW_FROM = 108, + TOKEN_TYPE_KEYW_FUNCREF = 109, + TOKEN_TYPE_KEYW_FUNCTION = 110, + TOKEN_TYPE_KEYW_GET = 111, + TOKEN_TYPE_KEYW_GLOBAL = 112, + TOKEN_TYPE_KEYW_I8 = 113, + TOKEN_TYPE_KEYW_I16 = 114, + TOKEN_TYPE_KEYW_I31REF = 115, + TOKEN_TYPE_KEYW_I32 = 116, + TOKEN_TYPE_KEYW_I64 = 117, + TOKEN_TYPE_KEYW_IF = 118, + TOKEN_TYPE_KEYW_IMPLEMENTS = 119, + TOKEN_TYPE_KEYW_IMPORT = 120, + TOKEN_TYPE_KEYW_IN = 121, + TOKEN_TYPE_KEYW_INFER = 122, + TOKEN_TYPE_KEYW_INSTANCEOF = 123, + TOKEN_TYPE_KEYW_INT = 124, + TOKEN_TYPE_KEYW_INTERFACE = 125, + TOKEN_TYPE_KEYW_IS = 126, + TOKEN_TYPE_KEYW_ISIZE = 127, + TOKEN_TYPE_KEYW_KEYOF = 128, + TOKEN_TYPE_KEYW_LET = 129, + TOKEN_TYPE_KEYW_LAUNCH = 130, + TOKEN_TYPE_KEYW_LONG = 131, + TOKEN_TYPE_KEYW_META = 132, + TOKEN_TYPE_KEYW_MODULE = 133, + TOKEN_TYPE_KEYW_NAMESPACE = 134, + TOKEN_TYPE_KEYW_NATIVE = 135, + TOKEN_TYPE_KEYW_NEVER = 136, + TOKEN_TYPE_KEYW_NEW = 137, + TOKEN_TYPE_LITERAL_NULL = 138, + TOKEN_TYPE_KEYW_NUMBER = 139, + TOKEN_TYPE_KEYW_OBJECT = 140, + TOKEN_TYPE_KEYW_OF = 141, + TOKEN_TYPE_KEYW_FINAL = 142, + TOKEN_TYPE_KEYW_OUT = 143, + TOKEN_TYPE_KEYW_OVERRIDE = 144, + TOKEN_TYPE_KEYW_PACKAGE = 145, + TOKEN_TYPE_KEYW_INTERNAL = 146, + TOKEN_TYPE_KEYW_PRIVATE = 147, + TOKEN_TYPE_KEYW_PROTECTED = 148, + TOKEN_TYPE_KEYW_PUBLIC = 149, + TOKEN_TYPE_KEYW_READONLY = 150, + TOKEN_TYPE_KEYW_RETHROWS = 151, + TOKEN_TYPE_KEYW_RETURN = 152, + TOKEN_TYPE_KEYW_REQUIRE = 153, + TOKEN_TYPE_KEYW_SET = 154, + TOKEN_TYPE_KEYW_SHORT = 155, + TOKEN_TYPE_KEYW_STATIC = 156, + TOKEN_TYPE_KEYW_STRING = 157, + TOKEN_TYPE_KEYW_STRUCT = 158, + TOKEN_TYPE_KEYW_SUPER = 159, + TOKEN_TYPE_KEYW_SWITCH = 160, + TOKEN_TYPE_KEYW_TARGET = 161, + TOKEN_TYPE_KEYW_THIS = 162, + TOKEN_TYPE_KEYW_THROW = 163, + TOKEN_TYPE_KEYW_THROWS = 164, + TOKEN_TYPE_LITERAL_TRUE = 165, + TOKEN_TYPE_KEYW_TRY = 166, + TOKEN_TYPE_KEYW_TYPE = 167, + TOKEN_TYPE_KEYW_TYPEOF = 168, + TOKEN_TYPE_KEYW_U8 = 169, + TOKEN_TYPE_KEYW_U16 = 170, + TOKEN_TYPE_KEYW_U32 = 171, + TOKEN_TYPE_KEYW_U64 = 172, + TOKEN_TYPE_KEYW_UNDEFINED = 173, + TOKEN_TYPE_KEYW_UNKNOWN = 174, + TOKEN_TYPE_KEYW_USIZE = 175, + TOKEN_TYPE_KEYW_V128 = 176, + TOKEN_TYPE_KEYW_VAR = 177, + TOKEN_TYPE_KEYW_VOID = 178, + TOKEN_TYPE_KEYW_WHILE = 179, + TOKEN_TYPE_KEYW_WITH = 180, + TOKEN_TYPE_KEYW_YIELD = 181, + TOKEN_TYPE_FIRST_PUNCTUATOR = 6, + TOKEN_TYPE_FIRST_KEYW = 68 +} +export enum Es2pandaAstNodeFlags { + AST_NODE_FLAGS_NO_OPTS = 0, + AST_NODE_FLAGS_CHECKCAST = 1, + AST_NODE_FLAGS_CONVERT_TO_STRING = 2, + AST_NODE_FLAGS_ALLOW_REQUIRED_INSTANTIATION = 4, + AST_NODE_FLAGS_HAS_EXPORT_ALIAS = 8, + AST_NODE_FLAGS_GENERATE_VALUE_OF = 16, + AST_NODE_FLAGS_GENERATE_GET_NAME = 32, + AST_NODE_FLAGS_RECHECK = 64 +} +export enum Es2pandaModifierFlags { + MODIFIER_FLAGS_NONE = 0, + MODIFIER_FLAGS_STATIC = 1, + MODIFIER_FLAGS_ASYNC = 2, + MODIFIER_FLAGS_PUBLIC = 4, + MODIFIER_FLAGS_PROTECTED = 8, + MODIFIER_FLAGS_PRIVATE = 16, + MODIFIER_FLAGS_DECLARE = 32, + MODIFIER_FLAGS_READONLY = 64, + MODIFIER_FLAGS_OPTIONAL = 128, + MODIFIER_FLAGS_DEFINITE = 256, + MODIFIER_FLAGS_ABSTRACT = 512, + MODIFIER_FLAGS_CONST = 1024, + MODIFIER_FLAGS_FINAL = 2048, + MODIFIER_FLAGS_NATIVE = 4096, + MODIFIER_FLAGS_OVERRIDE = 8192, + MODIFIER_FLAGS_CONSTRUCTOR = 16384, + MODIFIER_FLAGS_SYNCHRONIZED = 32768, + MODIFIER_FLAGS_FUNCTIONAL = 65536, + MODIFIER_FLAGS_IN = 131072, + MODIFIER_FLAGS_OUT = 262144, + MODIFIER_FLAGS_INTERNAL = 524288, + MODIFIER_FLAGS_EXPORT = 1048576, + MODIFIER_FLAGS_GETTER = 2097152, + MODIFIER_FLAGS_SETTER = 4194304, + MODIFIER_FLAGS_DEFAULT_EXPORT = 8388608, + MODIFIER_FLAGS_EXPORT_TYPE = 16777216, + MODIFIER_FLAGS_SUPER_OWNER = 33554432, + MODIFIER_FLAGS_ANNOTATION_DECLARATION = 67108864, + MODIFIER_FLAGS_ANNOTATION_USAGE = 134217728, + MODIFIER_FLAGS_READONLY_PARAMETER = 268435456, + MODIFIER_FLAGS_ACCESS = 524316, + MODIFIER_FLAGS_ALL = 524927, + MODIFIER_FLAGS_ALLOWED_IN_CTOR_PARAMETER = 524380, + MODIFIER_FLAGS_INTERNAL_PROTECTED = 524296, + MODIFIER_FLAGS_ACCESSOR_MODIFIERS = 2560, + MODIFIER_FLAGS_GETTER_SETTER = 6291456, + MODIFIER_FLAGS_EXPORTED = 26214400 +} +export enum Es2pandaPrivateFieldKind { + PRIVATE_FIELD_KIND_FIELD = 0, + PRIVATE_FIELD_KIND_METHOD = 1, + PRIVATE_FIELD_KIND_GET = 2, + PRIVATE_FIELD_KIND_SET = 3, + PRIVATE_FIELD_KIND_STATIC_FIELD = 4, + PRIVATE_FIELD_KIND_STATIC_METHOD = 5, + PRIVATE_FIELD_KIND_STATIC_GET = 6, + PRIVATE_FIELD_KIND_STATIC_SET = 7 +} +export enum Es2pandaScriptFunctionFlags { + SCRIPT_FUNCTION_FLAGS_NONE = 0, + SCRIPT_FUNCTION_FLAGS_GENERATOR = 1, + SCRIPT_FUNCTION_FLAGS_ASYNC = 2, + SCRIPT_FUNCTION_FLAGS_ARROW = 4, + SCRIPT_FUNCTION_FLAGS_EXPRESSION = 8, + SCRIPT_FUNCTION_FLAGS_OVERLOAD = 16, + SCRIPT_FUNCTION_FLAGS_CONSTRUCTOR = 32, + SCRIPT_FUNCTION_FLAGS_METHOD = 64, + SCRIPT_FUNCTION_FLAGS_STATIC_BLOCK = 128, + SCRIPT_FUNCTION_FLAGS_HIDDEN = 256, + SCRIPT_FUNCTION_FLAGS_IMPLICIT_SUPER_CALL_NEEDED = 512, + SCRIPT_FUNCTION_FLAGS_ENUM = 1024, + SCRIPT_FUNCTION_FLAGS_EXTERNAL = 2048, + SCRIPT_FUNCTION_FLAGS_PROXY = 4096, + SCRIPT_FUNCTION_FLAGS_THROWS = 8192, + SCRIPT_FUNCTION_FLAGS_RETHROWS = 16384, + SCRIPT_FUNCTION_FLAGS_GETTER = 32768, + SCRIPT_FUNCTION_FLAGS_SETTER = 65536, + SCRIPT_FUNCTION_FLAGS_ENTRY_POINT = 131072, + SCRIPT_FUNCTION_FLAGS_INSTANCE_EXTENSION_METHOD = 262144, + SCRIPT_FUNCTION_FLAGS_HAS_RETURN = 524288, + SCRIPT_FUNCTION_FLAGS_ASYNC_IMPL = 1048576, + SCRIPT_FUNCTION_FLAGS_EXTERNAL_OVERLOAD = 2097152, + SCRIPT_FUNCTION_FLAGS_HAS_THROW = 4194304 +} +export enum Es2pandaTSOperatorType { + TS_OPERATOR_TYPE_READONLY = 0, + TS_OPERATOR_TYPE_KEYOF = 1, + TS_OPERATOR_TYPE_UNIQUE = 2 +} +export enum Es2pandaMappedOption { + MAPPED_OPTION_NO_OPTS = 0, + MAPPED_OPTION_PLUS = 1, + MAPPED_OPTION_MINUS = 2 +} +export enum Es2pandaBoxingUnboxingFlags { + BOXING_UNBOXING_FLAGS_NONE = 0, + BOXING_UNBOXING_FLAGS_BOX_TO_BOOLEAN = 1, + BOXING_UNBOXING_FLAGS_BOX_TO_BYTE = 2, + BOXING_UNBOXING_FLAGS_BOX_TO_SHORT = 4, + BOXING_UNBOXING_FLAGS_BOX_TO_CHAR = 8, + BOXING_UNBOXING_FLAGS_BOX_TO_INT = 16, + BOXING_UNBOXING_FLAGS_BOX_TO_LONG = 32, + BOXING_UNBOXING_FLAGS_BOX_TO_FLOAT = 64, + BOXING_UNBOXING_FLAGS_BOX_TO_DOUBLE = 128, + BOXING_UNBOXING_FLAGS_BOX_TO_ENUM = 256, + BOXING_UNBOXING_FLAGS_UNBOX_TO_BOOLEAN = 512, + BOXING_UNBOXING_FLAGS_UNBOX_TO_BYTE = 1024, + BOXING_UNBOXING_FLAGS_UNBOX_TO_SHORT = 2048, + BOXING_UNBOXING_FLAGS_UNBOX_TO_CHAR = 4096, + BOXING_UNBOXING_FLAGS_UNBOX_TO_INT = 8192, + BOXING_UNBOXING_FLAGS_UNBOX_TO_LONG = 16384, + BOXING_UNBOXING_FLAGS_UNBOX_TO_FLOAT = 32768, + BOXING_UNBOXING_FLAGS_UNBOX_TO_DOUBLE = 65536, + BOXING_UNBOXING_FLAGS_UNBOX_TO_ENUM = 131072, + BOXING_UNBOXING_FLAGS_BOXING_FLAG = 511, + BOXING_UNBOXING_FLAGS_UNBOXING_FLAG = 261632 +} +export enum Es2pandaClassDefinitionModifiers { + CLASS_DEFINITION_MODIFIERS_NONE = 0, + CLASS_DEFINITION_MODIFIERS_DECLARATION = 1, + CLASS_DEFINITION_MODIFIERS_ID_REQUIRED = 2, + CLASS_DEFINITION_MODIFIERS_GLOBAL = 4, + CLASS_DEFINITION_MODIFIERS_HAS_SUPER = 8, + CLASS_DEFINITION_MODIFIERS_SET_CTOR_ID = 16, + CLASS_DEFINITION_MODIFIERS_EXTERN = 32, + CLASS_DEFINITION_MODIFIERS_ANONYMOUS = 64, + CLASS_DEFINITION_MODIFIERS_GLOBAL_INITIALIZED = 128, + CLASS_DEFINITION_MODIFIERS_CLASS_DECL = 256, + CLASS_DEFINITION_MODIFIERS_INNER = 512, + CLASS_DEFINITION_MODIFIERS_FROM_EXTERNAL = 1024, + CLASS_DEFINITION_MODIFIERS_LOCAL = 2048, + CLASS_DEFINITION_MODIFIERS_CLASSDEFINITION_CHECKED = 4096, + CLASS_DEFINITION_MODIFIERS_NAMESPACE_TRANSFORMED = 8192, + CLASS_DEFINITION_MODIFIERS_DECLARATION_ID_REQUIRED = 3, + CLASS_DEFINITION_MODIFIERS_ETS_MODULE = 8196 +} +export enum Es2pandaOperandKind { + OPERAND_KIND_SRC_VREG = 0, + OPERAND_KIND_DST_VREG = 1, + OPERAND_KIND_SRC_DST_VREG = 2, + OPERAND_KIND_IMM = 3, + OPERAND_KIND_ID = 4, + OPERAND_KIND_STRING_ID = 5, + OPERAND_KIND_LABEL = 6 +} +export enum Es2pandaOperandType { + OPERAND_TYPE_REF = 0, + OPERAND_TYPE_B32 = 1, + OPERAND_TYPE_B64 = 2, + OPERAND_TYPE_ANY = 3, + OPERAND_TYPE_NONE = 4 +} +export enum Es2pandaTypeRelationFlag { + TYPE_RELATION_FLAG_NONE = 0, + TYPE_RELATION_FLAG_NARROWING = 1, + TYPE_RELATION_FLAG_WIDENING = 2, + TYPE_RELATION_FLAG_BOXING = 4, + TYPE_RELATION_FLAG_UNBOXING = 8, + TYPE_RELATION_FLAG_CAPTURE = 16, + TYPE_RELATION_FLAG_STRING = 32, + TYPE_RELATION_FLAG_VALUE_SET = 64, + TYPE_RELATION_FLAG_UNCHECKED = 128, + TYPE_RELATION_FLAG_NO_THROW = 256, + TYPE_RELATION_FLAG_SELF_REFERENCE = 512, + TYPE_RELATION_FLAG_NO_RETURN_TYPE_CHECK = 1024, + TYPE_RELATION_FLAG_DIRECT_RETURN = 2048, + TYPE_RELATION_FLAG_NO_WIDENING = 4096, + TYPE_RELATION_FLAG_NO_BOXING = 8192, + TYPE_RELATION_FLAG_NO_UNBOXING = 16384, + TYPE_RELATION_FLAG_ONLY_CHECK_WIDENING = 32768, + TYPE_RELATION_FLAG_ONLY_CHECK_BOXING_UNBOXING = 65536, + TYPE_RELATION_FLAG_IN_ASSIGNMENT_CONTEXT = 131072, + TYPE_RELATION_FLAG_IN_CASTING_CONTEXT = 262144, + TYPE_RELATION_FLAG_UNCHECKED_CAST = 524288, + TYPE_RELATION_FLAG_IGNORE_TYPE_PARAMETERS = 1048576, + TYPE_RELATION_FLAG_CHECK_PROXY = 2097152, + TYPE_RELATION_FLAG_NO_CHECK_TRAILING_LAMBDA = 4194304, + TYPE_RELATION_FLAG_NO_THROW_GENERIC_TYPEALIAS = 8388608, + TYPE_RELATION_FLAG_OVERRIDING_CONTEXT = 16777216, + TYPE_RELATION_FLAG_IGNORE_REST_PARAM = 33554432, + TYPE_RELATION_FLAG_STRING_TO_CHAR = 67108864, + TYPE_RELATION_FLAG_ASSIGNMENT_CONTEXT = 14, + TYPE_RELATION_FLAG_BRIDGE_CHECK = 17826816, + TYPE_RELATION_FLAG_CASTING_CONTEXT = 524303 +} +export enum Es2pandaRelationResult { + RELATION_RESULT_TRUE = 0, + RELATION_RESULT_FALSE = 1, + RELATION_RESULT_UNKNOWN = 2, + RELATION_RESULT_MAYBE = 3, + RELATION_RESULT_CACHE_MISS = 4, + RELATION_RESULT_ERROR = 5 +} +export enum Es2pandaRelationType { + RELATION_TYPE_COMPARABLE = 0, + RELATION_TYPE_ASSIGNABLE = 1, + RELATION_TYPE_IDENTICAL = 2, + RELATION_TYPE_UNCHECKED_CASTABLE = 3, + RELATION_TYPE_SUPERTYPE = 4 +} +export enum Es2pandaImportKinds { + IMPORT_KINDS_VALUE = 0, + IMPORT_KINDS_TYPE = 1 +} +export enum Es2pandaPropertyKind { + PROPERTY_KIND_INIT = 0, + PROPERTY_KIND_GET = 1, + PROPERTY_KIND_SET = 2, + PROPERTY_KIND_PROTO = 3 +} +export enum Es2pandaConstant { + CONSTANT_PROP_NULL = 0, + CONSTANT_PROP_UNDEFINED = 1, + CONSTANT_EMPTY_ARRAY = 2 +} +export enum Es2pandaTSSignatureDeclarationKind { + TS_SIGNATURE_DECLARATION_KIND_CALL_SIGNATURE = 0, + TS_SIGNATURE_DECLARATION_KIND_CONSTRUCT_SIGNATURE = 1 +} +export enum Es2pandaTSIndexSignatureKind { + TS_INDEX_SIGNATURE_KIND_NUMBER = 0, + TS_INDEX_SIGNATURE_KIND_STRING = 1 +} +export enum Es2pandaEnumLiteralTypeKind { + ENUM_LITERAL_TYPE_KIND_NUMERIC = 0, + ENUM_LITERAL_TYPE_KIND_LITERAL = 1 +} +export enum Es2pandaIdentifierFlags { + IDENTIFIER_FLAGS_NONE = 0, + IDENTIFIER_FLAGS_OPTIONAL = 1, + IDENTIFIER_FLAGS_TDZ = 2, + IDENTIFIER_FLAGS_PRIVATE = 4, + IDENTIFIER_FLAGS_GET = 8, + IDENTIFIER_FLAGS_SET = 16, + IDENTIFIER_FLAGS_IGNORE_BOX = 32, + IDENTIFIER_FLAGS_ANNOTATIONDECL = 64, + IDENTIFIER_FLAGS_ANNOTATIONUSAGE = 128, + IDENTIFIER_FLAGS_ERROR_PLACEHOLDER = 256, + IDENTIFIER_FLAGS_IMPLICIT_THIS = 512 +} +export enum Es2pandaMemberExpressionKind { + MEMBER_EXPRESSION_KIND_NONE = 0, + MEMBER_EXPRESSION_KIND_ELEMENT_ACCESS = 1, + MEMBER_EXPRESSION_KIND_PROPERTY_ACCESS = 2, + MEMBER_EXPRESSION_KIND_GETTER = 4, + MEMBER_EXPRESSION_KIND_SETTER = 8, + MEMBER_EXPRESSION_KIND_EXTENSION_ACCESSOR = 16 +} +export enum Es2pandaTSTupleKind { + TS_TUPLE_KIND_NONE = 0, + TS_TUPLE_KIND_NAMED = 1, + TS_TUPLE_KIND_DEFAULT = 2 +} +export enum Es2pandaMetaPropertyKind { + META_PROPERTY_KIND_NEW_TARGET = 0, + META_PROPERTY_KIND_IMPORT_META = 1 +} +export enum Es2pandaModuleFlag { + MODULE_FLAG_NONE = 0, + MODULE_FLAG_ETSSCRIPT = 1, + MODULE_FLAG_NAMESPACE = 2, + MODULE_FLAG_NAMESPACE_CHAIN_LAST_NODE = 4 +} +export enum Es2pandaElementFlags { + ELEMENT_FLAGS_NO_OPTS = 0, + ELEMENT_FLAGS_REQUIRED = 1, + ELEMENT_FLAGS_OPTIONAL = 2, + ELEMENT_FLAGS_REST = 4, + ELEMENT_FLAGS_VARIADIC = 8, + ELEMENT_FLAGS_FIXED = 3, + ELEMENT_FLAGS_VARIABLE = 12, + ELEMENT_FLAGS_NON_REQUIRED = 14, + ELEMENT_FLAGS_NON_REST = 11 +} +export enum Es2pandaSignatureFlags { + SIGNATURE_FLAGS_NO_OPTS = 0, + SIGNATURE_FLAGS_VIRTUAL = 1, + SIGNATURE_FLAGS_ABSTRACT = 2, + SIGNATURE_FLAGS_CALL = 4, + SIGNATURE_FLAGS_CONSTRUCT = 8, + SIGNATURE_FLAGS_PUBLIC = 16, + SIGNATURE_FLAGS_PROTECTED = 32, + SIGNATURE_FLAGS_PRIVATE = 64, + SIGNATURE_FLAGS_STATIC = 128, + SIGNATURE_FLAGS_FINAL = 256, + SIGNATURE_FLAGS_CONSTRUCTOR = 512, + SIGNATURE_FLAGS_TYPE = 1024, + SIGNATURE_FLAGS_PROXY = 2048, + SIGNATURE_FLAGS_INTERNAL = 4096, + SIGNATURE_FLAGS_NEED_RETURN_TYPE = 8192, + SIGNATURE_FLAGS_INFERRED_RETURN_TYPE = 16384, + SIGNATURE_FLAGS_THIS_RETURN_TYPE = 32768, + SIGNATURE_FLAGS_GETTER = 65536, + SIGNATURE_FLAGS_SETTER = 131072, + SIGNATURE_FLAGS_THROWS = 262144, + SIGNATURE_FLAGS_RETHROWS = 524288, + SIGNATURE_FLAGS_EXTENSION_FUNCTION_RETURN_THIS = 1048576, + SIGNATURE_FLAGS_INTERNAL_PROTECTED = 4128, + SIGNATURE_FLAGS_GETTER_OR_SETTER = 196608, + SIGNATURE_FLAGS_THROWING = 786432, + SIGNATURE_FLAGS_FUNCTIONAL_INTERFACE_SIGNATURE = 1047 +} +export enum Es2pandaPrimitiveType { + PRIMITIVE_TYPE_BYTE = 0, + PRIMITIVE_TYPE_INT = 1, + PRIMITIVE_TYPE_LONG = 2, + PRIMITIVE_TYPE_SHORT = 3, + PRIMITIVE_TYPE_FLOAT = 4, + PRIMITIVE_TYPE_DOUBLE = 5, + PRIMITIVE_TYPE_BOOLEAN = 6, + PRIMITIVE_TYPE_CHAR = 7, + PRIMITIVE_TYPE_VOID = 8 +} +export enum Es2pandaObjectFlags { + OBJECT_FLAGS_NO_OPTS = 0, + OBJECT_FLAGS_CHECK_EXCESS_PROPS = 1, + OBJECT_FLAGS_RESOLVED_MEMBERS = 2, + OBJECT_FLAGS_RESOLVED_BASE_TYPES = 4, + OBJECT_FLAGS_RESOLVED_DECLARED_MEMBERS = 8 +} +export enum Es2pandaObjectTypeKind { + OBJECT_TYPE_KIND_LITERAL = 0, + OBJECT_TYPE_KIND_CLASS = 1, + OBJECT_TYPE_KIND_INTERFACE = 2, + OBJECT_TYPE_KIND_TUPLE = 3, + OBJECT_TYPE_KIND_FUNCTION = 4 +} +export enum Es2pandaVariableDeclaratorFlag { + VARIABLE_DECLARATOR_FLAG_LET = 0, + VARIABLE_DECLARATOR_FLAG_CONST = 1, + VARIABLE_DECLARATOR_FLAG_VAR = 2, + VARIABLE_DECLARATOR_FLAG_UNKNOWN = 3 +} +export enum Es2pandaTypeFacts { + TYPE_FACTS_NONE = 0, + TYPE_FACTS_TYPEOF_EQ_STRING = 1, + TYPE_FACTS_TYPEOF_EQ_NUMBER = 2, + TYPE_FACTS_TYPEOF_EQ_BIGINT = 4, + TYPE_FACTS_TYPEOF_EQ_BOOLEAN = 8, + TYPE_FACTS_TYPEOF_EQ_SYMBOL = 16, + TYPE_FACTS_TYPEOF_EQ_OBJECT = 32, + TYPE_FACTS_TYPEOF_EQ_FUNCTION = 64, + TYPE_FACTS_TYPEOF_EQ_HOST_OBJECT = 128, + TYPE_FACTS_TYPEOF_NE_STRING = 256, + TYPE_FACTS_TYPEOF_NE_NUMBER = 512, + TYPE_FACTS_TYPEOF_NE_BIGINT = 1024, + TYPE_FACTS_TYPEOF_NE_BOOLEAN = 2048, + TYPE_FACTS_TYPEOF_NE_SYMBOL = 4096, + TYPE_FACTS_TYPEOF_NE_OBJECT = 8192, + TYPE_FACTS_TYPEOF_NE_FUNCTION = 16384, + TYPE_FACTS_TYPEOF_NE_HOST_OBJECT = 32768, + TYPE_FACTS_EQ_UNDEFINED = 65536, + TYPE_FACTS_EQ_NULL = 131072, + TYPE_FACTS_EQ_UNDEFINED_OR_NULL = 262144, + TYPE_FACTS_NE_UNDEFINED = 524288, + TYPE_FACTS_NE_NULL = 1048576, + TYPE_FACTS_NE_UNDEFINED_OR_NULL = 2097152, + TYPE_FACTS_TRUTHY = 4194304, + TYPE_FACTS_FALSY = 8388608, + TYPE_FACTS_ALL = 16777216, + TYPE_FACTS_LAST = 8388608, + TYPE_FACTS_BASE_NUMBER_STRICT_FACTS = 3734786, + TYPE_FACTS_BASE_NUMBER_FACTS = 12582146, + TYPE_FACTS_NUMBER_FACTS = 16776450, + TYPE_FACTS_ZERO_NUMBER_STRICT_FACTS = 12123394, + TYPE_FACTS_ZERO_NUMBER_FACTS = 12582146, + TYPE_FACTS_NON_ZERO_NUMBER_FACTS = 16776450, + TYPE_FACTS_BASE_STRING_STRICT_FACTS = 3735041, + TYPE_FACTS_BASE_STRING_FACTS = 12582401, + TYPE_FACTS_STRING_FACTS = 16776705, + TYPE_FACTS_EMPTY_STRING_STRICT_FACTS = 16317953, + TYPE_FACTS_EMPTY_STRING_FACTS = 12582401, + TYPE_FACTS_NON_EMPTY_STRING_FACTS = 16776705, + TYPE_FACTS_BASE_BIGINT_STRICT_FACTS = 3734276, + TYPE_FACTS_BASE_BIGINT_FACTS = 12581636, + TYPE_FACTS_BIGINT_FACTS = 16775940, + TYPE_FACTS_ZERO_BIGINT_STRICT_FACTS = 12122884, + TYPE_FACTS_ZERO_BIGINT_FACTS = 12581636, + TYPE_FACTS_NON_ZERO_BIGINT_FACTS = 16775940, + TYPE_FACTS_BASE_BOOLEAN_STRICT_FACTS = 3733256, + TYPE_FACTS_BASE_BOOLEAN_FACTS = 12580616, + TYPE_FACTS_BOOLEAN_FACTS = 16774920, + TYPE_FACTS_FALSE_STRICT_FACTS = 12121864, + TYPE_FACTS_FALSE_FACTS = 12580616, + TYPE_FACTS_TRUE_STRICT_FACTS = 7927560, + TYPE_FACTS_TRUE_FACTS = 16774920, + TYPE_FACTS_OBJECT_STRICT_FACTS = 7888800, + TYPE_FACTS_OBJECT_FACTS = 16736160, + TYPE_FACTS_EMPTY_OBJECT_FACTS = 16777216, + TYPE_FACTS_FUNCTION_STRICT_FACTS = 7880640, + TYPE_FACTS_FUNCTION_FACTS = 16728000, + TYPE_FACTS_UNDEFINED_FACTS = 9830144, + TYPE_FACTS_NULL_FACTS = 9363232 +} +export enum Es2pandaGlobalTypeId { + GLOBAL_TYPE_ID_NUMBER = 0, + GLOBAL_TYPE_ID_ANY = 1, + GLOBAL_TYPE_ID_STRING = 2, + GLOBAL_TYPE_ID_BOOLEAN = 3, + GLOBAL_TYPE_ID_VOID = 4, + GLOBAL_TYPE_ID_NULL_ID = 5, + GLOBAL_TYPE_ID_UNDEFINED = 6, + GLOBAL_TYPE_ID_UNKNOWN = 7, + GLOBAL_TYPE_ID_NEVER = 8, + GLOBAL_TYPE_ID_NON_PRIMITIVE = 9, + GLOBAL_TYPE_ID_BIGINT = 10, + GLOBAL_TYPE_ID_FALSE_ID = 11, + GLOBAL_TYPE_ID_TRUE_ID = 12, + GLOBAL_TYPE_ID_NUMBER_OR_BIGINT = 13, + GLOBAL_TYPE_ID_STRING_OR_NUMBER = 14, + GLOBAL_TYPE_ID_ZERO = 15, + GLOBAL_TYPE_ID_EMPTY_STRING = 16, + GLOBAL_TYPE_ID_ZERO_BIGINT = 17, + GLOBAL_TYPE_ID_PRIMITIVE = 18, + GLOBAL_TYPE_ID_EMPTY_TUPLE = 19, + GLOBAL_TYPE_ID_EMPTY_OBJECT = 20, + GLOBAL_TYPE_ID_RESOLVING_RETURN_TYPE = 21, + GLOBAL_TYPE_ID_ERROR_TYPE = 22, + GLOBAL_TYPE_ID_BYTE = 23, + GLOBAL_TYPE_ID_SHORT = 24, + GLOBAL_TYPE_ID_INT = 25, + GLOBAL_TYPE_ID_LONG = 26, + GLOBAL_TYPE_ID_FLOAT = 27, + GLOBAL_TYPE_ID_DOUBLE = 28, + GLOBAL_TYPE_ID_CHAR = 29, + GLOBAL_TYPE_ID_ETS_BOOLEAN = 30, + GLOBAL_TYPE_ID_ETS_STRING = 31, + GLOBAL_TYPE_ID_ETS_VOID = 32, + GLOBAL_TYPE_ID_ETS_OBJECT_BUILTIN = 33, + GLOBAL_TYPE_ID_ETS_NULL = 34, + GLOBAL_TYPE_ID_ETS_UNDEFINED = 35, + GLOBAL_TYPE_ID_ETS_NULLISH_TYPE = 36, + GLOBAL_TYPE_ID_ETS_NEVER = 37, + GLOBAL_TYPE_ID_ETS_NULLISH_OBJECT = 38, + GLOBAL_TYPE_ID_ETS_WILDCARD = 39, + GLOBAL_TYPE_ID_ETS_BOOLEAN_BUILTIN = 40, + GLOBAL_TYPE_ID_ETS_BYTE_BUILTIN = 41, + GLOBAL_TYPE_ID_ETS_CHAR_BUILTIN = 42, + GLOBAL_TYPE_ID_ETS_COMPARABLE_BUILTIN = 43, + GLOBAL_TYPE_ID_ETS_CONSOLE_BUILTIN = 44, + GLOBAL_TYPE_ID_ETS_DATE_BUILTIN = 45, + GLOBAL_TYPE_ID_ETS_DOUBLE_BUILTIN = 46, + GLOBAL_TYPE_ID_ETS_EXCEPTION_BUILTIN = 47, + GLOBAL_TYPE_ID_ETS_FLOAT_BUILTIN = 48, + GLOBAL_TYPE_ID_ETS_FLOATING_BUILTIN = 49, + GLOBAL_TYPE_ID_ETS_INT_BUILTIN = 50, + GLOBAL_TYPE_ID_ETS_INTEGRAL_BUILTIN = 51, + GLOBAL_TYPE_ID_ETS_LONG_BUILTIN = 52, + GLOBAL_TYPE_ID_ETS_MAP_BUILTIN = 53, + GLOBAL_TYPE_ID_ETS_ERROR_BUILTIN = 54, + GLOBAL_TYPE_ID_ETS_RUNTIME_BUILTIN = 55, + GLOBAL_TYPE_ID_ETS_RUNTIME_LINKER_BUILTIN = 56, + GLOBAL_TYPE_ID_ETS_SET_BUILTIN = 57, + GLOBAL_TYPE_ID_ETS_SHORT_BUILTIN = 58, + GLOBAL_TYPE_ID_ETS_STACK_TRACE_ELEMENT_BUILTIN = 59, + GLOBAL_TYPE_ID_ETS_STACK_TRACE_BUILTIN = 60, + GLOBAL_TYPE_ID_ETS_ARRAY_INDEX_OUT_OF_BOUNDS_ERROR_BUILTIN = 61, + GLOBAL_TYPE_ID_ETS_ARITHMETIC_ERROR_BUILTIN = 62, + GLOBAL_TYPE_ID_ETS_CLASS_CAST_ERROR_BUILTIN = 63, + GLOBAL_TYPE_ID_ETS_ASSERTION_ERROR_BUILTIN = 64, + GLOBAL_TYPE_ID_ETS_DIVIDE_BY_ZERO_ERROR_BUILTIN = 65, + GLOBAL_TYPE_ID_ETS_NULL_POINTER_ERROR_BUILTIN = 66, + GLOBAL_TYPE_ID_ETS_UNCAUGHT_EXCEPTION_ERROR_BUILTIN = 67, + GLOBAL_TYPE_ID_ETS_STRING_BUILTIN = 68, + GLOBAL_TYPE_ID_ETS_STRING_BUILDER_BUILTIN = 69, + GLOBAL_TYPE_ID_ETS_TYPE_BUILTIN = 70, + GLOBAL_TYPE_ID_ETS_TYPES_BUILTIN = 71, + GLOBAL_TYPE_ID_ETS_PROMISE_BUILTIN = 72, + GLOBAL_TYPE_ID_ETS_REGEXP_BUILTIN = 73, + GLOBAL_TYPE_ID_ETS_ARRAY_BUILTIN = 74, + GLOBAL_TYPE_ID_ETS_INTEROP_JSRUNTIME_BUILTIN = 75, + GLOBAL_TYPE_ID_ETS_INTEROP_JSVALUE_BUILTIN = 76, + GLOBAL_TYPE_ID_ETS_BOX_BUILTIN = 77, + GLOBAL_TYPE_ID_ETS_BOOLEAN_BOX_BUILTIN = 78, + GLOBAL_TYPE_ID_ETS_BYTE_BOX_BUILTIN = 79, + GLOBAL_TYPE_ID_ETS_CHAR_BOX_BUILTIN = 80, + GLOBAL_TYPE_ID_ETS_SHORT_BOX_BUILTIN = 81, + GLOBAL_TYPE_ID_ETS_INT_BOX_BUILTIN = 82, + GLOBAL_TYPE_ID_ETS_LONG_BOX_BUILTIN = 83, + GLOBAL_TYPE_ID_ETS_FLOAT_BOX_BUILTIN = 84, + GLOBAL_TYPE_ID_ETS_DOUBLE_BOX_BUILTIN = 85, + GLOBAL_TYPE_ID_ETS_BIG_INT_BUILTIN = 86, + GLOBAL_TYPE_ID_ETS_BIG_INT = 87, + GLOBAL_TYPE_ID_ETS_FUNCTION0_CLASS = 88, + GLOBAL_TYPE_ID_ETS_FUNCTION1_CLASS = 89, + GLOBAL_TYPE_ID_ETS_FUNCTION2_CLASS = 90, + GLOBAL_TYPE_ID_ETS_FUNCTION3_CLASS = 91, + GLOBAL_TYPE_ID_ETS_FUNCTION4_CLASS = 92, + GLOBAL_TYPE_ID_ETS_FUNCTION5_CLASS = 93, + GLOBAL_TYPE_ID_ETS_FUNCTION6_CLASS = 94, + GLOBAL_TYPE_ID_ETS_FUNCTION7_CLASS = 95, + GLOBAL_TYPE_ID_ETS_FUNCTION8_CLASS = 96, + GLOBAL_TYPE_ID_ETS_FUNCTION9_CLASS = 97, + GLOBAL_TYPE_ID_ETS_FUNCTION10_CLASS = 98, + GLOBAL_TYPE_ID_ETS_FUNCTION11_CLASS = 99, + GLOBAL_TYPE_ID_ETS_FUNCTION12_CLASS = 100, + GLOBAL_TYPE_ID_ETS_FUNCTION13_CLASS = 101, + GLOBAL_TYPE_ID_ETS_FUNCTION14_CLASS = 102, + GLOBAL_TYPE_ID_ETS_FUNCTION15_CLASS = 103, + GLOBAL_TYPE_ID_ETS_FUNCTION16_CLASS = 104, + GLOBAL_TYPE_ID_ETS_FUNCTIONN_CLASS = 105, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION0_CLASS = 106, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION1_CLASS = 107, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION2_CLASS = 108, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION3_CLASS = 109, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION4_CLASS = 110, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION5_CLASS = 111, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION6_CLASS = 112, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION7_CLASS = 113, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION8_CLASS = 114, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION9_CLASS = 115, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION10_CLASS = 116, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION11_CLASS = 117, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION12_CLASS = 118, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION13_CLASS = 119, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION14_CLASS = 120, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION15_CLASS = 121, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTION16_CLASS = 122, + GLOBAL_TYPE_ID_ETS_THROWING_FUNCTIONN_CLASS = 123, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION0_CLASS = 124, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION1_CLASS = 125, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION2_CLASS = 126, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION3_CLASS = 127, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION4_CLASS = 128, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION5_CLASS = 129, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION6_CLASS = 130, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION7_CLASS = 131, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION8_CLASS = 132, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION9_CLASS = 133, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION10_CLASS = 134, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION11_CLASS = 135, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION12_CLASS = 136, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION13_CLASS = 137, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION14_CLASS = 138, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION15_CLASS = 139, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTION16_CLASS = 140, + GLOBAL_TYPE_ID_ETS_RETHROWING_FUNCTIONN_CLASS = 141, + GLOBAL_TYPE_ID_TYPE_ERROR = 142, + GLOBAL_TYPE_ID_COUNT = 143 +} +export enum Es2pandaMethodDefinitionKind { + METHOD_DEFINITION_KIND_NONE = 0, + METHOD_DEFINITION_KIND_CONSTRUCTOR = 1, + METHOD_DEFINITION_KIND_METHOD = 2, + METHOD_DEFINITION_KIND_EXTENSION_METHOD = 3, + METHOD_DEFINITION_KIND_GET = 4, + METHOD_DEFINITION_KIND_SET = 5, + METHOD_DEFINITION_KIND_EXTENSION_GET = 6, + METHOD_DEFINITION_KIND_EXTENSION_SET = 7 +} +export enum Es2pandaETSObjectFlags { + ETS_OBJECT_FLAGS_NO_OPTS = 0, + ETS_OBJECT_FLAGS_CLASS = 1, + ETS_OBJECT_FLAGS_INTERFACE = 2, + ETS_OBJECT_FLAGS_INSTANCE = 4, + ETS_OBJECT_FLAGS_ABSTRACT = 8, + ETS_OBJECT_FLAGS_GLOBAL = 16, + ETS_OBJECT_FLAGS_ENUM = 32, + ETS_OBJECT_FLAGS_FUNCTIONAL = 64, + ETS_OBJECT_FLAGS_RESOLVED_INTERFACES = 128, + ETS_OBJECT_FLAGS_RESOLVED_SUPER = 256, + ETS_OBJECT_FLAGS_RESOLVED_TYPE_PARAMS = 512, + ETS_OBJECT_FLAGS_CHECKED_COMPATIBLE_ABSTRACTS = 1024, + ETS_OBJECT_FLAGS_STRING = 2048, + ETS_OBJECT_FLAGS_INCOMPLETE_INSTANTIATION = 4096, + ETS_OBJECT_FLAGS_INNER = 8192, + ETS_OBJECT_FLAGS_DYNAMIC = 16384, + ETS_OBJECT_FLAGS_ASYNC_FUNC_RETURN_TYPE = 32768, + ETS_OBJECT_FLAGS_CHECKED_INVOKE_LEGITIMACY = 65536, + ETS_OBJECT_FLAGS_REQUIRED = 131072, + ETS_OBJECT_FLAGS_READONLY = 262144, + ETS_OBJECT_FLAGS_BUILTIN_BIGINT = 524288, + ETS_OBJECT_FLAGS_BUILTIN_STRING = 1048576, + ETS_OBJECT_FLAGS_BUILTIN_BOOLEAN = 2097152, + ETS_OBJECT_FLAGS_BUILTIN_BYTE = 4194304, + ETS_OBJECT_FLAGS_BUILTIN_CHAR = 8388608, + ETS_OBJECT_FLAGS_BUILTIN_SHORT = 16777216, + ETS_OBJECT_FLAGS_BUILTIN_INT = 33554432, + ETS_OBJECT_FLAGS_BUILTIN_LONG = 67108864, + ETS_OBJECT_FLAGS_BUILTIN_FLOAT = 134217728, + ETS_OBJECT_FLAGS_BUILTIN_DOUBLE = 268435456, + ETS_OBJECT_FLAGS_BOXED_ENUM = 536870912, + ETS_OBJECT_FLAGS_EXTENSION_FUNCTION = 1073741824, + ETS_OBJECT_FLAGS_BUILTIN_NUMERIC = 524288000, + ETS_OBJECT_FLAGS_VALUE_TYPED = 535300096, + ETS_OBJECT_FLAGS_UNBOXABLE_TYPE = 1071644672, + ETS_OBJECT_FLAGS_BUILTIN_TYPE = 1073217536, + ETS_OBJECT_FLAGS_GLOBAL_CLASS = 17, + ETS_OBJECT_FLAGS_FUNCTIONAL_INTERFACE = 74, + ETS_OBJECT_FLAGS_RESOLVED_HEADER = 896 +} +export enum Es2pandaPropertySearchFlags { + PROPERTY_SEARCH_FLAGS_NO_OPTS = 0, + PROPERTY_SEARCH_FLAGS_SEARCH_INSTANCE_METHOD = 1, + PROPERTY_SEARCH_FLAGS_SEARCH_INSTANCE_FIELD = 2, + PROPERTY_SEARCH_FLAGS_SEARCH_INSTANCE_DECL = 4, + PROPERTY_SEARCH_FLAGS_SEARCH_STATIC_METHOD = 8, + PROPERTY_SEARCH_FLAGS_SEARCH_STATIC_FIELD = 16, + PROPERTY_SEARCH_FLAGS_SEARCH_STATIC_DECL = 32, + PROPERTY_SEARCH_FLAGS_SEARCH_IN_BASE = 64, + PROPERTY_SEARCH_FLAGS_SEARCH_IN_INTERFACES = 128, + PROPERTY_SEARCH_FLAGS_IGNORE_ABSTRACT = 256, + PROPERTY_SEARCH_FLAGS_ALLOW_FUNCTIONAL_INTERFACE = 512, + PROPERTY_SEARCH_FLAGS_DISALLOW_SYNTHETIC_METHOD_CREATION = 1024, + PROPERTY_SEARCH_FLAGS_IS_FUNCTIONAL = 2048, + PROPERTY_SEARCH_FLAGS_IS_SETTER = 4096, + PROPERTY_SEARCH_FLAGS_IS_GETTER = 8192, + PROPERTY_SEARCH_FLAGS_SEARCH_INSTANCE = 7, + PROPERTY_SEARCH_FLAGS_SEARCH_STATIC = 56, + PROPERTY_SEARCH_FLAGS_SEARCH_METHOD = 9, + PROPERTY_SEARCH_FLAGS_SEARCH_FIELD = 18, + PROPERTY_SEARCH_FLAGS_SEARCH_DECL = 36, + PROPERTY_SEARCH_FLAGS_SEARCH_ALL = 63 +} +export enum Es2pandaPropertyType { + PROPERTY_TYPE_INSTANCE_METHOD = 0, + PROPERTY_TYPE_INSTANCE_FIELD = 1, + PROPERTY_TYPE_INSTANCE_DECL = 2, + PROPERTY_TYPE_STATIC_METHOD = 3, + PROPERTY_TYPE_STATIC_FIELD = 4, + PROPERTY_TYPE_STATIC_DECL = 5, + PROPERTY_TYPE_COUNT = 6 +} +export enum Es2pandaVariableDeclarationKind { + VARIABLE_DECLARATION_KIND_CONST = 0, + VARIABLE_DECLARATION_KIND_LET = 1, + VARIABLE_DECLARATION_KIND_VAR = 2 +} +export enum Es2pandaAccessibilityOption { + ACCESSIBILITY_OPTION_NO_OPTS = 0, + ACCESSIBILITY_OPTION_PUBLIC = 1, + ACCESSIBILITY_OPTION_PRIVATE = 2, + ACCESSIBILITY_OPTION_PROTECTED = 3 +} +export enum Es2pandaRecordTableFlags { + RECORD_TABLE_FLAGS_NONE = 0, + RECORD_TABLE_FLAGS_EXTERNAL = 1 +} +export enum Es2pandaCheckerStatus { + CHECKER_STATUS_NO_OPTS = 0, + CHECKER_STATUS_FORCE_TUPLE = 1, + CHECKER_STATUS_IN_CONST_CONTEXT = 2, + CHECKER_STATUS_KEEP_LITERAL_TYPE = 4, + CHECKER_STATUS_IN_PARAMETER = 8, + CHECKER_STATUS_IN_CLASS = 16, + CHECKER_STATUS_IN_INTERFACE = 32, + CHECKER_STATUS_IN_ABSTRACT = 64, + CHECKER_STATUS_IN_STATIC_CONTEXT = 128, + CHECKER_STATUS_IN_CONSTRUCTOR = 256, + CHECKER_STATUS_IN_STATIC_BLOCK = 512, + CHECKER_STATUS_INNER_CLASS = 1024, + CHECKER_STATUS_IN_ENUM = 2048, + CHECKER_STATUS_BUILTINS_INITIALIZED = 4096, + CHECKER_STATUS_IN_LAMBDA = 8192, + CHECKER_STATUS_IGNORE_VISIBILITY = 16384, + CHECKER_STATUS_IN_EXTENSION_METHOD = 32768, + CHECKER_STATUS_IN_LOCAL_CLASS = 65536, + CHECKER_STATUS_IN_INSTANCEOF_CONTEXT = 131072, + CHECKER_STATUS_IN_TEST_EXPRESSION = 262144, + CHECKER_STATUS_IN_LOOP = 524288, + CHECKER_STATUS_MEET_RETURN = 1048576, + CHECKER_STATUS_MEET_BREAK = 2097152, + CHECKER_STATUS_MEET_CONTINUE = 4194304, + CHECKER_STATUS_MEET_THROW = 8388608, + CHECKER_STATUS_IN_EXTERNAL = 16777216, + CHECKER_STATUS_IN_BRIDGE_TEST = 33554432, + CHECKER_STATUS_IN_GETTER = 67108864, + CHECKER_STATUS_IN_SETTER = 134217728, + CHECKER_STATUS_IN_EXTENSION_ACCESSOR_CHECK = 268435456 +} +export enum Es2pandaOverrideErrorCode { + OVERRIDE_ERROR_CODE_NO_ERROR = 0, + OVERRIDE_ERROR_CODE_OVERRIDDEN_FINAL = 1, + OVERRIDE_ERROR_CODE_INCOMPATIBLE_RETURN = 2, + OVERRIDE_ERROR_CODE_INCOMPATIBLE_TYPEPARAM = 3, + OVERRIDE_ERROR_CODE_OVERRIDDEN_WEAKER = 4 +} +export enum Es2pandaResolvedKind { + RESOLVED_KIND_PROPERTY = 0, + RESOLVED_KIND_EXTENSION_FUNCTION = 1, + RESOLVED_KIND_EXTENSION_ACCESSOR = 2 +} +export enum Es2pandaLexicalScopeType { + LEXICAL_SCOPE_TYPE_BLOCK = 0, + LEXICAL_SCOPE_TYPE_STRICT_BLOCK = 1, + LEXICAL_SCOPE_TYPE_CATCH = 2, + LEXICAL_SCOPE_TYPE_FUNCTION_PARAM = 3, + LEXICAL_SCOPE_TYPE_TS_TYPE_LITERAL = 4 +} +export enum Es2pandaVariableParsingFlags { + VARIABLE_PARSING_FLAGS_NO_OPTS = 0, + VARIABLE_PARSING_FLAGS_NO_SKIP_VAR_KIND = 1, + VARIABLE_PARSING_FLAGS_ACCEPT_CONST_NO_INIT = 2, + VARIABLE_PARSING_FLAGS_DISALLOW_INIT = 4, + VARIABLE_PARSING_FLAGS_VAR = 8, + VARIABLE_PARSING_FLAGS_LET = 16, + VARIABLE_PARSING_FLAGS_CONST = 32, + VARIABLE_PARSING_FLAGS_STOP_AT_IN = 64, + VARIABLE_PARSING_FLAGS_IN_FOR = 128, + VARIABLE_PARSING_FLAGS_FOR_OF = 256 +} +export enum Es2pandaExpressionParseFlags { + EXPRESSION_PARSE_FLAGS_NO_OPTS = 0, + EXPRESSION_PARSE_FLAGS_ACCEPT_COMMA = 1, + EXPRESSION_PARSE_FLAGS_ACCEPT_REST = 2, + EXPRESSION_PARSE_FLAGS_EXP_DISALLOW_AS = 4, + EXPRESSION_PARSE_FLAGS_DISALLOW_ASSIGNMENT = 8, + EXPRESSION_PARSE_FLAGS_DISALLOW_YIELD = 16, + EXPRESSION_PARSE_FLAGS_STOP_AT_IN = 32, + EXPRESSION_PARSE_FLAGS_MUST_BE_PATTERN = 64, + EXPRESSION_PARSE_FLAGS_POTENTIALLY_IN_PATTERN = 128, + EXPRESSION_PARSE_FLAGS_OBJECT_PATTERN = 256, + EXPRESSION_PARSE_FLAGS_IN_REST = 512, + EXPRESSION_PARSE_FLAGS_IMPORT = 1024, + EXPRESSION_PARSE_FLAGS_POTENTIAL_CLASS_LITERAL = 2048, + EXPRESSION_PARSE_FLAGS_IN_FOR = 4096, + EXPRESSION_PARSE_FLAGS_INSTANCEOF = 8192, + EXPRESSION_PARSE_FLAGS_POTENTIAL_NEW_ARRAY = 16384 +} +export enum Es2pandaStatementParsingFlags { + STATEMENT_PARSING_FLAGS_NONE = 0, + STATEMENT_PARSING_FLAGS_ALLOW_LEXICAL = 1, + STATEMENT_PARSING_FLAGS_GLOBAL = 2, + STATEMENT_PARSING_FLAGS_IF_ELSE = 4, + STATEMENT_PARSING_FLAGS_LABELLED = 8, + STATEMENT_PARSING_FLAGS_STMT_LEXICAL_SCOPE_NEEDED = 12, + STATEMENT_PARSING_FLAGS_STMT_GLOBAL_LEXICAL = 3 +} +export enum Es2pandaForStatementKind { + FOR_STATEMENT_KIND_UPDATE = 0, + FOR_STATEMENT_KIND_IN = 1, + FOR_STATEMENT_KIND_OF = 2 +} +export enum Es2pandaCompilationMode { + COMPILATION_MODE_GEN_STD_LIB = 0, + COMPILATION_MODE_PROJECT = 1, + COMPILATION_MODE_SINGLE_FILE = 2 +} +export enum Es2pandaCheckDecision { + CHECK_DECISION_CORRECT = 0, + CHECK_DECISION_INCORRECT = 1 +} +export enum Es2pandaCheckAction { + CHECK_ACTION_CONTINUE = 0, + CHECK_ACTION_SKIP_SUBTREE = 1 +} diff --git a/koala-wrapper/src/generated/Es2pandaNativeModule.ts b/koala-wrapper/src/generated/Es2pandaNativeModule.ts new file mode 100644 index 000000000..51040c02b --- /dev/null +++ b/koala-wrapper/src/generated/Es2pandaNativeModule.ts @@ -0,0 +1,3715 @@ +/* + * Copyright (c) 2022-2025 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 { + KNativePointer, + KStringPtr, + KUInt, + KInt, + KBoolean, + KDouble, + KFloat, + KLong +} from "@koalaui/interop" + +// TODO: this type should be in interop +export type KNativePointerArray = BigUint64Array + +export class Es2pandaNativeModule { + _CreateLabelledStatement(context: KNativePointer, ident: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("'CreateLabelledStatement was not overloaded by native module initialization") + } + _UpdateLabelledStatement(context: KNativePointer, original: KNativePointer, ident: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("'UpdateLabelledStatement was not overloaded by native module initialization") + } + _LabelledStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'LabelledStatementBodyConst was not overloaded by native module initialization") + } + _LabelledStatementIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'LabelledStatementIdentConst was not overloaded by native module initialization") + } + _LabelledStatementIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'LabelledStatementIdent was not overloaded by native module initialization") + } + _LabelledStatementGetReferencedStatementConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'LabelledStatementGetReferencedStatementConst was not overloaded by native module initialization") + } + _CreateThrowStatement(context: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("'CreateThrowStatement was not overloaded by native module initialization") + } + _UpdateThrowStatement(context: KNativePointer, original: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("'UpdateThrowStatement was not overloaded by native module initialization") + } + _ThrowStatementArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ThrowStatementArgumentConst was not overloaded by native module initialization") + } + _CreateClassProperty(context: KNativePointer, key: KNativePointer, value: KNativePointer, typeAnnotation: KNativePointer, modifiers: KInt, isComputed: KBoolean): KNativePointer { + throw new Error("'CreateClassProperty was not overloaded by native module initialization") + } + _UpdateClassProperty(context: KNativePointer, original: KNativePointer, key: KNativePointer, value: KNativePointer, typeAnnotation: KNativePointer, modifiers: KInt, isComputed: KBoolean): KNativePointer { + throw new Error("'UpdateClassProperty was not overloaded by native module initialization") + } + _ClassPropertyTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassPropertyTypeAnnotationConst was not overloaded by native module initialization") + } + _ClassPropertySetTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'ClassPropertySetTypeAnnotation was not overloaded by native module initialization") + } + _ClassPropertyAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassPropertyAnnotations was not overloaded by native module initialization") + } + _ClassPropertyAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassPropertyAnnotationsConst was not overloaded by native module initialization") + } + _ClassPropertySetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'ClassPropertySetAnnotations was not overloaded by native module initialization") + } + _CreateTSVoidKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSVoidKeyword was not overloaded by native module initialization") + } + _UpdateTSVoidKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSVoidKeyword was not overloaded by native module initialization") + } + _CreateETSFunctionTypeIr(context: KNativePointer, signature: KNativePointer, funcFlags: KInt): KNativePointer { + throw new Error("'CreateETSFunctionTypeIr was not overloaded by native module initialization") + } + _UpdateETSFunctionTypeIr(context: KNativePointer, original: KNativePointer, signature: KNativePointer, funcFlags: KInt): KNativePointer { + throw new Error("'UpdateETSFunctionTypeIr was not overloaded by native module initialization") + } + _ETSFunctionTypeIrTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSFunctionTypeIrTypeParamsConst was not overloaded by native module initialization") + } + _ETSFunctionTypeIrTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSFunctionTypeIrTypeParams was not overloaded by native module initialization") + } + _ETSFunctionTypeIrParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSFunctionTypeIrParamsConst was not overloaded by native module initialization") + } + _ETSFunctionTypeIrReturnTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSFunctionTypeIrReturnTypeConst was not overloaded by native module initialization") + } + _ETSFunctionTypeIrReturnType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSFunctionTypeIrReturnType was not overloaded by native module initialization") + } + _ETSFunctionTypeIrFunctionalInterface(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSFunctionTypeIrFunctionalInterface was not overloaded by native module initialization") + } + _ETSFunctionTypeIrFunctionalInterfaceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSFunctionTypeIrFunctionalInterfaceConst was not overloaded by native module initialization") + } + _ETSFunctionTypeIrSetFunctionalInterface(context: KNativePointer, receiver: KNativePointer, functionalInterface: KNativePointer): void { + throw new Error("'ETSFunctionTypeIrSetFunctionalInterface was not overloaded by native module initialization") + } + _ETSFunctionTypeIrFlags(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'ETSFunctionTypeIrFlags was not overloaded by native module initialization") + } + _ETSFunctionTypeIrIsThrowingConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSFunctionTypeIrIsThrowingConst was not overloaded by native module initialization") + } + _ETSFunctionTypeIrIsRethrowingConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSFunctionTypeIrIsRethrowingConst was not overloaded by native module initialization") + } + _ETSFunctionTypeIrIsExtensionFunctionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSFunctionTypeIrIsExtensionFunctionConst was not overloaded by native module initialization") + } + _CreateTSTypeOperator(context: KNativePointer, type: KNativePointer, operatorType: KInt): KNativePointer { + throw new Error("'CreateTSTypeOperator was not overloaded by native module initialization") + } + _UpdateTSTypeOperator(context: KNativePointer, original: KNativePointer, type: KNativePointer, operatorType: KInt): KNativePointer { + throw new Error("'UpdateTSTypeOperator was not overloaded by native module initialization") + } + _TSTypeOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeOperatorTypeConst was not overloaded by native module initialization") + } + _TSTypeOperatorIsReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSTypeOperatorIsReadonlyConst was not overloaded by native module initialization") + } + _TSTypeOperatorIsKeyofConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSTypeOperatorIsKeyofConst was not overloaded by native module initialization") + } + _TSTypeOperatorIsUniqueConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSTypeOperatorIsUniqueConst was not overloaded by native module initialization") + } + _CreateIfStatement(context: KNativePointer, test: KNativePointer, consequent: KNativePointer, alternate: KNativePointer): KNativePointer { + throw new Error("'CreateIfStatement was not overloaded by native module initialization") + } + _UpdateIfStatement(context: KNativePointer, original: KNativePointer, test: KNativePointer, consequent: KNativePointer, alternate: KNativePointer): KNativePointer { + throw new Error("'UpdateIfStatement was not overloaded by native module initialization") + } + _IfStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'IfStatementTestConst was not overloaded by native module initialization") + } + _IfStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'IfStatementTest was not overloaded by native module initialization") + } + _IfStatementConsequentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'IfStatementConsequentConst was not overloaded by native module initialization") + } + _IfStatementConsequent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'IfStatementConsequent was not overloaded by native module initialization") + } + _IfStatementAlternate(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'IfStatementAlternate was not overloaded by native module initialization") + } + _IfStatementAlternateConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'IfStatementAlternateConst was not overloaded by native module initialization") + } + _CreateTSConstructorType(context: KNativePointer, signature: KNativePointer, abstract: KBoolean): KNativePointer { + throw new Error("'CreateTSConstructorType was not overloaded by native module initialization") + } + _UpdateTSConstructorType(context: KNativePointer, original: KNativePointer, signature: KNativePointer, abstract: KBoolean): KNativePointer { + throw new Error("'UpdateTSConstructorType was not overloaded by native module initialization") + } + _TSConstructorTypeTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSConstructorTypeTypeParamsConst was not overloaded by native module initialization") + } + _TSConstructorTypeTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSConstructorTypeTypeParams was not overloaded by native module initialization") + } + _TSConstructorTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSConstructorTypeParamsConst was not overloaded by native module initialization") + } + _TSConstructorTypeReturnTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSConstructorTypeReturnTypeConst was not overloaded by native module initialization") + } + _TSConstructorTypeReturnType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSConstructorTypeReturnType was not overloaded by native module initialization") + } + _TSConstructorTypeAbstractConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSConstructorTypeAbstractConst was not overloaded by native module initialization") + } + _CreateDecorator(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'CreateDecorator was not overloaded by native module initialization") + } + _UpdateDecorator(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'UpdateDecorator was not overloaded by native module initialization") + } + _DecoratorExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'DecoratorExprConst was not overloaded by native module initialization") + } + _CreateTSEnumDeclaration(context: KNativePointer, key: KNativePointer, members: BigUint64Array, membersSequenceLength: KUInt, isConst: KBoolean, isStatic: KBoolean, isDeclare: KBoolean): KNativePointer { + throw new Error("'CreateTSEnumDeclaration was not overloaded by native module initialization") + } + _UpdateTSEnumDeclaration(context: KNativePointer, original: KNativePointer, key: KNativePointer, members: BigUint64Array, membersSequenceLength: KUInt, isConst: KBoolean, isStatic: KBoolean, isDeclare: KBoolean): KNativePointer { + throw new Error("'UpdateTSEnumDeclaration was not overloaded by native module initialization") + } + _TSEnumDeclarationKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSEnumDeclarationKeyConst was not overloaded by native module initialization") + } + _TSEnumDeclarationKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSEnumDeclarationKey was not overloaded by native module initialization") + } + _TSEnumDeclarationMembersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSEnumDeclarationMembersConst was not overloaded by native module initialization") + } + _TSEnumDeclarationInternalNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'TSEnumDeclarationInternalNameConst was not overloaded by native module initialization") + } + _TSEnumDeclarationSetInternalName(context: KNativePointer, receiver: KNativePointer, internalName: KStringPtr): void { + throw new Error("'TSEnumDeclarationSetInternalName was not overloaded by native module initialization") + } + _TSEnumDeclarationBoxedClassConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSEnumDeclarationBoxedClassConst was not overloaded by native module initialization") + } + _TSEnumDeclarationSetBoxedClass(context: KNativePointer, receiver: KNativePointer, wrapperClass: KNativePointer): void { + throw new Error("'TSEnumDeclarationSetBoxedClass was not overloaded by native module initialization") + } + _TSEnumDeclarationIsConstConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSEnumDeclarationIsConstConst was not overloaded by native module initialization") + } + _TSEnumDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSEnumDeclarationDecoratorsConst was not overloaded by native module initialization") + } + _CreateTSNeverKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSNeverKeyword was not overloaded by native module initialization") + } + _UpdateTSNeverKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSNeverKeyword was not overloaded by native module initialization") + } + _CreateImportDefaultSpecifier(context: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("'CreateImportDefaultSpecifier was not overloaded by native module initialization") + } + _UpdateImportDefaultSpecifier(context: KNativePointer, original: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("'UpdateImportDefaultSpecifier was not overloaded by native module initialization") + } + _ImportDefaultSpecifierLocalConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportDefaultSpecifierLocalConst was not overloaded by native module initialization") + } + _ImportDefaultSpecifierLocal(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportDefaultSpecifierLocal was not overloaded by native module initialization") + } + _CreateObjectExpression(context: KNativePointer, nodeType: KInt, properties: BigUint64Array, propertiesSequenceLength: KUInt, trailingComma: KBoolean): KNativePointer { + throw new Error("'CreateObjectExpression was not overloaded by native module initialization") + } + _UpdateObjectExpression(context: KNativePointer, original: KNativePointer, nodeType: KInt, properties: BigUint64Array, propertiesSequenceLength: KUInt, trailingComma: KBoolean): KNativePointer { + throw new Error("'UpdateObjectExpression was not overloaded by native module initialization") + } + _ObjectExpressionPropertiesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ObjectExpressionPropertiesConst was not overloaded by native module initialization") + } + _ObjectExpressionIsDeclarationConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ObjectExpressionIsDeclarationConst was not overloaded by native module initialization") + } + _ObjectExpressionIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ObjectExpressionIsOptionalConst was not overloaded by native module initialization") + } + _ObjectExpressionDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ObjectExpressionDecoratorsConst was not overloaded by native module initialization") + } + _ObjectExpressionValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ObjectExpressionValidateExpression was not overloaded by native module initialization") + } + _ObjectExpressionConvertibleToObjectPattern(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ObjectExpressionConvertibleToObjectPattern was not overloaded by native module initialization") + } + _ObjectExpressionSetDeclaration(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'ObjectExpressionSetDeclaration was not overloaded by native module initialization") + } + _ObjectExpressionSetOptional(context: KNativePointer, receiver: KNativePointer, optional_arg: KBoolean): void { + throw new Error("'ObjectExpressionSetOptional was not overloaded by native module initialization") + } + _ObjectExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ObjectExpressionTypeAnnotationConst was not overloaded by native module initialization") + } + _ObjectExpressionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'ObjectExpressionSetTsTypeAnnotation was not overloaded by native module initialization") + } + _CreateImportSpecifier(context: KNativePointer, imported: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("'CreateImportSpecifier was not overloaded by native module initialization") + } + _UpdateImportSpecifier(context: KNativePointer, original: KNativePointer, imported: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("'UpdateImportSpecifier was not overloaded by native module initialization") + } + _ImportSpecifierImported(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportSpecifierImported was not overloaded by native module initialization") + } + _ImportSpecifierImportedConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportSpecifierImportedConst was not overloaded by native module initialization") + } + _ImportSpecifierLocal(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportSpecifierLocal was not overloaded by native module initialization") + } + _ImportSpecifierLocalConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportSpecifierLocalConst was not overloaded by native module initialization") + } + _CreateConditionalExpression(context: KNativePointer, test: KNativePointer, consequent: KNativePointer, alternate: KNativePointer): KNativePointer { + throw new Error("'CreateConditionalExpression was not overloaded by native module initialization") + } + _UpdateConditionalExpression(context: KNativePointer, original: KNativePointer, test: KNativePointer, consequent: KNativePointer, alternate: KNativePointer): KNativePointer { + throw new Error("'UpdateConditionalExpression was not overloaded by native module initialization") + } + _ConditionalExpressionTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ConditionalExpressionTestConst was not overloaded by native module initialization") + } + _ConditionalExpressionTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ConditionalExpressionTest was not overloaded by native module initialization") + } + _ConditionalExpressionSetTest(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'ConditionalExpressionSetTest was not overloaded by native module initialization") + } + _ConditionalExpressionConsequentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ConditionalExpressionConsequentConst was not overloaded by native module initialization") + } + _ConditionalExpressionConsequent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ConditionalExpressionConsequent was not overloaded by native module initialization") + } + _ConditionalExpressionSetConsequent(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'ConditionalExpressionSetConsequent was not overloaded by native module initialization") + } + _ConditionalExpressionAlternateConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ConditionalExpressionAlternateConst was not overloaded by native module initialization") + } + _ConditionalExpressionAlternate(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ConditionalExpressionAlternate was not overloaded by native module initialization") + } + _ConditionalExpressionSetAlternate(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'ConditionalExpressionSetAlternate was not overloaded by native module initialization") + } + _CreateCallExpression(context: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt, typeParams: KNativePointer, optional_arg: KBoolean, trailingComma: KBoolean): KNativePointer { + throw new Error("'CreateCallExpression was not overloaded by native module initialization") + } + _CreateCallExpression1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("'CreateCallExpression1 was not overloaded by native module initialization") + } + _UpdateCallExpression1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("'UpdateCallExpression1 was not overloaded by native module initialization") + } + _CallExpressionCalleeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CallExpressionCalleeConst was not overloaded by native module initialization") + } + _CallExpressionCallee(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CallExpressionCallee was not overloaded by native module initialization") + } + _CallExpressionSetCallee(context: KNativePointer, receiver: KNativePointer, callee: KNativePointer): void { + throw new Error("'CallExpressionSetCallee was not overloaded by native module initialization") + } + _CallExpressionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CallExpressionTypeParamsConst was not overloaded by native module initialization") + } + _CallExpressionTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CallExpressionTypeParams was not overloaded by native module initialization") + } + _CallExpressionArgumentsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CallExpressionArgumentsConst was not overloaded by native module initialization") + } + _CallExpressionArguments(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CallExpressionArguments was not overloaded by native module initialization") + } + _CallExpressionHasTrailingCommaConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'CallExpressionHasTrailingCommaConst was not overloaded by native module initialization") + } + _CallExpressionSetTypeParams(context: KNativePointer, receiver: KNativePointer, typeParams: KNativePointer): void { + throw new Error("'CallExpressionSetTypeParams was not overloaded by native module initialization") + } + _CallExpressionSetTrailingBlock(context: KNativePointer, receiver: KNativePointer, block: KNativePointer): void { + throw new Error("'CallExpressionSetTrailingBlock was not overloaded by native module initialization") + } + _CallExpressionIsExtensionAccessorCall(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'CallExpressionIsExtensionAccessorCall was not overloaded by native module initialization") + } + _CallExpressionTrailingBlockConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CallExpressionTrailingBlockConst was not overloaded by native module initialization") + } + _CallExpressionSetIsTrailingBlockInNewLine(context: KNativePointer, receiver: KNativePointer, isNewLine: KBoolean): void { + throw new Error("'CallExpressionSetIsTrailingBlockInNewLine was not overloaded by native module initialization") + } + _CallExpressionIsTrailingBlockInNewLineConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'CallExpressionIsTrailingBlockInNewLineConst was not overloaded by native module initialization") + } + _CallExpressionIsETSConstructorCallConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'CallExpressionIsETSConstructorCallConst was not overloaded by native module initialization") + } + _CreateBigIntLiteral(context: KNativePointer, src: KStringPtr): KNativePointer { + throw new Error("'CreateBigIntLiteral was not overloaded by native module initialization") + } + _UpdateBigIntLiteral(context: KNativePointer, original: KNativePointer, src: KStringPtr): KNativePointer { + throw new Error("'UpdateBigIntLiteral was not overloaded by native module initialization") + } + _BigIntLiteralStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'BigIntLiteralStrConst was not overloaded by native module initialization") + } + _ClassElementId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassElementId was not overloaded by native module initialization") + } + _ClassElementIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassElementIdConst was not overloaded by native module initialization") + } + _ClassElementKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassElementKey was not overloaded by native module initialization") + } + _ClassElementKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassElementKeyConst was not overloaded by native module initialization") + } + _ClassElementValue(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassElementValue was not overloaded by native module initialization") + } + _ClassElementSetValue(context: KNativePointer, receiver: KNativePointer, value: KNativePointer): void { + throw new Error("'ClassElementSetValue was not overloaded by native module initialization") + } + _ClassElementValueConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassElementValueConst was not overloaded by native module initialization") + } + _ClassElementIsPrivateElementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassElementIsPrivateElementConst was not overloaded by native module initialization") + } + _ClassElementDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassElementDecoratorsConst was not overloaded by native module initialization") + } + _ClassElementIsComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassElementIsComputedConst was not overloaded by native module initialization") + } + _ClassElementAddDecorator(context: KNativePointer, receiver: KNativePointer, decorator: KNativePointer): void { + throw new Error("'ClassElementAddDecorator was not overloaded by native module initialization") + } + _ClassElementToPrivateFieldKindConst(context: KNativePointer, receiver: KNativePointer, isStatic: KBoolean): KInt { + throw new Error("'ClassElementToPrivateFieldKindConst was not overloaded by native module initialization") + } + _CreateTSImportType(context: KNativePointer, param: KNativePointer, typeParams: KNativePointer, qualifier: KNativePointer, isTypeof: KBoolean): KNativePointer { + throw new Error("'CreateTSImportType was not overloaded by native module initialization") + } + _UpdateTSImportType(context: KNativePointer, original: KNativePointer, param: KNativePointer, typeParams: KNativePointer, qualifier: KNativePointer, isTypeof: KBoolean): KNativePointer { + throw new Error("'UpdateTSImportType was not overloaded by native module initialization") + } + _TSImportTypeParamConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSImportTypeParamConst was not overloaded by native module initialization") + } + _TSImportTypeTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSImportTypeTypeParamsConst was not overloaded by native module initialization") + } + _TSImportTypeQualifierConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSImportTypeQualifierConst was not overloaded by native module initialization") + } + _TSImportTypeIsTypeofConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSImportTypeIsTypeofConst was not overloaded by native module initialization") + } + _CreateTaggedTemplateExpression(context: KNativePointer, tag: KNativePointer, quasi: KNativePointer, typeParams: KNativePointer): KNativePointer { + throw new Error("'CreateTaggedTemplateExpression was not overloaded by native module initialization") + } + _UpdateTaggedTemplateExpression(context: KNativePointer, original: KNativePointer, tag: KNativePointer, quasi: KNativePointer, typeParams: KNativePointer): KNativePointer { + throw new Error("'UpdateTaggedTemplateExpression was not overloaded by native module initialization") + } + _TaggedTemplateExpressionTagConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TaggedTemplateExpressionTagConst was not overloaded by native module initialization") + } + _TaggedTemplateExpressionQuasiConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TaggedTemplateExpressionQuasiConst was not overloaded by native module initialization") + } + _TaggedTemplateExpressionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TaggedTemplateExpressionTypeParamsConst was not overloaded by native module initialization") + } + _CreateFunctionDeclaration(context: KNativePointer, func: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt, isAnonymous: KBoolean): KNativePointer { + throw new Error("'CreateFunctionDeclaration was not overloaded by native module initialization") + } + _UpdateFunctionDeclaration(context: KNativePointer, original: KNativePointer, func: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt, isAnonymous: KBoolean): KNativePointer { + throw new Error("'UpdateFunctionDeclaration was not overloaded by native module initialization") + } + _CreateFunctionDeclaration1(context: KNativePointer, func: KNativePointer, isAnonymous: KBoolean): KNativePointer { + throw new Error("'CreateFunctionDeclaration1 was not overloaded by native module initialization") + } + _UpdateFunctionDeclaration1(context: KNativePointer, original: KNativePointer, func: KNativePointer, isAnonymous: KBoolean): KNativePointer { + throw new Error("'UpdateFunctionDeclaration1 was not overloaded by native module initialization") + } + _FunctionDeclarationFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionDeclarationFunction was not overloaded by native module initialization") + } + _FunctionDeclarationIsAnonymousConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'FunctionDeclarationIsAnonymousConst was not overloaded by native module initialization") + } + _FunctionDeclarationFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionDeclarationFunctionConst was not overloaded by native module initialization") + } + _FunctionDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionDeclarationAnnotations was not overloaded by native module initialization") + } + _FunctionDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionDeclarationAnnotationsConst was not overloaded by native module initialization") + } + _FunctionDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'FunctionDeclarationSetAnnotations was not overloaded by native module initialization") + } + _CreateETSTypeReference(context: KNativePointer, part: KNativePointer): KNativePointer { + throw new Error("'CreateETSTypeReference was not overloaded by native module initialization") + } + _UpdateETSTypeReference(context: KNativePointer, original: KNativePointer, part: KNativePointer): KNativePointer { + throw new Error("'UpdateETSTypeReference was not overloaded by native module initialization") + } + _ETSTypeReferencePart(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSTypeReferencePart was not overloaded by native module initialization") + } + _ETSTypeReferencePartConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSTypeReferencePartConst was not overloaded by native module initialization") + } + _ETSTypeReferenceBaseNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSTypeReferenceBaseNameConst was not overloaded by native module initialization") + } + _CreateTSTypeReference(context: KNativePointer, typeName: KNativePointer, typeParams: KNativePointer): KNativePointer { + throw new Error("'CreateTSTypeReference was not overloaded by native module initialization") + } + _UpdateTSTypeReference(context: KNativePointer, original: KNativePointer, typeName: KNativePointer, typeParams: KNativePointer): KNativePointer { + throw new Error("'UpdateTSTypeReference was not overloaded by native module initialization") + } + _TSTypeReferenceTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeReferenceTypeParamsConst was not overloaded by native module initialization") + } + _TSTypeReferenceTypeNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeReferenceTypeNameConst was not overloaded by native module initialization") + } + _TSTypeReferenceBaseNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeReferenceBaseNameConst was not overloaded by native module initialization") + } + _CreateImportSource(context: KNativePointer, source: KNativePointer, resolvedSource: KNativePointer, hasDecl: KBoolean): KNativePointer { + throw new Error("'CreateImportSource was not overloaded by native module initialization") + } + _ImportSourceSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportSourceSourceConst was not overloaded by native module initialization") + } + _ImportSourceSource(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportSourceSource was not overloaded by native module initialization") + } + _ImportSourceResolvedSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportSourceResolvedSourceConst was not overloaded by native module initialization") + } + _ImportSourceResolvedSource(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportSourceResolvedSource was not overloaded by native module initialization") + } + _ImportSourceHasDeclConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ImportSourceHasDeclConst was not overloaded by native module initialization") + } + _CreateNamedType(context: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("'CreateNamedType was not overloaded by native module initialization") + } + _UpdateNamedType(context: KNativePointer, original: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("'UpdateNamedType was not overloaded by native module initialization") + } + _NamedTypeNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'NamedTypeNameConst was not overloaded by native module initialization") + } + _NamedTypeTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'NamedTypeTypeParamsConst was not overloaded by native module initialization") + } + _NamedTypeIsNullableConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'NamedTypeIsNullableConst was not overloaded by native module initialization") + } + _NamedTypeSetNullable(context: KNativePointer, receiver: KNativePointer, nullable: KBoolean): void { + throw new Error("'NamedTypeSetNullable was not overloaded by native module initialization") + } + _NamedTypeSetNext(context: KNativePointer, receiver: KNativePointer, next: KNativePointer): void { + throw new Error("'NamedTypeSetNext was not overloaded by native module initialization") + } + _NamedTypeSetTypeParams(context: KNativePointer, receiver: KNativePointer, typeParams: KNativePointer): void { + throw new Error("'NamedTypeSetTypeParams was not overloaded by native module initialization") + } + _NumberLiteralStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'NumberLiteralStrConst was not overloaded by native module initialization") + } + _CreateTSFunctionType(context: KNativePointer, signature: KNativePointer): KNativePointer { + throw new Error("'CreateTSFunctionType was not overloaded by native module initialization") + } + _UpdateTSFunctionType(context: KNativePointer, original: KNativePointer, signature: KNativePointer): KNativePointer { + throw new Error("'UpdateTSFunctionType was not overloaded by native module initialization") + } + _TSFunctionTypeTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSFunctionTypeTypeParamsConst was not overloaded by native module initialization") + } + _TSFunctionTypeTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSFunctionTypeTypeParams was not overloaded by native module initialization") + } + _TSFunctionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSFunctionTypeParamsConst was not overloaded by native module initialization") + } + _TSFunctionTypeReturnTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSFunctionTypeReturnTypeConst was not overloaded by native module initialization") + } + _TSFunctionTypeReturnType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSFunctionTypeReturnType was not overloaded by native module initialization") + } + _TSFunctionTypeSetNullable(context: KNativePointer, receiver: KNativePointer, nullable: KBoolean): void { + throw new Error("'TSFunctionTypeSetNullable was not overloaded by native module initialization") + } + _CreateTemplateElement(context: KNativePointer): KNativePointer { + throw new Error("'CreateTemplateElement was not overloaded by native module initialization") + } + _UpdateTemplateElement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTemplateElement was not overloaded by native module initialization") + } + _CreateTemplateElement1(context: KNativePointer, raw: KStringPtr, cooked: KStringPtr): KNativePointer { + throw new Error("'CreateTemplateElement1 was not overloaded by native module initialization") + } + _UpdateTemplateElement1(context: KNativePointer, original: KNativePointer, raw: KStringPtr, cooked: KStringPtr): KNativePointer { + throw new Error("'UpdateTemplateElement1 was not overloaded by native module initialization") + } + _TemplateElementRawConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'TemplateElementRawConst was not overloaded by native module initialization") + } + _TemplateElementCookedConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'TemplateElementCookedConst was not overloaded by native module initialization") + } + _CreateTSInterfaceDeclaration(context: KNativePointer, _extends: BigUint64Array, _extendsSequenceLength: KUInt, id: KNativePointer, typeParams: KNativePointer, body: KNativePointer, isStatic: KBoolean, isExternal: KBoolean): KNativePointer { + throw new Error("'CreateTSInterfaceDeclaration was not overloaded by native module initialization") + } + _UpdateTSInterfaceDeclaration(context: KNativePointer, original: KNativePointer, _extends: BigUint64Array, _extendsSequenceLength: KUInt, id: KNativePointer, typeParams: KNativePointer, body: KNativePointer, isStatic: KBoolean, isExternal: KBoolean): KNativePointer { + throw new Error("'UpdateTSInterfaceDeclaration was not overloaded by native module initialization") + } + _TSInterfaceDeclarationBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationBody was not overloaded by native module initialization") + } + _TSInterfaceDeclarationBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationBodyConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationId was not overloaded by native module initialization") + } + _TSInterfaceDeclarationIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationIdConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationInternalNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'TSInterfaceDeclarationInternalNameConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationSetInternalName(context: KNativePointer, receiver: KNativePointer, internalName: KStringPtr): void { + throw new Error("'TSInterfaceDeclarationSetInternalName was not overloaded by native module initialization") + } + _TSInterfaceDeclarationIsStaticConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSInterfaceDeclarationIsStaticConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationIsFromExternalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSInterfaceDeclarationIsFromExternalConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationTypeParamsConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationTypeParams was not overloaded by native module initialization") + } + _TSInterfaceDeclarationExtends(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationExtends was not overloaded by native module initialization") + } + _TSInterfaceDeclarationExtendsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationExtendsConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationDecoratorsConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationGetAnonClass(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationGetAnonClass was not overloaded by native module initialization") + } + _TSInterfaceDeclarationGetAnonClassConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationGetAnonClassConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationSetAnonClass(context: KNativePointer, receiver: KNativePointer, anonClass: KNativePointer): void { + throw new Error("'TSInterfaceDeclarationSetAnonClass was not overloaded by native module initialization") + } + _TSInterfaceDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationAnnotations was not overloaded by native module initialization") + } + _TSInterfaceDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceDeclarationAnnotationsConst was not overloaded by native module initialization") + } + _TSInterfaceDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'TSInterfaceDeclarationSetAnnotations was not overloaded by native module initialization") + } + _CreateVariableDeclaration(context: KNativePointer, kind: KInt, declarators: BigUint64Array, declaratorsSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateVariableDeclaration was not overloaded by native module initialization") + } + _UpdateVariableDeclaration(context: KNativePointer, original: KNativePointer, kind: KInt, declarators: BigUint64Array, declaratorsSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateVariableDeclaration was not overloaded by native module initialization") + } + _VariableDeclarationDeclaratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'VariableDeclarationDeclaratorsConst was not overloaded by native module initialization") + } + _VariableDeclarationKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'VariableDeclarationKindConst was not overloaded by native module initialization") + } + _VariableDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'VariableDeclarationDecoratorsConst was not overloaded by native module initialization") + } + _VariableDeclarationGetDeclaratorByNameConst(context: KNativePointer, receiver: KNativePointer, name: KStringPtr): KNativePointer { + throw new Error("'VariableDeclarationGetDeclaratorByNameConst was not overloaded by native module initialization") + } + _VariableDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'VariableDeclarationAnnotations was not overloaded by native module initialization") + } + _VariableDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'VariableDeclarationAnnotationsConst was not overloaded by native module initialization") + } + _VariableDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'VariableDeclarationSetAnnotations was not overloaded by native module initialization") + } + _CreateUndefinedLiteral(context: KNativePointer): KNativePointer { + throw new Error("'CreateUndefinedLiteral was not overloaded by native module initialization") + } + _UpdateUndefinedLiteral(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateUndefinedLiteral was not overloaded by native module initialization") + } + _CreateMemberExpression(context: KNativePointer, object_arg: KNativePointer, property: KNativePointer, kind: KInt, computed: KBoolean, optional_arg: KBoolean): KNativePointer { + throw new Error("'CreateMemberExpression was not overloaded by native module initialization") + } + _UpdateMemberExpression(context: KNativePointer, original: KNativePointer, object_arg: KNativePointer, property: KNativePointer, kind: KInt, computed: KBoolean, optional_arg: KBoolean): KNativePointer { + throw new Error("'UpdateMemberExpression was not overloaded by native module initialization") + } + _MemberExpressionObject(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MemberExpressionObject was not overloaded by native module initialization") + } + _MemberExpressionObjectConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MemberExpressionObjectConst was not overloaded by native module initialization") + } + _MemberExpressionSetObject(context: KNativePointer, receiver: KNativePointer, object_arg: KNativePointer): void { + throw new Error("'MemberExpressionSetObject was not overloaded by native module initialization") + } + _MemberExpressionSetProperty(context: KNativePointer, receiver: KNativePointer, prop: KNativePointer): void { + throw new Error("'MemberExpressionSetProperty was not overloaded by native module initialization") + } + _MemberExpressionProperty(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MemberExpressionProperty was not overloaded by native module initialization") + } + _MemberExpressionPropertyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MemberExpressionPropertyConst was not overloaded by native module initialization") + } + _MemberExpressionIsComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'MemberExpressionIsComputedConst was not overloaded by native module initialization") + } + _MemberExpressionKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'MemberExpressionKindConst was not overloaded by native module initialization") + } + _MemberExpressionAddMemberKind(context: KNativePointer, receiver: KNativePointer, kind: KInt): void { + throw new Error("'MemberExpressionAddMemberKind was not overloaded by native module initialization") + } + _MemberExpressionHasMemberKindConst(context: KNativePointer, receiver: KNativePointer, kind: KInt): KBoolean { + throw new Error("'MemberExpressionHasMemberKindConst was not overloaded by native module initialization") + } + _MemberExpressionRemoveMemberKind(context: KNativePointer, receiver: KNativePointer, kind: KInt): void { + throw new Error("'MemberExpressionRemoveMemberKind was not overloaded by native module initialization") + } + _MemberExpressionIsIgnoreBoxConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'MemberExpressionIsIgnoreBoxConst was not overloaded by native module initialization") + } + _MemberExpressionSetIgnoreBox(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'MemberExpressionSetIgnoreBox was not overloaded by native module initialization") + } + _MemberExpressionIsPrivateReferenceConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'MemberExpressionIsPrivateReferenceConst was not overloaded by native module initialization") + } + _CreateTSClassImplements(context: KNativePointer, expression: KNativePointer, typeParameters: KNativePointer): KNativePointer { + throw new Error("'CreateTSClassImplements was not overloaded by native module initialization") + } + _UpdateTSClassImplements(context: KNativePointer, original: KNativePointer, expression: KNativePointer, typeParameters: KNativePointer): KNativePointer { + throw new Error("'UpdateTSClassImplements was not overloaded by native module initialization") + } + _CreateTSClassImplements1(context: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("'CreateTSClassImplements1 was not overloaded by native module initialization") + } + _UpdateTSClassImplements1(context: KNativePointer, original: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("'UpdateTSClassImplements1 was not overloaded by native module initialization") + } + _TSClassImplementsExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSClassImplementsExpr was not overloaded by native module initialization") + } + _TSClassImplementsExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSClassImplementsExprConst was not overloaded by native module initialization") + } + _TSClassImplementsTypeParametersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSClassImplementsTypeParametersConst was not overloaded by native module initialization") + } + _CreateTSObjectKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSObjectKeyword was not overloaded by native module initialization") + } + _UpdateTSObjectKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSObjectKeyword was not overloaded by native module initialization") + } + _CreateETSUnionTypeIr(context: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateETSUnionTypeIr was not overloaded by native module initialization") + } + _UpdateETSUnionTypeIr(context: KNativePointer, original: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateETSUnionTypeIr was not overloaded by native module initialization") + } + _ETSUnionTypeIrTypesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSUnionTypeIrTypesConst was not overloaded by native module initialization") + } + _CreateTSPropertySignature(context: KNativePointer, key: KNativePointer, typeAnnotation: KNativePointer, computed: KBoolean, optional_arg: KBoolean, readonly_arg: KBoolean): KNativePointer { + throw new Error("'CreateTSPropertySignature was not overloaded by native module initialization") + } + _UpdateTSPropertySignature(context: KNativePointer, original: KNativePointer, key: KNativePointer, typeAnnotation: KNativePointer, computed: KBoolean, optional_arg: KBoolean, readonly_arg: KBoolean): KNativePointer { + throw new Error("'UpdateTSPropertySignature was not overloaded by native module initialization") + } + _TSPropertySignatureKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSPropertySignatureKeyConst was not overloaded by native module initialization") + } + _TSPropertySignatureKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSPropertySignatureKey was not overloaded by native module initialization") + } + _TSPropertySignatureComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSPropertySignatureComputedConst was not overloaded by native module initialization") + } + _TSPropertySignatureOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSPropertySignatureOptionalConst was not overloaded by native module initialization") + } + _TSPropertySignatureReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSPropertySignatureReadonlyConst was not overloaded by native module initialization") + } + _TSPropertySignatureTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSPropertySignatureTypeAnnotationConst was not overloaded by native module initialization") + } + _TSPropertySignatureSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'TSPropertySignatureSetTsTypeAnnotation was not overloaded by native module initialization") + } + _CreateTSConditionalType(context: KNativePointer, checkType: KNativePointer, extendsType: KNativePointer, trueType: KNativePointer, falseType: KNativePointer): KNativePointer { + throw new Error("'CreateTSConditionalType was not overloaded by native module initialization") + } + _UpdateTSConditionalType(context: KNativePointer, original: KNativePointer, checkType: KNativePointer, extendsType: KNativePointer, trueType: KNativePointer, falseType: KNativePointer): KNativePointer { + throw new Error("'UpdateTSConditionalType was not overloaded by native module initialization") + } + _TSConditionalTypeCheckTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSConditionalTypeCheckTypeConst was not overloaded by native module initialization") + } + _TSConditionalTypeExtendsTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSConditionalTypeExtendsTypeConst was not overloaded by native module initialization") + } + _TSConditionalTypeTrueTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSConditionalTypeTrueTypeConst was not overloaded by native module initialization") + } + _TSConditionalTypeFalseTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSConditionalTypeFalseTypeConst was not overloaded by native module initialization") + } + _CreateTSLiteralType(context: KNativePointer, literal: KNativePointer): KNativePointer { + throw new Error("'CreateTSLiteralType was not overloaded by native module initialization") + } + _UpdateTSLiteralType(context: KNativePointer, original: KNativePointer, literal: KNativePointer): KNativePointer { + throw new Error("'UpdateTSLiteralType was not overloaded by native module initialization") + } + _TSLiteralTypeLiteralConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSLiteralTypeLiteralConst was not overloaded by native module initialization") + } + _CreateTSTypeAliasDeclaration(context: KNativePointer, id: KNativePointer, typeParams: KNativePointer, typeAnnotation: KNativePointer): KNativePointer { + throw new Error("'CreateTSTypeAliasDeclaration was not overloaded by native module initialization") + } + _UpdateTSTypeAliasDeclaration(context: KNativePointer, original: KNativePointer, id: KNativePointer, typeParams: KNativePointer, typeAnnotation: KNativePointer): KNativePointer { + throw new Error("'UpdateTSTypeAliasDeclaration was not overloaded by native module initialization") + } + _CreateTSTypeAliasDeclaration1(context: KNativePointer, id: KNativePointer): KNativePointer { + throw new Error("'CreateTSTypeAliasDeclaration1 was not overloaded by native module initialization") + } + _UpdateTSTypeAliasDeclaration1(context: KNativePointer, original: KNativePointer, id: KNativePointer): KNativePointer { + throw new Error("'UpdateTSTypeAliasDeclaration1 was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeAliasDeclarationId was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeAliasDeclarationIdConst was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeAliasDeclarationTypeParamsConst was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeAliasDeclarationDecoratorsConst was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationSetTypeParameters(context: KNativePointer, receiver: KNativePointer, typeParams: KNativePointer): void { + throw new Error("'TSTypeAliasDeclarationSetTypeParameters was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeAliasDeclarationAnnotations was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeAliasDeclarationAnnotationsConst was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'TSTypeAliasDeclarationSetAnnotations was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeAliasDeclarationTypeAnnotationConst was not overloaded by native module initialization") + } + _TSTypeAliasDeclarationSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'TSTypeAliasDeclarationSetTsTypeAnnotation was not overloaded by native module initialization") + } + _CreateDebuggerStatement(context: KNativePointer): KNativePointer { + throw new Error("'CreateDebuggerStatement was not overloaded by native module initialization") + } + _UpdateDebuggerStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateDebuggerStatement was not overloaded by native module initialization") + } + _CreateReturnStatement(context: KNativePointer): KNativePointer { + throw new Error("'CreateReturnStatement was not overloaded by native module initialization") + } + _UpdateReturnStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateReturnStatement was not overloaded by native module initialization") + } + _CreateReturnStatement1(context: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("'CreateReturnStatement1 was not overloaded by native module initialization") + } + _UpdateReturnStatement1(context: KNativePointer, original: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("'UpdateReturnStatement1 was not overloaded by native module initialization") + } + _ReturnStatementArgument(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ReturnStatementArgument was not overloaded by native module initialization") + } + _ReturnStatementArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ReturnStatementArgumentConst was not overloaded by native module initialization") + } + _ReturnStatementSetArgument(context: KNativePointer, receiver: KNativePointer, arg: KNativePointer): void { + throw new Error("'ReturnStatementSetArgument was not overloaded by native module initialization") + } + _CreateExportDefaultDeclaration(context: KNativePointer, decl: KNativePointer, exportEquals: KBoolean): KNativePointer { + throw new Error("'CreateExportDefaultDeclaration was not overloaded by native module initialization") + } + _UpdateExportDefaultDeclaration(context: KNativePointer, original: KNativePointer, decl: KNativePointer, exportEquals: KBoolean): KNativePointer { + throw new Error("'UpdateExportDefaultDeclaration was not overloaded by native module initialization") + } + _ExportDefaultDeclarationDecl(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExportDefaultDeclarationDecl was not overloaded by native module initialization") + } + _ExportDefaultDeclarationDeclConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExportDefaultDeclarationDeclConst was not overloaded by native module initialization") + } + _ExportDefaultDeclarationIsExportEqualsConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ExportDefaultDeclarationIsExportEqualsConst was not overloaded by native module initialization") + } + _CreateScriptFunction(context: KNativePointer, databody: KNativePointer, datasignature: KNativePointer, datafuncFlags: KInt, dataflags: KInt): KNativePointer { + throw new Error("'CreateScriptFunction was not overloaded by native module initialization") + } + _UpdateScriptFunction(context: KNativePointer, original: KNativePointer, databody: KNativePointer, datasignature: KNativePointer, datafuncFlags: KInt, dataflags: KInt): KNativePointer { + throw new Error("'UpdateScriptFunction was not overloaded by native module initialization") + } + _ScriptFunctionIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionIdConst was not overloaded by native module initialization") + } + _ScriptFunctionId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionId was not overloaded by native module initialization") + } + _ScriptFunctionParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionParamsConst was not overloaded by native module initialization") + } + _ScriptFunctionParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionParams was not overloaded by native module initialization") + } + _ScriptFunctionReturnStatementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionReturnStatementsConst was not overloaded by native module initialization") + } + _ScriptFunctionReturnStatements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionReturnStatements was not overloaded by native module initialization") + } + _ScriptFunctionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionTypeParamsConst was not overloaded by native module initialization") + } + _ScriptFunctionTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionTypeParams was not overloaded by native module initialization") + } + _ScriptFunctionBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionBodyConst was not overloaded by native module initialization") + } + _ScriptFunctionBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionBody was not overloaded by native module initialization") + } + _ScriptFunctionAddReturnStatement(context: KNativePointer, receiver: KNativePointer, returnStatement: KNativePointer): void { + throw new Error("'ScriptFunctionAddReturnStatement was not overloaded by native module initialization") + } + _ScriptFunctionSetBody(context: KNativePointer, receiver: KNativePointer, body: KNativePointer): void { + throw new Error("'ScriptFunctionSetBody was not overloaded by native module initialization") + } + _ScriptFunctionReturnTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionReturnTypeAnnotationConst was not overloaded by native module initialization") + } + _ScriptFunctionReturnTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionReturnTypeAnnotation was not overloaded by native module initialization") + } + _ScriptFunctionSetReturnTypeAnnotation(context: KNativePointer, receiver: KNativePointer, node: KNativePointer): void { + throw new Error("'ScriptFunctionSetReturnTypeAnnotation was not overloaded by native module initialization") + } + _ScriptFunctionIsEntryPointConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsEntryPointConst was not overloaded by native module initialization") + } + _ScriptFunctionIsGeneratorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsGeneratorConst was not overloaded by native module initialization") + } + _ScriptFunctionIsAsyncFuncConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsAsyncFuncConst was not overloaded by native module initialization") + } + _ScriptFunctionIsAsyncImplFuncConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsAsyncImplFuncConst was not overloaded by native module initialization") + } + _ScriptFunctionIsArrowConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsArrowConst was not overloaded by native module initialization") + } + _ScriptFunctionIsOverloadConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsOverloadConst was not overloaded by native module initialization") + } + _ScriptFunctionIsExternalOverloadConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsExternalOverloadConst was not overloaded by native module initialization") + } + _ScriptFunctionIsConstructorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsConstructorConst was not overloaded by native module initialization") + } + _ScriptFunctionIsGetterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsGetterConst was not overloaded by native module initialization") + } + _ScriptFunctionIsSetterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsSetterConst was not overloaded by native module initialization") + } + _ScriptFunctionIsExtensionAccessorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsExtensionAccessorConst was not overloaded by native module initialization") + } + _ScriptFunctionIsMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsMethodConst was not overloaded by native module initialization") + } + _ScriptFunctionIsProxyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsProxyConst was not overloaded by native module initialization") + } + _ScriptFunctionIsStaticBlockConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsStaticBlockConst was not overloaded by native module initialization") + } + _ScriptFunctionIsEnumConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsEnumConst was not overloaded by native module initialization") + } + _ScriptFunctionIsHiddenConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsHiddenConst was not overloaded by native module initialization") + } + _ScriptFunctionIsExternalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsExternalConst was not overloaded by native module initialization") + } + _ScriptFunctionIsImplicitSuperCallNeededConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsImplicitSuperCallNeededConst was not overloaded by native module initialization") + } + _ScriptFunctionHasBodyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionHasBodyConst was not overloaded by native module initialization") + } + _ScriptFunctionHasRestParameterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionHasRestParameterConst was not overloaded by native module initialization") + } + _ScriptFunctionHasReturnStatementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionHasReturnStatementConst was not overloaded by native module initialization") + } + _ScriptFunctionHasThrowStatementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionHasThrowStatementConst was not overloaded by native module initialization") + } + _ScriptFunctionIsThrowingConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsThrowingConst was not overloaded by native module initialization") + } + _ScriptFunctionIsRethrowingConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsRethrowingConst was not overloaded by native module initialization") + } + _ScriptFunctionIsDynamicConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsDynamicConst was not overloaded by native module initialization") + } + _ScriptFunctionIsExtensionMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionIsExtensionMethodConst was not overloaded by native module initialization") + } + _ScriptFunctionFlagsConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'ScriptFunctionFlagsConst was not overloaded by native module initialization") + } + _ScriptFunctionHasReceiverConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ScriptFunctionHasReceiverConst was not overloaded by native module initialization") + } + _ScriptFunctionSetIdent(context: KNativePointer, receiver: KNativePointer, id: KNativePointer): void { + throw new Error("'ScriptFunctionSetIdent was not overloaded by native module initialization") + } + _ScriptFunctionAddFlag(context: KNativePointer, receiver: KNativePointer, flags: KInt): void { + throw new Error("'ScriptFunctionAddFlag was not overloaded by native module initialization") + } + _ScriptFunctionAddModifier(context: KNativePointer, receiver: KNativePointer, flags: KInt): void { + throw new Error("'ScriptFunctionAddModifier was not overloaded by native module initialization") + } + _ScriptFunctionFormalParamsLengthConst(context: KNativePointer, receiver: KNativePointer): KUInt { + throw new Error("'ScriptFunctionFormalParamsLengthConst was not overloaded by native module initialization") + } + _ScriptFunctionAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionAnnotations was not overloaded by native module initialization") + } + _ScriptFunctionAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ScriptFunctionAnnotationsConst was not overloaded by native module initialization") + } + _ScriptFunctionSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'ScriptFunctionSetAnnotations was not overloaded by native module initialization") + } + _CreateClassDefinition(context: KNativePointer, ident: KNativePointer, typeParams: KNativePointer, superTypeParams: KNativePointer, _implements: BigUint64Array, _implementsSequenceLength: KUInt, ctor: KNativePointer, superClass: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("'CreateClassDefinition was not overloaded by native module initialization") + } + _UpdateClassDefinition(context: KNativePointer, original: KNativePointer, ident: KNativePointer, typeParams: KNativePointer, superTypeParams: KNativePointer, _implements: BigUint64Array, _implementsSequenceLength: KUInt, ctor: KNativePointer, superClass: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("'UpdateClassDefinition was not overloaded by native module initialization") + } + _CreateClassDefinition1(context: KNativePointer, ident: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("'CreateClassDefinition1 was not overloaded by native module initialization") + } + _UpdateClassDefinition1(context: KNativePointer, original: KNativePointer, ident: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("'UpdateClassDefinition1 was not overloaded by native module initialization") + } + _CreateClassDefinition2(context: KNativePointer, ident: KNativePointer, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("'CreateClassDefinition2 was not overloaded by native module initialization") + } + _UpdateClassDefinition2(context: KNativePointer, original: KNativePointer, ident: KNativePointer, modifiers: KInt, flags: KInt): KNativePointer { + throw new Error("'UpdateClassDefinition2 was not overloaded by native module initialization") + } + _ClassDefinitionIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionIdentConst was not overloaded by native module initialization") + } + _ClassDefinitionIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionIdent was not overloaded by native module initialization") + } + _ClassDefinitionSetIdent(context: KNativePointer, receiver: KNativePointer, ident: KNativePointer): void { + throw new Error("'ClassDefinitionSetIdent was not overloaded by native module initialization") + } + _ClassDefinitionInternalNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ClassDefinitionInternalNameConst was not overloaded by native module initialization") + } + _ClassDefinitionSetInternalName(context: KNativePointer, receiver: KNativePointer, internalName: KStringPtr): void { + throw new Error("'ClassDefinitionSetInternalName was not overloaded by native module initialization") + } + _ClassDefinitionSuper(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionSuper was not overloaded by native module initialization") + } + _ClassDefinitionSuperConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionSuperConst was not overloaded by native module initialization") + } + _ClassDefinitionSetSuper(context: KNativePointer, receiver: KNativePointer, superClass: KNativePointer): void { + throw new Error("'ClassDefinitionSetSuper was not overloaded by native module initialization") + } + _ClassDefinitionIsGlobalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsGlobalConst was not overloaded by native module initialization") + } + _ClassDefinitionIsLocalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsLocalConst was not overloaded by native module initialization") + } + _ClassDefinitionIsExternConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsExternConst was not overloaded by native module initialization") + } + _ClassDefinitionIsFromExternalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsFromExternalConst was not overloaded by native module initialization") + } + _ClassDefinitionIsInnerConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsInnerConst was not overloaded by native module initialization") + } + _ClassDefinitionIsGlobalInitializedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsGlobalInitializedConst was not overloaded by native module initialization") + } + _ClassDefinitionIsClassDefinitionCheckedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsClassDefinitionCheckedConst was not overloaded by native module initialization") + } + _ClassDefinitionIsAnonymousConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsAnonymousConst was not overloaded by native module initialization") + } + _ClassDefinitionIsNamespaceTransformedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsNamespaceTransformedConst was not overloaded by native module initialization") + } + _ClassDefinitionIsModuleConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionIsModuleConst was not overloaded by native module initialization") + } + _ClassDefinitionSetGlobalInitialized(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'ClassDefinitionSetGlobalInitialized was not overloaded by native module initialization") + } + _ClassDefinitionSetInnerModifier(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'ClassDefinitionSetInnerModifier was not overloaded by native module initialization") + } + _ClassDefinitionSetClassDefinitionChecked(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'ClassDefinitionSetClassDefinitionChecked was not overloaded by native module initialization") + } + _ClassDefinitionSetAnonymousModifier(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'ClassDefinitionSetAnonymousModifier was not overloaded by native module initialization") + } + _ClassDefinitionSetNamespaceTransformed(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'ClassDefinitionSetNamespaceTransformed was not overloaded by native module initialization") + } + _ClassDefinitionModifiersConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'ClassDefinitionModifiersConst was not overloaded by native module initialization") + } + _ClassDefinitionSetModifiers(context: KNativePointer, receiver: KNativePointer, modifiers: KInt): void { + throw new Error("'ClassDefinitionSetModifiers was not overloaded by native module initialization") + } + _ClassDefinitionAddProperties(context: KNativePointer, receiver: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt): void { + throw new Error("'ClassDefinitionAddProperties was not overloaded by native module initialization") + } + _ClassDefinitionBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionBody was not overloaded by native module initialization") + } + _ClassDefinitionBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionBodyConst was not overloaded by native module initialization") + } + _ClassDefinitionCtor(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionCtor was not overloaded by native module initialization") + } + _ClassDefinitionSetCtor(context: KNativePointer, receiver: KNativePointer, ctor: KNativePointer): void { + throw new Error("'ClassDefinitionSetCtor was not overloaded by native module initialization") + } + _ClassDefinitionImplements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionImplements was not overloaded by native module initialization") + } + _ClassDefinitionImplementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionImplementsConst was not overloaded by native module initialization") + } + _ClassDefinitionTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionTypeParamsConst was not overloaded by native module initialization") + } + _ClassDefinitionTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionTypeParams was not overloaded by native module initialization") + } + _ClassDefinitionSetTypeParams(context: KNativePointer, receiver: KNativePointer, typeParams: KNativePointer): void { + throw new Error("'ClassDefinitionSetTypeParams was not overloaded by native module initialization") + } + _ClassDefinitionSuperTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionSuperTypeParamsConst was not overloaded by native module initialization") + } + _ClassDefinitionSuperTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionSuperTypeParams was not overloaded by native module initialization") + } + _ClassDefinitionLocalTypeCounter(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'ClassDefinitionLocalTypeCounter was not overloaded by native module initialization") + } + _ClassDefinitionLocalIndexConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'ClassDefinitionLocalIndexConst was not overloaded by native module initialization") + } + _ClassDefinitionLocalPrefixConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ClassDefinitionLocalPrefixConst was not overloaded by native module initialization") + } + _ClassDefinitionSetOrigEnumDecl(context: KNativePointer, receiver: KNativePointer, enumDecl: KNativePointer): void { + throw new Error("'ClassDefinitionSetOrigEnumDecl was not overloaded by native module initialization") + } + _ClassDefinitionOrigEnumDeclConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionOrigEnumDeclConst was not overloaded by native module initialization") + } + _ClassDefinitionGetAnonClass(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionGetAnonClass was not overloaded by native module initialization") + } + _ClassDefinitionSetAnonClass(context: KNativePointer, receiver: KNativePointer, anonClass: KNativePointer): void { + throw new Error("'ClassDefinitionSetAnonClass was not overloaded by native module initialization") + } + _ClassDefinitionCtorConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionCtorConst was not overloaded by native module initialization") + } + _ClassDefinitionHasPrivateMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionHasPrivateMethodConst was not overloaded by native module initialization") + } + _ClassDefinitionHasComputedInstanceFieldConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ClassDefinitionHasComputedInstanceFieldConst was not overloaded by native module initialization") + } + _ClassDefinitionHasMatchingPrivateKeyConst(context: KNativePointer, receiver: KNativePointer, name: KStringPtr): KBoolean { + throw new Error("'ClassDefinitionHasMatchingPrivateKeyConst was not overloaded by native module initialization") + } + _ClassDefinitionAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionAnnotations was not overloaded by native module initialization") + } + _ClassDefinitionAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDefinitionAnnotationsConst was not overloaded by native module initialization") + } + _ClassDefinitionSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'ClassDefinitionSetAnnotations was not overloaded by native module initialization") + } + _CreateArrayExpression(context: KNativePointer, elements: BigUint64Array, elementsSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateArrayExpression was not overloaded by native module initialization") + } + _UpdateArrayExpression(context: KNativePointer, original: KNativePointer, elements: BigUint64Array, elementsSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateArrayExpression was not overloaded by native module initialization") + } + _CreateArrayExpression1(context: KNativePointer, nodeType: KInt, elements: BigUint64Array, elementsSequenceLength: KUInt, trailingComma: KBoolean): KNativePointer { + throw new Error("'CreateArrayExpression1 was not overloaded by native module initialization") + } + _UpdateArrayExpression1(context: KNativePointer, original: KNativePointer, nodeType: KInt, elements: BigUint64Array, elementsSequenceLength: KUInt, trailingComma: KBoolean): KNativePointer { + throw new Error("'UpdateArrayExpression1 was not overloaded by native module initialization") + } + _ArrayExpressionElementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrayExpressionElementsConst was not overloaded by native module initialization") + } + _ArrayExpressionElements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrayExpressionElements was not overloaded by native module initialization") + } + _ArrayExpressionSetElements(context: KNativePointer, receiver: KNativePointer, elements: BigUint64Array, elementsSequenceLength: KUInt): void { + throw new Error("'ArrayExpressionSetElements was not overloaded by native module initialization") + } + _ArrayExpressionIsDeclarationConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ArrayExpressionIsDeclarationConst was not overloaded by native module initialization") + } + _ArrayExpressionIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ArrayExpressionIsOptionalConst was not overloaded by native module initialization") + } + _ArrayExpressionSetDeclaration(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'ArrayExpressionSetDeclaration was not overloaded by native module initialization") + } + _ArrayExpressionSetOptional(context: KNativePointer, receiver: KNativePointer, optional_arg: KBoolean): void { + throw new Error("'ArrayExpressionSetOptional was not overloaded by native module initialization") + } + _ArrayExpressionDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrayExpressionDecoratorsConst was not overloaded by native module initialization") + } + _ArrayExpressionConvertibleToArrayPattern(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ArrayExpressionConvertibleToArrayPattern was not overloaded by native module initialization") + } + _ArrayExpressionValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrayExpressionValidateExpression was not overloaded by native module initialization") + } + _ArrayExpressionHandleNestedArrayExpression(context: KNativePointer, receiver: KNativePointer, currentElement: KNativePointer, isPreferredTuple: KBoolean, idx: KUInt): KBoolean { + throw new Error("'ArrayExpressionHandleNestedArrayExpression was not overloaded by native module initialization") + } + _ArrayExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrayExpressionTypeAnnotationConst was not overloaded by native module initialization") + } + _ArrayExpressionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'ArrayExpressionSetTsTypeAnnotation was not overloaded by native module initialization") + } + _CreateTSInterfaceBody(context: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt): KNativePointer { + throw new Error("'CreateTSInterfaceBody was not overloaded by native module initialization") + } + _UpdateTSInterfaceBody(context: KNativePointer, original: KNativePointer, body: BigUint64Array, bodySequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateTSInterfaceBody was not overloaded by native module initialization") + } + _TSInterfaceBodyBodyPtr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceBodyBodyPtr was not overloaded by native module initialization") + } + _TSInterfaceBodyBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceBodyBody was not overloaded by native module initialization") + } + _TSInterfaceBodyBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceBodyBodyConst was not overloaded by native module initialization") + } + _CreateTSTypeQuery(context: KNativePointer, exprName: KNativePointer): KNativePointer { + throw new Error("'CreateTSTypeQuery was not overloaded by native module initialization") + } + _UpdateTSTypeQuery(context: KNativePointer, original: KNativePointer, exprName: KNativePointer): KNativePointer { + throw new Error("'UpdateTSTypeQuery was not overloaded by native module initialization") + } + _TSTypeQueryExprNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeQueryExprNameConst was not overloaded by native module initialization") + } + _CreateTSBigintKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSBigintKeyword was not overloaded by native module initialization") + } + _UpdateTSBigintKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSBigintKeyword was not overloaded by native module initialization") + } + _CreateProperty(context: KNativePointer, key: KNativePointer, value: KNativePointer): KNativePointer { + throw new Error("'CreateProperty was not overloaded by native module initialization") + } + _UpdateProperty(context: KNativePointer, original: KNativePointer, key: KNativePointer, value: KNativePointer): KNativePointer { + throw new Error("'UpdateProperty was not overloaded by native module initialization") + } + _CreateProperty1(context: KNativePointer, kind: KInt, key: KNativePointer, value: KNativePointer, isMethod: KBoolean, isComputed: KBoolean): KNativePointer { + throw new Error("'CreateProperty1 was not overloaded by native module initialization") + } + _UpdateProperty1(context: KNativePointer, original: KNativePointer, kind: KInt, key: KNativePointer, value: KNativePointer, isMethod: KBoolean, isComputed: KBoolean): KNativePointer { + throw new Error("'UpdateProperty1 was not overloaded by native module initialization") + } + _PropertyKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'PropertyKey was not overloaded by native module initialization") + } + _PropertyKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'PropertyKeyConst was not overloaded by native module initialization") + } + _PropertyValueConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'PropertyValueConst was not overloaded by native module initialization") + } + _PropertyValue(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'PropertyValue was not overloaded by native module initialization") + } + _PropertyKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'PropertyKindConst was not overloaded by native module initialization") + } + _PropertyIsMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'PropertyIsMethodConst was not overloaded by native module initialization") + } + _PropertyIsShorthandConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'PropertyIsShorthandConst was not overloaded by native module initialization") + } + _PropertyIsComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'PropertyIsComputedConst was not overloaded by native module initialization") + } + _PropertyIsAccessorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'PropertyIsAccessorConst was not overloaded by native module initialization") + } + _PropertyIsAccessorKind(context: KNativePointer, receiver: KNativePointer, kind: KInt): KBoolean { + throw new Error("'PropertyIsAccessorKind was not overloaded by native module initialization") + } + _PropertyConvertibleToPatternProperty(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'PropertyConvertibleToPatternProperty was not overloaded by native module initialization") + } + _PropertyValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'PropertyValidateExpression was not overloaded by native module initialization") + } + _CreateVariableDeclarator(context: KNativePointer, flag: KInt, ident: KNativePointer): KNativePointer { + throw new Error("'CreateVariableDeclarator was not overloaded by native module initialization") + } + _UpdateVariableDeclarator(context: KNativePointer, original: KNativePointer, flag: KInt, ident: KNativePointer): KNativePointer { + throw new Error("'UpdateVariableDeclarator was not overloaded by native module initialization") + } + _CreateVariableDeclarator1(context: KNativePointer, flag: KInt, ident: KNativePointer, init: KNativePointer): KNativePointer { + throw new Error("'CreateVariableDeclarator1 was not overloaded by native module initialization") + } + _UpdateVariableDeclarator1(context: KNativePointer, original: KNativePointer, flag: KInt, ident: KNativePointer, init: KNativePointer): KNativePointer { + throw new Error("'UpdateVariableDeclarator1 was not overloaded by native module initialization") + } + _VariableDeclaratorInit(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'VariableDeclaratorInit was not overloaded by native module initialization") + } + _VariableDeclaratorInitConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'VariableDeclaratorInitConst was not overloaded by native module initialization") + } + _VariableDeclaratorSetInit(context: KNativePointer, receiver: KNativePointer, init: KNativePointer): void { + throw new Error("'VariableDeclaratorSetInit was not overloaded by native module initialization") + } + _VariableDeclaratorId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'VariableDeclaratorId was not overloaded by native module initialization") + } + _VariableDeclaratorIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'VariableDeclaratorIdConst was not overloaded by native module initialization") + } + _VariableDeclaratorFlag(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'VariableDeclaratorFlag was not overloaded by native module initialization") + } + _CreateStringLiteral(context: KNativePointer): KNativePointer { + throw new Error("'CreateStringLiteral was not overloaded by native module initialization") + } + _UpdateStringLiteral(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateStringLiteral was not overloaded by native module initialization") + } + _CreateStringLiteral1(context: KNativePointer, str: KStringPtr): KNativePointer { + throw new Error("'CreateStringLiteral1 was not overloaded by native module initialization") + } + _UpdateStringLiteral1(context: KNativePointer, original: KNativePointer, str: KStringPtr): KNativePointer { + throw new Error("'UpdateStringLiteral1 was not overloaded by native module initialization") + } + _StringLiteralStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'StringLiteralStrConst was not overloaded by native module initialization") + } + _CreateTSTypeAssertion(context: KNativePointer, typeAnnotation: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("'CreateTSTypeAssertion was not overloaded by native module initialization") + } + _UpdateTSTypeAssertion(context: KNativePointer, original: KNativePointer, typeAnnotation: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("'UpdateTSTypeAssertion was not overloaded by native module initialization") + } + _TSTypeAssertionGetExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeAssertionGetExpressionConst was not overloaded by native module initialization") + } + _TSTypeAssertionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeAssertionTypeAnnotationConst was not overloaded by native module initialization") + } + _TSTypeAssertionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'TSTypeAssertionSetTsTypeAnnotation was not overloaded by native module initialization") + } + _CreateTSExternalModuleReference(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'CreateTSExternalModuleReference was not overloaded by native module initialization") + } + _UpdateTSExternalModuleReference(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'UpdateTSExternalModuleReference was not overloaded by native module initialization") + } + _TSExternalModuleReferenceExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSExternalModuleReferenceExprConst was not overloaded by native module initialization") + } + _CreateTSUndefinedKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSUndefinedKeyword was not overloaded by native module initialization") + } + _UpdateTSUndefinedKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSUndefinedKeyword was not overloaded by native module initialization") + } + _CreateETSTuple(context: KNativePointer): KNativePointer { + throw new Error("'CreateETSTuple was not overloaded by native module initialization") + } + _UpdateETSTuple(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateETSTuple was not overloaded by native module initialization") + } + _CreateETSTuple1(context: KNativePointer, size: KUInt): KNativePointer { + throw new Error("'CreateETSTuple1 was not overloaded by native module initialization") + } + _UpdateETSTuple1(context: KNativePointer, original: KNativePointer, size: KUInt): KNativePointer { + throw new Error("'UpdateETSTuple1 was not overloaded by native module initialization") + } + _CreateETSTuple2(context: KNativePointer, typeList: BigUint64Array, typeListSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateETSTuple2 was not overloaded by native module initialization") + } + _UpdateETSTuple2(context: KNativePointer, original: KNativePointer, typeList: BigUint64Array, typeListSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateETSTuple2 was not overloaded by native module initialization") + } + _ETSTupleGetTupleSizeConst(context: KNativePointer, receiver: KNativePointer): KUInt { + throw new Error("'ETSTupleGetTupleSizeConst was not overloaded by native module initialization") + } + _ETSTupleGetTupleTypeAnnotationsListConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSTupleGetTupleTypeAnnotationsListConst was not overloaded by native module initialization") + } + _ETSTupleHasSpreadTypeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSTupleHasSpreadTypeConst was not overloaded by native module initialization") + } + _ETSTupleSetSpreadType(context: KNativePointer, receiver: KNativePointer, newSpreadType: KNativePointer): void { + throw new Error("'ETSTupleSetSpreadType was not overloaded by native module initialization") + } + _ETSTupleSetTypeAnnotationsList(context: KNativePointer, receiver: KNativePointer, typeNodeList: BigUint64Array, typeNodeListSequenceLength: KUInt): void { + throw new Error("'ETSTupleSetTypeAnnotationsList was not overloaded by native module initialization") + } + _TryStatementFinallyBlockConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TryStatementFinallyBlockConst was not overloaded by native module initialization") + } + _TryStatementBlockConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TryStatementBlockConst was not overloaded by native module initialization") + } + _TryStatementHasFinalizerConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TryStatementHasFinalizerConst was not overloaded by native module initialization") + } + _TryStatementHasDefaultCatchClauseConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TryStatementHasDefaultCatchClauseConst was not overloaded by native module initialization") + } + _TryStatementCatchClausesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TryStatementCatchClausesConst was not overloaded by native module initialization") + } + _TryStatementFinallyCanCompleteNormallyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TryStatementFinallyCanCompleteNormallyConst was not overloaded by native module initialization") + } + _TryStatementSetFinallyCanCompleteNormally(context: KNativePointer, receiver: KNativePointer, finallyCanCompleteNormally: KBoolean): void { + throw new Error("'TryStatementSetFinallyCanCompleteNormally was not overloaded by native module initialization") + } + _AstNodeIsProgramConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsProgramConst was not overloaded by native module initialization") + } + _AstNodeIsStatementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsStatementConst was not overloaded by native module initialization") + } + _AstNodeIsExpressionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsExpressionConst was not overloaded by native module initialization") + } + _AstNodeIsTypedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsTypedConst was not overloaded by native module initialization") + } + _AstNodeAsTyped(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeAsTyped was not overloaded by native module initialization") + } + _AstNodeAsTypedConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeAsTypedConst was not overloaded by native module initialization") + } + _AstNodeIsBrokenStatementConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsBrokenStatementConst was not overloaded by native module initialization") + } + _AstNodeAsExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeAsExpression was not overloaded by native module initialization") + } + _AstNodeAsExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeAsExpressionConst was not overloaded by native module initialization") + } + _AstNodeAsStatement(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeAsStatement was not overloaded by native module initialization") + } + _AstNodeAsStatementConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeAsStatementConst was not overloaded by native module initialization") + } + _AstNodeTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'AstNodeTypeConst was not overloaded by native module initialization") + } + _AstNodeParent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeParent was not overloaded by native module initialization") + } + _AstNodeParentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeParentConst was not overloaded by native module initialization") + } + _AstNodeSetParent(context: KNativePointer, receiver: KNativePointer, parent: KNativePointer): void { + throw new Error("'AstNodeSetParent was not overloaded by native module initialization") + } + _AstNodeDecoratorsPtrConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeDecoratorsPtrConst was not overloaded by native module initialization") + } + _AstNodeAddDecorators(context: KNativePointer, receiver: KNativePointer, decorators: BigUint64Array, decoratorsSequenceLength: KUInt): void { + throw new Error("'AstNodeAddDecorators was not overloaded by native module initialization") + } + _AstNodeCanHaveDecoratorConst(context: KNativePointer, receiver: KNativePointer, inTs: KBoolean): KBoolean { + throw new Error("'AstNodeCanHaveDecoratorConst was not overloaded by native module initialization") + } + _AstNodeIsReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsReadonlyConst was not overloaded by native module initialization") + } + _AstNodeIsReadonlyTypeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsReadonlyTypeConst was not overloaded by native module initialization") + } + _AstNodeIsOptionalDeclarationConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsOptionalDeclarationConst was not overloaded by native module initialization") + } + _AstNodeIsDefiniteConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsDefiniteConst was not overloaded by native module initialization") + } + _AstNodeIsConstructorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsConstructorConst was not overloaded by native module initialization") + } + _AstNodeIsOverrideConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsOverrideConst was not overloaded by native module initialization") + } + _AstNodeSetOverride(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'AstNodeSetOverride was not overloaded by native module initialization") + } + _AstNodeIsAsyncConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsAsyncConst was not overloaded by native module initialization") + } + _AstNodeIsSynchronizedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsSynchronizedConst was not overloaded by native module initialization") + } + _AstNodeIsNativeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsNativeConst was not overloaded by native module initialization") + } + _AstNodeIsConstConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsConstConst was not overloaded by native module initialization") + } + _AstNodeIsStaticConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsStaticConst was not overloaded by native module initialization") + } + _AstNodeIsFinalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsFinalConst was not overloaded by native module initialization") + } + _AstNodeIsAbstractConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsAbstractConst was not overloaded by native module initialization") + } + _AstNodeIsPublicConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsPublicConst was not overloaded by native module initialization") + } + _AstNodeIsProtectedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsProtectedConst was not overloaded by native module initialization") + } + _AstNodeIsPrivateConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsPrivateConst was not overloaded by native module initialization") + } + _AstNodeIsInternalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsInternalConst was not overloaded by native module initialization") + } + _AstNodeIsExportedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsExportedConst was not overloaded by native module initialization") + } + _AstNodeIsDefaultExportedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsDefaultExportedConst was not overloaded by native module initialization") + } + _AstNodeIsExportedTypeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsExportedTypeConst was not overloaded by native module initialization") + } + _AstNodeIsDeclareConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsDeclareConst was not overloaded by native module initialization") + } + _AstNodeIsInConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsInConst was not overloaded by native module initialization") + } + _AstNodeIsOutConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsOutConst was not overloaded by native module initialization") + } + _AstNodeIsSetterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsSetterConst was not overloaded by native module initialization") + } + _AstNodeAddModifier(context: KNativePointer, receiver: KNativePointer, flags: KInt): void { + throw new Error("'AstNodeAddModifier was not overloaded by native module initialization") + } + _AstNodeClearModifier(context: KNativePointer, receiver: KNativePointer, flags: KInt): void { + throw new Error("'AstNodeClearModifier was not overloaded by native module initialization") + } + _AstNodeModifiers(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'AstNodeModifiers was not overloaded by native module initialization") + } + _AstNodeModifiersConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'AstNodeModifiersConst was not overloaded by native module initialization") + } + _AstNodeHasExportAliasConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeHasExportAliasConst was not overloaded by native module initialization") + } + _AstNodeAsClassElement(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeAsClassElement was not overloaded by native module initialization") + } + _AstNodeAsClassElementConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeAsClassElementConst was not overloaded by native module initialization") + } + _AstNodeIsScopeBearerConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AstNodeIsScopeBearerConst was not overloaded by native module initialization") + } + _AstNodeClearScope(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'AstNodeClearScope was not overloaded by native module initialization") + } + _AstNodeGetTopStatement(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeGetTopStatement was not overloaded by native module initialization") + } + _AstNodeGetTopStatementConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeGetTopStatementConst was not overloaded by native module initialization") + } + _AstNodeClone(context: KNativePointer, receiver: KNativePointer, parent: KNativePointer): KNativePointer { + throw new Error("'AstNodeClone was not overloaded by native module initialization") + } + _AstNodeDumpJSONConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'AstNodeDumpJSONConst was not overloaded by native module initialization") + } + _AstNodeDumpEtsSrcConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'AstNodeDumpEtsSrcConst was not overloaded by native module initialization") + } + _AstNodeDumpConst(context: KNativePointer, receiver: KNativePointer, dumper: KNativePointer): void { + throw new Error("'AstNodeDumpConst was not overloaded by native module initialization") + } + _AstNodeDumpConst1(context: KNativePointer, receiver: KNativePointer, dumper: KNativePointer): void { + throw new Error("'AstNodeDumpConst1 was not overloaded by native module initialization") + } + _AstNodeSetTransformedNode(context: KNativePointer, receiver: KNativePointer, transformationName: KStringPtr, transformedNode: KNativePointer): void { + throw new Error("'AstNodeSetTransformedNode was not overloaded by native module initialization") + } + _AstNodeSetOriginalNode(context: KNativePointer, receiver: KNativePointer, originalNode: KNativePointer): void { + throw new Error("'AstNodeSetOriginalNode was not overloaded by native module initialization") + } + _AstNodeOriginalNodeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AstNodeOriginalNodeConst was not overloaded by native module initialization") + } + _CreateUnaryExpression(context: KNativePointer, argument: KNativePointer, unaryOperator: KInt): KNativePointer { + throw new Error("'CreateUnaryExpression was not overloaded by native module initialization") + } + _UpdateUnaryExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer, unaryOperator: KInt): KNativePointer { + throw new Error("'UpdateUnaryExpression was not overloaded by native module initialization") + } + _UnaryExpressionOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'UnaryExpressionOperatorTypeConst was not overloaded by native module initialization") + } + _UnaryExpressionArgument(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'UnaryExpressionArgument was not overloaded by native module initialization") + } + _UnaryExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'UnaryExpressionArgumentConst was not overloaded by native module initialization") + } + _CreateForInStatement(context: KNativePointer, left: KNativePointer, right: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("'CreateForInStatement was not overloaded by native module initialization") + } + _UpdateForInStatement(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("'UpdateForInStatement was not overloaded by native module initialization") + } + _ForInStatementLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForInStatementLeft was not overloaded by native module initialization") + } + _ForInStatementLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForInStatementLeftConst was not overloaded by native module initialization") + } + _ForInStatementRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForInStatementRight was not overloaded by native module initialization") + } + _ForInStatementRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForInStatementRightConst was not overloaded by native module initialization") + } + _ForInStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForInStatementBody was not overloaded by native module initialization") + } + _ForInStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForInStatementBodyConst was not overloaded by native module initialization") + } + _CreateThisExpression(context: KNativePointer): KNativePointer { + throw new Error("'CreateThisExpression was not overloaded by native module initialization") + } + _UpdateThisExpression(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateThisExpression was not overloaded by native module initialization") + } + _CreateTSMethodSignature(context: KNativePointer, key: KNativePointer, signature: KNativePointer, computed: KBoolean, optional_arg: KBoolean): KNativePointer { + throw new Error("'CreateTSMethodSignature was not overloaded by native module initialization") + } + _UpdateTSMethodSignature(context: KNativePointer, original: KNativePointer, key: KNativePointer, signature: KNativePointer, computed: KBoolean, optional_arg: KBoolean): KNativePointer { + throw new Error("'UpdateTSMethodSignature was not overloaded by native module initialization") + } + _TSMethodSignatureKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSMethodSignatureKeyConst was not overloaded by native module initialization") + } + _TSMethodSignatureKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSMethodSignatureKey was not overloaded by native module initialization") + } + _TSMethodSignatureTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSMethodSignatureTypeParamsConst was not overloaded by native module initialization") + } + _TSMethodSignatureTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSMethodSignatureTypeParams was not overloaded by native module initialization") + } + _TSMethodSignatureParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSMethodSignatureParamsConst was not overloaded by native module initialization") + } + _TSMethodSignatureReturnTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSMethodSignatureReturnTypeAnnotationConst was not overloaded by native module initialization") + } + _TSMethodSignatureReturnTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSMethodSignatureReturnTypeAnnotation was not overloaded by native module initialization") + } + _TSMethodSignatureComputedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSMethodSignatureComputedConst was not overloaded by native module initialization") + } + _TSMethodSignatureOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSMethodSignatureOptionalConst was not overloaded by native module initialization") + } + _CreateBinaryExpression(context: KNativePointer, left: KNativePointer, right: KNativePointer, operatorType: KInt): KNativePointer { + throw new Error("'CreateBinaryExpression was not overloaded by native module initialization") + } + _UpdateBinaryExpression(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer, operatorType: KInt): KNativePointer { + throw new Error("'UpdateBinaryExpression was not overloaded by native module initialization") + } + _BinaryExpressionLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BinaryExpressionLeftConst was not overloaded by native module initialization") + } + _BinaryExpressionLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BinaryExpressionLeft was not overloaded by native module initialization") + } + _BinaryExpressionRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BinaryExpressionRightConst was not overloaded by native module initialization") + } + _BinaryExpressionRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BinaryExpressionRight was not overloaded by native module initialization") + } + _BinaryExpressionResultConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BinaryExpressionResultConst was not overloaded by native module initialization") + } + _BinaryExpressionResult(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BinaryExpressionResult was not overloaded by native module initialization") + } + _BinaryExpressionOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'BinaryExpressionOperatorTypeConst was not overloaded by native module initialization") + } + _BinaryExpressionIsLogicalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'BinaryExpressionIsLogicalConst was not overloaded by native module initialization") + } + _BinaryExpressionIsLogicalExtendedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'BinaryExpressionIsLogicalExtendedConst was not overloaded by native module initialization") + } + _BinaryExpressionIsBitwiseConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'BinaryExpressionIsBitwiseConst was not overloaded by native module initialization") + } + _BinaryExpressionIsArithmeticConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'BinaryExpressionIsArithmeticConst was not overloaded by native module initialization") + } + _BinaryExpressionSetLeft(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'BinaryExpressionSetLeft was not overloaded by native module initialization") + } + _BinaryExpressionSetRight(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'BinaryExpressionSetRight was not overloaded by native module initialization") + } + _BinaryExpressionSetResult(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'BinaryExpressionSetResult was not overloaded by native module initialization") + } + _BinaryExpressionSetOperator(context: KNativePointer, receiver: KNativePointer, operatorType: KInt): void { + throw new Error("'BinaryExpressionSetOperator was not overloaded by native module initialization") + } + _CreateSuperExpression(context: KNativePointer): KNativePointer { + throw new Error("'CreateSuperExpression was not overloaded by native module initialization") + } + _UpdateSuperExpression(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateSuperExpression was not overloaded by native module initialization") + } + _CreateAssertStatement(context: KNativePointer, test: KNativePointer, second: KNativePointer): KNativePointer { + throw new Error("'CreateAssertStatement was not overloaded by native module initialization") + } + _UpdateAssertStatement(context: KNativePointer, original: KNativePointer, test: KNativePointer, second: KNativePointer): KNativePointer { + throw new Error("'UpdateAssertStatement was not overloaded by native module initialization") + } + _AssertStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AssertStatementTestConst was not overloaded by native module initialization") + } + _AssertStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AssertStatementTest was not overloaded by native module initialization") + } + _AssertStatementSecondConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AssertStatementSecondConst was not overloaded by native module initialization") + } + _CreateTSStringKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSStringKeyword was not overloaded by native module initialization") + } + _UpdateTSStringKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSStringKeyword was not overloaded by native module initialization") + } + _CreateAssignmentExpression(context: KNativePointer, left: KNativePointer, right: KNativePointer, assignmentOperator: KInt): KNativePointer { + throw new Error("'CreateAssignmentExpression was not overloaded by native module initialization") + } + _UpdateAssignmentExpression(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer, assignmentOperator: KInt): KNativePointer { + throw new Error("'UpdateAssignmentExpression was not overloaded by native module initialization") + } + _CreateAssignmentExpression1(context: KNativePointer, type: KInt, left: KNativePointer, right: KNativePointer, assignmentOperator: KInt): KNativePointer { + throw new Error("'CreateAssignmentExpression1 was not overloaded by native module initialization") + } + _UpdateAssignmentExpression1(context: KNativePointer, original: KNativePointer, type: KInt, left: KNativePointer, right: KNativePointer, assignmentOperator: KInt): KNativePointer { + throw new Error("'UpdateAssignmentExpression1 was not overloaded by native module initialization") + } + _AssignmentExpressionLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AssignmentExpressionLeftConst was not overloaded by native module initialization") + } + _AssignmentExpressionLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AssignmentExpressionLeft was not overloaded by native module initialization") + } + _AssignmentExpressionRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AssignmentExpressionRight was not overloaded by native module initialization") + } + _AssignmentExpressionRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AssignmentExpressionRightConst was not overloaded by native module initialization") + } + _AssignmentExpressionSetRight(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'AssignmentExpressionSetRight was not overloaded by native module initialization") + } + _AssignmentExpressionSetLeft(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'AssignmentExpressionSetLeft was not overloaded by native module initialization") + } + _AssignmentExpressionResultConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AssignmentExpressionResultConst was not overloaded by native module initialization") + } + _AssignmentExpressionResult(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AssignmentExpressionResult was not overloaded by native module initialization") + } + _AssignmentExpressionOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'AssignmentExpressionOperatorTypeConst was not overloaded by native module initialization") + } + _AssignmentExpressionSetOperatorType(context: KNativePointer, receiver: KNativePointer, tokenType: KInt): KInt { + throw new Error("'AssignmentExpressionSetOperatorType was not overloaded by native module initialization") + } + _AssignmentExpressionSetResult(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'AssignmentExpressionSetResult was not overloaded by native module initialization") + } + _AssignmentExpressionIsLogicalExtendedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AssignmentExpressionIsLogicalExtendedConst was not overloaded by native module initialization") + } + _AssignmentExpressionSetIgnoreConstAssign(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'AssignmentExpressionSetIgnoreConstAssign was not overloaded by native module initialization") + } + _AssignmentExpressionIsIgnoreConstAssignConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AssignmentExpressionIsIgnoreConstAssignConst was not overloaded by native module initialization") + } + _AssignmentExpressionConvertibleToAssignmentPatternLeft(context: KNativePointer, receiver: KNativePointer, mustBePattern: KBoolean): KBoolean { + throw new Error("'AssignmentExpressionConvertibleToAssignmentPatternLeft was not overloaded by native module initialization") + } + _AssignmentExpressionConvertibleToAssignmentPatternRight(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AssignmentExpressionConvertibleToAssignmentPatternRight was not overloaded by native module initialization") + } + _AssignmentExpressionConvertibleToAssignmentPattern(context: KNativePointer, receiver: KNativePointer, mustBePattern: KBoolean): KBoolean { + throw new Error("'AssignmentExpressionConvertibleToAssignmentPattern was not overloaded by native module initialization") + } + _CreateExpressionStatement(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'CreateExpressionStatement was not overloaded by native module initialization") + } + _UpdateExpressionStatement(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'UpdateExpressionStatement was not overloaded by native module initialization") + } + _ExpressionStatementGetExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExpressionStatementGetExpressionConst was not overloaded by native module initialization") + } + _ExpressionStatementGetExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExpressionStatementGetExpression was not overloaded by native module initialization") + } + _ExpressionStatementSetExpression(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'ExpressionStatementSetExpression was not overloaded by native module initialization") + } + _ETSModuleIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSModuleIdent was not overloaded by native module initialization") + } + _ETSModuleIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSModuleIdentConst was not overloaded by native module initialization") + } + _ETSModuleIsETSScriptConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSModuleIsETSScriptConst was not overloaded by native module initialization") + } + _ETSModuleIsNamespaceConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSModuleIsNamespaceConst was not overloaded by native module initialization") + } + _ETSModuleIsNamespaceChainLastNodeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSModuleIsNamespaceChainLastNodeConst was not overloaded by native module initialization") + } + _ETSModuleSetNamespaceChainLastNode(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'ETSModuleSetNamespaceChainLastNode was not overloaded by native module initialization") + } + _ETSModuleAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSModuleAnnotations was not overloaded by native module initialization") + } + _ETSModuleAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSModuleAnnotationsConst was not overloaded by native module initialization") + } + _ETSModuleSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'ETSModuleSetAnnotations was not overloaded by native module initialization") + } + _CreateMetaProperty(context: KNativePointer, kind: KInt): KNativePointer { + throw new Error("'CreateMetaProperty was not overloaded by native module initialization") + } + _UpdateMetaProperty(context: KNativePointer, original: KNativePointer, kind: KInt): KNativePointer { + throw new Error("'UpdateMetaProperty was not overloaded by native module initialization") + } + _MetaPropertyKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'MetaPropertyKindConst was not overloaded by native module initialization") + } + _CreateTSArrayType(context: KNativePointer, elementType: KNativePointer): KNativePointer { + throw new Error("'CreateTSArrayType was not overloaded by native module initialization") + } + _UpdateTSArrayType(context: KNativePointer, original: KNativePointer, elementType: KNativePointer): KNativePointer { + throw new Error("'UpdateTSArrayType was not overloaded by native module initialization") + } + _TSArrayTypeElementTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSArrayTypeElementTypeConst was not overloaded by native module initialization") + } + _CreateTSSignatureDeclaration(context: KNativePointer, kind: KInt, signature: KNativePointer): KNativePointer { + throw new Error("'CreateTSSignatureDeclaration was not overloaded by native module initialization") + } + _UpdateTSSignatureDeclaration(context: KNativePointer, original: KNativePointer, kind: KInt, signature: KNativePointer): KNativePointer { + throw new Error("'UpdateTSSignatureDeclaration was not overloaded by native module initialization") + } + _TSSignatureDeclarationTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSSignatureDeclarationTypeParamsConst was not overloaded by native module initialization") + } + _TSSignatureDeclarationTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSSignatureDeclarationTypeParams was not overloaded by native module initialization") + } + _TSSignatureDeclarationParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSSignatureDeclarationParamsConst was not overloaded by native module initialization") + } + _TSSignatureDeclarationReturnTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSSignatureDeclarationReturnTypeAnnotationConst was not overloaded by native module initialization") + } + _TSSignatureDeclarationReturnTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSSignatureDeclarationReturnTypeAnnotation was not overloaded by native module initialization") + } + _TSSignatureDeclarationKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'TSSignatureDeclarationKindConst was not overloaded by native module initialization") + } + _CreateExportAllDeclaration(context: KNativePointer, source: KNativePointer, exported: KNativePointer): KNativePointer { + throw new Error("'CreateExportAllDeclaration was not overloaded by native module initialization") + } + _UpdateExportAllDeclaration(context: KNativePointer, original: KNativePointer, source: KNativePointer, exported: KNativePointer): KNativePointer { + throw new Error("'UpdateExportAllDeclaration was not overloaded by native module initialization") + } + _ExportAllDeclarationSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExportAllDeclarationSourceConst was not overloaded by native module initialization") + } + _ExportAllDeclarationExportedConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExportAllDeclarationExportedConst was not overloaded by native module initialization") + } + _CreateExportSpecifier(context: KNativePointer, local: KNativePointer, exported: KNativePointer): KNativePointer { + throw new Error("'CreateExportSpecifier was not overloaded by native module initialization") + } + _UpdateExportSpecifier(context: KNativePointer, original: KNativePointer, local: KNativePointer, exported: KNativePointer): KNativePointer { + throw new Error("'UpdateExportSpecifier was not overloaded by native module initialization") + } + _ExportSpecifierLocalConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExportSpecifierLocalConst was not overloaded by native module initialization") + } + _ExportSpecifierExportedConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExportSpecifierExportedConst was not overloaded by native module initialization") + } + _CreateTSTupleType(context: KNativePointer, elementTypes: BigUint64Array, elementTypesSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateTSTupleType was not overloaded by native module initialization") + } + _UpdateTSTupleType(context: KNativePointer, original: KNativePointer, elementTypes: BigUint64Array, elementTypesSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateTSTupleType was not overloaded by native module initialization") + } + _TSTupleTypeElementTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTupleTypeElementTypeConst was not overloaded by native module initialization") + } + _CreateFunctionExpression(context: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("'CreateFunctionExpression was not overloaded by native module initialization") + } + _UpdateFunctionExpression(context: KNativePointer, original: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("'UpdateFunctionExpression was not overloaded by native module initialization") + } + _CreateFunctionExpression1(context: KNativePointer, namedExpr: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("'CreateFunctionExpression1 was not overloaded by native module initialization") + } + _UpdateFunctionExpression1(context: KNativePointer, original: KNativePointer, namedExpr: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("'UpdateFunctionExpression1 was not overloaded by native module initialization") + } + _FunctionExpressionFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionExpressionFunctionConst was not overloaded by native module initialization") + } + _FunctionExpressionFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionExpressionFunction was not overloaded by native module initialization") + } + _FunctionExpressionIsAnonymousConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'FunctionExpressionIsAnonymousConst was not overloaded by native module initialization") + } + _FunctionExpressionId(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionExpressionId was not overloaded by native module initialization") + } + _CreateTSIndexSignature(context: KNativePointer, param: KNativePointer, typeAnnotation: KNativePointer, readonly_arg: KBoolean): KNativePointer { + throw new Error("'CreateTSIndexSignature was not overloaded by native module initialization") + } + _UpdateTSIndexSignature(context: KNativePointer, original: KNativePointer, param: KNativePointer, typeAnnotation: KNativePointer, readonly_arg: KBoolean): KNativePointer { + throw new Error("'UpdateTSIndexSignature was not overloaded by native module initialization") + } + _TSIndexSignatureParamConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSIndexSignatureParamConst was not overloaded by native module initialization") + } + _TSIndexSignatureTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSIndexSignatureTypeAnnotationConst was not overloaded by native module initialization") + } + _TSIndexSignatureReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSIndexSignatureReadonlyConst was not overloaded by native module initialization") + } + _TSIndexSignatureKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'TSIndexSignatureKindConst was not overloaded by native module initialization") + } + _CreateTSModuleDeclaration(context: KNativePointer, name: KNativePointer, body: KNativePointer, declare: KBoolean, _global: KBoolean): KNativePointer { + throw new Error("'CreateTSModuleDeclaration was not overloaded by native module initialization") + } + _UpdateTSModuleDeclaration(context: KNativePointer, original: KNativePointer, name: KNativePointer, body: KNativePointer, declare: KBoolean, _global: KBoolean): KNativePointer { + throw new Error("'UpdateTSModuleDeclaration was not overloaded by native module initialization") + } + _TSModuleDeclarationNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSModuleDeclarationNameConst was not overloaded by native module initialization") + } + _TSModuleDeclarationBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSModuleDeclarationBodyConst was not overloaded by native module initialization") + } + _TSModuleDeclarationGlobalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSModuleDeclarationGlobalConst was not overloaded by native module initialization") + } + _TSModuleDeclarationIsExternalOrAmbientConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSModuleDeclarationIsExternalOrAmbientConst was not overloaded by native module initialization") + } + _CreateImportDeclaration(context: KNativePointer, source: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt, importKind: KInt): KNativePointer { + throw new Error("'CreateImportDeclaration was not overloaded by native module initialization") + } + _UpdateImportDeclaration(context: KNativePointer, original: KNativePointer, source: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt, importKind: KInt): KNativePointer { + throw new Error("'UpdateImportDeclaration was not overloaded by native module initialization") + } + _ImportDeclarationSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportDeclarationSourceConst was not overloaded by native module initialization") + } + _ImportDeclarationSource(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportDeclarationSource was not overloaded by native module initialization") + } + _ImportDeclarationSpecifiersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportDeclarationSpecifiersConst was not overloaded by native module initialization") + } + _ImportDeclarationSpecifiers(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportDeclarationSpecifiers was not overloaded by native module initialization") + } + _ImportDeclarationIsTypeKindConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ImportDeclarationIsTypeKindConst was not overloaded by native module initialization") + } + _CreateTSParenthesizedType(context: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("'CreateTSParenthesizedType was not overloaded by native module initialization") + } + _UpdateTSParenthesizedType(context: KNativePointer, original: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("'UpdateTSParenthesizedType was not overloaded by native module initialization") + } + _TSParenthesizedTypeTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSParenthesizedTypeTypeConst was not overloaded by native module initialization") + } + _CreateCharLiteral(context: KNativePointer): KNativePointer { + throw new Error("'CreateCharLiteral was not overloaded by native module initialization") + } + _UpdateCharLiteral(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateCharLiteral was not overloaded by native module initialization") + } + _CreateETSPackageDeclaration(context: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("'CreateETSPackageDeclaration was not overloaded by native module initialization") + } + _UpdateETSPackageDeclaration(context: KNativePointer, original: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("'UpdateETSPackageDeclaration was not overloaded by native module initialization") + } + _CreateETSImportDeclaration(context: KNativePointer, importPath: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt, importKind: KInt): KNativePointer { + throw new Error("'CreateETSImportDeclaration was not overloaded by native module initialization") + } + _UpdateETSImportDeclaration(context: KNativePointer, original: KNativePointer, source: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt, importKind: KInt): KNativePointer { + throw new Error("'UpdateETSImportDeclaration was not overloaded by native module initialization") + } + _ETSImportDeclarationHasDeclConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSImportDeclarationHasDeclConst was not overloaded by native module initialization") + } + _ETSImportDeclarationIsPureDynamicConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSImportDeclarationIsPureDynamicConst was not overloaded by native module initialization") + } + _ETSImportDeclarationAssemblerName(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ETSImportDeclarationAssemblerName was not overloaded by native module initialization") + } + _ETSImportDeclarationAssemblerNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ETSImportDeclarationAssemblerNameConst was not overloaded by native module initialization") + } + _ETSImportDeclarationSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSImportDeclarationSourceConst was not overloaded by native module initialization") + } + _ETSImportDeclarationResolvedSource(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSImportDeclarationResolvedSource was not overloaded by native module initialization") + } + _ETSImportDeclarationResolvedSourceConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ETSImportDeclarationResolvedSourceConst was not overloaded by native module initialization") + } + _CreateETSStructDeclaration(context: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("'CreateETSStructDeclaration was not overloaded by native module initialization") + } + _UpdateETSStructDeclaration(context: KNativePointer, original: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("'UpdateETSStructDeclaration was not overloaded by native module initialization") + } + _CreateTSModuleBlock(context: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateTSModuleBlock was not overloaded by native module initialization") + } + _UpdateTSModuleBlock(context: KNativePointer, original: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateTSModuleBlock was not overloaded by native module initialization") + } + _TSModuleBlockStatementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSModuleBlockStatementsConst was not overloaded by native module initialization") + } + _CreateETSNewArrayInstanceExpression(context: KNativePointer, typeReference: KNativePointer, dimension: KNativePointer): KNativePointer { + throw new Error("'CreateETSNewArrayInstanceExpression was not overloaded by native module initialization") + } + _UpdateETSNewArrayInstanceExpression(context: KNativePointer, original: KNativePointer, typeReference: KNativePointer, dimension: KNativePointer): KNativePointer { + throw new Error("'UpdateETSNewArrayInstanceExpression was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionTypeReference(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewArrayInstanceExpressionTypeReference was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionTypeReferenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewArrayInstanceExpressionTypeReferenceConst was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionDimension(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewArrayInstanceExpressionDimension was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionDimensionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewArrayInstanceExpressionDimensionConst was not overloaded by native module initialization") + } + _ETSNewArrayInstanceExpressionSetDimension(context: KNativePointer, receiver: KNativePointer, dimension: KNativePointer): void { + throw new Error("'ETSNewArrayInstanceExpressionSetDimension was not overloaded by native module initialization") + } + _CreateAnnotationDeclaration(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'CreateAnnotationDeclaration was not overloaded by native module initialization") + } + _UpdateAnnotationDeclaration(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'UpdateAnnotationDeclaration was not overloaded by native module initialization") + } + _CreateAnnotationDeclaration1(context: KNativePointer, expr: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateAnnotationDeclaration1 was not overloaded by native module initialization") + } + _UpdateAnnotationDeclaration1(context: KNativePointer, original: KNativePointer, expr: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateAnnotationDeclaration1 was not overloaded by native module initialization") + } + _AnnotationDeclarationInternalNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'AnnotationDeclarationInternalNameConst was not overloaded by native module initialization") + } + _AnnotationDeclarationSetInternalName(context: KNativePointer, receiver: KNativePointer, internalName: KStringPtr): void { + throw new Error("'AnnotationDeclarationSetInternalName was not overloaded by native module initialization") + } + _AnnotationDeclarationExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationDeclarationExprConst was not overloaded by native module initialization") + } + _AnnotationDeclarationExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationDeclarationExpr was not overloaded by native module initialization") + } + _AnnotationDeclarationProperties(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationDeclarationProperties was not overloaded by native module initialization") + } + _AnnotationDeclarationPropertiesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationDeclarationPropertiesConst was not overloaded by native module initialization") + } + _AnnotationDeclarationPropertiesPtrConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationDeclarationPropertiesPtrConst was not overloaded by native module initialization") + } + _AnnotationDeclarationAddProperties(context: KNativePointer, receiver: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): void { + throw new Error("'AnnotationDeclarationAddProperties was not overloaded by native module initialization") + } + _AnnotationDeclarationIsSourceRetentionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AnnotationDeclarationIsSourceRetentionConst was not overloaded by native module initialization") + } + _AnnotationDeclarationIsBytecodeRetentionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AnnotationDeclarationIsBytecodeRetentionConst was not overloaded by native module initialization") + } + _AnnotationDeclarationIsRuntimeRetentionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'AnnotationDeclarationIsRuntimeRetentionConst was not overloaded by native module initialization") + } + _AnnotationDeclarationSetSourceRetention(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'AnnotationDeclarationSetSourceRetention was not overloaded by native module initialization") + } + _AnnotationDeclarationSetBytecodeRetention(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'AnnotationDeclarationSetBytecodeRetention was not overloaded by native module initialization") + } + _AnnotationDeclarationSetRuntimeRetention(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'AnnotationDeclarationSetRuntimeRetention was not overloaded by native module initialization") + } + _AnnotationDeclarationGetBaseNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationDeclarationGetBaseNameConst was not overloaded by native module initialization") + } + _AnnotationDeclarationAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationDeclarationAnnotations was not overloaded by native module initialization") + } + _AnnotationDeclarationAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationDeclarationAnnotationsConst was not overloaded by native module initialization") + } + _AnnotationDeclarationSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'AnnotationDeclarationSetAnnotations was not overloaded by native module initialization") + } + _CreateAnnotationUsageIr(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'CreateAnnotationUsageIr was not overloaded by native module initialization") + } + _UpdateAnnotationUsageIr(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'UpdateAnnotationUsageIr was not overloaded by native module initialization") + } + _CreateAnnotationUsageIr1(context: KNativePointer, expr: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateAnnotationUsageIr1 was not overloaded by native module initialization") + } + _UpdateAnnotationUsageIr1(context: KNativePointer, original: KNativePointer, expr: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateAnnotationUsageIr1 was not overloaded by native module initialization") + } + _AnnotationUsageIrExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationUsageIrExpr was not overloaded by native module initialization") + } + _AnnotationUsageIrProperties(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationUsageIrProperties was not overloaded by native module initialization") + } + _AnnotationUsageIrPropertiesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationUsageIrPropertiesConst was not overloaded by native module initialization") + } + _AnnotationUsageIrPropertiesPtrConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationUsageIrPropertiesPtrConst was not overloaded by native module initialization") + } + _AnnotationUsageIrAddProperty(context: KNativePointer, receiver: KNativePointer, property: KNativePointer): void { + throw new Error("'AnnotationUsageIrAddProperty was not overloaded by native module initialization") + } + _AnnotationUsageIrSetProperties(context: KNativePointer, receiver: KNativePointer, properties: BigUint64Array, propertiesSequenceLength: KUInt): void { + throw new Error("'AnnotationUsageIrSetProperties was not overloaded by native module initialization") + } + _AnnotationUsageIrGetBaseNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotationUsageIrGetBaseNameConst was not overloaded by native module initialization") + } + _CreateEmptyStatement(context: KNativePointer): KNativePointer { + throw new Error("'CreateEmptyStatement was not overloaded by native module initialization") + } + _UpdateEmptyStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateEmptyStatement was not overloaded by native module initialization") + } + _CreateETSLaunchExpression(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'CreateETSLaunchExpression was not overloaded by native module initialization") + } + _UpdateETSLaunchExpression(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'UpdateETSLaunchExpression was not overloaded by native module initialization") + } + _ETSLaunchExpressionIsStaticCallConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSLaunchExpressionIsStaticCallConst was not overloaded by native module initialization") + } + _ETSLaunchExpressionCallConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSLaunchExpressionCallConst was not overloaded by native module initialization") + } + _CreateWhileStatement(context: KNativePointer, test: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("'CreateWhileStatement was not overloaded by native module initialization") + } + _UpdateWhileStatement(context: KNativePointer, original: KNativePointer, test: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("'UpdateWhileStatement was not overloaded by native module initialization") + } + _WhileStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'WhileStatementTestConst was not overloaded by native module initialization") + } + _WhileStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'WhileStatementTest was not overloaded by native module initialization") + } + _WhileStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'WhileStatementBodyConst was not overloaded by native module initialization") + } + _WhileStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'WhileStatementBody was not overloaded by native module initialization") + } + _CreateFunctionSignature(context: KNativePointer, typeParams: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt, returnTypeAnnotation: KNativePointer, hasReceiver: KBoolean): KNativePointer { + throw new Error("'CreateFunctionSignature was not overloaded by native module initialization") + } + _FunctionSignatureParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionSignatureParamsConst was not overloaded by native module initialization") + } + _FunctionSignatureParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionSignatureParams was not overloaded by native module initialization") + } + _FunctionSignatureTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionSignatureTypeParams was not overloaded by native module initialization") + } + _FunctionSignatureTypeParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionSignatureTypeParamsConst was not overloaded by native module initialization") + } + _FunctionSignatureReturnType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionSignatureReturnType was not overloaded by native module initialization") + } + _FunctionSignatureSetReturnType(context: KNativePointer, receiver: KNativePointer, type: KNativePointer): void { + throw new Error("'FunctionSignatureSetReturnType was not overloaded by native module initialization") + } + _FunctionSignatureReturnTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionSignatureReturnTypeConst was not overloaded by native module initialization") + } + _FunctionSignatureClone(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'FunctionSignatureClone was not overloaded by native module initialization") + } + _FunctionSignatureHasReceiverConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'FunctionSignatureHasReceiverConst was not overloaded by native module initialization") + } + _CreateChainExpression(context: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("'CreateChainExpression was not overloaded by native module initialization") + } + _UpdateChainExpression(context: KNativePointer, original: KNativePointer, expression: KNativePointer): KNativePointer { + throw new Error("'UpdateChainExpression was not overloaded by native module initialization") + } + _ChainExpressionGetExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ChainExpressionGetExpressionConst was not overloaded by native module initialization") + } + _ChainExpressionGetExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ChainExpressionGetExpression was not overloaded by native module initialization") + } + _CreateTSIntersectionType(context: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateTSIntersectionType was not overloaded by native module initialization") + } + _UpdateTSIntersectionType(context: KNativePointer, original: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateTSIntersectionType was not overloaded by native module initialization") + } + _TSIntersectionTypeTypesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSIntersectionTypeTypesConst was not overloaded by native module initialization") + } + _CreateUpdateExpression(context: KNativePointer, argument: KNativePointer, updateOperator: KInt, isPrefix: KBoolean): KNativePointer { + throw new Error("'CreateUpdateExpression was not overloaded by native module initialization") + } + _UpdateUpdateExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer, updateOperator: KInt, isPrefix: KBoolean): KNativePointer { + throw new Error("'UpdateUpdateExpression was not overloaded by native module initialization") + } + _UpdateExpressionOperatorTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'UpdateExpressionOperatorTypeConst was not overloaded by native module initialization") + } + _UpdateExpressionArgument(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'UpdateExpressionArgument was not overloaded by native module initialization") + } + _UpdateExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'UpdateExpressionArgumentConst was not overloaded by native module initialization") + } + _UpdateExpressionIsPrefixConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'UpdateExpressionIsPrefixConst was not overloaded by native module initialization") + } + _CreateBlockExpression(context: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateBlockExpression was not overloaded by native module initialization") + } + _UpdateBlockExpression(context: KNativePointer, original: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateBlockExpression was not overloaded by native module initialization") + } + _BlockExpressionStatementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BlockExpressionStatementsConst was not overloaded by native module initialization") + } + _BlockExpressionStatements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BlockExpressionStatements was not overloaded by native module initialization") + } + _BlockExpressionAddStatements(context: KNativePointer, receiver: KNativePointer, statements: BigUint64Array, statementsSequenceLength: KUInt): void { + throw new Error("'BlockExpressionAddStatements was not overloaded by native module initialization") + } + _BlockExpressionAddStatement(context: KNativePointer, receiver: KNativePointer, statement: KNativePointer): void { + throw new Error("'BlockExpressionAddStatement was not overloaded by native module initialization") + } + _CreateTSTypeLiteral(context: KNativePointer, members: BigUint64Array, membersSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateTSTypeLiteral was not overloaded by native module initialization") + } + _UpdateTSTypeLiteral(context: KNativePointer, original: KNativePointer, members: BigUint64Array, membersSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateTSTypeLiteral was not overloaded by native module initialization") + } + _TSTypeLiteralMembersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeLiteralMembersConst was not overloaded by native module initialization") + } + _CreateTSTypeParameter(context: KNativePointer, name: KNativePointer, constraint: KNativePointer, defaultType: KNativePointer): KNativePointer { + throw new Error("'CreateTSTypeParameter was not overloaded by native module initialization") + } + _UpdateTSTypeParameter(context: KNativePointer, original: KNativePointer, name: KNativePointer, constraint: KNativePointer, defaultType: KNativePointer): KNativePointer { + throw new Error("'UpdateTSTypeParameter was not overloaded by native module initialization") + } + _CreateTSTypeParameter1(context: KNativePointer, name: KNativePointer, constraint: KNativePointer, defaultType: KNativePointer, flags: KInt): KNativePointer { + throw new Error("'CreateTSTypeParameter1 was not overloaded by native module initialization") + } + _UpdateTSTypeParameter1(context: KNativePointer, original: KNativePointer, name: KNativePointer, constraint: KNativePointer, defaultType: KNativePointer, flags: KInt): KNativePointer { + throw new Error("'UpdateTSTypeParameter1 was not overloaded by native module initialization") + } + _TSTypeParameterNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeParameterNameConst was not overloaded by native module initialization") + } + _TSTypeParameterName(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeParameterName was not overloaded by native module initialization") + } + _TSTypeParameterConstraint(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeParameterConstraint was not overloaded by native module initialization") + } + _TSTypeParameterConstraintConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeParameterConstraintConst was not overloaded by native module initialization") + } + _TSTypeParameterSetConstraint(context: KNativePointer, receiver: KNativePointer, constraint: KNativePointer): void { + throw new Error("'TSTypeParameterSetConstraint was not overloaded by native module initialization") + } + _TSTypeParameterDefaultTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeParameterDefaultTypeConst was not overloaded by native module initialization") + } + _TSTypeParameterSetDefaultType(context: KNativePointer, receiver: KNativePointer, defaultType: KNativePointer): void { + throw new Error("'TSTypeParameterSetDefaultType was not overloaded by native module initialization") + } + _TSTypeParameterAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeParameterAnnotations was not overloaded by native module initialization") + } + _TSTypeParameterAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeParameterAnnotationsConst was not overloaded by native module initialization") + } + _TSTypeParameterSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'TSTypeParameterSetAnnotations was not overloaded by native module initialization") + } + _CreateTSBooleanKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSBooleanKeyword was not overloaded by native module initialization") + } + _UpdateTSBooleanKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSBooleanKeyword was not overloaded by native module initialization") + } + _CreateSpreadElement(context: KNativePointer, nodeType: KInt, argument: KNativePointer): KNativePointer { + throw new Error("'CreateSpreadElement was not overloaded by native module initialization") + } + _UpdateSpreadElement(context: KNativePointer, original: KNativePointer, nodeType: KInt, argument: KNativePointer): KNativePointer { + throw new Error("'UpdateSpreadElement was not overloaded by native module initialization") + } + _SpreadElementArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SpreadElementArgumentConst was not overloaded by native module initialization") + } + _SpreadElementArgument(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SpreadElementArgument was not overloaded by native module initialization") + } + _SpreadElementIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'SpreadElementIsOptionalConst was not overloaded by native module initialization") + } + _SpreadElementDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SpreadElementDecoratorsConst was not overloaded by native module initialization") + } + _SpreadElementSetOptional(context: KNativePointer, receiver: KNativePointer, optional_arg: KBoolean): void { + throw new Error("'SpreadElementSetOptional was not overloaded by native module initialization") + } + _SpreadElementValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SpreadElementValidateExpression was not overloaded by native module initialization") + } + _SpreadElementConvertibleToRest(context: KNativePointer, receiver: KNativePointer, isDeclaration: KBoolean, allowPattern: KBoolean): KBoolean { + throw new Error("'SpreadElementConvertibleToRest was not overloaded by native module initialization") + } + _SpreadElementTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SpreadElementTypeAnnotationConst was not overloaded by native module initialization") + } + _SpreadElementSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'SpreadElementSetTsTypeAnnotation was not overloaded by native module initialization") + } + _CreateTSTypePredicate(context: KNativePointer, parameterName: KNativePointer, typeAnnotation: KNativePointer, asserts: KBoolean): KNativePointer { + throw new Error("'CreateTSTypePredicate was not overloaded by native module initialization") + } + _UpdateTSTypePredicate(context: KNativePointer, original: KNativePointer, parameterName: KNativePointer, typeAnnotation: KNativePointer, asserts: KBoolean): KNativePointer { + throw new Error("'UpdateTSTypePredicate was not overloaded by native module initialization") + } + _TSTypePredicateParameterNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypePredicateParameterNameConst was not overloaded by native module initialization") + } + _TSTypePredicateTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypePredicateTypeAnnotationConst was not overloaded by native module initialization") + } + _TSTypePredicateAssertsConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSTypePredicateAssertsConst was not overloaded by native module initialization") + } + _CreateImportNamespaceSpecifier(context: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("'CreateImportNamespaceSpecifier was not overloaded by native module initialization") + } + _UpdateImportNamespaceSpecifier(context: KNativePointer, original: KNativePointer, local: KNativePointer): KNativePointer { + throw new Error("'UpdateImportNamespaceSpecifier was not overloaded by native module initialization") + } + _ImportNamespaceSpecifierLocal(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportNamespaceSpecifierLocal was not overloaded by native module initialization") + } + _ImportNamespaceSpecifierLocalConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportNamespaceSpecifierLocalConst was not overloaded by native module initialization") + } + _CreateExportNamedDeclaration(context: KNativePointer, source: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateExportNamedDeclaration was not overloaded by native module initialization") + } + _UpdateExportNamedDeclaration(context: KNativePointer, original: KNativePointer, source: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateExportNamedDeclaration was not overloaded by native module initialization") + } + _CreateExportNamedDeclaration1(context: KNativePointer, decl: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateExportNamedDeclaration1 was not overloaded by native module initialization") + } + _UpdateExportNamedDeclaration1(context: KNativePointer, original: KNativePointer, decl: KNativePointer, specifiers: BigUint64Array, specifiersSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateExportNamedDeclaration1 was not overloaded by native module initialization") + } + _CreateExportNamedDeclaration2(context: KNativePointer, decl: KNativePointer): KNativePointer { + throw new Error("'CreateExportNamedDeclaration2 was not overloaded by native module initialization") + } + _UpdateExportNamedDeclaration2(context: KNativePointer, original: KNativePointer, decl: KNativePointer): KNativePointer { + throw new Error("'UpdateExportNamedDeclaration2 was not overloaded by native module initialization") + } + _ExportNamedDeclarationDeclConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExportNamedDeclarationDeclConst was not overloaded by native module initialization") + } + _ExportNamedDeclarationSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExportNamedDeclarationSourceConst was not overloaded by native module initialization") + } + _ExportNamedDeclarationSpecifiersConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExportNamedDeclarationSpecifiersConst was not overloaded by native module initialization") + } + _CreateETSParameterExpression(context: KNativePointer, identOrSpread: KNativePointer, isOptional: KBoolean): KNativePointer { + throw new Error("'CreateETSParameterExpression was not overloaded by native module initialization") + } + _UpdateETSParameterExpression(context: KNativePointer, original: KNativePointer, identOrSpread: KNativePointer, isOptional: KBoolean): KNativePointer { + throw new Error("'UpdateETSParameterExpression was not overloaded by native module initialization") + } + _CreateETSParameterExpression1(context: KNativePointer, identOrSpread: KNativePointer, initializer: KNativePointer): KNativePointer { + throw new Error("'CreateETSParameterExpression1 was not overloaded by native module initialization") + } + _UpdateETSParameterExpression1(context: KNativePointer, original: KNativePointer, identOrSpread: KNativePointer, initializer: KNativePointer): KNativePointer { + throw new Error("'UpdateETSParameterExpression1 was not overloaded by native module initialization") + } + _ETSParameterExpressionNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ETSParameterExpressionNameConst was not overloaded by native module initialization") + } + _ETSParameterExpressionIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionIdentConst was not overloaded by native module initialization") + } + _ETSParameterExpressionIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionIdent was not overloaded by native module initialization") + } + _ETSParameterExpressionSetIdent(context: KNativePointer, receiver: KNativePointer, ident: KNativePointer): void { + throw new Error("'ETSParameterExpressionSetIdent was not overloaded by native module initialization") + } + _ETSParameterExpressionRestParameterConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionRestParameterConst was not overloaded by native module initialization") + } + _ETSParameterExpressionRestParameter(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionRestParameter was not overloaded by native module initialization") + } + _ETSParameterExpressionInitializerConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionInitializerConst was not overloaded by native module initialization") + } + _ETSParameterExpressionInitializer(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionInitializer was not overloaded by native module initialization") + } + _ETSParameterExpressionSetLexerSaved(context: KNativePointer, receiver: KNativePointer, s: KStringPtr): void { + throw new Error("'ETSParameterExpressionSetLexerSaved was not overloaded by native module initialization") + } + _ETSParameterExpressionLexerSavedConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ETSParameterExpressionLexerSavedConst was not overloaded by native module initialization") + } + _ETSParameterExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionTypeAnnotationConst was not overloaded by native module initialization") + } + _ETSParameterExpressionTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionTypeAnnotation was not overloaded by native module initialization") + } + _ETSParameterExpressionSetTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeNode: KNativePointer): void { + throw new Error("'ETSParameterExpressionSetTypeAnnotation was not overloaded by native module initialization") + } + _ETSParameterExpressionIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSParameterExpressionIsOptionalConst was not overloaded by native module initialization") + } + _ETSParameterExpressionSetOptional(context: KNativePointer, receiver: KNativePointer, value: KBoolean): void { + throw new Error("'ETSParameterExpressionSetOptional was not overloaded by native module initialization") + } + _ETSParameterExpressionSetInitializer(context: KNativePointer, receiver: KNativePointer, initExpr: KNativePointer): void { + throw new Error("'ETSParameterExpressionSetInitializer was not overloaded by native module initialization") + } + _ETSParameterExpressionIsRestParameterConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ETSParameterExpressionIsRestParameterConst was not overloaded by native module initialization") + } + _ETSParameterExpressionGetRequiredParamsConst(context: KNativePointer, receiver: KNativePointer): KUInt { + throw new Error("'ETSParameterExpressionGetRequiredParamsConst was not overloaded by native module initialization") + } + _ETSParameterExpressionSetRequiredParams(context: KNativePointer, receiver: KNativePointer, value: KUInt): void { + throw new Error("'ETSParameterExpressionSetRequiredParams was not overloaded by native module initialization") + } + _ETSParameterExpressionAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionAnnotations was not overloaded by native module initialization") + } + _ETSParameterExpressionAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSParameterExpressionAnnotationsConst was not overloaded by native module initialization") + } + _ETSParameterExpressionSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'ETSParameterExpressionSetAnnotations was not overloaded by native module initialization") + } + _CreateTSTypeParameterInstantiation(context: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateTSTypeParameterInstantiation was not overloaded by native module initialization") + } + _UpdateTSTypeParameterInstantiation(context: KNativePointer, original: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateTSTypeParameterInstantiation was not overloaded by native module initialization") + } + _TSTypeParameterInstantiationParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeParameterInstantiationParamsConst was not overloaded by native module initialization") + } + _CreateNullLiteral(context: KNativePointer): KNativePointer { + throw new Error("'CreateNullLiteral was not overloaded by native module initialization") + } + _UpdateNullLiteral(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateNullLiteral was not overloaded by native module initialization") + } + _CreateTSInferType(context: KNativePointer, typeParam: KNativePointer): KNativePointer { + throw new Error("'CreateTSInferType was not overloaded by native module initialization") + } + _UpdateTSInferType(context: KNativePointer, original: KNativePointer, typeParam: KNativePointer): KNativePointer { + throw new Error("'UpdateTSInferType was not overloaded by native module initialization") + } + _TSInferTypeTypeParamConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInferTypeTypeParamConst was not overloaded by native module initialization") + } + _CreateSwitchCaseStatement(context: KNativePointer, test: KNativePointer, consequent: BigUint64Array, consequentSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateSwitchCaseStatement was not overloaded by native module initialization") + } + _UpdateSwitchCaseStatement(context: KNativePointer, original: KNativePointer, test: KNativePointer, consequent: BigUint64Array, consequentSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateSwitchCaseStatement was not overloaded by native module initialization") + } + _SwitchCaseStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SwitchCaseStatementTest was not overloaded by native module initialization") + } + _SwitchCaseStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SwitchCaseStatementTestConst was not overloaded by native module initialization") + } + _SwitchCaseStatementConsequentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SwitchCaseStatementConsequentConst was not overloaded by native module initialization") + } + _CreateYieldExpression(context: KNativePointer, argument: KNativePointer, isDelegate: KBoolean): KNativePointer { + throw new Error("'CreateYieldExpression was not overloaded by native module initialization") + } + _UpdateYieldExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer, isDelegate: KBoolean): KNativePointer { + throw new Error("'UpdateYieldExpression was not overloaded by native module initialization") + } + _YieldExpressionHasDelegateConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'YieldExpressionHasDelegateConst was not overloaded by native module initialization") + } + _YieldExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'YieldExpressionArgumentConst was not overloaded by native module initialization") + } + _CreateTSImportEqualsDeclaration(context: KNativePointer, id: KNativePointer, moduleReference: KNativePointer, isExport: KBoolean): KNativePointer { + throw new Error("'CreateTSImportEqualsDeclaration was not overloaded by native module initialization") + } + _UpdateTSImportEqualsDeclaration(context: KNativePointer, original: KNativePointer, id: KNativePointer, moduleReference: KNativePointer, isExport: KBoolean): KNativePointer { + throw new Error("'UpdateTSImportEqualsDeclaration was not overloaded by native module initialization") + } + _TSImportEqualsDeclarationIdConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSImportEqualsDeclarationIdConst was not overloaded by native module initialization") + } + _TSImportEqualsDeclarationModuleReferenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSImportEqualsDeclarationModuleReferenceConst was not overloaded by native module initialization") + } + _TSImportEqualsDeclarationIsExportConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSImportEqualsDeclarationIsExportConst was not overloaded by native module initialization") + } + _CreateBooleanLiteral(context: KNativePointer, value: KBoolean): KNativePointer { + throw new Error("'CreateBooleanLiteral was not overloaded by native module initialization") + } + _UpdateBooleanLiteral(context: KNativePointer, original: KNativePointer, value: KBoolean): KNativePointer { + throw new Error("'UpdateBooleanLiteral was not overloaded by native module initialization") + } + _BooleanLiteralValueConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'BooleanLiteralValueConst was not overloaded by native module initialization") + } + _CreateTSNumberKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSNumberKeyword was not overloaded by native module initialization") + } + _UpdateTSNumberKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSNumberKeyword was not overloaded by native module initialization") + } + _CreateClassStaticBlock(context: KNativePointer, value: KNativePointer): KNativePointer { + throw new Error("'CreateClassStaticBlock was not overloaded by native module initialization") + } + _UpdateClassStaticBlock(context: KNativePointer, original: KNativePointer, value: KNativePointer): KNativePointer { + throw new Error("'UpdateClassStaticBlock was not overloaded by native module initialization") + } + _ClassStaticBlockFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassStaticBlockFunction was not overloaded by native module initialization") + } + _ClassStaticBlockFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassStaticBlockFunctionConst was not overloaded by native module initialization") + } + _ClassStaticBlockNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ClassStaticBlockNameConst was not overloaded by native module initialization") + } + _CreateTSNonNullExpression(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'CreateTSNonNullExpression was not overloaded by native module initialization") + } + _UpdateTSNonNullExpression(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'UpdateTSNonNullExpression was not overloaded by native module initialization") + } + _TSNonNullExpressionExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSNonNullExpressionExprConst was not overloaded by native module initialization") + } + _TSNonNullExpressionExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSNonNullExpressionExpr was not overloaded by native module initialization") + } + _TSNonNullExpressionSetExpr(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'TSNonNullExpressionSetExpr was not overloaded by native module initialization") + } + _CreatePrefixAssertionExpression(context: KNativePointer, expr: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("'CreatePrefixAssertionExpression was not overloaded by native module initialization") + } + _UpdatePrefixAssertionExpression(context: KNativePointer, original: KNativePointer, expr: KNativePointer, type: KNativePointer): KNativePointer { + throw new Error("'UpdatePrefixAssertionExpression was not overloaded by native module initialization") + } + _PrefixAssertionExpressionExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'PrefixAssertionExpressionExprConst was not overloaded by native module initialization") + } + _PrefixAssertionExpressionTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'PrefixAssertionExpressionTypeConst was not overloaded by native module initialization") + } + _CreateClassExpression(context: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("'CreateClassExpression was not overloaded by native module initialization") + } + _UpdateClassExpression(context: KNativePointer, original: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("'UpdateClassExpression was not overloaded by native module initialization") + } + _ClassExpressionDefinitionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassExpressionDefinitionConst was not overloaded by native module initialization") + } + _CreateForOfStatement(context: KNativePointer, left: KNativePointer, right: KNativePointer, body: KNativePointer, isAwait: KBoolean): KNativePointer { + throw new Error("'CreateForOfStatement was not overloaded by native module initialization") + } + _UpdateForOfStatement(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer, body: KNativePointer, isAwait: KBoolean): KNativePointer { + throw new Error("'UpdateForOfStatement was not overloaded by native module initialization") + } + _ForOfStatementLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForOfStatementLeft was not overloaded by native module initialization") + } + _ForOfStatementLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForOfStatementLeftConst was not overloaded by native module initialization") + } + _ForOfStatementRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForOfStatementRight was not overloaded by native module initialization") + } + _ForOfStatementRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForOfStatementRightConst was not overloaded by native module initialization") + } + _ForOfStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForOfStatementBody was not overloaded by native module initialization") + } + _ForOfStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForOfStatementBodyConst was not overloaded by native module initialization") + } + _ForOfStatementIsAwaitConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ForOfStatementIsAwaitConst was not overloaded by native module initialization") + } + _CreateTemplateLiteral(context: KNativePointer, quasis: BigUint64Array, quasisSequenceLength: KUInt, expressions: BigUint64Array, expressionsSequenceLength: KUInt, multilineString: KStringPtr): KNativePointer { + throw new Error("'CreateTemplateLiteral was not overloaded by native module initialization") + } + _UpdateTemplateLiteral(context: KNativePointer, original: KNativePointer, quasis: BigUint64Array, quasisSequenceLength: KUInt, expressions: BigUint64Array, expressionsSequenceLength: KUInt, multilineString: KStringPtr): KNativePointer { + throw new Error("'UpdateTemplateLiteral was not overloaded by native module initialization") + } + _TemplateLiteralQuasisConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TemplateLiteralQuasisConst was not overloaded by native module initialization") + } + _TemplateLiteralExpressionsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TemplateLiteralExpressionsConst was not overloaded by native module initialization") + } + _TemplateLiteralGetMultilineStringConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'TemplateLiteralGetMultilineStringConst was not overloaded by native module initialization") + } + _CreateTSUnionType(context: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateTSUnionType was not overloaded by native module initialization") + } + _UpdateTSUnionType(context: KNativePointer, original: KNativePointer, types: BigUint64Array, typesSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateTSUnionType was not overloaded by native module initialization") + } + _TSUnionTypeTypesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSUnionTypeTypesConst was not overloaded by native module initialization") + } + _CreateTSUnknownKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSUnknownKeyword was not overloaded by native module initialization") + } + _UpdateTSUnknownKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSUnknownKeyword was not overloaded by native module initialization") + } + _CreateIdentifier(context: KNativePointer): KNativePointer { + throw new Error("'CreateIdentifier was not overloaded by native module initialization") + } + _UpdateIdentifier(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateIdentifier was not overloaded by native module initialization") + } + _CreateIdentifier1(context: KNativePointer, name: KStringPtr): KNativePointer { + throw new Error("'CreateIdentifier1 was not overloaded by native module initialization") + } + _UpdateIdentifier1(context: KNativePointer, original: KNativePointer, name: KStringPtr): KNativePointer { + throw new Error("'UpdateIdentifier1 was not overloaded by native module initialization") + } + _CreateIdentifier2(context: KNativePointer, name: KStringPtr, typeAnnotation: KNativePointer): KNativePointer { + throw new Error("'CreateIdentifier2 was not overloaded by native module initialization") + } + _UpdateIdentifier2(context: KNativePointer, original: KNativePointer, name: KStringPtr, typeAnnotation: KNativePointer): KNativePointer { + throw new Error("'UpdateIdentifier2 was not overloaded by native module initialization") + } + _IdentifierNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'IdentifierNameConst was not overloaded by native module initialization") + } + _IdentifierName(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'IdentifierName was not overloaded by native module initialization") + } + _IdentifierSetName(context: KNativePointer, receiver: KNativePointer, newName: KStringPtr): void { + throw new Error("'IdentifierSetName was not overloaded by native module initialization") + } + _IdentifierDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'IdentifierDecoratorsConst was not overloaded by native module initialization") + } + _IdentifierIsErrorPlaceHolderConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsErrorPlaceHolderConst was not overloaded by native module initialization") + } + _IdentifierIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsOptionalConst was not overloaded by native module initialization") + } + _IdentifierSetOptional(context: KNativePointer, receiver: KNativePointer, optional_arg: KBoolean): void { + throw new Error("'IdentifierSetOptional was not overloaded by native module initialization") + } + _IdentifierIsReferenceConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsReferenceConst was not overloaded by native module initialization") + } + _IdentifierIsTdzConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsTdzConst was not overloaded by native module initialization") + } + _IdentifierSetTdz(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'IdentifierSetTdz was not overloaded by native module initialization") + } + _IdentifierSetAccessor(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'IdentifierSetAccessor was not overloaded by native module initialization") + } + _IdentifierIsAccessorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsAccessorConst was not overloaded by native module initialization") + } + _IdentifierSetMutator(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'IdentifierSetMutator was not overloaded by native module initialization") + } + _IdentifierIsMutatorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsMutatorConst was not overloaded by native module initialization") + } + _IdentifierIsReceiverConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsReceiverConst was not overloaded by native module initialization") + } + _IdentifierIsPrivateIdentConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsPrivateIdentConst was not overloaded by native module initialization") + } + _IdentifierSetPrivate(context: KNativePointer, receiver: KNativePointer, isPrivate: KBoolean): void { + throw new Error("'IdentifierSetPrivate was not overloaded by native module initialization") + } + _IdentifierIsIgnoreBoxConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsIgnoreBoxConst was not overloaded by native module initialization") + } + _IdentifierSetIgnoreBox(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'IdentifierSetIgnoreBox was not overloaded by native module initialization") + } + _IdentifierIsAnnotationDeclConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsAnnotationDeclConst was not overloaded by native module initialization") + } + _IdentifierSetAnnotationDecl(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'IdentifierSetAnnotationDecl was not overloaded by native module initialization") + } + _IdentifierIsAnnotationUsageConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'IdentifierIsAnnotationUsageConst was not overloaded by native module initialization") + } + _IdentifierSetAnnotationUsage(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'IdentifierSetAnnotationUsage was not overloaded by native module initialization") + } + _IdentifierCloneReference(context: KNativePointer, receiver: KNativePointer, parent: KNativePointer): KNativePointer { + throw new Error("'IdentifierCloneReference was not overloaded by native module initialization") + } + _IdentifierValidateExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'IdentifierValidateExpression was not overloaded by native module initialization") + } + _IdentifierTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'IdentifierTypeAnnotationConst was not overloaded by native module initialization") + } + _IdentifierSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'IdentifierSetTsTypeAnnotation was not overloaded by native module initialization") + } + _CreateOpaqueTypeNode1(context: KNativePointer): KNativePointer { + throw new Error("'CreateOpaqueTypeNode1 was not overloaded by native module initialization") + } + _UpdateOpaqueTypeNode1(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateOpaqueTypeNode1 was not overloaded by native module initialization") + } + _CreateBlockStatement(context: KNativePointer, statementList: BigUint64Array, statementListSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateBlockStatement was not overloaded by native module initialization") + } + _UpdateBlockStatement(context: KNativePointer, original: KNativePointer, statementList: BigUint64Array, statementListSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateBlockStatement was not overloaded by native module initialization") + } + _BlockStatementStatementsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BlockStatementStatementsConst was not overloaded by native module initialization") + } + _BlockStatementStatements(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BlockStatementStatements was not overloaded by native module initialization") + } + _BlockStatementSetStatements(context: KNativePointer, receiver: KNativePointer, statementList: BigUint64Array, statementListSequenceLength: KUInt): void { + throw new Error("'BlockStatementSetStatements was not overloaded by native module initialization") + } + _BlockStatementAddTrailingBlock(context: KNativePointer, receiver: KNativePointer, stmt: KNativePointer, trailingBlock: KNativePointer): void { + throw new Error("'BlockStatementAddTrailingBlock was not overloaded by native module initialization") + } + _CreateDirectEvalExpression(context: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt, typeParams: KNativePointer, optional_arg: KBoolean, parserStatus: KUInt): KNativePointer { + throw new Error("'CreateDirectEvalExpression was not overloaded by native module initialization") + } + _UpdateDirectEvalExpression(context: KNativePointer, original: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt, typeParams: KNativePointer, optional_arg: KBoolean, parserStatus: KUInt): KNativePointer { + throw new Error("'UpdateDirectEvalExpression was not overloaded by native module initialization") + } + _CreateTSTypeParameterDeclaration(context: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt, requiredParams: KUInt): KNativePointer { + throw new Error("'CreateTSTypeParameterDeclaration was not overloaded by native module initialization") + } + _UpdateTSTypeParameterDeclaration(context: KNativePointer, original: KNativePointer, params: BigUint64Array, paramsSequenceLength: KUInt, requiredParams: KUInt): KNativePointer { + throw new Error("'UpdateTSTypeParameterDeclaration was not overloaded by native module initialization") + } + _TSTypeParameterDeclarationParamsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSTypeParameterDeclarationParamsConst was not overloaded by native module initialization") + } + _TSTypeParameterDeclarationAddParam(context: KNativePointer, receiver: KNativePointer, param: KNativePointer): void { + throw new Error("'TSTypeParameterDeclarationAddParam was not overloaded by native module initialization") + } + _TSTypeParameterDeclarationRequiredParamsConst(context: KNativePointer, receiver: KNativePointer): KUInt { + throw new Error("'TSTypeParameterDeclarationRequiredParamsConst was not overloaded by native module initialization") + } + _CreateMethodDefinition(context: KNativePointer, kind: KInt, key: KNativePointer, value: KNativePointer, modifiers: KInt, isComputed: KBoolean): KNativePointer { + throw new Error("'CreateMethodDefinition was not overloaded by native module initialization") + } + _UpdateMethodDefinition(context: KNativePointer, original: KNativePointer, kind: KInt, key: KNativePointer, value: KNativePointer, modifiers: KInt, isComputed: KBoolean): KNativePointer { + throw new Error("'UpdateMethodDefinition was not overloaded by native module initialization") + } + _MethodDefinitionKindConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'MethodDefinitionKindConst was not overloaded by native module initialization") + } + _MethodDefinitionIsConstructorConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'MethodDefinitionIsConstructorConst was not overloaded by native module initialization") + } + _MethodDefinitionIsExtensionMethodConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'MethodDefinitionIsExtensionMethodConst was not overloaded by native module initialization") + } + _MethodDefinitionOverloadsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MethodDefinitionOverloadsConst was not overloaded by native module initialization") + } + _MethodDefinitionBaseOverloadMethodConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MethodDefinitionBaseOverloadMethodConst was not overloaded by native module initialization") + } + _MethodDefinitionBaseOverloadMethod(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MethodDefinitionBaseOverloadMethod was not overloaded by native module initialization") + } + _MethodDefinitionAsyncPairMethodConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MethodDefinitionAsyncPairMethodConst was not overloaded by native module initialization") + } + _MethodDefinitionAsyncPairMethod(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MethodDefinitionAsyncPairMethod was not overloaded by native module initialization") + } + _MethodDefinitionSetOverloads(context: KNativePointer, receiver: KNativePointer, overloads: BigUint64Array, overloadsSequenceLength: KUInt): void { + throw new Error("'MethodDefinitionSetOverloads was not overloaded by native module initialization") + } + _MethodDefinitionClearOverloads(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'MethodDefinitionClearOverloads was not overloaded by native module initialization") + } + _MethodDefinitionAddOverload(context: KNativePointer, receiver: KNativePointer, overload: KNativePointer): void { + throw new Error("'MethodDefinitionAddOverload was not overloaded by native module initialization") + } + _MethodDefinitionSetBaseOverloadMethod(context: KNativePointer, receiver: KNativePointer, baseOverloadMethod: KNativePointer): void { + throw new Error("'MethodDefinitionSetBaseOverloadMethod was not overloaded by native module initialization") + } + _MethodDefinitionSetAsyncPairMethod(context: KNativePointer, receiver: KNativePointer, method: KNativePointer): void { + throw new Error("'MethodDefinitionSetAsyncPairMethod was not overloaded by native module initialization") + } + _MethodDefinitionHasOverload(context: KNativePointer, receiver: KNativePointer, overload: KNativePointer): KBoolean { + throw new Error("'MethodDefinitionHasOverload was not overloaded by native module initialization") + } + _MethodDefinitionFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MethodDefinitionFunction was not overloaded by native module initialization") + } + _MethodDefinitionFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'MethodDefinitionFunctionConst was not overloaded by native module initialization") + } + _CreateTSNullKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSNullKeyword was not overloaded by native module initialization") + } + _UpdateTSNullKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSNullKeyword was not overloaded by native module initialization") + } + _CreateTSInterfaceHeritage(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'CreateTSInterfaceHeritage was not overloaded by native module initialization") + } + _UpdateTSInterfaceHeritage(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'UpdateTSInterfaceHeritage was not overloaded by native module initialization") + } + _TSInterfaceHeritageExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceHeritageExpr was not overloaded by native module initialization") + } + _TSInterfaceHeritageExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSInterfaceHeritageExprConst was not overloaded by native module initialization") + } + _ExpressionIsGroupedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ExpressionIsGroupedConst was not overloaded by native module initialization") + } + _ExpressionSetGrouped(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'ExpressionSetGrouped was not overloaded by native module initialization") + } + _ExpressionAsLiteralConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExpressionAsLiteralConst was not overloaded by native module initialization") + } + _ExpressionAsLiteral(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExpressionAsLiteral was not overloaded by native module initialization") + } + _ExpressionIsLiteralConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ExpressionIsLiteralConst was not overloaded by native module initialization") + } + _ExpressionIsTypeNodeConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ExpressionIsTypeNodeConst was not overloaded by native module initialization") + } + _ExpressionIsAnnotatedExpressionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ExpressionIsAnnotatedExpressionConst was not overloaded by native module initialization") + } + _ExpressionAsTypeNode(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExpressionAsTypeNode was not overloaded by native module initialization") + } + _ExpressionAsTypeNodeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExpressionAsTypeNodeConst was not overloaded by native module initialization") + } + _ExpressionAsAnnotatedExpression(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExpressionAsAnnotatedExpression was not overloaded by native module initialization") + } + _ExpressionAsAnnotatedExpressionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ExpressionAsAnnotatedExpressionConst was not overloaded by native module initialization") + } + _ExpressionIsBrokenExpressionConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ExpressionIsBrokenExpressionConst was not overloaded by native module initialization") + } + _ExpressionToStringConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ExpressionToStringConst was not overloaded by native module initialization") + } + _AnnotatedExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AnnotatedExpressionTypeAnnotationConst was not overloaded by native module initialization") + } + _AnnotatedExpressionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'AnnotatedExpressionSetTsTypeAnnotation was not overloaded by native module initialization") + } + _MaybeOptionalExpressionIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'MaybeOptionalExpressionIsOptionalConst was not overloaded by native module initialization") + } + _MaybeOptionalExpressionClearOptional(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'MaybeOptionalExpressionClearOptional was not overloaded by native module initialization") + } + _CreateSrcDumper(context: KNativePointer, node: KNativePointer): KNativePointer { + throw new Error("'CreateSrcDumper was not overloaded by native module initialization") + } + _SrcDumperAdd(context: KNativePointer, receiver: KNativePointer, str: KStringPtr): void { + throw new Error("'SrcDumperAdd was not overloaded by native module initialization") + } + _SrcDumperAdd1(context: KNativePointer, receiver: KNativePointer, i: KInt): void { + throw new Error("'SrcDumperAdd1 was not overloaded by native module initialization") + } + _SrcDumperAdd2(context: KNativePointer, receiver: KNativePointer, l: KLong): void { + throw new Error("'SrcDumperAdd2 was not overloaded by native module initialization") + } + _SrcDumperAdd3(context: KNativePointer, receiver: KNativePointer, f: KFloat): void { + throw new Error("'SrcDumperAdd3 was not overloaded by native module initialization") + } + _SrcDumperAdd4(context: KNativePointer, receiver: KNativePointer, d: KDouble): void { + throw new Error("'SrcDumperAdd4 was not overloaded by native module initialization") + } + _SrcDumperStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'SrcDumperStrConst was not overloaded by native module initialization") + } + _SrcDumperIncrIndent(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'SrcDumperIncrIndent was not overloaded by native module initialization") + } + _SrcDumperDecrIndent(context: KNativePointer, receiver: KNativePointer): void { + throw new Error("'SrcDumperDecrIndent was not overloaded by native module initialization") + } + _SrcDumperEndl(context: KNativePointer, receiver: KNativePointer, num: KUInt): void { + throw new Error("'SrcDumperEndl was not overloaded by native module initialization") + } + _CreateETSClassLiteral(context: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'CreateETSClassLiteral was not overloaded by native module initialization") + } + _UpdateETSClassLiteral(context: KNativePointer, original: KNativePointer, expr: KNativePointer): KNativePointer { + throw new Error("'UpdateETSClassLiteral was not overloaded by native module initialization") + } + _ETSClassLiteralExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSClassLiteralExprConst was not overloaded by native module initialization") + } + _CreateBreakStatement(context: KNativePointer): KNativePointer { + throw new Error("'CreateBreakStatement was not overloaded by native module initialization") + } + _UpdateBreakStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateBreakStatement was not overloaded by native module initialization") + } + _CreateBreakStatement1(context: KNativePointer, ident: KNativePointer): KNativePointer { + throw new Error("'CreateBreakStatement1 was not overloaded by native module initialization") + } + _UpdateBreakStatement1(context: KNativePointer, original: KNativePointer, ident: KNativePointer): KNativePointer { + throw new Error("'UpdateBreakStatement1 was not overloaded by native module initialization") + } + _BreakStatementIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BreakStatementIdentConst was not overloaded by native module initialization") + } + _BreakStatementIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BreakStatementIdent was not overloaded by native module initialization") + } + _BreakStatementTargetConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'BreakStatementTargetConst was not overloaded by native module initialization") + } + _BreakStatementSetTarget(context: KNativePointer, receiver: KNativePointer, target: KNativePointer): void { + throw new Error("'BreakStatementSetTarget was not overloaded by native module initialization") + } + _CreateRegExpLiteral(context: KNativePointer, pattern: KStringPtr, flags: KInt, flagsStr: KStringPtr): KNativePointer { + throw new Error("'CreateRegExpLiteral was not overloaded by native module initialization") + } + _UpdateRegExpLiteral(context: KNativePointer, original: KNativePointer, pattern: KStringPtr, flags: KInt, flagsStr: KStringPtr): KNativePointer { + throw new Error("'UpdateRegExpLiteral was not overloaded by native module initialization") + } + _RegExpLiteralPatternConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'RegExpLiteralPatternConst was not overloaded by native module initialization") + } + _RegExpLiteralFlagsConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'RegExpLiteralFlagsConst was not overloaded by native module initialization") + } + _CreateTSMappedType(context: KNativePointer, typeParameter: KNativePointer, typeAnnotation: KNativePointer, readonly_arg: KInt, optional_arg: KInt): KNativePointer { + throw new Error("'CreateTSMappedType was not overloaded by native module initialization") + } + _UpdateTSMappedType(context: KNativePointer, original: KNativePointer, typeParameter: KNativePointer, typeAnnotation: KNativePointer, readonly_arg: KInt, optional_arg: KInt): KNativePointer { + throw new Error("'UpdateTSMappedType was not overloaded by native module initialization") + } + _TSMappedTypeTypeParameter(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSMappedTypeTypeParameter was not overloaded by native module initialization") + } + _TSMappedTypeTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSMappedTypeTypeAnnotation was not overloaded by native module initialization") + } + _TSMappedTypeReadonly(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'TSMappedTypeReadonly was not overloaded by native module initialization") + } + _TSMappedTypeOptional(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'TSMappedTypeOptional was not overloaded by native module initialization") + } + _CreateTSAnyKeyword(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSAnyKeyword was not overloaded by native module initialization") + } + _UpdateTSAnyKeyword(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSAnyKeyword was not overloaded by native module initialization") + } + _CreateClassDeclaration(context: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("'CreateClassDeclaration was not overloaded by native module initialization") + } + _UpdateClassDeclaration(context: KNativePointer, original: KNativePointer, def: KNativePointer): KNativePointer { + throw new Error("'UpdateClassDeclaration was not overloaded by native module initialization") + } + _ClassDeclarationDefinition(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDeclarationDefinition was not overloaded by native module initialization") + } + _ClassDeclarationDefinitionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDeclarationDefinitionConst was not overloaded by native module initialization") + } + _ClassDeclarationDecoratorsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ClassDeclarationDecoratorsConst was not overloaded by native module initialization") + } + _CreateTSIndexedAccessType(context: KNativePointer, objectType: KNativePointer, indexType: KNativePointer): KNativePointer { + throw new Error("'CreateTSIndexedAccessType was not overloaded by native module initialization") + } + _UpdateTSIndexedAccessType(context: KNativePointer, original: KNativePointer, objectType: KNativePointer, indexType: KNativePointer): KNativePointer { + throw new Error("'UpdateTSIndexedAccessType was not overloaded by native module initialization") + } + _TSIndexedAccessTypeObjectTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSIndexedAccessTypeObjectTypeConst was not overloaded by native module initialization") + } + _TSIndexedAccessTypeIndexTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSIndexedAccessTypeIndexTypeConst was not overloaded by native module initialization") + } + _CreateTSQualifiedName(context: KNativePointer, left: KNativePointer, right: KNativePointer): KNativePointer { + throw new Error("'CreateTSQualifiedName was not overloaded by native module initialization") + } + _UpdateTSQualifiedName(context: KNativePointer, original: KNativePointer, left: KNativePointer, right: KNativePointer): KNativePointer { + throw new Error("'UpdateTSQualifiedName was not overloaded by native module initialization") + } + _TSQualifiedNameLeftConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSQualifiedNameLeftConst was not overloaded by native module initialization") + } + _TSQualifiedNameLeft(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSQualifiedNameLeft was not overloaded by native module initialization") + } + _TSQualifiedNameRightConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSQualifiedNameRightConst was not overloaded by native module initialization") + } + _TSQualifiedNameRight(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSQualifiedNameRight was not overloaded by native module initialization") + } + _TSQualifiedNameNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'TSQualifiedNameNameConst was not overloaded by native module initialization") + } + _TSQualifiedNameResolveLeftMostQualifiedName(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSQualifiedNameResolveLeftMostQualifiedName was not overloaded by native module initialization") + } + _TSQualifiedNameResolveLeftMostQualifiedNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSQualifiedNameResolveLeftMostQualifiedNameConst was not overloaded by native module initialization") + } + _CreateAwaitExpression(context: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("'CreateAwaitExpression was not overloaded by native module initialization") + } + _UpdateAwaitExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("'UpdateAwaitExpression was not overloaded by native module initialization") + } + _AwaitExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'AwaitExpressionArgumentConst was not overloaded by native module initialization") + } + _CreateValidationInfo(context: KNativePointer): KNativePointer { + throw new Error("'CreateValidationInfo was not overloaded by native module initialization") + } + _ValidationInfoFailConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'ValidationInfoFailConst was not overloaded by native module initialization") + } + _CreateContinueStatement(context: KNativePointer): KNativePointer { + throw new Error("'CreateContinueStatement was not overloaded by native module initialization") + } + _UpdateContinueStatement(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateContinueStatement was not overloaded by native module initialization") + } + _CreateContinueStatement1(context: KNativePointer, ident: KNativePointer): KNativePointer { + throw new Error("'CreateContinueStatement1 was not overloaded by native module initialization") + } + _UpdateContinueStatement1(context: KNativePointer, original: KNativePointer, ident: KNativePointer): KNativePointer { + throw new Error("'UpdateContinueStatement1 was not overloaded by native module initialization") + } + _ContinueStatementIdentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ContinueStatementIdentConst was not overloaded by native module initialization") + } + _ContinueStatementIdent(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ContinueStatementIdent was not overloaded by native module initialization") + } + _ContinueStatementTargetConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ContinueStatementTargetConst was not overloaded by native module initialization") + } + _ContinueStatementSetTarget(context: KNativePointer, receiver: KNativePointer, target: KNativePointer): void { + throw new Error("'ContinueStatementSetTarget was not overloaded by native module initialization") + } + _CreateETSNewMultiDimArrayInstanceExpression(context: KNativePointer, typeReference: KNativePointer, dimensions: BigUint64Array, dimensionsSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateETSNewMultiDimArrayInstanceExpression was not overloaded by native module initialization") + } + _UpdateETSNewMultiDimArrayInstanceExpression(context: KNativePointer, original: KNativePointer, typeReference: KNativePointer, dimensions: BigUint64Array, dimensionsSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateETSNewMultiDimArrayInstanceExpression was not overloaded by native module initialization") + } + _CreateETSNewMultiDimArrayInstanceExpression1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("'CreateETSNewMultiDimArrayInstanceExpression1 was not overloaded by native module initialization") + } + _UpdateETSNewMultiDimArrayInstanceExpression1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("'UpdateETSNewMultiDimArrayInstanceExpression1 was not overloaded by native module initialization") + } + _ETSNewMultiDimArrayInstanceExpressionTypeReference(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewMultiDimArrayInstanceExpressionTypeReference was not overloaded by native module initialization") + } + _ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst was not overloaded by native module initialization") + } + _ETSNewMultiDimArrayInstanceExpressionDimensions(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewMultiDimArrayInstanceExpressionDimensions was not overloaded by native module initialization") + } + _ETSNewMultiDimArrayInstanceExpressionDimensionsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewMultiDimArrayInstanceExpressionDimensionsConst was not overloaded by native module initialization") + } + _CreateTSNamedTupleMember(context: KNativePointer, label: KNativePointer, elementType: KNativePointer, optional_arg: KBoolean): KNativePointer { + throw new Error("'CreateTSNamedTupleMember was not overloaded by native module initialization") + } + _UpdateTSNamedTupleMember(context: KNativePointer, original: KNativePointer, label: KNativePointer, elementType: KNativePointer, optional_arg: KBoolean): KNativePointer { + throw new Error("'UpdateTSNamedTupleMember was not overloaded by native module initialization") + } + _TSNamedTupleMemberLabelConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSNamedTupleMemberLabelConst was not overloaded by native module initialization") + } + _TSNamedTupleMemberElementType(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSNamedTupleMemberElementType was not overloaded by native module initialization") + } + _TSNamedTupleMemberElementTypeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSNamedTupleMemberElementTypeConst was not overloaded by native module initialization") + } + _TSNamedTupleMemberIsOptionalConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSNamedTupleMemberIsOptionalConst was not overloaded by native module initialization") + } + _CreateImportExpression(context: KNativePointer, source: KNativePointer): KNativePointer { + throw new Error("'CreateImportExpression was not overloaded by native module initialization") + } + _UpdateImportExpression(context: KNativePointer, original: KNativePointer, source: KNativePointer): KNativePointer { + throw new Error("'UpdateImportExpression was not overloaded by native module initialization") + } + _ImportExpressionSource(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportExpressionSource was not overloaded by native module initialization") + } + _ImportExpressionSourceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ImportExpressionSourceConst was not overloaded by native module initialization") + } + _CreateAstDumper(context: KNativePointer, node: KNativePointer, sourceCode: KStringPtr): KNativePointer { + throw new Error("'CreateAstDumper was not overloaded by native module initialization") + } + _AstDumperModifierToString(context: KNativePointer, receiver: KNativePointer, flags: KInt): KStringPtr { + throw new Error("'AstDumperModifierToString was not overloaded by native module initialization") + } + _AstDumperTypeOperatorToString(context: KNativePointer, receiver: KNativePointer, operatorType: KInt): KStringPtr { + throw new Error("'AstDumperTypeOperatorToString was not overloaded by native module initialization") + } + _AstDumperStrConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'AstDumperStrConst was not overloaded by native module initialization") + } + _CreateETSNullTypeIr(context: KNativePointer): KNativePointer { + throw new Error("'CreateETSNullTypeIr was not overloaded by native module initialization") + } + _UpdateETSNullTypeIr(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateETSNullTypeIr was not overloaded by native module initialization") + } + _CreateETSUndefinedTypeIr(context: KNativePointer): KNativePointer { + throw new Error("'CreateETSUndefinedTypeIr was not overloaded by native module initialization") + } + _UpdateETSUndefinedTypeIr(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateETSUndefinedTypeIr was not overloaded by native module initialization") + } + _CreateTypeofExpression(context: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("'CreateTypeofExpression was not overloaded by native module initialization") + } + _UpdateTypeofExpression(context: KNativePointer, original: KNativePointer, argument: KNativePointer): KNativePointer { + throw new Error("'UpdateTypeofExpression was not overloaded by native module initialization") + } + _TypeofExpressionArgumentConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TypeofExpressionArgumentConst was not overloaded by native module initialization") + } + _CreateTSEnumMember(context: KNativePointer, key: KNativePointer, init: KNativePointer): KNativePointer { + throw new Error("'CreateTSEnumMember was not overloaded by native module initialization") + } + _UpdateTSEnumMember(context: KNativePointer, original: KNativePointer, key: KNativePointer, init: KNativePointer): KNativePointer { + throw new Error("'UpdateTSEnumMember was not overloaded by native module initialization") + } + _CreateTSEnumMember1(context: KNativePointer, key: KNativePointer, init: KNativePointer, isGenerated: KBoolean): KNativePointer { + throw new Error("'CreateTSEnumMember1 was not overloaded by native module initialization") + } + _UpdateTSEnumMember1(context: KNativePointer, original: KNativePointer, key: KNativePointer, init: KNativePointer, isGenerated: KBoolean): KNativePointer { + throw new Error("'UpdateTSEnumMember1 was not overloaded by native module initialization") + } + _TSEnumMemberKeyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSEnumMemberKeyConst was not overloaded by native module initialization") + } + _TSEnumMemberKey(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSEnumMemberKey was not overloaded by native module initialization") + } + _TSEnumMemberInitConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSEnumMemberInitConst was not overloaded by native module initialization") + } + _TSEnumMemberInit(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSEnumMemberInit was not overloaded by native module initialization") + } + _TSEnumMemberIsGeneratedConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSEnumMemberIsGeneratedConst was not overloaded by native module initialization") + } + _TSEnumMemberNameConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'TSEnumMemberNameConst was not overloaded by native module initialization") + } + _CreateSwitchStatement(context: KNativePointer, discriminant: KNativePointer, cases: BigUint64Array, casesSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateSwitchStatement was not overloaded by native module initialization") + } + _UpdateSwitchStatement(context: KNativePointer, original: KNativePointer, discriminant: KNativePointer, cases: BigUint64Array, casesSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateSwitchStatement was not overloaded by native module initialization") + } + _SwitchStatementDiscriminantConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SwitchStatementDiscriminantConst was not overloaded by native module initialization") + } + _SwitchStatementDiscriminant(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SwitchStatementDiscriminant was not overloaded by native module initialization") + } + _SwitchStatementCasesConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SwitchStatementCasesConst was not overloaded by native module initialization") + } + _SwitchStatementCases(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SwitchStatementCases was not overloaded by native module initialization") + } + _CreateDoWhileStatement(context: KNativePointer, body: KNativePointer, test: KNativePointer): KNativePointer { + throw new Error("'CreateDoWhileStatement was not overloaded by native module initialization") + } + _UpdateDoWhileStatement(context: KNativePointer, original: KNativePointer, body: KNativePointer, test: KNativePointer): KNativePointer { + throw new Error("'UpdateDoWhileStatement was not overloaded by native module initialization") + } + _DoWhileStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'DoWhileStatementBodyConst was not overloaded by native module initialization") + } + _DoWhileStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'DoWhileStatementBody was not overloaded by native module initialization") + } + _DoWhileStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'DoWhileStatementTestConst was not overloaded by native module initialization") + } + _DoWhileStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'DoWhileStatementTest was not overloaded by native module initialization") + } + _CreateCatchClause(context: KNativePointer, param: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("'CreateCatchClause was not overloaded by native module initialization") + } + _UpdateCatchClause(context: KNativePointer, original: KNativePointer, param: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("'UpdateCatchClause was not overloaded by native module initialization") + } + _CatchClauseParam(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CatchClauseParam was not overloaded by native module initialization") + } + _CatchClauseParamConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CatchClauseParamConst was not overloaded by native module initialization") + } + _CatchClauseBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CatchClauseBody was not overloaded by native module initialization") + } + _CatchClauseBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'CatchClauseBodyConst was not overloaded by native module initialization") + } + _CatchClauseIsDefaultCatchClauseConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'CatchClauseIsDefaultCatchClauseConst was not overloaded by native module initialization") + } + _CreateSequenceExpression(context: KNativePointer, sequence_arg: BigUint64Array, sequence_argSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateSequenceExpression was not overloaded by native module initialization") + } + _UpdateSequenceExpression(context: KNativePointer, original: KNativePointer, sequence_arg: BigUint64Array, sequence_argSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateSequenceExpression was not overloaded by native module initialization") + } + _SequenceExpressionSequenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SequenceExpressionSequenceConst was not overloaded by native module initialization") + } + _SequenceExpressionSequence(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'SequenceExpressionSequence was not overloaded by native module initialization") + } + _CreateArrowFunctionExpression(context: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("'CreateArrowFunctionExpression was not overloaded by native module initialization") + } + _UpdateArrowFunctionExpression(context: KNativePointer, original: KNativePointer, func: KNativePointer): KNativePointer { + throw new Error("'UpdateArrowFunctionExpression was not overloaded by native module initialization") + } + _CreateArrowFunctionExpression1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("'CreateArrowFunctionExpression1 was not overloaded by native module initialization") + } + _UpdateArrowFunctionExpression1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("'UpdateArrowFunctionExpression1 was not overloaded by native module initialization") + } + _ArrowFunctionExpressionFunctionConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrowFunctionExpressionFunctionConst was not overloaded by native module initialization") + } + _ArrowFunctionExpressionFunction(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrowFunctionExpressionFunction was not overloaded by native module initialization") + } + _ArrowFunctionExpressionCreateTypeAnnotation(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrowFunctionExpressionCreateTypeAnnotation was not overloaded by native module initialization") + } + _ArrowFunctionExpressionAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrowFunctionExpressionAnnotations was not overloaded by native module initialization") + } + _ArrowFunctionExpressionAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ArrowFunctionExpressionAnnotationsConst was not overloaded by native module initialization") + } + _ArrowFunctionExpressionSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'ArrowFunctionExpressionSetAnnotations was not overloaded by native module initialization") + } + _CreateOmittedExpression(context: KNativePointer): KNativePointer { + throw new Error("'CreateOmittedExpression was not overloaded by native module initialization") + } + _UpdateOmittedExpression(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateOmittedExpression was not overloaded by native module initialization") + } + _CreateETSNewClassInstanceExpression(context: KNativePointer, typeReference: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateETSNewClassInstanceExpression was not overloaded by native module initialization") + } + _UpdateETSNewClassInstanceExpression(context: KNativePointer, original: KNativePointer, typeReference: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateETSNewClassInstanceExpression was not overloaded by native module initialization") + } + _CreateETSNewClassInstanceExpression1(context: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("'CreateETSNewClassInstanceExpression1 was not overloaded by native module initialization") + } + _UpdateETSNewClassInstanceExpression1(context: KNativePointer, original: KNativePointer, other: KNativePointer): KNativePointer { + throw new Error("'UpdateETSNewClassInstanceExpression1 was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionGetTypeRefConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewClassInstanceExpressionGetTypeRefConst was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionGetArguments(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewClassInstanceExpressionGetArguments was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionGetArgumentsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSNewClassInstanceExpressionGetArgumentsConst was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionSetArguments(context: KNativePointer, receiver: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): void { + throw new Error("'ETSNewClassInstanceExpressionSetArguments was not overloaded by native module initialization") + } + _ETSNewClassInstanceExpressionAddToArgumentsFront(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'ETSNewClassInstanceExpressionAddToArgumentsFront was not overloaded by native module initialization") + } + _CreateTSAsExpression(context: KNativePointer, expression: KNativePointer, typeAnnotation: KNativePointer, isConst: KBoolean): KNativePointer { + throw new Error("'CreateTSAsExpression was not overloaded by native module initialization") + } + _UpdateTSAsExpression(context: KNativePointer, original: KNativePointer, expression: KNativePointer, typeAnnotation: KNativePointer, isConst: KBoolean): KNativePointer { + throw new Error("'UpdateTSAsExpression was not overloaded by native module initialization") + } + _TSAsExpressionExprConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSAsExpressionExprConst was not overloaded by native module initialization") + } + _TSAsExpressionExpr(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSAsExpressionExpr was not overloaded by native module initialization") + } + _TSAsExpressionSetExpr(context: KNativePointer, receiver: KNativePointer, expr: KNativePointer): void { + throw new Error("'TSAsExpressionSetExpr was not overloaded by native module initialization") + } + _TSAsExpressionIsConstConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSAsExpressionIsConstConst was not overloaded by native module initialization") + } + _TSAsExpressionSetUncheckedCast(context: KNativePointer, receiver: KNativePointer, isUncheckedCast: KBoolean): void { + throw new Error("'TSAsExpressionSetUncheckedCast was not overloaded by native module initialization") + } + _TSAsExpressionTypeAnnotationConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSAsExpressionTypeAnnotationConst was not overloaded by native module initialization") + } + _TSAsExpressionSetTsTypeAnnotation(context: KNativePointer, receiver: KNativePointer, typeAnnotation: KNativePointer): void { + throw new Error("'TSAsExpressionSetTsTypeAnnotation was not overloaded by native module initialization") + } + _CreateForUpdateStatement(context: KNativePointer, init: KNativePointer, test: KNativePointer, update: KNativePointer, body: KNativePointer): KNativePointer { + throw new Error("'CreateForUpdateStatement was not overloaded by native module initialization") + } + _ForUpdateStatementInit(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForUpdateStatementInit was not overloaded by native module initialization") + } + _ForUpdateStatementInitConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForUpdateStatementInitConst was not overloaded by native module initialization") + } + _ForUpdateStatementTest(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForUpdateStatementTest was not overloaded by native module initialization") + } + _ForUpdateStatementTestConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForUpdateStatementTestConst was not overloaded by native module initialization") + } + _ForUpdateStatementUpdateConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForUpdateStatementUpdateConst was not overloaded by native module initialization") + } + _ForUpdateStatementBody(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForUpdateStatementBody was not overloaded by native module initialization") + } + _ForUpdateStatementBodyConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ForUpdateStatementBodyConst was not overloaded by native module initialization") + } + _CreateETSTypeReferencePart(context: KNativePointer, name: KNativePointer, typeParams: KNativePointer, prev: KNativePointer): KNativePointer { + throw new Error("'CreateETSTypeReferencePart was not overloaded by native module initialization") + } + _UpdateETSTypeReferencePart(context: KNativePointer, original: KNativePointer, name: KNativePointer, typeParams: KNativePointer, prev: KNativePointer): KNativePointer { + throw new Error("'UpdateETSTypeReferencePart was not overloaded by native module initialization") + } + _CreateETSTypeReferencePart1(context: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("'CreateETSTypeReferencePart1 was not overloaded by native module initialization") + } + _UpdateETSTypeReferencePart1(context: KNativePointer, original: KNativePointer, name: KNativePointer): KNativePointer { + throw new Error("'UpdateETSTypeReferencePart1 was not overloaded by native module initialization") + } + _ETSTypeReferencePartPrevious(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSTypeReferencePartPrevious was not overloaded by native module initialization") + } + _ETSTypeReferencePartPreviousConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSTypeReferencePartPreviousConst was not overloaded by native module initialization") + } + _ETSTypeReferencePartName(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSTypeReferencePartName was not overloaded by native module initialization") + } + _ETSTypeReferencePartTypeParams(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSTypeReferencePartTypeParams was not overloaded by native module initialization") + } + _ETSTypeReferencePartNameConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSTypeReferencePartNameConst was not overloaded by native module initialization") + } + _ETSReExportDeclarationGetETSImportDeclarationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSReExportDeclarationGetETSImportDeclarationsConst was not overloaded by native module initialization") + } + _ETSReExportDeclarationGetETSImportDeclarations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSReExportDeclarationGetETSImportDeclarations was not overloaded by native module initialization") + } + _ETSReExportDeclarationGetProgramPathConst(context: KNativePointer, receiver: KNativePointer): KStringPtr { + throw new Error("'ETSReExportDeclarationGetProgramPathConst was not overloaded by native module initialization") + } + _CreateETSPrimitiveType(context: KNativePointer, type: KInt): KNativePointer { + throw new Error("'CreateETSPrimitiveType was not overloaded by native module initialization") + } + _UpdateETSPrimitiveType(context: KNativePointer, original: KNativePointer, type: KInt): KNativePointer { + throw new Error("'UpdateETSPrimitiveType was not overloaded by native module initialization") + } + _ETSPrimitiveTypeGetPrimitiveTypeConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'ETSPrimitiveTypeGetPrimitiveTypeConst was not overloaded by native module initialization") + } + _TypeNodeAnnotations(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TypeNodeAnnotations was not overloaded by native module initialization") + } + _TypeNodeAnnotationsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TypeNodeAnnotationsConst was not overloaded by native module initialization") + } + _TypeNodeSetAnnotations(context: KNativePointer, receiver: KNativePointer, annotations: BigUint64Array, annotationsSequenceLength: KUInt): void { + throw new Error("'TypeNodeSetAnnotations was not overloaded by native module initialization") + } + _CreateNewExpression(context: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): KNativePointer { + throw new Error("'CreateNewExpression was not overloaded by native module initialization") + } + _UpdateNewExpression(context: KNativePointer, original: KNativePointer, callee: KNativePointer, _arguments: BigUint64Array, _argumentsSequenceLength: KUInt): KNativePointer { + throw new Error("'UpdateNewExpression was not overloaded by native module initialization") + } + _NewExpressionCalleeConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'NewExpressionCalleeConst was not overloaded by native module initialization") + } + _NewExpressionArgumentsConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'NewExpressionArgumentsConst was not overloaded by native module initialization") + } + _CreateTSParameterProperty(context: KNativePointer, accessibility: KInt, parameter: KNativePointer, readonly_arg: KBoolean, isStatic: KBoolean, isExport: KBoolean): KNativePointer { + throw new Error("'CreateTSParameterProperty was not overloaded by native module initialization") + } + _UpdateTSParameterProperty(context: KNativePointer, original: KNativePointer, accessibility: KInt, parameter: KNativePointer, readonly_arg: KBoolean, isStatic: KBoolean, isExport: KBoolean): KNativePointer { + throw new Error("'UpdateTSParameterProperty was not overloaded by native module initialization") + } + _TSParameterPropertyAccessibilityConst(context: KNativePointer, receiver: KNativePointer): KInt { + throw new Error("'TSParameterPropertyAccessibilityConst was not overloaded by native module initialization") + } + _TSParameterPropertyReadonlyConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSParameterPropertyReadonlyConst was not overloaded by native module initialization") + } + _TSParameterPropertyIsStaticConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSParameterPropertyIsStaticConst was not overloaded by native module initialization") + } + _TSParameterPropertyIsExportConst(context: KNativePointer, receiver: KNativePointer): KBoolean { + throw new Error("'TSParameterPropertyIsExportConst was not overloaded by native module initialization") + } + _TSParameterPropertyParameterConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'TSParameterPropertyParameterConst was not overloaded by native module initialization") + } + _CreateETSWildcardType(context: KNativePointer, typeReference: KNativePointer, flags: KInt): KNativePointer { + throw new Error("'CreateETSWildcardType was not overloaded by native module initialization") + } + _UpdateETSWildcardType(context: KNativePointer, original: KNativePointer, typeReference: KNativePointer, flags: KInt): KNativePointer { + throw new Error("'UpdateETSWildcardType was not overloaded by native module initialization") + } + _ETSWildcardTypeTypeReference(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSWildcardTypeTypeReference was not overloaded by native module initialization") + } + _ETSWildcardTypeTypeReferenceConst(context: KNativePointer, receiver: KNativePointer): KNativePointer { + throw new Error("'ETSWildcardTypeTypeReferenceConst was not overloaded by native module initialization") + } + _CreateTSThisType(context: KNativePointer): KNativePointer { + throw new Error("'CreateTSThisType was not overloaded by native module initialization") + } + _UpdateTSThisType(context: KNativePointer, original: KNativePointer): KNativePointer { + throw new Error("'UpdateTSThisType was not overloaded by native module initialization") + } + _CreateInterfaceDecl(context: KNativePointer, name: KStringPtr): KNativePointer { + throw new Error("'CreateInterfaceDecl was not overloaded by native module initialization") + } + _CreateInterfaceDecl1(context: KNativePointer, name: KStringPtr, declNode: KNativePointer): KNativePointer { + throw new Error("'CreateInterfaceDecl1 was not overloaded by native module initialization") + } + _CreateFunctionDecl(context: KNativePointer, name: KStringPtr, node: KNativePointer): KNativePointer { + throw new Error("'CreateFunctionDecl was not overloaded by native module initialization") + } +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/index.ts b/koala-wrapper/src/generated/index.ts new file mode 100644 index 000000000..4b9ae3fc2 --- /dev/null +++ b/koala-wrapper/src/generated/index.ts @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2025 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 * from "./peers/TypedAstNode" +export * from "./peers/AnnotatedAstNode" +export * from "./peers/TypedStatement" +export * from "./peers/AnnotatedStatement" +export * from "./peers/LabelledStatement" +export * from "./peers/ThrowStatement" +export * from "./peers/ClassProperty" +export * from "./peers/TSVoidKeyword" +export * from "./peers/ETSFunctionType" +export * from "./peers/TSTypeOperator" +export * from "./peers/IfStatement" +export * from "./peers/TSConstructorType" +export * from "./peers/Decorator" +export * from "./peers/TSEnumDeclaration" +export * from "./peers/TSNeverKeyword" +export * from "./peers/ImportDefaultSpecifier" +export * from "./peers/ObjectExpression" +export * from "./peers/ImportSpecifier" +export * from "./peers/ConditionalExpression" +export * from "./peers/CallExpression" +export * from "./peers/BigIntLiteral" +export * from "./peers/ClassElement" +export * from "./peers/TSImportType" +export * from "./peers/TaggedTemplateExpression" +export * from "./peers/FunctionDeclaration" +export * from "./peers/ETSTypeReference" +export * from "./peers/TSTypeReference" +export * from "./peers/ImportSource" +export * from "./peers/NamedType" +export * from "./peers/NumberLiteral" +export * from "./peers/TSFunctionType" +export * from "./peers/TemplateElement" +export * from "./peers/TSInterfaceDeclaration" +export * from "./peers/VariableDeclaration" +export * from "./peers/UndefinedLiteral" +export * from "./peers/MemberExpression" +export * from "./peers/TSClassImplements" +export * from "./peers/TSObjectKeyword" +export * from "./peers/ETSUnionType" +export * from "./peers/TSPropertySignature" +export * from "./peers/TSConditionalType" +export * from "./peers/TSLiteralType" +export * from "./peers/TSTypeAliasDeclaration" +export * from "./peers/DebuggerStatement" +export * from "./peers/ReturnStatement" +export * from "./peers/ExportDefaultDeclaration" +export * from "./peers/ScriptFunction" +export * from "./peers/ClassDefinition" +export * from "./peers/ArrayExpression" +export * from "./peers/TSInterfaceBody" +export * from "./peers/TSTypeQuery" +export * from "./peers/TSBigintKeyword" +export * from "./peers/Property" +export * from "./peers/VariableDeclarator" +export * from "./peers/StringLiteral" +export * from "./peers/TSTypeAssertion" +export * from "./peers/TSExternalModuleReference" +export * from "./peers/TSUndefinedKeyword" +export * from "./peers/ETSTuple" +export * from "./peers/TryStatement" +export * from "./peers/UnaryExpression" +export * from "./peers/ForInStatement" +export * from "./peers/ThisExpression" +export * from "./peers/TSMethodSignature" +export * from "./peers/BinaryExpression" +export * from "./peers/SuperExpression" +export * from "./peers/AssertStatement" +export * from "./peers/TSStringKeyword" +export * from "./peers/AssignmentExpression" +export * from "./peers/ExpressionStatement" +export * from "./peers/ETSModule" +export * from "./peers/MetaProperty" +export * from "./peers/TSArrayType" +export * from "./peers/TSSignatureDeclaration" +export * from "./peers/ExportAllDeclaration" +export * from "./peers/ExportSpecifier" +export * from "./peers/TSTupleType" +export * from "./peers/FunctionExpression" +export * from "./peers/TSIndexSignature" +export * from "./peers/TSModuleDeclaration" +export * from "./peers/ImportDeclaration" +export * from "./peers/TSParenthesizedType" +export * from "./peers/Literal" +export * from "./peers/CharLiteral" +export * from "./peers/ETSPackageDeclaration" +export * from "./peers/ETSImportDeclaration" +export * from "./peers/ETSStructDeclaration" +export * from "./peers/TSModuleBlock" +export * from "./peers/ETSNewArrayInstanceExpression" +export * from "./peers/LoopStatement" +export * from "./peers/AnnotationDeclaration" +export * from "./peers/AnnotationUsage" +export * from "./peers/EmptyStatement" +export * from "./peers/ETSLaunchExpression" +export * from "./peers/WhileStatement" +export * from "./peers/FunctionSignature" +export * from "./peers/ChainExpression" +export * from "./peers/TSIntersectionType" +export * from "./peers/UpdateExpression" +export * from "./peers/BlockExpression" +export * from "./peers/TSTypeLiteral" +export * from "./peers/TSTypeParameter" +export * from "./peers/TSBooleanKeyword" +export * from "./peers/SpreadElement" +export * from "./peers/TSTypePredicate" +export * from "./peers/ImportNamespaceSpecifier" +export * from "./peers/ExportNamedDeclaration" +export * from "./peers/ETSParameterExpression" +export * from "./peers/TSTypeParameterInstantiation" +export * from "./peers/NullLiteral" +export * from "./peers/TSInferType" +export * from "./peers/SwitchCaseStatement" +export * from "./peers/YieldExpression" +export * from "./peers/TSImportEqualsDeclaration" +export * from "./peers/BooleanLiteral" +export * from "./peers/TSNumberKeyword" +export * from "./peers/ClassStaticBlock" +export * from "./peers/TSNonNullExpression" +export * from "./peers/PrefixAssertionExpression" +export * from "./peers/ClassExpression" +export * from "./peers/ForOfStatement" +export * from "./peers/TemplateLiteral" +export * from "./peers/TSUnionType" +export * from "./peers/TSUnknownKeyword" +export * from "./peers/Identifier" +export * from "./peers/OpaqueTypeNode" +export * from "./peers/BlockStatement" +export * from "./peers/Statement" +export * from "./peers/DirectEvalExpression" +export * from "./peers/TSTypeParameterDeclaration" +export * from "./peers/MethodDefinition" +export * from "./peers/TSNullKeyword" +export * from "./peers/TSInterfaceHeritage" +export * from "./peers/Expression" +export * from "./peers/AnnotatedExpression" +export * from "./peers/MaybeOptionalExpression" +export * from "./peers/SrcDumper" +export * from "./peers/ETSClassLiteral" +export * from "./peers/BreakStatement" +export * from "./peers/RegExpLiteral" +export * from "./peers/TSMappedType" +export * from "./peers/TSAnyKeyword" +export * from "./peers/ClassDeclaration" +export * from "./peers/TSIndexedAccessType" +export * from "./peers/TSQualifiedName" +export * from "./peers/AwaitExpression" +export * from "./peers/ValidationInfo" +export * from "./peers/ContinueStatement" +export * from "./peers/ETSNewMultiDimArrayInstanceExpression" +export * from "./peers/TSNamedTupleMember" +export * from "./peers/ImportExpression" +export * from "./peers/AstDumper" +export * from "./peers/ETSNullType" +export * from "./peers/ETSUndefinedType" +export * from "./peers/TypeofExpression" +export * from "./peers/TSEnumMember" +export * from "./peers/SwitchStatement" +export * from "./peers/DoWhileStatement" +export * from "./peers/CatchClause" +export * from "./peers/SequenceExpression" +export * from "./peers/ArrowFunctionExpression" +export * from "./peers/OmittedExpression" +export * from "./peers/ETSNewClassInstanceExpression" +export * from "./peers/TSAsExpression" +export * from "./peers/ForUpdateStatement" +export * from "./peers/ETSTypeReferencePart" +export * from "./peers/ETSReExportDeclaration" +export * from "./peers/ETSPrimitiveType" +export * from "./peers/TypeNode" +export * from "./peers/NewExpression" +export * from "./peers/TSParameterProperty" +export * from "./peers/ETSWildcardType" +export * from "./peers/TSThisType" +export * from "./peers/ETSDynamicFunctionType" +export * from "./peers/InterfaceDecl" +export * from "./peers/FunctionDecl" +export * from "./peers/Context" \ No newline at end of file diff --git a/koala-wrapper/src/generated/node-map.ts b/koala-wrapper/src/generated/node-map.ts new file mode 100644 index 000000000..c8d894039 --- /dev/null +++ b/koala-wrapper/src/generated/node-map.ts @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + unpackNonNullableNode, + Es2pandaMemberExpressionKind, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer +} from "../reexport-for-generated" + +import * as peers from "./index" + +export const nodes = new Map([ + [44, peers.LabelledStatement], + [146, peers.ThrowStatement], + [17, peers.ClassProperty], + [94, peers.TSVoidKeyword], + [66, peers.ETSFunctionType], + [117, peers.TSTypeOperator], + [38, peers.IfStatement], + [126, peers.TSConstructorType], + [22, peers.Decorator], + [87, peers.TSEnumDeclaration], + [99, peers.TSNeverKeyword], + [41, peers.ImportDefaultSpecifier], + [43, peers.ImportSpecifier], + [19, peers.ConditionalExpression], + [10, peers.CallExpression], + [5, peers.BigIntLiteral], + [112, peers.TSImportType], + [141, peers.TaggedTemplateExpression], + [34, peers.FunctionDeclaration], + [71, peers.ETSTypeReference], + [128, peers.TSTypeReference], + [48, peers.NamedType], + [52, peers.NumberLiteral], + [125, peers.TSFunctionType], + [142, peers.TemplateElement], + [131, peers.TSInterfaceDeclaration], + [150, peers.VariableDeclaration], + [51, peers.UndefinedLiteral], + [45, peers.MemberExpression], + [139, peers.TSClassImplements], + [97, peers.TSObjectKeyword], + [73, peers.ETSUnionType], + [105, peers.TSPropertySignature], + [111, peers.TSConditionalType], + [109, peers.TSLiteralType], + [127, peers.TSTypeAliasDeclaration], + [21, peers.DebuggerStatement], + [58, peers.ReturnStatement], + [27, peers.ExportDefaultDeclaration], + [59, peers.ScriptFunction], + [14, peers.ClassDefinition], + [132, peers.TSInterfaceBody], + [137, peers.TSTypeQuery], + [98, peers.TSBigintKeyword], + [55, peers.Property], + [151, peers.VariableDeclarator], + [61, peers.StringLiteral], + [140, peers.TSTypeAssertion], + [89, peers.TSExternalModuleReference], + [95, peers.TSUndefinedKeyword], + [81, peers.ETSTuple], + [147, peers.TryStatement], + [148, peers.UnaryExpression], + [31, peers.ForInStatement], + [144, peers.ThisExpression], + [106, peers.TSMethodSignature], + [6, peers.BinaryExpression], + [83, peers.SuperExpression], + [3, peers.AssertStatement], + [92, peers.TSStringKeyword], + [30, peers.ExpressionStatement], + [82, peers.ETSModule], + [46, peers.MetaProperty], + [102, peers.TSArrayType], + [107, peers.TSSignatureDeclaration], + [26, peers.ExportAllDeclaration], + [29, peers.ExportSpecifier], + [134, peers.TSTupleType], + [35, peers.FunctionExpression], + [136, peers.TSIndexSignature], + [123, peers.TSModuleDeclaration], + [39, peers.ImportDeclaration], + [108, peers.TSParenthesizedType], + [13, peers.CharLiteral], + [69, peers.ETSPackageDeclaration], + [79, peers.ETSImportDeclaration], + [84, peers.ETSStructDeclaration], + [115, peers.TSModuleBlock], + [76, peers.ETSNewArrayInstanceExpression], + [1, peers.AnnotationDeclaration], + [2, peers.AnnotationUsage], + [25, peers.EmptyStatement], + [75, peers.ETSLaunchExpression], + [152, peers.WhileStatement], + [12, peers.ChainExpression], + [113, peers.TSIntersectionType], + [149, peers.UpdateExpression], + [155, peers.BlockExpression], + [104, peers.TSTypeLiteral], + [118, peers.TSTypeParameter], + [93, peers.TSBooleanKeyword], + [121, peers.TSTypePredicate], + [42, peers.ImportNamespaceSpecifier], + [28, peers.ExportNamedDeclaration], + [80, peers.ETSParameterExpression], + [120, peers.TSTypeParameterInstantiation], + [50, peers.NullLiteral], + [110, peers.TSInferType], + [85, peers.SwitchCaseStatement], + [153, peers.YieldExpression], + [124, peers.TSImportEqualsDeclaration], + [8, peers.BooleanLiteral], + [90, peers.TSNumberKeyword], + [18, peers.ClassStaticBlock], + [100, peers.TSNonNullExpression], + [54, peers.PrefixAssertionExpression], + [16, peers.ClassExpression], + [32, peers.ForOfStatement], + [143, peers.TemplateLiteral], + [103, peers.TSUnionType], + [96, peers.TSUnknownKeyword], + [36, peers.Identifier], + [154, peers.OpaqueTypeNode], + [7, peers.BlockStatement], + [23, peers.DirectEvalExpression], + [119, peers.TSTypeParameterDeclaration], + [47, peers.MethodDefinition], + [101, peers.TSNullKeyword], + [133, peers.TSInterfaceHeritage], + [70, peers.ETSClassLiteral], + [9, peers.BreakStatement], + [56, peers.RegExpLiteral], + [114, peers.TSMappedType], + [91, peers.TSAnyKeyword], + [15, peers.ClassDeclaration], + [130, peers.TSIndexedAccessType], + [129, peers.TSQualifiedName], + [4, peers.AwaitExpression], + [20, peers.ContinueStatement], + [77, peers.ETSNewMultiDimArrayInstanceExpression], + [135, peers.TSNamedTupleMember], + [40, peers.ImportExpression], + [62, peers.ETSNullType], + [63, peers.ETSUndefinedType], + [145, peers.TypeofExpression], + [88, peers.TSEnumMember], + [86, peers.SwitchStatement], + [24, peers.DoWhileStatement], + [11, peers.CatchClause], + [60, peers.SequenceExpression], + [0, peers.ArrowFunctionExpression], + [53, peers.OmittedExpression], + [78, peers.ETSNewClassInstanceExpression], + [138, peers.TSAsExpression], + [33, peers.ForUpdateStatement], + [72, peers.ETSTypeReferencePart], + [57, peers.ETSReExportDeclaration], + [68, peers.ETSPrimitiveType], + [49, peers.NewExpression], + [122, peers.TSParameterProperty], + [67, peers.ETSWildcardType], + [116, peers.TSThisType], +]) \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/AnnotatedAstNode.ts b/koala-wrapper/src/generated/peers/AnnotatedAstNode.ts new file mode 100644 index 000000000..f1199de4d --- /dev/null +++ b/koala-wrapper/src/generated/peers/AnnotatedAstNode.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class AnnotatedAstNode extends AstNode { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isAnnotatedAstNode(node: AstNode): node is AnnotatedAstNode { + return node instanceof AnnotatedAstNode +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/AnnotatedExpression.ts b/koala-wrapper/src/generated/peers/AnnotatedExpression.ts new file mode 100644 index 000000000..2a5924eb9 --- /dev/null +++ b/koala-wrapper/src/generated/peers/AnnotatedExpression.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class AnnotatedExpression extends Expression { + constructor(pointer: KNativePointer) { + super(pointer) + + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._AnnotatedExpressionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._AnnotatedExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isAnnotatedExpression(node: AstNode): node is AnnotatedExpression { + return node instanceof AnnotatedExpression +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/AnnotatedStatement.ts b/koala-wrapper/src/generated/peers/AnnotatedStatement.ts new file mode 100644 index 000000000..64f91f5cf --- /dev/null +++ b/koala-wrapper/src/generated/peers/AnnotatedStatement.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class AnnotatedStatement extends Statement { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isAnnotatedStatement(node: AstNode): node is AnnotatedStatement { + return node instanceof AnnotatedStatement +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/AnnotationDeclaration.ts b/koala-wrapper/src/generated/peers/AnnotationDeclaration.ts new file mode 100644 index 000000000..135f8ac73 --- /dev/null +++ b/koala-wrapper/src/generated/peers/AnnotationDeclaration.ts @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { AnnotationUsage } from "./AnnotationUsage" +export class AnnotationDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 1) + super(pointer) + + } + static createAnnotationDeclaration(expr?: Expression): AnnotationDeclaration { + return new AnnotationDeclaration(global.generatedEs2panda._CreateAnnotationDeclaration(global.context, passNode(expr))) + } + static updateAnnotationDeclaration(original?: AnnotationDeclaration, expr?: Expression): AnnotationDeclaration { + return new AnnotationDeclaration(global.generatedEs2panda._UpdateAnnotationDeclaration(global.context, passNode(original), passNode(expr))) + } + static create1AnnotationDeclaration(expr: Expression | undefined, properties: readonly AstNode[]): AnnotationDeclaration { + return new AnnotationDeclaration(global.generatedEs2panda._CreateAnnotationDeclaration1(global.context, passNode(expr), passNodeArray(properties), properties.length)) + } + static update1AnnotationDeclaration(original: AnnotationDeclaration | undefined, expr: Expression | undefined, properties: readonly AstNode[]): AnnotationDeclaration { + return new AnnotationDeclaration(global.generatedEs2panda._UpdateAnnotationDeclaration1(global.context, passNode(original), passNode(expr), passNodeArray(properties), properties.length)) + } + get internalName(): string { + return unpackString(global.generatedEs2panda._AnnotationDeclarationInternalNameConst(global.context, this.peer)) + } + /** @deprecated */ + setInternalName(internalName: string): this { + global.generatedEs2panda._AnnotationDeclarationSetInternalName(global.context, this.peer, internalName) + return this + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AnnotationDeclarationExprConst(global.context, this.peer)) + } + get properties(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._AnnotationDeclarationPropertiesConst(global.context, this.peer)) + } + get propertiesPtr(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._AnnotationDeclarationPropertiesPtrConst(global.context, this.peer)) + } + /** @deprecated */ + addProperties(properties: readonly AstNode[]): this { + global.generatedEs2panda._AnnotationDeclarationAddProperties(global.context, this.peer, passNodeArray(properties), properties.length) + return this + } + get isSourceRetention(): boolean { + return global.generatedEs2panda._AnnotationDeclarationIsSourceRetentionConst(global.context, this.peer) + } + get isBytecodeRetention(): boolean { + return global.generatedEs2panda._AnnotationDeclarationIsBytecodeRetentionConst(global.context, this.peer) + } + get isRuntimeRetention(): boolean { + return global.generatedEs2panda._AnnotationDeclarationIsRuntimeRetentionConst(global.context, this.peer) + } + /** @deprecated */ + setSourceRetention(): this { + global.generatedEs2panda._AnnotationDeclarationSetSourceRetention(global.context, this.peer) + return this + } + /** @deprecated */ + setBytecodeRetention(): this { + global.generatedEs2panda._AnnotationDeclarationSetBytecodeRetention(global.context, this.peer) + return this + } + /** @deprecated */ + setRuntimeRetention(): this { + global.generatedEs2panda._AnnotationDeclarationSetRuntimeRetention(global.context, this.peer) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._AnnotationDeclarationAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._AnnotationDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isAnnotationDeclaration(node: AstNode): node is AnnotationDeclaration { + return node instanceof AnnotationDeclaration +} +if (!nodeByType.has(1)) { + nodeByType.set(1, AnnotationDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/AnnotationUsage.ts b/koala-wrapper/src/generated/peers/AnnotationUsage.ts new file mode 100644 index 000000000..1ee1f98b7 --- /dev/null +++ b/koala-wrapper/src/generated/peers/AnnotationUsage.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +export class AnnotationUsage extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 2) + super(pointer) + + } + static createAnnotationUsage(expr?: Expression): AnnotationUsage { + return new AnnotationUsage(global.generatedEs2panda._CreateAnnotationUsageIr(global.context, passNode(expr))) + } + static updateAnnotationUsage(original?: AnnotationUsage, expr?: Expression): AnnotationUsage { + return new AnnotationUsage(global.generatedEs2panda._UpdateAnnotationUsageIr(global.context, passNode(original), passNode(expr))) + } + static create1AnnotationUsage(expr: Expression | undefined, properties: readonly AstNode[]): AnnotationUsage { + return new AnnotationUsage(global.generatedEs2panda._CreateAnnotationUsageIr1(global.context, passNode(expr), passNodeArray(properties), properties.length)) + } + static update1AnnotationUsage(original: AnnotationUsage | undefined, expr: Expression | undefined, properties: readonly AstNode[]): AnnotationUsage { + return new AnnotationUsage(global.generatedEs2panda._UpdateAnnotationUsageIr1(global.context, passNode(original), passNode(expr), passNodeArray(properties), properties.length)) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AnnotationUsageIrExpr(global.context, this.peer)) + } + get properties(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._AnnotationUsageIrPropertiesConst(global.context, this.peer)) + } + get propertiesPtr(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._AnnotationUsageIrPropertiesPtrConst(global.context, this.peer)) + } + /** @deprecated */ + addProperty(property: AstNode): this { + global.generatedEs2panda._AnnotationUsageIrAddProperty(global.context, this.peer, passNode(property)) + return this + } + /** @deprecated */ + setProperties(properties: readonly AstNode[]): this { + global.generatedEs2panda._AnnotationUsageIrSetProperties(global.context, this.peer, passNodeArray(properties), properties.length) + return this + } +} +export function isAnnotationUsage(node: AstNode): node is AnnotationUsage { + return node instanceof AnnotationUsage +} +if (!nodeByType.has(2)) { + nodeByType.set(2, AnnotationUsage) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ArrayExpression.ts b/koala-wrapper/src/generated/peers/ArrayExpression.ts new file mode 100644 index 000000000..200648cdb --- /dev/null +++ b/koala-wrapper/src/generated/peers/ArrayExpression.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Expression } from "./Expression" +import { Decorator } from "./Decorator" +import { ValidationInfo } from "./ValidationInfo" +import { TypeNode } from "./TypeNode" +export class ArrayExpression extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + super(pointer) + + } + get elements(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ArrayExpressionElementsConst(global.context, this.peer)) + } + /** @deprecated */ + setElements(elements: readonly Expression[]): this { + global.generatedEs2panda._ArrayExpressionSetElements(global.context, this.peer, passNodeArray(elements), elements.length) + return this + } + get isDeclaration(): boolean { + return global.generatedEs2panda._ArrayExpressionIsDeclarationConst(global.context, this.peer) + } + get isOptional(): boolean { + return global.generatedEs2panda._ArrayExpressionIsOptionalConst(global.context, this.peer) + } + /** @deprecated */ + setDeclaration(): this { + global.generatedEs2panda._ArrayExpressionSetDeclaration(global.context, this.peer) + return this + } + /** @deprecated */ + setOptional(optional_arg: boolean): this { + global.generatedEs2panda._ArrayExpressionSetOptional(global.context, this.peer, optional_arg) + return this + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._ArrayExpressionDecoratorsConst(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ArrayExpressionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._ArrayExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isArrayExpression(node: AstNode): node is ArrayExpression { + return node instanceof ArrayExpression +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ArrowFunctionExpression.ts b/koala-wrapper/src/generated/peers/ArrowFunctionExpression.ts new file mode 100644 index 000000000..7c8ca00f5 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ArrowFunctionExpression.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { ScriptFunction } from "./ScriptFunction" +import { TypeNode } from "./TypeNode" +import { AnnotationUsage } from "./AnnotationUsage" +export class ArrowFunctionExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 0) + super(pointer) + + } + static createArrowFunctionExpression(func?: ScriptFunction): ArrowFunctionExpression { + return new ArrowFunctionExpression(global.generatedEs2panda._CreateArrowFunctionExpression(global.context, passNode(func))) + } + static updateArrowFunctionExpression(original?: ArrowFunctionExpression, func?: ScriptFunction): ArrowFunctionExpression { + return new ArrowFunctionExpression(global.generatedEs2panda._UpdateArrowFunctionExpression(global.context, passNode(original), passNode(func))) + } + static create1ArrowFunctionExpression(other?: ArrowFunctionExpression): ArrowFunctionExpression { + return new ArrowFunctionExpression(global.generatedEs2panda._CreateArrowFunctionExpression1(global.context, passNode(other))) + } + static update1ArrowFunctionExpression(original?: ArrowFunctionExpression, other?: ArrowFunctionExpression): ArrowFunctionExpression { + return new ArrowFunctionExpression(global.generatedEs2panda._UpdateArrowFunctionExpression1(global.context, passNode(original), passNode(other))) + } + get function(): ScriptFunction | undefined { + return unpackNode(global.generatedEs2panda._ArrowFunctionExpressionFunctionConst(global.context, this.peer)) + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ArrowFunctionExpressionAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ArrowFunctionExpressionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isArrowFunctionExpression(node: AstNode): node is ArrowFunctionExpression { + return node instanceof ArrowFunctionExpression +} +if (!nodeByType.has(0)) { + nodeByType.set(0, ArrowFunctionExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/AssertStatement.ts b/koala-wrapper/src/generated/peers/AssertStatement.ts new file mode 100644 index 000000000..0d2dcfe05 --- /dev/null +++ b/koala-wrapper/src/generated/peers/AssertStatement.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class AssertStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 3) + super(pointer) + + } + static createAssertStatement(test?: Expression, second?: Expression): AssertStatement { + return new AssertStatement(global.generatedEs2panda._CreateAssertStatement(global.context, passNode(test), passNode(second))) + } + static updateAssertStatement(original?: AssertStatement, test?: Expression, second?: Expression): AssertStatement { + return new AssertStatement(global.generatedEs2panda._UpdateAssertStatement(global.context, passNode(original), passNode(test), passNode(second))) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssertStatementTestConst(global.context, this.peer)) + } + get second(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssertStatementSecondConst(global.context, this.peer)) + } +} +export function isAssertStatement(node: AstNode): node is AssertStatement { + return node instanceof AssertStatement +} +if (!nodeByType.has(3)) { + nodeByType.set(3, AssertStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/AssignmentExpression.ts b/koala-wrapper/src/generated/peers/AssignmentExpression.ts new file mode 100644 index 000000000..687fbd853 --- /dev/null +++ b/koala-wrapper/src/generated/peers/AssignmentExpression.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Es2pandaTokenType } from "./../Es2pandaEnums" +export class AssignmentExpression extends Expression { + constructor(pointer: KNativePointer) { + super(pointer) + + } + get left(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssignmentExpressionLeftConst(global.context, this.peer)) + } + get right(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssignmentExpressionRightConst(global.context, this.peer)) + } + /** @deprecated */ + setRight(expr: Expression): this { + global.generatedEs2panda._AssignmentExpressionSetRight(global.context, this.peer, passNode(expr)) + return this + } + /** @deprecated */ + setLeft(expr: Expression): this { + global.generatedEs2panda._AssignmentExpressionSetLeft(global.context, this.peer, passNode(expr)) + return this + } + get result(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AssignmentExpressionResultConst(global.context, this.peer)) + } + get operatorType(): Es2pandaTokenType { + return global.generatedEs2panda._AssignmentExpressionOperatorTypeConst(global.context, this.peer) + } + /** @deprecated */ + setResult(expr: Expression): this { + global.generatedEs2panda._AssignmentExpressionSetResult(global.context, this.peer, passNode(expr)) + return this + } + get isLogicalExtended(): boolean { + return global.generatedEs2panda._AssignmentExpressionIsLogicalExtendedConst(global.context, this.peer) + } + /** @deprecated */ + setIgnoreConstAssign(): this { + global.generatedEs2panda._AssignmentExpressionSetIgnoreConstAssign(global.context, this.peer) + return this + } + get isIgnoreConstAssign(): boolean { + return global.generatedEs2panda._AssignmentExpressionIsIgnoreConstAssignConst(global.context, this.peer) + } +} +export function isAssignmentExpression(node: AstNode): node is AssignmentExpression { + return node instanceof AssignmentExpression +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/AstDumper.ts b/koala-wrapper/src/generated/peers/AstDumper.ts new file mode 100644 index 000000000..dc62ec347 --- /dev/null +++ b/koala-wrapper/src/generated/peers/AstDumper.ts @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { Es2pandaTSOperatorType } from "./../Es2pandaEnums" +export class AstDumper extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + + } + static createAstDumper(node: AstNode | undefined, sourceCode: string): AstDumper { + return new AstDumper(global.generatedEs2panda._CreateAstDumper(global.context, passNode(node), sourceCode)) + } + get str(): string { + return unpackString(global.generatedEs2panda._AstDumperStrConst(global.context, this.peer)) + } +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/AwaitExpression.ts b/koala-wrapper/src/generated/peers/AwaitExpression.ts new file mode 100644 index 000000000..1e5520228 --- /dev/null +++ b/koala-wrapper/src/generated/peers/AwaitExpression.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class AwaitExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 4) + super(pointer) + + } + static createAwaitExpression(argument?: Expression): AwaitExpression { + return new AwaitExpression(global.generatedEs2panda._CreateAwaitExpression(global.context, passNode(argument))) + } + static updateAwaitExpression(original?: AwaitExpression, argument?: Expression): AwaitExpression { + return new AwaitExpression(global.generatedEs2panda._UpdateAwaitExpression(global.context, passNode(original), passNode(argument))) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._AwaitExpressionArgumentConst(global.context, this.peer)) + } +} +export function isAwaitExpression(node: AstNode): node is AwaitExpression { + return node instanceof AwaitExpression +} +if (!nodeByType.has(4)) { + nodeByType.set(4, AwaitExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/BigIntLiteral.ts b/koala-wrapper/src/generated/peers/BigIntLiteral.ts new file mode 100644 index 000000000..9d390c0c4 --- /dev/null +++ b/koala-wrapper/src/generated/peers/BigIntLiteral.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Literal } from "./Literal" +export class BigIntLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 5) + super(pointer) + + } + static createBigIntLiteral(src: string): BigIntLiteral { + return new BigIntLiteral(global.generatedEs2panda._CreateBigIntLiteral(global.context, src)) + } + static updateBigIntLiteral(original: BigIntLiteral | undefined, src: string): BigIntLiteral { + return new BigIntLiteral(global.generatedEs2panda._UpdateBigIntLiteral(global.context, passNode(original), src)) + } + get str(): string { + return unpackString(global.generatedEs2panda._BigIntLiteralStrConst(global.context, this.peer)) + } +} +export function isBigIntLiteral(node: AstNode): node is BigIntLiteral { + return node instanceof BigIntLiteral +} +if (!nodeByType.has(5)) { + nodeByType.set(5, BigIntLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/BinaryExpression.ts b/koala-wrapper/src/generated/peers/BinaryExpression.ts new file mode 100644 index 000000000..c524075b1 --- /dev/null +++ b/koala-wrapper/src/generated/peers/BinaryExpression.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Es2pandaTokenType } from "./../Es2pandaEnums" +export class BinaryExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 6) + super(pointer) + + } + static createBinaryExpression(left: Expression | undefined, right: Expression | undefined, operatorType: Es2pandaTokenType): BinaryExpression { + return new BinaryExpression(global.generatedEs2panda._CreateBinaryExpression(global.context, passNode(left), passNode(right), operatorType)) + } + static updateBinaryExpression(original: BinaryExpression | undefined, left: Expression | undefined, right: Expression | undefined, operatorType: Es2pandaTokenType): BinaryExpression { + return new BinaryExpression(global.generatedEs2panda._UpdateBinaryExpression(global.context, passNode(original), passNode(left), passNode(right), operatorType)) + } + get left(): Expression | undefined { + return unpackNode(global.generatedEs2panda._BinaryExpressionLeftConst(global.context, this.peer)) + } + get right(): Expression | undefined { + return unpackNode(global.generatedEs2panda._BinaryExpressionRightConst(global.context, this.peer)) + } + get result(): Expression | undefined { + return unpackNode(global.generatedEs2panda._BinaryExpressionResultConst(global.context, this.peer)) + } + get operatorType(): Es2pandaTokenType { + return global.generatedEs2panda._BinaryExpressionOperatorTypeConst(global.context, this.peer) + } + get isLogical(): boolean { + return global.generatedEs2panda._BinaryExpressionIsLogicalConst(global.context, this.peer) + } + get isLogicalExtended(): boolean { + return global.generatedEs2panda._BinaryExpressionIsLogicalExtendedConst(global.context, this.peer) + } + get isBitwise(): boolean { + return global.generatedEs2panda._BinaryExpressionIsBitwiseConst(global.context, this.peer) + } + get isArithmetic(): boolean { + return global.generatedEs2panda._BinaryExpressionIsArithmeticConst(global.context, this.peer) + } + /** @deprecated */ + setLeft(expr: Expression): this { + global.generatedEs2panda._BinaryExpressionSetLeft(global.context, this.peer, passNode(expr)) + return this + } + /** @deprecated */ + setRight(expr: Expression): this { + global.generatedEs2panda._BinaryExpressionSetRight(global.context, this.peer, passNode(expr)) + return this + } + /** @deprecated */ + setResult(expr: Expression): this { + global.generatedEs2panda._BinaryExpressionSetResult(global.context, this.peer, passNode(expr)) + return this + } + /** @deprecated */ + setOperator(operatorType: Es2pandaTokenType): this { + global.generatedEs2panda._BinaryExpressionSetOperator(global.context, this.peer, operatorType) + return this + } +} +export function isBinaryExpression(node: AstNode): node is BinaryExpression { + return node instanceof BinaryExpression +} +if (!nodeByType.has(6)) { + nodeByType.set(6, BinaryExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/BlockExpression.ts b/koala-wrapper/src/generated/peers/BlockExpression.ts new file mode 100644 index 000000000..7e22eef67 --- /dev/null +++ b/koala-wrapper/src/generated/peers/BlockExpression.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class BlockExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 155) + super(pointer) + + } + static createBlockExpression(statements: readonly Statement[]): BlockExpression { + return new BlockExpression(global.generatedEs2panda._CreateBlockExpression(global.context, passNodeArray(statements), statements.length)) + } + static updateBlockExpression(original: BlockExpression | undefined, statements: readonly Statement[]): BlockExpression { + return new BlockExpression(global.generatedEs2panda._UpdateBlockExpression(global.context, passNode(original), passNodeArray(statements), statements.length)) + } + get statements(): readonly Statement[] { + return unpackNodeArray(global.generatedEs2panda._BlockExpressionStatementsConst(global.context, this.peer)) + } + /** @deprecated */ + addStatements(statements: readonly Statement[]): this { + global.generatedEs2panda._BlockExpressionAddStatements(global.context, this.peer, passNodeArray(statements), statements.length) + return this + } + /** @deprecated */ + addStatement(statement: Statement): this { + global.generatedEs2panda._BlockExpressionAddStatement(global.context, this.peer, passNode(statement)) + return this + } +} +export function isBlockExpression(node: AstNode): node is BlockExpression { + return node instanceof BlockExpression +} +if (!nodeByType.has(155)) { + nodeByType.set(155, BlockExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/BlockStatement.ts b/koala-wrapper/src/generated/peers/BlockStatement.ts new file mode 100644 index 000000000..8d8ddf9fa --- /dev/null +++ b/koala-wrapper/src/generated/peers/BlockStatement.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class BlockStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 7) + super(pointer) + + } + static createBlockStatement(statementList: readonly Statement[]): BlockStatement { + return new BlockStatement(global.generatedEs2panda._CreateBlockStatement(global.context, passNodeArray(statementList), statementList.length)) + } + static updateBlockStatement(original: BlockStatement | undefined, statementList: readonly Statement[]): BlockStatement { + return new BlockStatement(global.generatedEs2panda._UpdateBlockStatement(global.context, passNode(original), passNodeArray(statementList), statementList.length)) + } + get statements(): readonly Statement[] { + return unpackNodeArray(global.generatedEs2panda._BlockStatementStatementsConst(global.context, this.peer)) + } + /** @deprecated */ + setStatements(statementList: readonly Statement[]): this { + global.generatedEs2panda._BlockStatementSetStatements(global.context, this.peer, passNodeArray(statementList), statementList.length) + return this + } + /** @deprecated */ + addTrailingBlock(stmt: AstNode, trailingBlock: BlockStatement): this { + global.generatedEs2panda._BlockStatementAddTrailingBlock(global.context, this.peer, passNode(stmt), passNode(trailingBlock)) + return this + } +} +export function isBlockStatement(node: AstNode): node is BlockStatement { + return node instanceof BlockStatement +} +if (!nodeByType.has(7)) { + nodeByType.set(7, BlockStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/BooleanLiteral.ts b/koala-wrapper/src/generated/peers/BooleanLiteral.ts new file mode 100644 index 000000000..9995a9f89 --- /dev/null +++ b/koala-wrapper/src/generated/peers/BooleanLiteral.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Literal } from "./Literal" +export class BooleanLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 8) + super(pointer) + + } + static createBooleanLiteral(value: boolean): BooleanLiteral { + return new BooleanLiteral(global.generatedEs2panda._CreateBooleanLiteral(global.context, value)) + } + static updateBooleanLiteral(original: BooleanLiteral | undefined, value: boolean): BooleanLiteral { + return new BooleanLiteral(global.generatedEs2panda._UpdateBooleanLiteral(global.context, passNode(original), value)) + } + get value(): boolean { + return global.generatedEs2panda._BooleanLiteralValueConst(global.context, this.peer) + } +} +export function isBooleanLiteral(node: AstNode): node is BooleanLiteral { + return node instanceof BooleanLiteral +} +if (!nodeByType.has(8)) { + nodeByType.set(8, BooleanLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/BreakStatement.ts b/koala-wrapper/src/generated/peers/BreakStatement.ts new file mode 100644 index 000000000..e293ddf59 --- /dev/null +++ b/koala-wrapper/src/generated/peers/BreakStatement.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Identifier } from "./Identifier" +export class BreakStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 9) + super(pointer) + + } + static createBreakStatement(): BreakStatement { + return new BreakStatement(global.generatedEs2panda._CreateBreakStatement(global.context)) + } + static updateBreakStatement(original?: BreakStatement): BreakStatement { + return new BreakStatement(global.generatedEs2panda._UpdateBreakStatement(global.context, passNode(original))) + } + static create1BreakStatement(ident?: Identifier): BreakStatement { + return new BreakStatement(global.generatedEs2panda._CreateBreakStatement1(global.context, passNode(ident))) + } + static update1BreakStatement(original?: BreakStatement, ident?: Identifier): BreakStatement { + return new BreakStatement(global.generatedEs2panda._UpdateBreakStatement1(global.context, passNode(original), passNode(ident))) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._BreakStatementIdentConst(global.context, this.peer)) + } + get target(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._BreakStatementTargetConst(global.context, this.peer)) + } + /** @deprecated */ + setTarget(target: AstNode): this { + global.generatedEs2panda._BreakStatementSetTarget(global.context, this.peer, passNode(target)) + return this + } +} +export function isBreakStatement(node: AstNode): node is BreakStatement { + return node instanceof BreakStatement +} +if (!nodeByType.has(9)) { + nodeByType.set(9, BreakStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/CallExpression.ts b/koala-wrapper/src/generated/peers/CallExpression.ts new file mode 100644 index 000000000..3a61208f9 --- /dev/null +++ b/koala-wrapper/src/generated/peers/CallExpression.ts @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { MaybeOptionalExpression } from "./MaybeOptionalExpression" +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +import { BlockStatement } from "./BlockStatement" +export class CallExpression extends MaybeOptionalExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 10) + super(pointer) + + } + static createCallExpression(callee: Expression | undefined, _arguments: readonly Expression[], typeParams: TSTypeParameterInstantiation | undefined, optional_arg: boolean, trailingComma: boolean): CallExpression { + return new CallExpression(global.generatedEs2panda._CreateCallExpression(global.context, passNode(callee), passNodeArray(_arguments), _arguments.length, passNode(typeParams), optional_arg, trailingComma)) + } + static create1CallExpression(other?: CallExpression): CallExpression { + return new CallExpression(global.generatedEs2panda._CreateCallExpression1(global.context, passNode(other))) + } + static update1CallExpression(original?: CallExpression, other?: CallExpression): CallExpression { + return new CallExpression(global.generatedEs2panda._UpdateCallExpression1(global.context, passNode(original), passNode(other))) + } + get callee(): Expression | undefined { + return unpackNode(global.generatedEs2panda._CallExpressionCalleeConst(global.context, this.peer)) + } + /** @deprecated */ + setCallee(callee: Expression): this { + global.generatedEs2panda._CallExpressionSetCallee(global.context, this.peer, passNode(callee)) + return this + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._CallExpressionTypeParamsConst(global.context, this.peer)) + } + get arguments(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._CallExpressionArgumentsConst(global.context, this.peer)) + } + get hasTrailingComma(): boolean { + return global.generatedEs2panda._CallExpressionHasTrailingCommaConst(global.context, this.peer) + } + /** @deprecated */ + setTypeParams(typeParams: TSTypeParameterInstantiation): this { + global.generatedEs2panda._CallExpressionSetTypeParams(global.context, this.peer, passNode(typeParams)) + return this + } + /** @deprecated */ + setTrailingBlock(block: BlockStatement): this { + global.generatedEs2panda._CallExpressionSetTrailingBlock(global.context, this.peer, passNode(block)) + return this + } + get trailingBlock(): BlockStatement | undefined { + return unpackNode(global.generatedEs2panda._CallExpressionTrailingBlockConst(global.context, this.peer)) + } + /** @deprecated */ + setIsTrailingBlockInNewLine(isNewLine: boolean): this { + global.generatedEs2panda._CallExpressionSetIsTrailingBlockInNewLine(global.context, this.peer, isNewLine) + return this + } + get isTrailingBlockInNewLine(): boolean { + return global.generatedEs2panda._CallExpressionIsTrailingBlockInNewLineConst(global.context, this.peer) + } + get isETSConstructorCall(): boolean { + return global.generatedEs2panda._CallExpressionIsETSConstructorCallConst(global.context, this.peer) + } +} +export function isCallExpression(node: AstNode): node is CallExpression { + return node instanceof CallExpression +} +if (!nodeByType.has(10)) { + nodeByType.set(10, CallExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/CatchClause.ts b/koala-wrapper/src/generated/peers/CatchClause.ts new file mode 100644 index 000000000..068b1dd80 --- /dev/null +++ b/koala-wrapper/src/generated/peers/CatchClause.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypedStatement } from "./TypedStatement" +import { Expression } from "./Expression" +import { BlockStatement } from "./BlockStatement" +export class CatchClause extends TypedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 11) + super(pointer) + + } + static createCatchClause(param?: Expression, body?: BlockStatement): CatchClause { + return new CatchClause(global.generatedEs2panda._CreateCatchClause(global.context, passNode(param), passNode(body))) + } + static updateCatchClause(original?: CatchClause, param?: Expression, body?: BlockStatement): CatchClause { + return new CatchClause(global.generatedEs2panda._UpdateCatchClause(global.context, passNode(original), passNode(param), passNode(body))) + } + get param(): Expression | undefined { + return unpackNode(global.generatedEs2panda._CatchClauseParamConst(global.context, this.peer)) + } + get body(): BlockStatement | undefined { + return unpackNode(global.generatedEs2panda._CatchClauseBodyConst(global.context, this.peer)) + } +} +export function isCatchClause(node: AstNode): node is CatchClause { + return node instanceof CatchClause +} +if (!nodeByType.has(11)) { + nodeByType.set(11, CatchClause) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ChainExpression.ts b/koala-wrapper/src/generated/peers/ChainExpression.ts new file mode 100644 index 000000000..ae76f46e0 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ChainExpression.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class ChainExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 12) + super(pointer) + + } + static createChainExpression(expression?: Expression): ChainExpression { + return new ChainExpression(global.generatedEs2panda._CreateChainExpression(global.context, passNode(expression))) + } + static updateChainExpression(original?: ChainExpression, expression?: Expression): ChainExpression { + return new ChainExpression(global.generatedEs2panda._UpdateChainExpression(global.context, passNode(original), passNode(expression))) + } + get getExpression(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ChainExpressionGetExpressionConst(global.context, this.peer)) + } +} +export function isChainExpression(node: AstNode): node is ChainExpression { + return node instanceof ChainExpression +} +if (!nodeByType.has(12)) { + nodeByType.set(12, ChainExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/CharLiteral.ts b/koala-wrapper/src/generated/peers/CharLiteral.ts new file mode 100644 index 000000000..7dbceda4c --- /dev/null +++ b/koala-wrapper/src/generated/peers/CharLiteral.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Literal } from "./Literal" +export class CharLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 13) + super(pointer) + + } + static createCharLiteral(): CharLiteral { + return new CharLiteral(global.generatedEs2panda._CreateCharLiteral(global.context)) + } + static updateCharLiteral(original?: CharLiteral): CharLiteral { + return new CharLiteral(global.generatedEs2panda._UpdateCharLiteral(global.context, passNode(original))) + } +} +export function isCharLiteral(node: AstNode): node is CharLiteral { + return node instanceof CharLiteral +} +if (!nodeByType.has(13)) { + nodeByType.set(13, CharLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ClassDeclaration.ts b/koala-wrapper/src/generated/peers/ClassDeclaration.ts new file mode 100644 index 000000000..1af101f1c --- /dev/null +++ b/koala-wrapper/src/generated/peers/ClassDeclaration.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { ClassDefinition } from "./ClassDefinition" +import { Decorator } from "./Decorator" +export class ClassDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 15) + super(pointer) + + } + static createClassDeclaration(def?: ClassDefinition): ClassDeclaration { + return new ClassDeclaration(global.generatedEs2panda._CreateClassDeclaration(global.context, passNode(def))) + } + static updateClassDeclaration(original?: ClassDeclaration, def?: ClassDefinition): ClassDeclaration { + return new ClassDeclaration(global.generatedEs2panda._UpdateClassDeclaration(global.context, passNode(original), passNode(def))) + } + get definition(): ClassDefinition | undefined { + return unpackNode(global.generatedEs2panda._ClassDeclarationDefinitionConst(global.context, this.peer)) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._ClassDeclarationDecoratorsConst(global.context, this.peer)) + } +} +export function isClassDeclaration(node: AstNode): node is ClassDeclaration { + return node instanceof ClassDeclaration +} +if (!nodeByType.has(15)) { + nodeByType.set(15, ClassDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ClassDefinition.ts b/koala-wrapper/src/generated/peers/ClassDefinition.ts new file mode 100644 index 000000000..f1187001d --- /dev/null +++ b/koala-wrapper/src/generated/peers/ClassDefinition.ts @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypedAstNode } from "./TypedAstNode" +import { Identifier } from "./Identifier" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +import { TSClassImplements } from "./TSClassImplements" +import { MethodDefinition } from "./MethodDefinition" +import { Expression } from "./Expression" +import { Es2pandaClassDefinitionModifiers } from "./../Es2pandaEnums" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { TSEnumDeclaration } from "./TSEnumDeclaration" +import { ClassDeclaration } from "./ClassDeclaration" +import { FunctionExpression } from "./FunctionExpression" +import { AnnotationUsage } from "./AnnotationUsage" +export class ClassDefinition extends TypedAstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 14) + super(pointer) + + } + static createClassDefinition(ident: Identifier | undefined, typeParams: TSTypeParameterDeclaration | undefined, superTypeParams: TSTypeParameterInstantiation | undefined, _implements: readonly TSClassImplements[], ctor: MethodDefinition | undefined, superClass: Expression | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._CreateClassDefinition(global.context, passNode(ident), passNode(typeParams), passNode(superTypeParams), passNodeArray(_implements), _implements.length, passNode(ctor), passNode(superClass), passNodeArray(body), body.length, modifiers, flags)) + } + static updateClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, typeParams: TSTypeParameterDeclaration | undefined, superTypeParams: TSTypeParameterInstantiation | undefined, _implements: readonly TSClassImplements[], ctor: MethodDefinition | undefined, superClass: Expression | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition(global.context, passNode(original), passNode(ident), passNode(typeParams), passNode(superTypeParams), passNodeArray(_implements), _implements.length, passNode(ctor), passNode(superClass), passNodeArray(body), body.length, modifiers, flags)) + } + static create1ClassDefinition(ident: Identifier | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._CreateClassDefinition1(global.context, passNode(ident), passNodeArray(body), body.length, modifiers, flags)) + } + static update1ClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, body: readonly AstNode[], modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition1(global.context, passNode(original), passNode(ident), passNodeArray(body), body.length, modifiers, flags)) + } + static create2ClassDefinition(ident: Identifier | undefined, modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._CreateClassDefinition2(global.context, passNode(ident), modifiers, flags)) + } + static update2ClassDefinition(original: ClassDefinition | undefined, ident: Identifier | undefined, modifiers: Es2pandaClassDefinitionModifiers, flags: Es2pandaModifierFlags): ClassDefinition { + return new ClassDefinition(global.generatedEs2panda._UpdateClassDefinition2(global.context, passNode(original), passNode(ident), modifiers, flags)) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionIdentConst(global.context, this.peer)) + } + /** @deprecated */ + setIdent(ident: Identifier): this { + global.generatedEs2panda._ClassDefinitionSetIdent(global.context, this.peer, passNode(ident)) + return this + } + get internalName(): string { + return unpackString(global.generatedEs2panda._ClassDefinitionInternalNameConst(global.context, this.peer)) + } + /** @deprecated */ + setInternalName(internalName: string): this { + global.generatedEs2panda._ClassDefinitionSetInternalName(global.context, this.peer, internalName) + return this + } + get super(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionSuperConst(global.context, this.peer)) + } + /** @deprecated */ + setSuper(superClass: Expression): this { + global.generatedEs2panda._ClassDefinitionSetSuper(global.context, this.peer, passNode(superClass)) + return this + } + get isGlobal(): boolean { + return global.generatedEs2panda._ClassDefinitionIsGlobalConst(global.context, this.peer) + } + get isLocal(): boolean { + return global.generatedEs2panda._ClassDefinitionIsLocalConst(global.context, this.peer) + } + get isExtern(): boolean { + return global.generatedEs2panda._ClassDefinitionIsExternConst(global.context, this.peer) + } + get isFromExternal(): boolean { + return global.generatedEs2panda._ClassDefinitionIsFromExternalConst(global.context, this.peer) + } + get isInner(): boolean { + return global.generatedEs2panda._ClassDefinitionIsInnerConst(global.context, this.peer) + } + get isGlobalInitialized(): boolean { + return global.generatedEs2panda._ClassDefinitionIsGlobalInitializedConst(global.context, this.peer) + } + get isClassDefinitionChecked(): boolean { + return global.generatedEs2panda._ClassDefinitionIsClassDefinitionCheckedConst(global.context, this.peer) + } + get isAnonymous(): boolean { + return global.generatedEs2panda._ClassDefinitionIsAnonymousConst(global.context, this.peer) + } + get isNamespaceTransformed(): boolean { + return global.generatedEs2panda._ClassDefinitionIsNamespaceTransformedConst(global.context, this.peer) + } + get isModule(): boolean { + return global.generatedEs2panda._ClassDefinitionIsModuleConst(global.context, this.peer) + } + /** @deprecated */ + setGlobalInitialized(): this { + global.generatedEs2panda._ClassDefinitionSetGlobalInitialized(global.context, this.peer) + return this + } + /** @deprecated */ + setInnerModifier(): this { + global.generatedEs2panda._ClassDefinitionSetInnerModifier(global.context, this.peer) + return this + } + /** @deprecated */ + setClassDefinitionChecked(): this { + global.generatedEs2panda._ClassDefinitionSetClassDefinitionChecked(global.context, this.peer) + return this + } + /** @deprecated */ + setAnonymousModifier(): this { + global.generatedEs2panda._ClassDefinitionSetAnonymousModifier(global.context, this.peer) + return this + } + /** @deprecated */ + setNamespaceTransformed(): this { + global.generatedEs2panda._ClassDefinitionSetNamespaceTransformed(global.context, this.peer) + return this + } + get modifiers(): Es2pandaClassDefinitionModifiers { + return global.generatedEs2panda._ClassDefinitionModifiersConst(global.context, this.peer) + } + /** @deprecated */ + setModifiers(modifiers: Es2pandaClassDefinitionModifiers): this { + global.generatedEs2panda._ClassDefinitionSetModifiers(global.context, this.peer, modifiers) + return this + } + /** @deprecated */ + addProperties(body: readonly AstNode[]): this { + global.generatedEs2panda._ClassDefinitionAddProperties(global.context, this.peer, passNodeArray(body), body.length) + return this + } + get body(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._ClassDefinitionBodyConst(global.context, this.peer)) + } + /** @deprecated */ + setCtor(ctor: MethodDefinition): this { + global.generatedEs2panda._ClassDefinitionSetCtor(global.context, this.peer, passNode(ctor)) + return this + } + get implements(): readonly TSClassImplements[] { + return unpackNodeArray(global.generatedEs2panda._ClassDefinitionImplementsConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionTypeParamsConst(global.context, this.peer)) + } + /** @deprecated */ + setTypeParams(typeParams: TSTypeParameterDeclaration): this { + global.generatedEs2panda._ClassDefinitionSetTypeParams(global.context, this.peer, passNode(typeParams)) + return this + } + get superTypeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionSuperTypeParamsConst(global.context, this.peer)) + } + get localTypeCounter(): number { + return global.generatedEs2panda._ClassDefinitionLocalTypeCounter(global.context, this.peer) + } + get localIndex(): number { + return global.generatedEs2panda._ClassDefinitionLocalIndexConst(global.context, this.peer) + } + get localPrefix(): string { + return unpackString(global.generatedEs2panda._ClassDefinitionLocalPrefixConst(global.context, this.peer)) + } + /** @deprecated */ + setOrigEnumDecl(enumDecl: TSEnumDeclaration): this { + global.generatedEs2panda._ClassDefinitionSetOrigEnumDecl(global.context, this.peer, passNode(enumDecl)) + return this + } + get origEnumDecl(): TSEnumDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionOrigEnumDeclConst(global.context, this.peer)) + } + get getAnonClass(): ClassDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ClassDefinitionGetAnonClass(global.context, this.peer)) + } + /** @deprecated */ + setAnonClass(anonClass: ClassDeclaration): this { + global.generatedEs2panda._ClassDefinitionSetAnonClass(global.context, this.peer, passNode(anonClass)) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ClassDefinitionAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ClassDefinitionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isClassDefinition(node: AstNode): node is ClassDefinition { + return node instanceof ClassDefinition +} +if (!nodeByType.has(14)) { + nodeByType.set(14, ClassDefinition) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ClassElement.ts b/koala-wrapper/src/generated/peers/ClassElement.ts new file mode 100644 index 000000000..2299f192f --- /dev/null +++ b/koala-wrapper/src/generated/peers/ClassElement.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypedStatement } from "./TypedStatement" +import { Identifier } from "./Identifier" +import { Expression } from "./Expression" +import { Decorator } from "./Decorator" +import { Es2pandaPrivateFieldKind } from "./../Es2pandaEnums" +export class ClassElement extends TypedStatement { + constructor(pointer: KNativePointer) { + super(pointer) + + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ClassElementKeyConst(global.context, this.peer)) + } + /** @deprecated */ + setValue(value: Expression): this { + global.generatedEs2panda._ClassElementSetValue(global.context, this.peer, passNode(value)) + return this + } + get value(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ClassElementValueConst(global.context, this.peer)) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._ClassElementDecoratorsConst(global.context, this.peer)) + } + get isComputed(): boolean { + return global.generatedEs2panda._ClassElementIsComputedConst(global.context, this.peer) + } + /** @deprecated */ + addDecorator(decorator: Decorator): this { + global.generatedEs2panda._ClassElementAddDecorator(global.context, this.peer, passNode(decorator)) + return this + } +} +export function isClassElement(node: AstNode): node is ClassElement { + return node instanceof ClassElement +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ClassExpression.ts b/koala-wrapper/src/generated/peers/ClassExpression.ts new file mode 100644 index 000000000..9b2f05b2e --- /dev/null +++ b/koala-wrapper/src/generated/peers/ClassExpression.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { ClassDefinition } from "./ClassDefinition" +export class ClassExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 16) + super(pointer) + + } + static createClassExpression(def?: ClassDefinition): ClassExpression { + return new ClassExpression(global.generatedEs2panda._CreateClassExpression(global.context, passNode(def))) + } + static updateClassExpression(original?: ClassExpression, def?: ClassDefinition): ClassExpression { + return new ClassExpression(global.generatedEs2panda._UpdateClassExpression(global.context, passNode(original), passNode(def))) + } + get definition(): ClassDefinition | undefined { + return unpackNode(global.generatedEs2panda._ClassExpressionDefinitionConst(global.context, this.peer)) + } +} +export function isClassExpression(node: AstNode): node is ClassExpression { + return node instanceof ClassExpression +} +if (!nodeByType.has(16)) { + nodeByType.set(16, ClassExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ClassProperty.ts b/koala-wrapper/src/generated/peers/ClassProperty.ts new file mode 100644 index 000000000..cac674bfb --- /dev/null +++ b/koala-wrapper/src/generated/peers/ClassProperty.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassElement } from "./ClassElement" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { AnnotationUsage } from "./AnnotationUsage" +export class ClassProperty extends ClassElement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 17) + super(pointer) + + } + static createClassProperty(key: Expression | undefined, value: Expression | undefined, typeAnnotation: TypeNode | undefined, modifiers: Es2pandaModifierFlags, isComputed: boolean): ClassProperty { + return new ClassProperty(global.generatedEs2panda._CreateClassProperty(global.context, passNode(key), passNode(value), passNode(typeAnnotation), modifiers, isComputed)) + } + static updateClassProperty(original: ClassProperty | undefined, key: Expression | undefined, value: Expression | undefined, typeAnnotation: TypeNode | undefined, modifiers: Es2pandaModifierFlags, isComputed: boolean): ClassProperty { + return new ClassProperty(global.generatedEs2panda._UpdateClassProperty(global.context, passNode(original), passNode(key), passNode(value), passNode(typeAnnotation), modifiers, isComputed)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ClassPropertyTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._ClassPropertySetTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ClassPropertyAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ClassPropertySetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isClassProperty(node: AstNode): node is ClassProperty { + return node instanceof ClassProperty +} +if (!nodeByType.has(17)) { + nodeByType.set(17, ClassProperty) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ClassStaticBlock.ts b/koala-wrapper/src/generated/peers/ClassStaticBlock.ts new file mode 100644 index 000000000..92ff36429 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ClassStaticBlock.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassElement } from "./ClassElement" +import { Expression } from "./Expression" +import { ScriptFunction } from "./ScriptFunction" +export class ClassStaticBlock extends ClassElement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 18) + super(pointer) + + } + static createClassStaticBlock(value?: Expression): ClassStaticBlock { + return new ClassStaticBlock(global.generatedEs2panda._CreateClassStaticBlock(global.context, passNode(value))) + } + static updateClassStaticBlock(original?: ClassStaticBlock, value?: Expression): ClassStaticBlock { + return new ClassStaticBlock(global.generatedEs2panda._UpdateClassStaticBlock(global.context, passNode(original), passNode(value))) + } +} +export function isClassStaticBlock(node: AstNode): node is ClassStaticBlock { + return node instanceof ClassStaticBlock +} +if (!nodeByType.has(18)) { + nodeByType.set(18, ClassStaticBlock) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ConditionalExpression.ts b/koala-wrapper/src/generated/peers/ConditionalExpression.ts new file mode 100644 index 000000000..20ab3b028 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ConditionalExpression.ts @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class ConditionalExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 19) + super(pointer) + + } + static createConditionalExpression(test?: Expression, consequent?: Expression, alternate?: Expression): ConditionalExpression { + return new ConditionalExpression(global.generatedEs2panda._CreateConditionalExpression(global.context, passNode(test), passNode(consequent), passNode(alternate))) + } + static updateConditionalExpression(original?: ConditionalExpression, test?: Expression, consequent?: Expression, alternate?: Expression): ConditionalExpression { + return new ConditionalExpression(global.generatedEs2panda._UpdateConditionalExpression(global.context, passNode(original), passNode(test), passNode(consequent), passNode(alternate))) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ConditionalExpressionTestConst(global.context, this.peer)) + } + /** @deprecated */ + setTest(expr: Expression): this { + global.generatedEs2panda._ConditionalExpressionSetTest(global.context, this.peer, passNode(expr)) + return this + } + get consequent(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ConditionalExpressionConsequentConst(global.context, this.peer)) + } + /** @deprecated */ + setConsequent(expr: Expression): this { + global.generatedEs2panda._ConditionalExpressionSetConsequent(global.context, this.peer, passNode(expr)) + return this + } + get alternate(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ConditionalExpressionAlternateConst(global.context, this.peer)) + } + /** @deprecated */ + setAlternate(expr: Expression): this { + global.generatedEs2panda._ConditionalExpressionSetAlternate(global.context, this.peer, passNode(expr)) + return this + } +} +export function isConditionalExpression(node: AstNode): node is ConditionalExpression { + return node instanceof ConditionalExpression +} +if (!nodeByType.has(19)) { + nodeByType.set(19, ConditionalExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/Context.ts b/koala-wrapper/src/generated/peers/Context.ts new file mode 100644 index 000000000..b34fc3981 --- /dev/null +++ b/koala-wrapper/src/generated/peers/Context.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class Context extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ContinueStatement.ts b/koala-wrapper/src/generated/peers/ContinueStatement.ts new file mode 100644 index 000000000..6d9f8a42e --- /dev/null +++ b/koala-wrapper/src/generated/peers/ContinueStatement.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Identifier } from "./Identifier" +export class ContinueStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 20) + super(pointer) + + } + static createContinueStatement(): ContinueStatement { + return new ContinueStatement(global.generatedEs2panda._CreateContinueStatement(global.context)) + } + static updateContinueStatement(original?: ContinueStatement): ContinueStatement { + return new ContinueStatement(global.generatedEs2panda._UpdateContinueStatement(global.context, passNode(original))) + } + static create1ContinueStatement(ident?: Identifier): ContinueStatement { + return new ContinueStatement(global.generatedEs2panda._CreateContinueStatement1(global.context, passNode(ident))) + } + static update1ContinueStatement(original?: ContinueStatement, ident?: Identifier): ContinueStatement { + return new ContinueStatement(global.generatedEs2panda._UpdateContinueStatement1(global.context, passNode(original), passNode(ident))) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ContinueStatementIdentConst(global.context, this.peer)) + } + get target(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ContinueStatementTargetConst(global.context, this.peer)) + } + /** @deprecated */ + setTarget(target: AstNode): this { + global.generatedEs2panda._ContinueStatementSetTarget(global.context, this.peer, passNode(target)) + return this + } +} +export function isContinueStatement(node: AstNode): node is ContinueStatement { + return node instanceof ContinueStatement +} +if (!nodeByType.has(20)) { + nodeByType.set(20, ContinueStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/DebuggerStatement.ts b/koala-wrapper/src/generated/peers/DebuggerStatement.ts new file mode 100644 index 000000000..e74c35108 --- /dev/null +++ b/koala-wrapper/src/generated/peers/DebuggerStatement.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class DebuggerStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 21) + super(pointer) + + } + static createDebuggerStatement(): DebuggerStatement { + return new DebuggerStatement(global.generatedEs2panda._CreateDebuggerStatement(global.context)) + } + static updateDebuggerStatement(original?: DebuggerStatement): DebuggerStatement { + return new DebuggerStatement(global.generatedEs2panda._UpdateDebuggerStatement(global.context, passNode(original))) + } +} +export function isDebuggerStatement(node: AstNode): node is DebuggerStatement { + return node instanceof DebuggerStatement +} +if (!nodeByType.has(21)) { + nodeByType.set(21, DebuggerStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/Decorator.ts b/koala-wrapper/src/generated/peers/Decorator.ts new file mode 100644 index 000000000..de635c11e --- /dev/null +++ b/koala-wrapper/src/generated/peers/Decorator.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class Decorator extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 22) + super(pointer) + + } + static createDecorator(expr?: Expression): Decorator { + return new Decorator(global.generatedEs2panda._CreateDecorator(global.context, passNode(expr))) + } + static updateDecorator(original?: Decorator, expr?: Expression): Decorator { + return new Decorator(global.generatedEs2panda._UpdateDecorator(global.context, passNode(original), passNode(expr))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._DecoratorExprConst(global.context, this.peer)) + } +} +export function isDecorator(node: AstNode): node is Decorator { + return node instanceof Decorator +} +if (!nodeByType.has(22)) { + nodeByType.set(22, Decorator) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/DirectEvalExpression.ts b/koala-wrapper/src/generated/peers/DirectEvalExpression.ts new file mode 100644 index 000000000..d432f9f0d --- /dev/null +++ b/koala-wrapper/src/generated/peers/DirectEvalExpression.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { CallExpression } from "./CallExpression" +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +export class DirectEvalExpression extends CallExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 23) + super(pointer) + + } + static createDirectEvalExpression(callee: Expression | undefined, _arguments: readonly Expression[], typeParams: TSTypeParameterInstantiation | undefined, optional_arg: boolean, parserStatus: number): DirectEvalExpression { + return new DirectEvalExpression(global.generatedEs2panda._CreateDirectEvalExpression(global.context, passNode(callee), passNodeArray(_arguments), _arguments.length, passNode(typeParams), optional_arg, parserStatus)) + } + static updateDirectEvalExpression(original: DirectEvalExpression | undefined, callee: Expression | undefined, _arguments: readonly Expression[], typeParams: TSTypeParameterInstantiation | undefined, optional_arg: boolean, parserStatus: number): DirectEvalExpression { + return new DirectEvalExpression(global.generatedEs2panda._UpdateDirectEvalExpression(global.context, passNode(original), passNode(callee), passNodeArray(_arguments), _arguments.length, passNode(typeParams), optional_arg, parserStatus)) + } +} +export function isDirectEvalExpression(node: AstNode): node is DirectEvalExpression { + return node instanceof DirectEvalExpression +} +if (!nodeByType.has(23)) { + nodeByType.set(23, DirectEvalExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/DoWhileStatement.ts b/koala-wrapper/src/generated/peers/DoWhileStatement.ts new file mode 100644 index 000000000..c6ce8c8cd --- /dev/null +++ b/koala-wrapper/src/generated/peers/DoWhileStatement.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { LoopStatement } from "./LoopStatement" +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class DoWhileStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 24) + super(pointer) + + } + static createDoWhileStatement(body?: Statement, test?: Expression): DoWhileStatement { + return new DoWhileStatement(global.generatedEs2panda._CreateDoWhileStatement(global.context, passNode(body), passNode(test))) + } + static updateDoWhileStatement(original?: DoWhileStatement, body?: Statement, test?: Expression): DoWhileStatement { + return new DoWhileStatement(global.generatedEs2panda._UpdateDoWhileStatement(global.context, passNode(original), passNode(body), passNode(test))) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._DoWhileStatementBodyConst(global.context, this.peer)) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._DoWhileStatementTestConst(global.context, this.peer)) + } +} +export function isDoWhileStatement(node: AstNode): node is DoWhileStatement { + return node instanceof DoWhileStatement +} +if (!nodeByType.has(24)) { + nodeByType.set(24, DoWhileStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSClassLiteral.ts b/koala-wrapper/src/generated/peers/ETSClassLiteral.ts new file mode 100644 index 000000000..d78af3b90 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSClassLiteral.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class ETSClassLiteral extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 70) + super(pointer) + + } + static createETSClassLiteral(expr?: TypeNode): ETSClassLiteral { + return new ETSClassLiteral(global.generatedEs2panda._CreateETSClassLiteral(global.context, passNode(expr))) + } + static updateETSClassLiteral(original?: ETSClassLiteral, expr?: TypeNode): ETSClassLiteral { + return new ETSClassLiteral(global.generatedEs2panda._UpdateETSClassLiteral(global.context, passNode(original), passNode(expr))) + } + get expr(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSClassLiteralExprConst(global.context, this.peer)) + } +} +export function isETSClassLiteral(node: AstNode): node is ETSClassLiteral { + return node instanceof ETSClassLiteral +} +if (!nodeByType.has(70)) { + nodeByType.set(70, ETSClassLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSDynamicFunctionType.ts b/koala-wrapper/src/generated/peers/ETSDynamicFunctionType.ts new file mode 100644 index 000000000..8b9b32069 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSDynamicFunctionType.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ETSFunctionType } from "./ETSFunctionType" +export class ETSDynamicFunctionType extends ETSFunctionType { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isETSDynamicFunctionType(node: AstNode): node is ETSDynamicFunctionType { + return node instanceof ETSDynamicFunctionType +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSFunctionType.ts b/koala-wrapper/src/generated/peers/ETSFunctionType.ts new file mode 100644 index 000000000..5354546f8 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSFunctionType.ts @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { FunctionSignature } from "./FunctionSignature" +import { Es2pandaScriptFunctionFlags } from "./../Es2pandaEnums" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { Expression } from "./Expression" +import { TSInterfaceDeclaration } from "./TSInterfaceDeclaration" +export class ETSFunctionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 66) + super(pointer) + + } + static createETSFunctionType(signature: FunctionSignature | undefined, funcFlags: Es2pandaScriptFunctionFlags): ETSFunctionType { + return new ETSFunctionType(global.generatedEs2panda._CreateETSFunctionTypeIr(global.context, passNode(signature), funcFlags)) + } + static updateETSFunctionType(original: ETSFunctionType | undefined, signature: FunctionSignature | undefined, funcFlags: Es2pandaScriptFunctionFlags): ETSFunctionType { + return new ETSFunctionType(global.generatedEs2panda._UpdateETSFunctionTypeIr(global.context, passNode(original), passNode(signature), funcFlags)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ETSFunctionTypeIrTypeParamsConst(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ETSFunctionTypeIrParamsConst(global.context, this.peer)) + } + get returnType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSFunctionTypeIrReturnTypeConst(global.context, this.peer)) + } + get functionalInterface(): TSInterfaceDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ETSFunctionTypeIrFunctionalInterfaceConst(global.context, this.peer)) + } + /** @deprecated */ + setFunctionalInterface(functionalInterface: TSInterfaceDeclaration): this { + global.generatedEs2panda._ETSFunctionTypeIrSetFunctionalInterface(global.context, this.peer, passNode(functionalInterface)) + return this + } + get flags(): Es2pandaScriptFunctionFlags { + return global.generatedEs2panda._ETSFunctionTypeIrFlags(global.context, this.peer) + } + get isThrowing(): boolean { + return global.generatedEs2panda._ETSFunctionTypeIrIsThrowingConst(global.context, this.peer) + } + get isRethrowing(): boolean { + return global.generatedEs2panda._ETSFunctionTypeIrIsRethrowingConst(global.context, this.peer) + } + get isExtensionFunction(): boolean { + return global.generatedEs2panda._ETSFunctionTypeIrIsExtensionFunctionConst(global.context, this.peer) + } +} +export function isETSFunctionType(node: AstNode): node is ETSFunctionType { + return node instanceof ETSFunctionType +} +if (!nodeByType.has(66)) { + nodeByType.set(66, ETSFunctionType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSImportDeclaration.ts b/koala-wrapper/src/generated/peers/ETSImportDeclaration.ts new file mode 100644 index 000000000..9261c82c6 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSImportDeclaration.ts @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ImportDeclaration } from "./ImportDeclaration" +import { ImportSource } from "./ImportSource" +import { Es2pandaImportKinds } from "./../Es2pandaEnums" +import { StringLiteral } from "./StringLiteral" +export class ETSImportDeclaration extends ImportDeclaration { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 79) + super(pointer) + + } + static createETSImportDeclaration(source: StringLiteral | undefined, specifiers: readonly AstNode[], importKind: Es2pandaImportKinds): ETSImportDeclaration { + return new ETSImportDeclaration(global.generatedEs2panda._CreateETSImportDeclaration(global.context, passNode(source), passNodeArray(specifiers), specifiers.length, importKind)) + } + static updateETSImportDeclaration(original: ETSImportDeclaration | undefined, source: StringLiteral | undefined, specifiers: readonly AstNode[], importKind: Es2pandaImportKinds): ETSImportDeclaration { + return new ETSImportDeclaration(global.generatedEs2panda._UpdateETSImportDeclaration(global.context, passNode(original), passNode(source), passNodeArray(specifiers), specifiers.length, importKind)) + } + get hasDecl(): boolean { + return global.generatedEs2panda._ETSImportDeclarationHasDeclConst(global.context, this.peer) + } + get isPureDynamic(): boolean { + return global.generatedEs2panda._ETSImportDeclarationIsPureDynamicConst(global.context, this.peer) + } + get assemblerName(): string { + return unpackString(global.generatedEs2panda._ETSImportDeclarationAssemblerNameConst(global.context, this.peer)) + } + // get source(): StringLiteral | undefined { + // return unpackNode(global.generatedEs2panda._ETSImportDeclarationSourceConst(global.context, this.peer)) + // } + get resolvedSource(): StringLiteral | undefined { + return unpackNode(global.generatedEs2panda._ETSImportDeclarationResolvedSourceConst(global.context, this.peer)) + } +} +export function isETSImportDeclaration(node: AstNode): node is ETSImportDeclaration { + return node instanceof ETSImportDeclaration +} +if (!nodeByType.has(79)) { + nodeByType.set(79, ETSImportDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSLaunchExpression.ts b/koala-wrapper/src/generated/peers/ETSLaunchExpression.ts new file mode 100644 index 000000000..39a42bcc6 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSLaunchExpression.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { CallExpression } from "./CallExpression" +export class ETSLaunchExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 75) + super(pointer) + + } + static createETSLaunchExpression(expr?: CallExpression): ETSLaunchExpression { + return new ETSLaunchExpression(global.generatedEs2panda._CreateETSLaunchExpression(global.context, passNode(expr))) + } + static updateETSLaunchExpression(original?: ETSLaunchExpression, expr?: CallExpression): ETSLaunchExpression { + return new ETSLaunchExpression(global.generatedEs2panda._UpdateETSLaunchExpression(global.context, passNode(original), passNode(expr))) + } + get call(): CallExpression | undefined { + return unpackNode(global.generatedEs2panda._ETSLaunchExpressionCallConst(global.context, this.peer)) + } +} +export function isETSLaunchExpression(node: AstNode): node is ETSLaunchExpression { + return node instanceof ETSLaunchExpression +} +if (!nodeByType.has(75)) { + nodeByType.set(75, ETSLaunchExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSModule.ts b/koala-wrapper/src/generated/peers/ETSModule.ts new file mode 100644 index 000000000..df693d3b1 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSModule.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { BlockStatement } from "./BlockStatement" +import { Identifier } from "./Identifier" +import { AnnotationUsage } from "./AnnotationUsage" +export class ETSModule extends BlockStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 82) + super(pointer) + + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ETSModuleIdentConst(global.context, this.peer)) + } + get isETSScript(): boolean { + return global.generatedEs2panda._ETSModuleIsETSScriptConst(global.context, this.peer) + } + get isNamespace(): boolean { + return global.generatedEs2panda._ETSModuleIsNamespaceConst(global.context, this.peer) + } + get isNamespaceChainLastNode(): boolean { + return global.generatedEs2panda._ETSModuleIsNamespaceChainLastNodeConst(global.context, this.peer) + } + /** @deprecated */ + setNamespaceChainLastNode(): this { + global.generatedEs2panda._ETSModuleSetNamespaceChainLastNode(global.context, this.peer) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ETSModuleAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ETSModuleSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isETSModule(node: AstNode): node is ETSModule { + return node instanceof ETSModule +} +if (!nodeByType.has(82)) { + nodeByType.set(82, ETSModule) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSNewArrayInstanceExpression.ts b/koala-wrapper/src/generated/peers/ETSNewArrayInstanceExpression.ts new file mode 100644 index 000000000..05135647e --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSNewArrayInstanceExpression.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class ETSNewArrayInstanceExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 76) + super(pointer) + + } + static createETSNewArrayInstanceExpression(typeReference?: TypeNode, dimension?: Expression): ETSNewArrayInstanceExpression { + return new ETSNewArrayInstanceExpression(global.generatedEs2panda._CreateETSNewArrayInstanceExpression(global.context, passNode(typeReference), passNode(dimension))) + } + static updateETSNewArrayInstanceExpression(original?: ETSNewArrayInstanceExpression, typeReference?: TypeNode, dimension?: Expression): ETSNewArrayInstanceExpression { + return new ETSNewArrayInstanceExpression(global.generatedEs2panda._UpdateETSNewArrayInstanceExpression(global.context, passNode(original), passNode(typeReference), passNode(dimension))) + } + get typeReference(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSNewArrayInstanceExpressionTypeReferenceConst(global.context, this.peer)) + } + get dimension(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ETSNewArrayInstanceExpressionDimensionConst(global.context, this.peer)) + } + /** @deprecated */ + setDimension(dimension: Expression): this { + global.generatedEs2panda._ETSNewArrayInstanceExpressionSetDimension(global.context, this.peer, passNode(dimension)) + return this + } +} +export function isETSNewArrayInstanceExpression(node: AstNode): node is ETSNewArrayInstanceExpression { + return node instanceof ETSNewArrayInstanceExpression +} +if (!nodeByType.has(76)) { + nodeByType.set(76, ETSNewArrayInstanceExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSNewClassInstanceExpression.ts b/koala-wrapper/src/generated/peers/ETSNewClassInstanceExpression.ts new file mode 100644 index 000000000..7e0bb389b --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSNewClassInstanceExpression.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class ETSNewClassInstanceExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 78) + super(pointer) + + } + static createETSNewClassInstanceExpression(typeReference: Expression | undefined, _arguments: readonly Expression[]): ETSNewClassInstanceExpression { + return new ETSNewClassInstanceExpression(global.generatedEs2panda._CreateETSNewClassInstanceExpression(global.context, passNode(typeReference), passNodeArray(_arguments), _arguments.length)) + } + static updateETSNewClassInstanceExpression(original: ETSNewClassInstanceExpression | undefined, typeReference: Expression | undefined, _arguments: readonly Expression[]): ETSNewClassInstanceExpression { + return new ETSNewClassInstanceExpression(global.generatedEs2panda._UpdateETSNewClassInstanceExpression(global.context, passNode(original), passNode(typeReference), passNodeArray(_arguments), _arguments.length)) + } + static create1ETSNewClassInstanceExpression(other?: ETSNewClassInstanceExpression): ETSNewClassInstanceExpression { + return new ETSNewClassInstanceExpression(global.generatedEs2panda._CreateETSNewClassInstanceExpression1(global.context, passNode(other))) + } + static update1ETSNewClassInstanceExpression(original?: ETSNewClassInstanceExpression, other?: ETSNewClassInstanceExpression): ETSNewClassInstanceExpression { + return new ETSNewClassInstanceExpression(global.generatedEs2panda._UpdateETSNewClassInstanceExpression1(global.context, passNode(original), passNode(other))) + } + get getTypeRef(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ETSNewClassInstanceExpressionGetTypeRefConst(global.context, this.peer)) + } + get getArguments(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ETSNewClassInstanceExpressionGetArgumentsConst(global.context, this.peer)) + } + /** @deprecated */ + setArguments(_arguments: readonly Expression[]): this { + global.generatedEs2panda._ETSNewClassInstanceExpressionSetArguments(global.context, this.peer, passNodeArray(_arguments), _arguments.length) + return this + } + /** @deprecated */ + addToArgumentsFront(expr: Expression): this { + global.generatedEs2panda._ETSNewClassInstanceExpressionAddToArgumentsFront(global.context, this.peer, passNode(expr)) + return this + } +} +export function isETSNewClassInstanceExpression(node: AstNode): node is ETSNewClassInstanceExpression { + return node instanceof ETSNewClassInstanceExpression +} +if (!nodeByType.has(78)) { + nodeByType.set(78, ETSNewClassInstanceExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts b/koala-wrapper/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts new file mode 100644 index 000000000..e99e3ed42 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSNewMultiDimArrayInstanceExpression.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class ETSNewMultiDimArrayInstanceExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 77) + super(pointer) + + } + static createETSNewMultiDimArrayInstanceExpression(typeReference: TypeNode | undefined, dimensions: readonly Expression[]): ETSNewMultiDimArrayInstanceExpression { + return new ETSNewMultiDimArrayInstanceExpression(global.generatedEs2panda._CreateETSNewMultiDimArrayInstanceExpression(global.context, passNode(typeReference), passNodeArray(dimensions), dimensions.length)) + } + static updateETSNewMultiDimArrayInstanceExpression(original: ETSNewMultiDimArrayInstanceExpression | undefined, typeReference: TypeNode | undefined, dimensions: readonly Expression[]): ETSNewMultiDimArrayInstanceExpression { + return new ETSNewMultiDimArrayInstanceExpression(global.generatedEs2panda._UpdateETSNewMultiDimArrayInstanceExpression(global.context, passNode(original), passNode(typeReference), passNodeArray(dimensions), dimensions.length)) + } + static create1ETSNewMultiDimArrayInstanceExpression(other?: ETSNewMultiDimArrayInstanceExpression): ETSNewMultiDimArrayInstanceExpression { + return new ETSNewMultiDimArrayInstanceExpression(global.generatedEs2panda._CreateETSNewMultiDimArrayInstanceExpression1(global.context, passNode(other))) + } + static update1ETSNewMultiDimArrayInstanceExpression(original?: ETSNewMultiDimArrayInstanceExpression, other?: ETSNewMultiDimArrayInstanceExpression): ETSNewMultiDimArrayInstanceExpression { + return new ETSNewMultiDimArrayInstanceExpression(global.generatedEs2panda._UpdateETSNewMultiDimArrayInstanceExpression1(global.context, passNode(original), passNode(other))) + } + get typeReference(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ETSNewMultiDimArrayInstanceExpressionTypeReferenceConst(global.context, this.peer)) + } + get dimensions(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ETSNewMultiDimArrayInstanceExpressionDimensionsConst(global.context, this.peer)) + } +} +export function isETSNewMultiDimArrayInstanceExpression(node: AstNode): node is ETSNewMultiDimArrayInstanceExpression { + return node instanceof ETSNewMultiDimArrayInstanceExpression +} +if (!nodeByType.has(77)) { + nodeByType.set(77, ETSNewMultiDimArrayInstanceExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSNullType.ts b/koala-wrapper/src/generated/peers/ETSNullType.ts new file mode 100644 index 000000000..edf561cf1 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSNullType.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class ETSNullType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 62) + super(pointer) + + } + static createETSNullType(): ETSNullType { + return new ETSNullType(global.generatedEs2panda._CreateETSNullTypeIr(global.context)) + } + static updateETSNullType(original?: ETSNullType): ETSNullType { + return new ETSNullType(global.generatedEs2panda._UpdateETSNullTypeIr(global.context, passNode(original))) + } +} +export function isETSNullType(node: AstNode): node is ETSNullType { + return node instanceof ETSNullType +} +if (!nodeByType.has(62)) { + nodeByType.set(62, ETSNullType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSPackageDeclaration.ts b/koala-wrapper/src/generated/peers/ETSPackageDeclaration.ts new file mode 100644 index 000000000..1148df88e --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSPackageDeclaration.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class ETSPackageDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 69) + super(pointer) + + } + static createETSPackageDeclaration(name?: Expression): ETSPackageDeclaration { + return new ETSPackageDeclaration(global.generatedEs2panda._CreateETSPackageDeclaration(global.context, passNode(name))) + } + static updateETSPackageDeclaration(original?: ETSPackageDeclaration, name?: Expression): ETSPackageDeclaration { + return new ETSPackageDeclaration(global.generatedEs2panda._UpdateETSPackageDeclaration(global.context, passNode(original), passNode(name))) + } +} +export function isETSPackageDeclaration(node: AstNode): node is ETSPackageDeclaration { + return node instanceof ETSPackageDeclaration +} +if (!nodeByType.has(69)) { + nodeByType.set(69, ETSPackageDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSParameterExpression.ts b/koala-wrapper/src/generated/peers/ETSParameterExpression.ts new file mode 100644 index 000000000..3b8c76a41 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSParameterExpression.ts @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Identifier } from "./Identifier" +import { SpreadElement } from "./SpreadElement" +import { TypeNode } from "./TypeNode" +import { AnnotationUsage } from "./AnnotationUsage" +export class ETSParameterExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 80) + super(pointer) + + } + static createETSParameterExpression(identOrSpread: AnnotatedExpression | undefined, isOptional: boolean): ETSParameterExpression { + return new ETSParameterExpression(global.generatedEs2panda._CreateETSParameterExpression(global.context, passNode(identOrSpread), isOptional)) + } + static updateETSParameterExpression(original: ETSParameterExpression | undefined, identOrSpread: AnnotatedExpression | undefined, isOptional: boolean): ETSParameterExpression { + return new ETSParameterExpression(global.generatedEs2panda._UpdateETSParameterExpression(global.context, passNode(original), passNode(identOrSpread), isOptional)) + } + static create1ETSParameterExpression(identOrSpread?: AnnotatedExpression, initializer?: Expression): ETSParameterExpression { + return new ETSParameterExpression(global.generatedEs2panda._CreateETSParameterExpression1(global.context, passNode(identOrSpread), passNode(initializer))) + } + static update1ETSParameterExpression(original?: ETSParameterExpression, identOrSpread?: AnnotatedExpression, initializer?: Expression): ETSParameterExpression { + return new ETSParameterExpression(global.generatedEs2panda._UpdateETSParameterExpression1(global.context, passNode(original), passNode(identOrSpread), passNode(initializer))) + } + /** @deprecated */ + setIdent(ident: Identifier): this { + global.generatedEs2panda._ETSParameterExpressionSetIdent(global.context, this.peer, passNode(ident)) + return this + } + /** @deprecated */ + setLexerSaved(s: string): this { + global.generatedEs2panda._ETSParameterExpressionSetLexerSaved(global.context, this.peer, s) + return this + } + /** @deprecated */ + setTypeAnnotation(typeNode: TypeNode): this { + global.generatedEs2panda._ETSParameterExpressionSetTypeAnnotation(global.context, this.peer, passNode(typeNode)) + return this + } + get isOptional(): boolean { + return global.generatedEs2panda._ETSParameterExpressionIsOptionalConst(global.context, this.peer) + } + /** @deprecated */ + setOptional(value: boolean): this { + global.generatedEs2panda._ETSParameterExpressionSetOptional(global.context, this.peer, value) + return this + } + /** @deprecated */ + setInitializer(initExpr: Expression): this { + global.generatedEs2panda._ETSParameterExpressionSetInitializer(global.context, this.peer, passNode(initExpr)) + return this + } + get isRestParameter(): boolean { + return global.generatedEs2panda._ETSParameterExpressionIsRestParameterConst(global.context, this.peer) + } + get getRequiredParams(): number { + return global.generatedEs2panda._ETSParameterExpressionGetRequiredParamsConst(global.context, this.peer) + } + /** @deprecated */ + setRequiredParams(value: number): this { + global.generatedEs2panda._ETSParameterExpressionSetRequiredParams(global.context, this.peer, value) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ETSParameterExpressionAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ETSParameterExpressionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isETSParameterExpression(node: AstNode): node is ETSParameterExpression { + return node instanceof ETSParameterExpression +} +if (!nodeByType.has(80)) { + nodeByType.set(80, ETSParameterExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSPrimitiveType.ts b/koala-wrapper/src/generated/peers/ETSPrimitiveType.ts new file mode 100644 index 000000000..82713f44b --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSPrimitiveType.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Es2pandaPrimitiveType } from "./../Es2pandaEnums" +export class ETSPrimitiveType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 68) + super(pointer) + + } + static createETSPrimitiveType(type: Es2pandaPrimitiveType): ETSPrimitiveType { + return new ETSPrimitiveType(global.generatedEs2panda._CreateETSPrimitiveType(global.context, type)) + } + static updateETSPrimitiveType(original: ETSPrimitiveType | undefined, type: Es2pandaPrimitiveType): ETSPrimitiveType { + return new ETSPrimitiveType(global.generatedEs2panda._UpdateETSPrimitiveType(global.context, passNode(original), type)) + } + get getPrimitiveType(): Es2pandaPrimitiveType { + return global.generatedEs2panda._ETSPrimitiveTypeGetPrimitiveTypeConst(global.context, this.peer) + } +} +export function isETSPrimitiveType(node: AstNode): node is ETSPrimitiveType { + return node instanceof ETSPrimitiveType +} +if (!nodeByType.has(68)) { + nodeByType.set(68, ETSPrimitiveType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSReExportDeclaration.ts b/koala-wrapper/src/generated/peers/ETSReExportDeclaration.ts new file mode 100644 index 000000000..6e33931db --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSReExportDeclaration.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { ETSImportDeclaration } from "./ETSImportDeclaration" +export class ETSReExportDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 57) + super(pointer) + + } + get getETSImportDeclarations(): ETSImportDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ETSReExportDeclarationGetETSImportDeclarationsConst(global.context, this.peer)) + } + get getProgramPath(): string { + return unpackString(global.generatedEs2panda._ETSReExportDeclarationGetProgramPathConst(global.context, this.peer)) + } +} +export function isETSReExportDeclaration(node: AstNode): node is ETSReExportDeclaration { + return node instanceof ETSReExportDeclaration +} +if (!nodeByType.has(57)) { + nodeByType.set(57, ETSReExportDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSStructDeclaration.ts b/koala-wrapper/src/generated/peers/ETSStructDeclaration.ts new file mode 100644 index 000000000..9a060fdce --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSStructDeclaration.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassDeclaration } from "./ClassDeclaration" +import { ClassDefinition } from "./ClassDefinition" +export class ETSStructDeclaration extends ClassDeclaration { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 84) + super(pointer) + + } + static createETSStructDeclaration(def?: ClassDefinition): ETSStructDeclaration { + return new ETSStructDeclaration(global.generatedEs2panda._CreateETSStructDeclaration(global.context, passNode(def))) + } + static updateETSStructDeclaration(original?: ETSStructDeclaration, def?: ClassDefinition): ETSStructDeclaration { + return new ETSStructDeclaration(global.generatedEs2panda._UpdateETSStructDeclaration(global.context, passNode(original), passNode(def))) + } +} +export function isETSStructDeclaration(node: AstNode): node is ETSStructDeclaration { + return node instanceof ETSStructDeclaration +} +if (!nodeByType.has(84)) { + nodeByType.set(84, ETSStructDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSTuple.ts b/koala-wrapper/src/generated/peers/ETSTuple.ts new file mode 100644 index 000000000..158eee3f8 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSTuple.ts @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class ETSTuple extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 81) + super(pointer) + + } + static createETSTuple(): ETSTuple { + return new ETSTuple(global.generatedEs2panda._CreateETSTuple(global.context)) + } + static updateETSTuple(original?: ETSTuple): ETSTuple { + return new ETSTuple(global.generatedEs2panda._UpdateETSTuple(global.context, passNode(original))) + } + static create1ETSTuple(size: number): ETSTuple { + return new ETSTuple(global.generatedEs2panda._CreateETSTuple1(global.context, size)) + } + static update1ETSTuple(original: ETSTuple | undefined, size: number): ETSTuple { + return new ETSTuple(global.generatedEs2panda._UpdateETSTuple1(global.context, passNode(original), size)) + } + static create2ETSTuple(typeList: readonly TypeNode[]): ETSTuple { + return new ETSTuple(global.generatedEs2panda._CreateETSTuple2(global.context, passNodeArray(typeList), typeList.length)) + } + static update2ETSTuple(original: ETSTuple | undefined, typeList: readonly TypeNode[]): ETSTuple { + return new ETSTuple(global.generatedEs2panda._UpdateETSTuple2(global.context, passNode(original), passNodeArray(typeList), typeList.length)) + } + get getTupleSize(): number { + return global.generatedEs2panda._ETSTupleGetTupleSizeConst(global.context, this.peer) + } + get getTupleTypeAnnotationsList(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._ETSTupleGetTupleTypeAnnotationsListConst(global.context, this.peer)) + } + get hasSpreadType(): boolean { + return global.generatedEs2panda._ETSTupleHasSpreadTypeConst(global.context, this.peer) + } + /** @deprecated */ + setSpreadType(newSpreadType: TypeNode): this { + global.generatedEs2panda._ETSTupleSetSpreadType(global.context, this.peer, passNode(newSpreadType)) + return this + } + /** @deprecated */ + setTypeAnnotationsList(typeNodeList: readonly TypeNode[]): this { + global.generatedEs2panda._ETSTupleSetTypeAnnotationsList(global.context, this.peer, passNodeArray(typeNodeList), typeNodeList.length) + return this + } +} +export function isETSTuple(node: AstNode): node is ETSTuple { + return node instanceof ETSTuple +} +if (!nodeByType.has(81)) { + nodeByType.set(81, ETSTuple) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSTypeReference.ts b/koala-wrapper/src/generated/peers/ETSTypeReference.ts new file mode 100644 index 000000000..f18f4c8b3 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSTypeReference.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { ETSTypeReferencePart } from "./ETSTypeReferencePart" +import { Identifier } from "./Identifier" +export class ETSTypeReference extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 71) + super(pointer) + + } + static createETSTypeReference(part?: ETSTypeReferencePart): ETSTypeReference { + return new ETSTypeReference(global.generatedEs2panda._CreateETSTypeReference(global.context, passNode(part))) + } + static updateETSTypeReference(original?: ETSTypeReference, part?: ETSTypeReferencePart): ETSTypeReference { + return new ETSTypeReference(global.generatedEs2panda._UpdateETSTypeReference(global.context, passNode(original), passNode(part))) + } + get part(): ETSTypeReferencePart | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferencePartConst(global.context, this.peer)) + } +} +export function isETSTypeReference(node: AstNode): node is ETSTypeReference { + return node instanceof ETSTypeReference +} +if (!nodeByType.has(71)) { + nodeByType.set(71, ETSTypeReference) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSTypeReferencePart.ts b/koala-wrapper/src/generated/peers/ETSTypeReferencePart.ts new file mode 100644 index 000000000..804642d30 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSTypeReferencePart.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +export class ETSTypeReferencePart extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 72) + super(pointer) + + } + static createETSTypeReferencePart(name?: Expression, typeParams?: TSTypeParameterInstantiation, prev?: ETSTypeReferencePart): ETSTypeReferencePart { + return new ETSTypeReferencePart(global.generatedEs2panda._CreateETSTypeReferencePart(global.context, passNode(name), passNode(typeParams), passNode(prev))) + } + static updateETSTypeReferencePart(original?: ETSTypeReferencePart, name?: Expression, typeParams?: TSTypeParameterInstantiation, prev?: ETSTypeReferencePart): ETSTypeReferencePart { + return new ETSTypeReferencePart(global.generatedEs2panda._UpdateETSTypeReferencePart(global.context, passNode(original), passNode(name), passNode(typeParams), passNode(prev))) + } + static create1ETSTypeReferencePart(name?: Expression): ETSTypeReferencePart { + return new ETSTypeReferencePart(global.generatedEs2panda._CreateETSTypeReferencePart1(global.context, passNode(name))) + } + static update1ETSTypeReferencePart(original?: ETSTypeReferencePart, name?: Expression): ETSTypeReferencePart { + return new ETSTypeReferencePart(global.generatedEs2panda._UpdateETSTypeReferencePart1(global.context, passNode(original), passNode(name))) + } + get previous(): ETSTypeReferencePart | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferencePartPreviousConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferencePartTypeParams(global.context, this.peer)) + } + get name(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ETSTypeReferencePartNameConst(global.context, this.peer)) + } +} +export function isETSTypeReferencePart(node: AstNode): node is ETSTypeReferencePart { + return node instanceof ETSTypeReferencePart +} +if (!nodeByType.has(72)) { + nodeByType.set(72, ETSTypeReferencePart) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSUndefinedType.ts b/koala-wrapper/src/generated/peers/ETSUndefinedType.ts new file mode 100644 index 000000000..6f44b6a87 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSUndefinedType.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class ETSUndefinedType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 63) + super(pointer) + + } + static createETSUndefinedType(): ETSUndefinedType { + return new ETSUndefinedType(global.generatedEs2panda._CreateETSUndefinedTypeIr(global.context)) + } + static updateETSUndefinedType(original?: ETSUndefinedType): ETSUndefinedType { + return new ETSUndefinedType(global.generatedEs2panda._UpdateETSUndefinedTypeIr(global.context, passNode(original))) + } +} +export function isETSUndefinedType(node: AstNode): node is ETSUndefinedType { + return node instanceof ETSUndefinedType +} +if (!nodeByType.has(63)) { + nodeByType.set(63, ETSUndefinedType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSUnionType.ts b/koala-wrapper/src/generated/peers/ETSUnionType.ts new file mode 100644 index 000000000..18ea1f142 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSUnionType.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class ETSUnionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 73) + super(pointer) + + } + static createETSUnionType(types: readonly TypeNode[]): ETSUnionType { + return new ETSUnionType(global.generatedEs2panda._CreateETSUnionTypeIr(global.context, passNodeArray(types), types.length)) + } + static updateETSUnionType(original: ETSUnionType | undefined, types: readonly TypeNode[]): ETSUnionType { + return new ETSUnionType(global.generatedEs2panda._UpdateETSUnionTypeIr(global.context, passNode(original), passNodeArray(types), types.length)) + } + get types(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._ETSUnionTypeIrTypesConst(global.context, this.peer)) + } +} +export function isETSUnionType(node: AstNode): node is ETSUnionType { + return node instanceof ETSUnionType +} +if (!nodeByType.has(73)) { + nodeByType.set(73, ETSUnionType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ETSWildcardType.ts b/koala-wrapper/src/generated/peers/ETSWildcardType.ts new file mode 100644 index 000000000..7dd790f55 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ETSWildcardType.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { ETSTypeReference } from "./ETSTypeReference" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +export class ETSWildcardType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 67) + super(pointer) + + } + static createETSWildcardType(typeReference: ETSTypeReference | undefined, flags: Es2pandaModifierFlags): ETSWildcardType { + return new ETSWildcardType(global.generatedEs2panda._CreateETSWildcardType(global.context, passNode(typeReference), flags)) + } + static updateETSWildcardType(original: ETSWildcardType | undefined, typeReference: ETSTypeReference | undefined, flags: Es2pandaModifierFlags): ETSWildcardType { + return new ETSWildcardType(global.generatedEs2panda._UpdateETSWildcardType(global.context, passNode(original), passNode(typeReference), flags)) + } + get typeReference(): ETSTypeReference | undefined { + return unpackNode(global.generatedEs2panda._ETSWildcardTypeTypeReferenceConst(global.context, this.peer)) + } +} +export function isETSWildcardType(node: AstNode): node is ETSWildcardType { + return node instanceof ETSWildcardType +} +if (!nodeByType.has(67)) { + nodeByType.set(67, ETSWildcardType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/EmptyStatement.ts b/koala-wrapper/src/generated/peers/EmptyStatement.ts new file mode 100644 index 000000000..9e3e61706 --- /dev/null +++ b/koala-wrapper/src/generated/peers/EmptyStatement.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class EmptyStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 25) + super(pointer) + + } + static createEmptyStatement(): EmptyStatement { + return new EmptyStatement(global.generatedEs2panda._CreateEmptyStatement(global.context)) + } + static updateEmptyStatement(original?: EmptyStatement): EmptyStatement { + return new EmptyStatement(global.generatedEs2panda._UpdateEmptyStatement(global.context, passNode(original))) + } +} +export function isEmptyStatement(node: AstNode): node is EmptyStatement { + return node instanceof EmptyStatement +} +if (!nodeByType.has(25)) { + nodeByType.set(25, EmptyStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ExportAllDeclaration.ts b/koala-wrapper/src/generated/peers/ExportAllDeclaration.ts new file mode 100644 index 000000000..631cdc354 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ExportAllDeclaration.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { StringLiteral } from "./StringLiteral" +import { Identifier } from "./Identifier" +export class ExportAllDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 26) + super(pointer) + + } + static createExportAllDeclaration(source?: StringLiteral, exported?: Identifier): ExportAllDeclaration { + return new ExportAllDeclaration(global.generatedEs2panda._CreateExportAllDeclaration(global.context, passNode(source), passNode(exported))) + } + static updateExportAllDeclaration(original?: ExportAllDeclaration, source?: StringLiteral, exported?: Identifier): ExportAllDeclaration { + return new ExportAllDeclaration(global.generatedEs2panda._UpdateExportAllDeclaration(global.context, passNode(original), passNode(source), passNode(exported))) + } + get source(): StringLiteral | undefined { + return unpackNode(global.generatedEs2panda._ExportAllDeclarationSourceConst(global.context, this.peer)) + } + get exported(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ExportAllDeclarationExportedConst(global.context, this.peer)) + } +} +export function isExportAllDeclaration(node: AstNode): node is ExportAllDeclaration { + return node instanceof ExportAllDeclaration +} +if (!nodeByType.has(26)) { + nodeByType.set(26, ExportAllDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ExportDefaultDeclaration.ts b/koala-wrapper/src/generated/peers/ExportDefaultDeclaration.ts new file mode 100644 index 000000000..d4f07bb62 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ExportDefaultDeclaration.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class ExportDefaultDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 27) + super(pointer) + + } + static createExportDefaultDeclaration(decl: AstNode | undefined, exportEquals: boolean): ExportDefaultDeclaration { + return new ExportDefaultDeclaration(global.generatedEs2panda._CreateExportDefaultDeclaration(global.context, passNode(decl), exportEquals)) + } + static updateExportDefaultDeclaration(original: ExportDefaultDeclaration | undefined, decl: AstNode | undefined, exportEquals: boolean): ExportDefaultDeclaration { + return new ExportDefaultDeclaration(global.generatedEs2panda._UpdateExportDefaultDeclaration(global.context, passNode(original), passNode(decl), exportEquals)) + } + get decl(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ExportDefaultDeclarationDeclConst(global.context, this.peer)) + } + get isExportEquals(): boolean { + return global.generatedEs2panda._ExportDefaultDeclarationIsExportEqualsConst(global.context, this.peer) + } +} +export function isExportDefaultDeclaration(node: AstNode): node is ExportDefaultDeclaration { + return node instanceof ExportDefaultDeclaration +} +if (!nodeByType.has(27)) { + nodeByType.set(27, ExportDefaultDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ExportNamedDeclaration.ts b/koala-wrapper/src/generated/peers/ExportNamedDeclaration.ts new file mode 100644 index 000000000..d7f82f76a --- /dev/null +++ b/koala-wrapper/src/generated/peers/ExportNamedDeclaration.ts @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { StringLiteral } from "./StringLiteral" +import { ExportSpecifier } from "./ExportSpecifier" +export class ExportNamedDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 28) + super(pointer) + + } + static createExportNamedDeclaration(source: StringLiteral | undefined, specifiers: readonly ExportSpecifier[]): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._CreateExportNamedDeclaration(global.context, passNode(source), passNodeArray(specifiers), specifiers.length)) + } + static updateExportNamedDeclaration(original: ExportNamedDeclaration | undefined, source: StringLiteral | undefined, specifiers: readonly ExportSpecifier[]): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._UpdateExportNamedDeclaration(global.context, passNode(original), passNode(source), passNodeArray(specifiers), specifiers.length)) + } + static create1ExportNamedDeclaration(decl: AstNode | undefined, specifiers: readonly ExportSpecifier[]): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._CreateExportNamedDeclaration1(global.context, passNode(decl), passNodeArray(specifiers), specifiers.length)) + } + static update1ExportNamedDeclaration(original: ExportNamedDeclaration | undefined, decl: AstNode | undefined, specifiers: readonly ExportSpecifier[]): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._UpdateExportNamedDeclaration1(global.context, passNode(original), passNode(decl), passNodeArray(specifiers), specifiers.length)) + } + static create2ExportNamedDeclaration(decl?: AstNode): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._CreateExportNamedDeclaration2(global.context, passNode(decl))) + } + static update2ExportNamedDeclaration(original?: ExportNamedDeclaration, decl?: AstNode): ExportNamedDeclaration { + return new ExportNamedDeclaration(global.generatedEs2panda._UpdateExportNamedDeclaration2(global.context, passNode(original), passNode(decl))) + } + get decl(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ExportNamedDeclarationDeclConst(global.context, this.peer)) + } + get source(): StringLiteral | undefined { + return unpackNode(global.generatedEs2panda._ExportNamedDeclarationSourceConst(global.context, this.peer)) + } + get specifiers(): readonly ExportSpecifier[] { + return unpackNodeArray(global.generatedEs2panda._ExportNamedDeclarationSpecifiersConst(global.context, this.peer)) + } +} +export function isExportNamedDeclaration(node: AstNode): node is ExportNamedDeclaration { + return node instanceof ExportNamedDeclaration +} +if (!nodeByType.has(28)) { + nodeByType.set(28, ExportNamedDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ExportSpecifier.ts b/koala-wrapper/src/generated/peers/ExportSpecifier.ts new file mode 100644 index 000000000..de59281d9 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ExportSpecifier.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Identifier } from "./Identifier" +export class ExportSpecifier extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 29) + super(pointer) + + } + static createExportSpecifier(local?: Identifier, exported?: Identifier): ExportSpecifier { + return new ExportSpecifier(global.generatedEs2panda._CreateExportSpecifier(global.context, passNode(local), passNode(exported))) + } + static updateExportSpecifier(original?: ExportSpecifier, local?: Identifier, exported?: Identifier): ExportSpecifier { + return new ExportSpecifier(global.generatedEs2panda._UpdateExportSpecifier(global.context, passNode(original), passNode(local), passNode(exported))) + } + get local(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ExportSpecifierLocalConst(global.context, this.peer)) + } + get exported(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ExportSpecifierExportedConst(global.context, this.peer)) + } +} +export function isExportSpecifier(node: AstNode): node is ExportSpecifier { + return node instanceof ExportSpecifier +} +if (!nodeByType.has(29)) { + nodeByType.set(29, ExportSpecifier) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/Expression.ts b/koala-wrapper/src/generated/peers/Expression.ts new file mode 100644 index 000000000..9a08ad491 --- /dev/null +++ b/koala-wrapper/src/generated/peers/Expression.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypedAstNode } from "./TypedAstNode" +import { Literal } from "./Literal" +import { TypeNode } from "./TypeNode" +import { AnnotatedExpression } from "./AnnotatedExpression" +export class Expression extends TypedAstNode { + constructor(pointer: KNativePointer) { + super(pointer) + + } + get isGrouped(): boolean { + return global.generatedEs2panda._ExpressionIsGroupedConst(global.context, this.peer) + } + /** @deprecated */ + setGrouped(): this { + global.generatedEs2panda._ExpressionSetGrouped(global.context, this.peer) + return this + } + get isLiteral(): boolean { + return global.generatedEs2panda._ExpressionIsLiteralConst(global.context, this.peer) + } + get isTypeNode(): boolean { + return global.generatedEs2panda._ExpressionIsTypeNodeConst(global.context, this.peer) + } + get isAnnotatedExpression(): boolean { + return global.generatedEs2panda._ExpressionIsAnnotatedExpressionConst(global.context, this.peer) + } +} +export function isExpression(node: AstNode): node is Expression { + return node instanceof Expression +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ExpressionStatement.ts b/koala-wrapper/src/generated/peers/ExpressionStatement.ts new file mode 100644 index 000000000..6603e673e --- /dev/null +++ b/koala-wrapper/src/generated/peers/ExpressionStatement.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class ExpressionStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 30) + super(pointer) + + } + static createExpressionStatement(expr?: Expression): ExpressionStatement { + return new ExpressionStatement(global.generatedEs2panda._CreateExpressionStatement(global.context, passNode(expr))) + } + static updateExpressionStatement(original?: ExpressionStatement, expr?: Expression): ExpressionStatement { + return new ExpressionStatement(global.generatedEs2panda._UpdateExpressionStatement(global.context, passNode(original), passNode(expr))) + } + get getExpression(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ExpressionStatementGetExpressionConst(global.context, this.peer)) + } + /** @deprecated */ + setExpression(expr: Expression): this { + global.generatedEs2panda._ExpressionStatementSetExpression(global.context, this.peer, passNode(expr)) + return this + } +} +export function isExpressionStatement(node: AstNode): node is ExpressionStatement { + return node instanceof ExpressionStatement +} +if (!nodeByType.has(30)) { + nodeByType.set(30, ExpressionStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ForInStatement.ts b/koala-wrapper/src/generated/peers/ForInStatement.ts new file mode 100644 index 000000000..ff051e35b --- /dev/null +++ b/koala-wrapper/src/generated/peers/ForInStatement.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { LoopStatement } from "./LoopStatement" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class ForInStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 31) + super(pointer) + + } + static createForInStatement(left?: AstNode, right?: Expression, body?: Statement): ForInStatement { + return new ForInStatement(global.generatedEs2panda._CreateForInStatement(global.context, passNode(left), passNode(right), passNode(body))) + } + static updateForInStatement(original?: ForInStatement, left?: AstNode, right?: Expression, body?: Statement): ForInStatement { + return new ForInStatement(global.generatedEs2panda._UpdateForInStatement(global.context, passNode(original), passNode(left), passNode(right), passNode(body))) + } + get left(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ForInStatementLeftConst(global.context, this.peer)) + } + get right(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ForInStatementRightConst(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._ForInStatementBodyConst(global.context, this.peer)) + } +} +export function isForInStatement(node: AstNode): node is ForInStatement { + return node instanceof ForInStatement +} +if (!nodeByType.has(31)) { + nodeByType.set(31, ForInStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ForOfStatement.ts b/koala-wrapper/src/generated/peers/ForOfStatement.ts new file mode 100644 index 000000000..801178fd3 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ForOfStatement.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { LoopStatement } from "./LoopStatement" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class ForOfStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 32) + super(pointer) + + } + static createForOfStatement(left: AstNode | undefined, right: Expression | undefined, body: Statement | undefined, isAwait: boolean): ForOfStatement { + return new ForOfStatement(global.generatedEs2panda._CreateForOfStatement(global.context, passNode(left), passNode(right), passNode(body), isAwait)) + } + static updateForOfStatement(original: ForOfStatement | undefined, left: AstNode | undefined, right: Expression | undefined, body: Statement | undefined, isAwait: boolean): ForOfStatement { + return new ForOfStatement(global.generatedEs2panda._UpdateForOfStatement(global.context, passNode(original), passNode(left), passNode(right), passNode(body), isAwait)) + } + get left(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ForOfStatementLeftConst(global.context, this.peer)) + } + get right(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ForOfStatementRightConst(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._ForOfStatementBodyConst(global.context, this.peer)) + } + get isAwait(): boolean { + return global.generatedEs2panda._ForOfStatementIsAwaitConst(global.context, this.peer) + } +} +export function isForOfStatement(node: AstNode): node is ForOfStatement { + return node instanceof ForOfStatement +} +if (!nodeByType.has(32)) { + nodeByType.set(32, ForOfStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ForUpdateStatement.ts b/koala-wrapper/src/generated/peers/ForUpdateStatement.ts new file mode 100644 index 000000000..dbf5a9686 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ForUpdateStatement.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { LoopStatement } from "./LoopStatement" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class ForUpdateStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 33) + super(pointer) + + } + static createForUpdateStatement(init?: AstNode, test?: Expression, update?: Expression, body?: Statement): ForUpdateStatement { + return new ForUpdateStatement(global.generatedEs2panda._CreateForUpdateStatement(global.context, passNode(init), passNode(test), passNode(update), passNode(body))) + } + get init(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ForUpdateStatementInitConst(global.context, this.peer)) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ForUpdateStatementTestConst(global.context, this.peer)) + } + get update(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ForUpdateStatementUpdateConst(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._ForUpdateStatementBodyConst(global.context, this.peer)) + } +} +export function isForUpdateStatement(node: AstNode): node is ForUpdateStatement { + return node instanceof ForUpdateStatement +} +if (!nodeByType.has(33)) { + nodeByType.set(33, ForUpdateStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/FunctionDecl.ts b/koala-wrapper/src/generated/peers/FunctionDecl.ts new file mode 100644 index 000000000..f4ede5520 --- /dev/null +++ b/koala-wrapper/src/generated/peers/FunctionDecl.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ScriptFunction } from "./ScriptFunction" +export class FunctionDecl extends ScriptFunction { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isFunctionDecl(node: AstNode): node is FunctionDecl { + return node instanceof FunctionDecl +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/FunctionDeclaration.ts b/koala-wrapper/src/generated/peers/FunctionDeclaration.ts new file mode 100644 index 000000000..1265a281a --- /dev/null +++ b/koala-wrapper/src/generated/peers/FunctionDeclaration.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { ScriptFunction } from "./ScriptFunction" +import { AnnotationUsage } from "./AnnotationUsage" +export class FunctionDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 34) + super(pointer) + + } + static createFunctionDeclaration(func: ScriptFunction | undefined, annotations: readonly AnnotationUsage[], isAnonymous: boolean): FunctionDeclaration { + return new FunctionDeclaration(global.generatedEs2panda._CreateFunctionDeclaration(global.context, passNode(func), passNodeArray(annotations), annotations.length, isAnonymous)) + } + static updateFunctionDeclaration(original: FunctionDeclaration | undefined, func: ScriptFunction | undefined, annotations: readonly AnnotationUsage[], isAnonymous: boolean): FunctionDeclaration { + return new FunctionDeclaration(global.generatedEs2panda._UpdateFunctionDeclaration(global.context, passNode(original), passNode(func), passNodeArray(annotations), annotations.length, isAnonymous)) + } + static create1FunctionDeclaration(func: ScriptFunction | undefined, isAnonymous: boolean): FunctionDeclaration { + return new FunctionDeclaration(global.generatedEs2panda._CreateFunctionDeclaration1(global.context, passNode(func), isAnonymous)) + } + static update1FunctionDeclaration(original: FunctionDeclaration | undefined, func: ScriptFunction | undefined, isAnonymous: boolean): FunctionDeclaration { + return new FunctionDeclaration(global.generatedEs2panda._UpdateFunctionDeclaration1(global.context, passNode(original), passNode(func), isAnonymous)) + } + get isAnonymous(): boolean { + return global.generatedEs2panda._FunctionDeclarationIsAnonymousConst(global.context, this.peer) + } + get function(): ScriptFunction | undefined { + return unpackNode(global.generatedEs2panda._FunctionDeclarationFunctionConst(global.context, this.peer)) + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._FunctionDeclarationAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._FunctionDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isFunctionDeclaration(node: AstNode): node is FunctionDeclaration { + return node instanceof FunctionDeclaration +} +if (!nodeByType.has(34)) { + nodeByType.set(34, FunctionDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/FunctionExpression.ts b/koala-wrapper/src/generated/peers/FunctionExpression.ts new file mode 100644 index 000000000..d9e2b3886 --- /dev/null +++ b/koala-wrapper/src/generated/peers/FunctionExpression.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { ScriptFunction } from "./ScriptFunction" +import { Identifier } from "./Identifier" +export class FunctionExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 35) + super(pointer) + + } + static createFunctionExpression(func?: ScriptFunction): FunctionExpression { + return new FunctionExpression(global.generatedEs2panda._CreateFunctionExpression(global.context, passNode(func))) + } + static updateFunctionExpression(original?: FunctionExpression, func?: ScriptFunction): FunctionExpression { + return new FunctionExpression(global.generatedEs2panda._UpdateFunctionExpression(global.context, passNode(original), passNode(func))) + } + static create1FunctionExpression(namedExpr?: Identifier, func?: ScriptFunction): FunctionExpression { + return new FunctionExpression(global.generatedEs2panda._CreateFunctionExpression1(global.context, passNode(namedExpr), passNode(func))) + } + static update1FunctionExpression(original?: FunctionExpression, namedExpr?: Identifier, func?: ScriptFunction): FunctionExpression { + return new FunctionExpression(global.generatedEs2panda._UpdateFunctionExpression1(global.context, passNode(original), passNode(namedExpr), passNode(func))) + } + get function(): ScriptFunction | undefined { + return unpackNode(global.generatedEs2panda._FunctionExpressionFunctionConst(global.context, this.peer)) + } + get isAnonymous(): boolean { + return global.generatedEs2panda._FunctionExpressionIsAnonymousConst(global.context, this.peer) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._FunctionExpressionId(global.context, this.peer)) + } +} +export function isFunctionExpression(node: AstNode): node is FunctionExpression { + return node instanceof FunctionExpression +} +if (!nodeByType.has(35)) { + nodeByType.set(35, FunctionExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/FunctionSignature.ts b/koala-wrapper/src/generated/peers/FunctionSignature.ts new file mode 100644 index 000000000..127399ef3 --- /dev/null +++ b/koala-wrapper/src/generated/peers/FunctionSignature.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class FunctionSignature extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + + } + static createFunctionSignature(typeParams: TSTypeParameterDeclaration | undefined, params: readonly Expression[], returnTypeAnnotation: TypeNode | undefined, hasReceiver: boolean): FunctionSignature { + return new FunctionSignature(global.generatedEs2panda._CreateFunctionSignature(global.context, passNode(typeParams), passNodeArray(params), params.length, passNode(returnTypeAnnotation), hasReceiver)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._FunctionSignatureParamsConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._FunctionSignatureTypeParamsConst(global.context, this.peer)) + } + /** @deprecated */ + setReturnType(type: TypeNode): this { + global.generatedEs2panda._FunctionSignatureSetReturnType(global.context, this.peer, passNode(type)) + return this + } + get returnType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._FunctionSignatureReturnTypeConst(global.context, this.peer)) + } + get hasReceiver(): boolean { + return global.generatedEs2panda._FunctionSignatureHasReceiverConst(global.context, this.peer) + } +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/Identifier.ts b/koala-wrapper/src/generated/peers/Identifier.ts new file mode 100644 index 000000000..042688c12 --- /dev/null +++ b/koala-wrapper/src/generated/peers/Identifier.ts @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { TypeNode } from "./TypeNode" +import { Decorator } from "./Decorator" +import { ValidationInfo } from "./ValidationInfo" +export class Identifier extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 36) + super(pointer) + + } + static createIdentifier(): Identifier { + return new Identifier(global.generatedEs2panda._CreateIdentifier(global.context)) + } + static updateIdentifier(original?: Identifier): Identifier { + return new Identifier(global.generatedEs2panda._UpdateIdentifier(global.context, passNode(original))) + } + static create1Identifier(name: string): Identifier { + return new Identifier(global.generatedEs2panda._CreateIdentifier1(global.context, name)) + } + static update1Identifier(original: Identifier | undefined, name: string): Identifier { + return new Identifier(global.generatedEs2panda._UpdateIdentifier1(global.context, passNode(original), name)) + } + static create2Identifier(name: string, typeAnnotation?: TypeNode): Identifier { + return new Identifier(global.generatedEs2panda._CreateIdentifier2(global.context, name, passNode(typeAnnotation))) + } + static update2Identifier(original: Identifier | undefined, name: string, typeAnnotation?: TypeNode): Identifier { + return new Identifier(global.generatedEs2panda._UpdateIdentifier2(global.context, passNode(original), name, passNode(typeAnnotation))) + } + get name(): string { + return unpackString(global.generatedEs2panda._IdentifierNameConst(global.context, this.peer)) + } + /** @deprecated */ + setName(newName: string): this { + global.generatedEs2panda._IdentifierSetName(global.context, this.peer, newName) + return this + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._IdentifierDecoratorsConst(global.context, this.peer)) + } + get isErrorPlaceHolder(): boolean { + return global.generatedEs2panda._IdentifierIsErrorPlaceHolderConst(global.context, this.peer) + } + get isOptional(): boolean { + return global.generatedEs2panda._IdentifierIsOptionalConst(global.context, this.peer) + } + /** @deprecated */ + setOptional(optional_arg: boolean): this { + global.generatedEs2panda._IdentifierSetOptional(global.context, this.peer, optional_arg) + return this + } + get isReference(): boolean { + return global.generatedEs2panda._IdentifierIsReferenceConst(global.context, this.peer) + } + get isTdz(): boolean { + return global.generatedEs2panda._IdentifierIsTdzConst(global.context, this.peer) + } + /** @deprecated */ + setTdz(): this { + global.generatedEs2panda._IdentifierSetTdz(global.context, this.peer) + return this + } + /** @deprecated */ + setAccessor(): this { + global.generatedEs2panda._IdentifierSetAccessor(global.context, this.peer) + return this + } + get isAccessor(): boolean { + return global.generatedEs2panda._IdentifierIsAccessorConst(global.context, this.peer) + } + /** @deprecated */ + setMutator(): this { + global.generatedEs2panda._IdentifierSetMutator(global.context, this.peer) + return this + } + get isMutator(): boolean { + return global.generatedEs2panda._IdentifierIsMutatorConst(global.context, this.peer) + } + get isReceiver(): boolean { + return global.generatedEs2panda._IdentifierIsReceiverConst(global.context, this.peer) + } + get isPrivateIdent(): boolean { + return global.generatedEs2panda._IdentifierIsPrivateIdentConst(global.context, this.peer) + } + /** @deprecated */ + setPrivate(isPrivate: boolean): this { + global.generatedEs2panda._IdentifierSetPrivate(global.context, this.peer, isPrivate) + return this + } + get isIgnoreBox(): boolean { + return global.generatedEs2panda._IdentifierIsIgnoreBoxConst(global.context, this.peer) + } + /** @deprecated */ + setIgnoreBox(): this { + global.generatedEs2panda._IdentifierSetIgnoreBox(global.context, this.peer) + return this + } + get isAnnotationDecl(): boolean { + return global.generatedEs2panda._IdentifierIsAnnotationDeclConst(global.context, this.peer) + } + /** @deprecated */ + setAnnotationDecl(): this { + global.generatedEs2panda._IdentifierSetAnnotationDecl(global.context, this.peer) + return this + } + get isAnnotationUsage(): boolean { + return global.generatedEs2panda._IdentifierIsAnnotationUsageConst(global.context, this.peer) + } + /** @deprecated */ + setAnnotationUsage(): this { + global.generatedEs2panda._IdentifierSetAnnotationUsage(global.context, this.peer) + return this + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._IdentifierTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._IdentifierSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isIdentifier(node: AstNode): node is Identifier { + return node instanceof Identifier +} +if (!nodeByType.has(36)) { + nodeByType.set(36, Identifier) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/IfStatement.ts b/koala-wrapper/src/generated/peers/IfStatement.ts new file mode 100644 index 000000000..056f095f6 --- /dev/null +++ b/koala-wrapper/src/generated/peers/IfStatement.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class IfStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 38) + super(pointer) + + } + static createIfStatement(test?: Expression, consequent?: Statement, alternate?: Statement): IfStatement { + return new IfStatement(global.generatedEs2panda._CreateIfStatement(global.context, passNode(test), passNode(consequent), passNode(alternate))) + } + static updateIfStatement(original?: IfStatement, test?: Expression, consequent?: Statement, alternate?: Statement): IfStatement { + return new IfStatement(global.generatedEs2panda._UpdateIfStatement(global.context, passNode(original), passNode(test), passNode(consequent), passNode(alternate))) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._IfStatementTestConst(global.context, this.peer)) + } + get consequent(): Statement | undefined { + return unpackNode(global.generatedEs2panda._IfStatementConsequentConst(global.context, this.peer)) + } + get alternate(): Statement | undefined { + return unpackNode(global.generatedEs2panda._IfStatementAlternateConst(global.context, this.peer)) + } +} +export function isIfStatement(node: AstNode): node is IfStatement { + return node instanceof IfStatement +} +if (!nodeByType.has(38)) { + nodeByType.set(38, IfStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ImportDeclaration.ts b/koala-wrapper/src/generated/peers/ImportDeclaration.ts new file mode 100644 index 000000000..3ce4b85d1 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ImportDeclaration.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { StringLiteral } from "./StringLiteral" +import { Es2pandaImportKinds } from "./../Es2pandaEnums" +export class ImportDeclaration extends Statement { + constructor(pointer: KNativePointer) { + // assertValidPeer(pointer, 39) + super(pointer) + + } + static createImportDeclaration(source: StringLiteral | undefined, specifiers: readonly AstNode[], importKind: Es2pandaImportKinds): ImportDeclaration { + return new ImportDeclaration(global.generatedEs2panda._CreateImportDeclaration(global.context, passNode(source), passNodeArray(specifiers), specifiers.length, importKind)) + } + static updateImportDeclaration(original: ImportDeclaration | undefined, source: StringLiteral | undefined, specifiers: readonly AstNode[], importKind: Es2pandaImportKinds): ImportDeclaration { + return new ImportDeclaration(global.generatedEs2panda._UpdateImportDeclaration(global.context, passNode(original), passNode(source), passNodeArray(specifiers), specifiers.length, importKind)) + } + get source(): StringLiteral | undefined { + return unpackNode(global.generatedEs2panda._ImportDeclarationSourceConst(global.context, this.peer)) + } + get specifiers(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._ImportDeclarationSpecifiersConst(global.context, this.peer)) + } + get isTypeKind(): boolean { + return global.generatedEs2panda._ImportDeclarationIsTypeKindConst(global.context, this.peer) + } +} +export function isImportDeclaration(node: AstNode): node is ImportDeclaration { + return node instanceof ImportDeclaration +} +if (!nodeByType.has(39)) { + nodeByType.set(39, ImportDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ImportDefaultSpecifier.ts b/koala-wrapper/src/generated/peers/ImportDefaultSpecifier.ts new file mode 100644 index 000000000..5b4ce34e9 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ImportDefaultSpecifier.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Identifier } from "./Identifier" +export class ImportDefaultSpecifier extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 41) + super(pointer) + + } + static createImportDefaultSpecifier(local?: Identifier): ImportDefaultSpecifier { + return new ImportDefaultSpecifier(global.generatedEs2panda._CreateImportDefaultSpecifier(global.context, passNode(local))) + } + static updateImportDefaultSpecifier(original?: ImportDefaultSpecifier, local?: Identifier): ImportDefaultSpecifier { + return new ImportDefaultSpecifier(global.generatedEs2panda._UpdateImportDefaultSpecifier(global.context, passNode(original), passNode(local))) + } + get local(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ImportDefaultSpecifierLocalConst(global.context, this.peer)) + } +} +export function isImportDefaultSpecifier(node: AstNode): node is ImportDefaultSpecifier { + return node instanceof ImportDefaultSpecifier +} +if (!nodeByType.has(41)) { + nodeByType.set(41, ImportDefaultSpecifier) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ImportExpression.ts b/koala-wrapper/src/generated/peers/ImportExpression.ts new file mode 100644 index 000000000..fc70fd1cb --- /dev/null +++ b/koala-wrapper/src/generated/peers/ImportExpression.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class ImportExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 40) + super(pointer) + + } + static createImportExpression(source?: Expression): ImportExpression { + return new ImportExpression(global.generatedEs2panda._CreateImportExpression(global.context, passNode(source))) + } + static updateImportExpression(original?: ImportExpression, source?: Expression): ImportExpression { + return new ImportExpression(global.generatedEs2panda._UpdateImportExpression(global.context, passNode(original), passNode(source))) + } + get source(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ImportExpressionSourceConst(global.context, this.peer)) + } +} +export function isImportExpression(node: AstNode): node is ImportExpression { + return node instanceof ImportExpression +} +if (!nodeByType.has(40)) { + nodeByType.set(40, ImportExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ImportNamespaceSpecifier.ts b/koala-wrapper/src/generated/peers/ImportNamespaceSpecifier.ts new file mode 100644 index 000000000..4f1e128bf --- /dev/null +++ b/koala-wrapper/src/generated/peers/ImportNamespaceSpecifier.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Identifier } from "./Identifier" +export class ImportNamespaceSpecifier extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 42) + super(pointer) + + } + static createImportNamespaceSpecifier(local?: Identifier): ImportNamespaceSpecifier { + return new ImportNamespaceSpecifier(global.generatedEs2panda._CreateImportNamespaceSpecifier(global.context, passNode(local))) + } + static updateImportNamespaceSpecifier(original?: ImportNamespaceSpecifier, local?: Identifier): ImportNamespaceSpecifier { + return new ImportNamespaceSpecifier(global.generatedEs2panda._UpdateImportNamespaceSpecifier(global.context, passNode(original), passNode(local))) + } + get local(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ImportNamespaceSpecifierLocalConst(global.context, this.peer)) + } +} +export function isImportNamespaceSpecifier(node: AstNode): node is ImportNamespaceSpecifier { + return node instanceof ImportNamespaceSpecifier +} +if (!nodeByType.has(42)) { + nodeByType.set(42, ImportNamespaceSpecifier) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ImportSource.ts b/koala-wrapper/src/generated/peers/ImportSource.ts new file mode 100644 index 000000000..70c8fb289 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ImportSource.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { StringLiteral } from "./StringLiteral" +export class ImportSource extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + + } + static createImportSource(source: StringLiteral | undefined, resolvedSource: StringLiteral | undefined, hasDecl: boolean): ImportSource { + return new ImportSource(global.generatedEs2panda._CreateImportSource(global.context, passNode(source), passNode(resolvedSource), hasDecl)) + } + get source(): StringLiteral | undefined { + return unpackNode(global.generatedEs2panda._ImportSourceSourceConst(global.context, this.peer)) + } + get resolvedSource(): StringLiteral | undefined { + return unpackNode(global.generatedEs2panda._ImportSourceResolvedSourceConst(global.context, this.peer)) + } + get hasDecl(): boolean { + return global.generatedEs2panda._ImportSourceHasDeclConst(global.context, this.peer) + } +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ImportSpecifier.ts b/koala-wrapper/src/generated/peers/ImportSpecifier.ts new file mode 100644 index 000000000..e2d49f139 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ImportSpecifier.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Identifier } from "./Identifier" +export class ImportSpecifier extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 43) + super(pointer) + + } + static createImportSpecifier(imported?: Identifier, local?: Identifier): ImportSpecifier { + return new ImportSpecifier(global.generatedEs2panda._CreateImportSpecifier(global.context, passNode(imported), passNode(local))) + } + static updateImportSpecifier(original?: ImportSpecifier, imported?: Identifier, local?: Identifier): ImportSpecifier { + return new ImportSpecifier(global.generatedEs2panda._UpdateImportSpecifier(global.context, passNode(original), passNode(imported), passNode(local))) + } + get imported(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ImportSpecifierImportedConst(global.context, this.peer)) + } + get local(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ImportSpecifierLocalConst(global.context, this.peer)) + } +} +export function isImportSpecifier(node: AstNode): node is ImportSpecifier { + return node instanceof ImportSpecifier +} +if (!nodeByType.has(43)) { + nodeByType.set(43, ImportSpecifier) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/InterfaceDecl.ts b/koala-wrapper/src/generated/peers/InterfaceDecl.ts new file mode 100644 index 000000000..3e708c7f9 --- /dev/null +++ b/koala-wrapper/src/generated/peers/InterfaceDecl.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TSInterfaceDeclaration } from "./TSInterfaceDeclaration" +export class InterfaceDecl extends TSInterfaceDeclaration { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isInterfaceDecl(node: AstNode): node is InterfaceDecl { + return node instanceof InterfaceDecl +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/LabelledStatement.ts b/koala-wrapper/src/generated/peers/LabelledStatement.ts new file mode 100644 index 000000000..7dec2f9ee --- /dev/null +++ b/koala-wrapper/src/generated/peers/LabelledStatement.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Identifier } from "./Identifier" +export class LabelledStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 44) + super(pointer) + + } + static createLabelledStatement(ident?: Identifier, body?: Statement): LabelledStatement { + return new LabelledStatement(global.generatedEs2panda._CreateLabelledStatement(global.context, passNode(ident), passNode(body))) + } + static updateLabelledStatement(original?: LabelledStatement, ident?: Identifier, body?: Statement): LabelledStatement { + return new LabelledStatement(global.generatedEs2panda._UpdateLabelledStatement(global.context, passNode(original), passNode(ident), passNode(body))) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._LabelledStatementBodyConst(global.context, this.peer)) + } + get ident(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._LabelledStatementIdentConst(global.context, this.peer)) + } +} +export function isLabelledStatement(node: AstNode): node is LabelledStatement { + return node instanceof LabelledStatement +} +if (!nodeByType.has(44)) { + nodeByType.set(44, LabelledStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/Literal.ts b/koala-wrapper/src/generated/peers/Literal.ts new file mode 100644 index 000000000..76b9e6681 --- /dev/null +++ b/koala-wrapper/src/generated/peers/Literal.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class Literal extends Expression { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isLiteral(node: AstNode): node is Literal { + return node instanceof Literal +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/LoopStatement.ts b/koala-wrapper/src/generated/peers/LoopStatement.ts new file mode 100644 index 000000000..eaed67cf3 --- /dev/null +++ b/koala-wrapper/src/generated/peers/LoopStatement.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class LoopStatement extends Statement { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isLoopStatement(node: AstNode): node is LoopStatement { + return node instanceof LoopStatement +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/MaybeOptionalExpression.ts b/koala-wrapper/src/generated/peers/MaybeOptionalExpression.ts new file mode 100644 index 000000000..b02bcf152 --- /dev/null +++ b/koala-wrapper/src/generated/peers/MaybeOptionalExpression.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class MaybeOptionalExpression extends Expression { + constructor(pointer: KNativePointer) { + super(pointer) + + } + get isOptional(): boolean { + return global.generatedEs2panda._MaybeOptionalExpressionIsOptionalConst(global.context, this.peer) + } + /** @deprecated */ + clearOptional(): this { + global.generatedEs2panda._MaybeOptionalExpressionClearOptional(global.context, this.peer) + return this + } +} +export function isMaybeOptionalExpression(node: AstNode): node is MaybeOptionalExpression { + return node instanceof MaybeOptionalExpression +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/MemberExpression.ts b/koala-wrapper/src/generated/peers/MemberExpression.ts new file mode 100644 index 000000000..40f74fe00 --- /dev/null +++ b/koala-wrapper/src/generated/peers/MemberExpression.ts @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { MaybeOptionalExpression } from "./MaybeOptionalExpression" +import { Expression } from "./Expression" +import { Es2pandaMemberExpressionKind } from "./../Es2pandaEnums" +export class MemberExpression extends MaybeOptionalExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 45) + super(pointer) + + } + static createMemberExpression(object_arg: Expression | undefined, property: Expression | undefined, kind: Es2pandaMemberExpressionKind, computed: boolean, optional_arg: boolean): MemberExpression { + return new MemberExpression(global.generatedEs2panda._CreateMemberExpression(global.context, passNode(object_arg), passNode(property), kind, computed, optional_arg)) + } + static updateMemberExpression(original: MemberExpression | undefined, object_arg: Expression | undefined, property: Expression | undefined, kind: Es2pandaMemberExpressionKind, computed: boolean, optional_arg: boolean): MemberExpression { + return new MemberExpression(global.generatedEs2panda._UpdateMemberExpression(global.context, passNode(original), passNode(object_arg), passNode(property), kind, computed, optional_arg)) + } + get object(): Expression | undefined { + return unpackNode(global.generatedEs2panda._MemberExpressionObjectConst(global.context, this.peer)) + } + /** @deprecated */ + setObject(object_arg: Expression): this { + global.generatedEs2panda._MemberExpressionSetObject(global.context, this.peer, passNode(object_arg)) + return this + } + /** @deprecated */ + setProperty(prop: Expression): this { + global.generatedEs2panda._MemberExpressionSetProperty(global.context, this.peer, passNode(prop)) + return this + } + get property(): Expression | undefined { + return unpackNode(global.generatedEs2panda._MemberExpressionPropertyConst(global.context, this.peer)) + } + get isComputed(): boolean { + return global.generatedEs2panda._MemberExpressionIsComputedConst(global.context, this.peer) + } + get kind(): Es2pandaMemberExpressionKind { + return global.generatedEs2panda._MemberExpressionKindConst(global.context, this.peer) + } + /** @deprecated */ + addMemberKind(kind: Es2pandaMemberExpressionKind): this { + global.generatedEs2panda._MemberExpressionAddMemberKind(global.context, this.peer, kind) + return this + } + /** @deprecated */ + removeMemberKind(kind: Es2pandaMemberExpressionKind): this { + global.generatedEs2panda._MemberExpressionRemoveMemberKind(global.context, this.peer, kind) + return this + } + get isIgnoreBox(): boolean { + return global.generatedEs2panda._MemberExpressionIsIgnoreBoxConst(global.context, this.peer) + } + /** @deprecated */ + setIgnoreBox(): this { + global.generatedEs2panda._MemberExpressionSetIgnoreBox(global.context, this.peer) + return this + } +} +export function isMemberExpression(node: AstNode): node is MemberExpression { + return node instanceof MemberExpression +} +if (!nodeByType.has(45)) { + nodeByType.set(45, MemberExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/MetaProperty.ts b/koala-wrapper/src/generated/peers/MetaProperty.ts new file mode 100644 index 000000000..82c8bc8ae --- /dev/null +++ b/koala-wrapper/src/generated/peers/MetaProperty.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Es2pandaMetaPropertyKind } from "./../Es2pandaEnums" +export class MetaProperty extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 46) + super(pointer) + + } + static createMetaProperty(kind: Es2pandaMetaPropertyKind): MetaProperty { + return new MetaProperty(global.generatedEs2panda._CreateMetaProperty(global.context, kind)) + } + static updateMetaProperty(original: MetaProperty | undefined, kind: Es2pandaMetaPropertyKind): MetaProperty { + return new MetaProperty(global.generatedEs2panda._UpdateMetaProperty(global.context, passNode(original), kind)) + } + get kind(): Es2pandaMetaPropertyKind { + return global.generatedEs2panda._MetaPropertyKindConst(global.context, this.peer) + } +} +export function isMetaProperty(node: AstNode): node is MetaProperty { + return node instanceof MetaProperty +} +if (!nodeByType.has(46)) { + nodeByType.set(46, MetaProperty) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/MethodDefinition.ts b/koala-wrapper/src/generated/peers/MethodDefinition.ts new file mode 100644 index 000000000..40dd13888 --- /dev/null +++ b/koala-wrapper/src/generated/peers/MethodDefinition.ts @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { ClassElement } from "./ClassElement" +import { Es2pandaMethodDefinitionKind } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { ScriptFunction } from "./ScriptFunction" +export class MethodDefinition extends ClassElement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 47) + super(pointer) + + } + static createMethodDefinition(kind: Es2pandaMethodDefinitionKind, key: Expression | undefined, value: Expression | undefined, modifiers: Es2pandaModifierFlags, isComputed: boolean): MethodDefinition { + return new MethodDefinition(global.generatedEs2panda._CreateMethodDefinition(global.context, kind, passNode(key), passNode(value), modifiers, isComputed)) + } + static updateMethodDefinition(original: MethodDefinition | undefined, kind: Es2pandaMethodDefinitionKind, key: Expression | undefined, value: Expression | undefined, modifiers: Es2pandaModifierFlags, isComputed: boolean): MethodDefinition { + return new MethodDefinition(global.generatedEs2panda._UpdateMethodDefinition(global.context, passNode(original), kind, passNode(key), passNode(value), modifiers, isComputed)) + } + get kind(): Es2pandaMethodDefinitionKind { + return global.generatedEs2panda._MethodDefinitionKindConst(global.context, this.peer) + } + get isConstructor(): boolean { + return global.generatedEs2panda._MethodDefinitionIsConstructorConst(global.context, this.peer) + } + get isExtensionMethod(): boolean { + return global.generatedEs2panda._MethodDefinitionIsExtensionMethodConst(global.context, this.peer) + } + get overloads(): readonly MethodDefinition[] { + return unpackNodeArray(global.generatedEs2panda._MethodDefinitionOverloadsConst(global.context, this.peer)) + } + get baseOverloadMethod(): MethodDefinition | undefined { + return unpackNode(global.generatedEs2panda._MethodDefinitionBaseOverloadMethodConst(global.context, this.peer)) + } + get asyncPairMethod(): MethodDefinition | undefined { + return unpackNode(global.generatedEs2panda._MethodDefinitionAsyncPairMethodConst(global.context, this.peer)) + } + /** @deprecated */ + setOverloads(overloads: readonly MethodDefinition[]): this { + global.generatedEs2panda._MethodDefinitionSetOverloads(global.context, this.peer, passNodeArray(overloads), overloads.length) + return this + } + /** @deprecated */ + clearOverloads(): this { + global.generatedEs2panda._MethodDefinitionClearOverloads(global.context, this.peer) + return this + } + /** @deprecated */ + addOverload(overload: MethodDefinition): this { + global.generatedEs2panda._MethodDefinitionAddOverload(global.context, this.peer, passNode(overload)) + return this + } + /** @deprecated */ + setBaseOverloadMethod(baseOverloadMethod: MethodDefinition): this { + global.generatedEs2panda._MethodDefinitionSetBaseOverloadMethod(global.context, this.peer, passNode(baseOverloadMethod)) + return this + } + /** @deprecated */ + setAsyncPairMethod(method: MethodDefinition): this { + global.generatedEs2panda._MethodDefinitionSetAsyncPairMethod(global.context, this.peer, passNode(method)) + return this + } +} +export function isMethodDefinition(node: AstNode): node is MethodDefinition { + return node instanceof MethodDefinition +} +if (!nodeByType.has(47)) { + nodeByType.set(47, MethodDefinition) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/NamedType.ts b/koala-wrapper/src/generated/peers/NamedType.ts new file mode 100644 index 000000000..ce6ee368e --- /dev/null +++ b/koala-wrapper/src/generated/peers/NamedType.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Identifier } from "./Identifier" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +export class NamedType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 48) + super(pointer) + + } + static createNamedType(name?: Identifier): NamedType { + return new NamedType(global.generatedEs2panda._CreateNamedType(global.context, passNode(name))) + } + static updateNamedType(original?: NamedType, name?: Identifier): NamedType { + return new NamedType(global.generatedEs2panda._UpdateNamedType(global.context, passNode(original), passNode(name))) + } + get name(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._NamedTypeNameConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._NamedTypeTypeParamsConst(global.context, this.peer)) + } + get isNullable(): boolean { + return global.generatedEs2panda._NamedTypeIsNullableConst(global.context, this.peer) + } + /** @deprecated */ + setNullable(nullable: boolean): this { + global.generatedEs2panda._NamedTypeSetNullable(global.context, this.peer, nullable) + return this + } + /** @deprecated */ + setNext(next: NamedType): this { + global.generatedEs2panda._NamedTypeSetNext(global.context, this.peer, passNode(next)) + return this + } + /** @deprecated */ + setTypeParams(typeParams: TSTypeParameterInstantiation): this { + global.generatedEs2panda._NamedTypeSetTypeParams(global.context, this.peer, passNode(typeParams)) + return this + } +} +export function isNamedType(node: AstNode): node is NamedType { + return node instanceof NamedType +} +if (!nodeByType.has(48)) { + nodeByType.set(48, NamedType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/NewExpression.ts b/koala-wrapper/src/generated/peers/NewExpression.ts new file mode 100644 index 000000000..c267a581d --- /dev/null +++ b/koala-wrapper/src/generated/peers/NewExpression.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class NewExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 49) + super(pointer) + + } + static createNewExpression(callee: Expression | undefined, _arguments: readonly Expression[]): NewExpression { + return new NewExpression(global.generatedEs2panda._CreateNewExpression(global.context, passNode(callee), passNodeArray(_arguments), _arguments.length)) + } + static updateNewExpression(original: NewExpression | undefined, callee: Expression | undefined, _arguments: readonly Expression[]): NewExpression { + return new NewExpression(global.generatedEs2panda._UpdateNewExpression(global.context, passNode(original), passNode(callee), passNodeArray(_arguments), _arguments.length)) + } + get callee(): Expression | undefined { + return unpackNode(global.generatedEs2panda._NewExpressionCalleeConst(global.context, this.peer)) + } + get arguments(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._NewExpressionArgumentsConst(global.context, this.peer)) + } +} +export function isNewExpression(node: AstNode): node is NewExpression { + return node instanceof NewExpression +} +if (!nodeByType.has(49)) { + nodeByType.set(49, NewExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/NullLiteral.ts b/koala-wrapper/src/generated/peers/NullLiteral.ts new file mode 100644 index 000000000..a8047b711 --- /dev/null +++ b/koala-wrapper/src/generated/peers/NullLiteral.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Literal } from "./Literal" +export class NullLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 50) + super(pointer) + + } + static createNullLiteral(): NullLiteral { + return new NullLiteral(global.generatedEs2panda._CreateNullLiteral(global.context)) + } + static updateNullLiteral(original?: NullLiteral): NullLiteral { + return new NullLiteral(global.generatedEs2panda._UpdateNullLiteral(global.context, passNode(original))) + } +} +export function isNullLiteral(node: AstNode): node is NullLiteral { + return node instanceof NullLiteral +} +if (!nodeByType.has(50)) { + nodeByType.set(50, NullLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/NumberLiteral.ts b/koala-wrapper/src/generated/peers/NumberLiteral.ts new file mode 100644 index 000000000..e14e174d9 --- /dev/null +++ b/koala-wrapper/src/generated/peers/NumberLiteral.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Literal } from "./Literal" +export class NumberLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 52) + super(pointer) + + } + get str(): string { + return unpackString(global.generatedEs2panda._NumberLiteralStrConst(global.context, this.peer)) + } +} +export function isNumberLiteral(node: AstNode): node is NumberLiteral { + return node instanceof NumberLiteral +} +if (!nodeByType.has(52)) { + nodeByType.set(52, NumberLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ObjectExpression.ts b/koala-wrapper/src/generated/peers/ObjectExpression.ts new file mode 100644 index 000000000..3c008e515 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ObjectExpression.ts @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Expression } from "./Expression" +import { Decorator } from "./Decorator" +import { ValidationInfo } from "./ValidationInfo" +import { TypeNode } from "./TypeNode" +import { Es2pandaObjectTypeKind } from "../Es2pandaEnums" +import { Property } from "./Property" +export class ObjectExpression extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + super(pointer) + + } + get properties(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ObjectExpressionPropertiesConst(global.context, this.peer)) + } + get isDeclaration(): boolean { + return global.generatedEs2panda._ObjectExpressionIsDeclarationConst(global.context, this.peer) + } + get isOptional(): boolean { + return global.generatedEs2panda._ObjectExpressionIsOptionalConst(global.context, this.peer) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._ObjectExpressionDecoratorsConst(global.context, this.peer)) + } + /** @deprecated */ + setDeclaration(): this { + global.generatedEs2panda._ObjectExpressionSetDeclaration(global.context, this.peer) + return this + } + /** @deprecated */ + setOptional(optional_arg: boolean): this { + global.generatedEs2panda._ObjectExpressionSetOptional(global.context, this.peer, optional_arg) + return this + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ObjectExpressionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._ObjectExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } + static createObjectExpression(nodeType: Es2pandaAstNodeType, properties: Property[], trailingComma: boolean): ObjectExpression { + return new ObjectExpression(global.generatedEs2panda._CreateObjectExpression(global.context, nodeType, passNodeArray(properties), properties.length, trailingComma)) + } + static updateObjectExpression(original: ObjectExpression, nodeType: Es2pandaAstNodeType, properties: Property[], trailingComma: boolean): ObjectExpression { + return new ObjectExpression(global.generatedEs2panda._UpdateObjectExpression(global.context, passNode(original), nodeType, passNodeArray(properties), properties.length, trailingComma)) + } +} +export function isObjectExpression(node: AstNode): node is ObjectExpression { + return node instanceof ObjectExpression +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/OmittedExpression.ts b/koala-wrapper/src/generated/peers/OmittedExpression.ts new file mode 100644 index 000000000..339202ae3 --- /dev/null +++ b/koala-wrapper/src/generated/peers/OmittedExpression.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class OmittedExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 53) + super(pointer) + + } + static createOmittedExpression(): OmittedExpression { + return new OmittedExpression(global.generatedEs2panda._CreateOmittedExpression(global.context)) + } + static updateOmittedExpression(original?: OmittedExpression): OmittedExpression { + return new OmittedExpression(global.generatedEs2panda._UpdateOmittedExpression(global.context, passNode(original))) + } +} +export function isOmittedExpression(node: AstNode): node is OmittedExpression { + return node instanceof OmittedExpression +} +if (!nodeByType.has(53)) { + nodeByType.set(53, OmittedExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/OpaqueTypeNode.ts b/koala-wrapper/src/generated/peers/OpaqueTypeNode.ts new file mode 100644 index 000000000..ba2d646dc --- /dev/null +++ b/koala-wrapper/src/generated/peers/OpaqueTypeNode.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class OpaqueTypeNode extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 154) + super(pointer) + + } + static create1OpaqueTypeNode(): OpaqueTypeNode { + return new OpaqueTypeNode(global.generatedEs2panda._CreateOpaqueTypeNode1(global.context)) + } + static update1OpaqueTypeNode(original?: OpaqueTypeNode): OpaqueTypeNode { + return new OpaqueTypeNode(global.generatedEs2panda._UpdateOpaqueTypeNode1(global.context, passNode(original))) + } +} +export function isOpaqueTypeNode(node: AstNode): node is OpaqueTypeNode { + return node instanceof OpaqueTypeNode +} +if (!nodeByType.has(154)) { + nodeByType.set(154, OpaqueTypeNode) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/PrefixAssertionExpression.ts b/koala-wrapper/src/generated/peers/PrefixAssertionExpression.ts new file mode 100644 index 000000000..03a093531 --- /dev/null +++ b/koala-wrapper/src/generated/peers/PrefixAssertionExpression.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class PrefixAssertionExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 54) + super(pointer) + + } + static createPrefixAssertionExpression(expr?: Expression, type?: TypeNode): PrefixAssertionExpression { + return new PrefixAssertionExpression(global.generatedEs2panda._CreatePrefixAssertionExpression(global.context, passNode(expr), passNode(type))) + } + static updatePrefixAssertionExpression(original?: PrefixAssertionExpression, expr?: Expression, type?: TypeNode): PrefixAssertionExpression { + return new PrefixAssertionExpression(global.generatedEs2panda._UpdatePrefixAssertionExpression(global.context, passNode(original), passNode(expr), passNode(type))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._PrefixAssertionExpressionExprConst(global.context, this.peer)) + } + get type(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._PrefixAssertionExpressionTypeConst(global.context, this.peer)) + } +} +export function isPrefixAssertionExpression(node: AstNode): node is PrefixAssertionExpression { + return node instanceof PrefixAssertionExpression +} +if (!nodeByType.has(54)) { + nodeByType.set(54, PrefixAssertionExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/Property.ts b/koala-wrapper/src/generated/peers/Property.ts new file mode 100644 index 000000000..982cb0241 --- /dev/null +++ b/koala-wrapper/src/generated/peers/Property.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Es2pandaPropertyKind } from "./../Es2pandaEnums" +import { ValidationInfo } from "./ValidationInfo" +export class Property extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 55) + super(pointer) + + } + static createProperty(key?: Expression, value?: Expression): Property { + return new Property(global.generatedEs2panda._CreateProperty(global.context, passNode(key), passNode(value))) + } + static updateProperty(original?: Property, key?: Expression, value?: Expression): Property { + return new Property(global.generatedEs2panda._UpdateProperty(global.context, passNode(original), passNode(key), passNode(value))) + } + static create1Property(kind: Es2pandaPropertyKind, key: Expression | undefined, value: Expression | undefined, isMethod: boolean, isComputed: boolean): Property { + return new Property(global.generatedEs2panda._CreateProperty1(global.context, kind, passNode(key), passNode(value), isMethod, isComputed)) + } + static update1Property(original: Property | undefined, kind: Es2pandaPropertyKind, key: Expression | undefined, value: Expression | undefined, isMethod: boolean, isComputed: boolean): Property { + return new Property(global.generatedEs2panda._UpdateProperty1(global.context, passNode(original), kind, passNode(key), passNode(value), isMethod, isComputed)) + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._PropertyKeyConst(global.context, this.peer)) + } + get value(): Expression | undefined { + return unpackNode(global.generatedEs2panda._PropertyValueConst(global.context, this.peer)) + } + get kind(): Es2pandaPropertyKind { + return global.generatedEs2panda._PropertyKindConst(global.context, this.peer) + } + get isMethod(): boolean { + return global.generatedEs2panda._PropertyIsMethodConst(global.context, this.peer) + } + get isShorthand(): boolean { + return global.generatedEs2panda._PropertyIsShorthandConst(global.context, this.peer) + } + get isComputed(): boolean { + return global.generatedEs2panda._PropertyIsComputedConst(global.context, this.peer) + } + get isAccessor(): boolean { + return global.generatedEs2panda._PropertyIsAccessorConst(global.context, this.peer) + } +} +export function isProperty(node: AstNode): node is Property { + return node instanceof Property +} +if (!nodeByType.has(55)) { + nodeByType.set(55, Property) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/RegExpLiteral.ts b/koala-wrapper/src/generated/peers/RegExpLiteral.ts new file mode 100644 index 000000000..5ae04143b --- /dev/null +++ b/koala-wrapper/src/generated/peers/RegExpLiteral.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Literal } from "./Literal" +import { Es2pandaRegExpFlags } from "./../Es2pandaEnums" +export class RegExpLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 56) + super(pointer) + + } + static createRegExpLiteral(pattern: string, flags: Es2pandaRegExpFlags, flagsStr: string): RegExpLiteral { + return new RegExpLiteral(global.generatedEs2panda._CreateRegExpLiteral(global.context, pattern, flags, flagsStr)) + } + static updateRegExpLiteral(original: RegExpLiteral | undefined, pattern: string, flags: Es2pandaRegExpFlags, flagsStr: string): RegExpLiteral { + return new RegExpLiteral(global.generatedEs2panda._UpdateRegExpLiteral(global.context, passNode(original), pattern, flags, flagsStr)) + } + get pattern(): string { + return unpackString(global.generatedEs2panda._RegExpLiteralPatternConst(global.context, this.peer)) + } + get flags(): Es2pandaRegExpFlags { + return global.generatedEs2panda._RegExpLiteralFlagsConst(global.context, this.peer) + } +} +export function isRegExpLiteral(node: AstNode): node is RegExpLiteral { + return node instanceof RegExpLiteral +} +if (!nodeByType.has(56)) { + nodeByType.set(56, RegExpLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ReturnStatement.ts b/koala-wrapper/src/generated/peers/ReturnStatement.ts new file mode 100644 index 000000000..6489e99df --- /dev/null +++ b/koala-wrapper/src/generated/peers/ReturnStatement.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class ReturnStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 58) + super(pointer) + + } + static createReturnStatement(): ReturnStatement { + return new ReturnStatement(global.generatedEs2panda._CreateReturnStatement(global.context)) + } + static updateReturnStatement(original?: ReturnStatement): ReturnStatement { + return new ReturnStatement(global.generatedEs2panda._UpdateReturnStatement(global.context, passNode(original))) + } + static create1ReturnStatement(argument?: Expression): ReturnStatement { + return new ReturnStatement(global.generatedEs2panda._CreateReturnStatement1(global.context, passNode(argument))) + } + static update1ReturnStatement(original?: ReturnStatement, argument?: Expression): ReturnStatement { + return new ReturnStatement(global.generatedEs2panda._UpdateReturnStatement1(global.context, passNode(original), passNode(argument))) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ReturnStatementArgumentConst(global.context, this.peer)) + } + /** @deprecated */ + setArgument(arg: Expression): this { + global.generatedEs2panda._ReturnStatementSetArgument(global.context, this.peer, passNode(arg)) + return this + } +} +export function isReturnStatement(node: AstNode): node is ReturnStatement { + return node instanceof ReturnStatement +} +if (!nodeByType.has(58)) { + nodeByType.set(58, ReturnStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ScriptFunction.ts b/koala-wrapper/src/generated/peers/ScriptFunction.ts new file mode 100644 index 000000000..28b262008 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ScriptFunction.ts @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { FunctionSignature } from "./FunctionSignature" +import { Identifier } from "./Identifier" +import { Expression } from "./Expression" +import { ReturnStatement } from "./ReturnStatement" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +import { Es2pandaScriptFunctionFlags } from "./../Es2pandaEnums" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { AnnotationUsage } from "./AnnotationUsage" +export class ScriptFunction extends AstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 59) + super(pointer) + + } + static createScriptFunction(databody: AstNode | undefined, datasignature: FunctionSignature | undefined, datafuncFlags: number, dataflags: number): ScriptFunction { + return new ScriptFunction(global.generatedEs2panda._CreateScriptFunction(global.context, passNode(databody), passNode(datasignature), datafuncFlags, dataflags)) + } + static updateScriptFunction(original: ScriptFunction | undefined, databody: AstNode | undefined, datasignature: FunctionSignature | undefined, datafuncFlags: number, dataflags: number): ScriptFunction { + return new ScriptFunction(global.generatedEs2panda._UpdateScriptFunction(global.context, passNode(original), passNode(databody), passNode(datasignature), datafuncFlags, dataflags)) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._ScriptFunctionIdConst(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._ScriptFunctionParamsConst(global.context, this.peer)) + } + get returnStatements(): readonly ReturnStatement[] { + return unpackNodeArray(global.generatedEs2panda._ScriptFunctionReturnStatementsConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._ScriptFunctionTypeParamsConst(global.context, this.peer)) + } + get body(): AstNode | undefined { + return unpackNode(global.generatedEs2panda._ScriptFunctionBodyConst(global.context, this.peer)) + } + /** @deprecated */ + addReturnStatement(returnStatement: ReturnStatement): this { + global.generatedEs2panda._ScriptFunctionAddReturnStatement(global.context, this.peer, passNode(returnStatement)) + return this + } + /** @deprecated */ + setBody(body: AstNode): this { + global.generatedEs2panda._ScriptFunctionSetBody(global.context, this.peer, passNode(body)) + return this + } + get returnTypeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._ScriptFunctionReturnTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setReturnTypeAnnotation(node: TypeNode): this { + global.generatedEs2panda._ScriptFunctionSetReturnTypeAnnotation(global.context, this.peer, passNode(node)) + return this + } + get isEntryPoint(): boolean { + return global.generatedEs2panda._ScriptFunctionIsEntryPointConst(global.context, this.peer) + } + get isGenerator(): boolean { + return global.generatedEs2panda._ScriptFunctionIsGeneratorConst(global.context, this.peer) + } + get isAsyncFunc(): boolean { + return global.generatedEs2panda._ScriptFunctionIsAsyncFuncConst(global.context, this.peer) + } + get isAsyncImplFunc(): boolean { + return global.generatedEs2panda._ScriptFunctionIsAsyncImplFuncConst(global.context, this.peer) + } + get isArrow(): boolean { + return global.generatedEs2panda._ScriptFunctionIsArrowConst(global.context, this.peer) + } + get isOverload(): boolean { + return global.generatedEs2panda._ScriptFunctionIsOverloadConst(global.context, this.peer) + } + get isExternalOverload(): boolean { + return global.generatedEs2panda._ScriptFunctionIsExternalOverloadConst(global.context, this.peer) + } + get isConstructor(): boolean { + return global.generatedEs2panda._ScriptFunctionIsConstructorConst(global.context, this.peer) + } + get isGetter(): boolean { + return global.generatedEs2panda._ScriptFunctionIsGetterConst(global.context, this.peer) + } + get isSetter(): boolean { + return global.generatedEs2panda._ScriptFunctionIsSetterConst(global.context, this.peer) + } + get isExtensionAccessor(): boolean { + return global.generatedEs2panda._ScriptFunctionIsExtensionAccessorConst(global.context, this.peer) + } + get isMethod(): boolean { + return global.generatedEs2panda._ScriptFunctionIsMethodConst(global.context, this.peer) + } + get isProxy(): boolean { + return global.generatedEs2panda._ScriptFunctionIsProxyConst(global.context, this.peer) + } + get isStaticBlock(): boolean { + return global.generatedEs2panda._ScriptFunctionIsStaticBlockConst(global.context, this.peer) + } + get isEnum(): boolean { + return global.generatedEs2panda._ScriptFunctionIsEnumConst(global.context, this.peer) + } + get isHidden(): boolean { + return global.generatedEs2panda._ScriptFunctionIsHiddenConst(global.context, this.peer) + } + get isExternal(): boolean { + return global.generatedEs2panda._ScriptFunctionIsExternalConst(global.context, this.peer) + } + get isImplicitSuperCallNeeded(): boolean { + return global.generatedEs2panda._ScriptFunctionIsImplicitSuperCallNeededConst(global.context, this.peer) + } + get hasBody(): boolean { + return global.generatedEs2panda._ScriptFunctionHasBodyConst(global.context, this.peer) + } + get hasRestParameter(): boolean { + return global.generatedEs2panda._ScriptFunctionHasRestParameterConst(global.context, this.peer) + } + get hasReturnStatement(): boolean { + return global.generatedEs2panda._ScriptFunctionHasReturnStatementConst(global.context, this.peer) + } + get hasThrowStatement(): boolean { + return global.generatedEs2panda._ScriptFunctionHasThrowStatementConst(global.context, this.peer) + } + get isThrowing(): boolean { + return global.generatedEs2panda._ScriptFunctionIsThrowingConst(global.context, this.peer) + } + get isRethrowing(): boolean { + return global.generatedEs2panda._ScriptFunctionIsRethrowingConst(global.context, this.peer) + } + get isDynamic(): boolean { + return global.generatedEs2panda._ScriptFunctionIsDynamicConst(global.context, this.peer) + } + get isExtensionMethod(): boolean { + return global.generatedEs2panda._ScriptFunctionIsExtensionMethodConst(global.context, this.peer) + } + get flags(): Es2pandaScriptFunctionFlags { + return global.generatedEs2panda._ScriptFunctionFlagsConst(global.context, this.peer) + } + get hasReceiver(): boolean { + return global.generatedEs2panda._ScriptFunctionHasReceiverConst(global.context, this.peer) + } + /** @deprecated */ + setIdent(id: Identifier): this { + global.generatedEs2panda._ScriptFunctionSetIdent(global.context, this.peer, passNode(id)) + return this + } + /** @deprecated */ + addFlag(flags: Es2pandaScriptFunctionFlags): this { + global.generatedEs2panda._ScriptFunctionAddFlag(global.context, this.peer, flags) + return this + } + /** @deprecated */ + addModifier(flags: Es2pandaModifierFlags): this { + global.generatedEs2panda._ScriptFunctionAddModifier(global.context, this.peer, flags) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._ScriptFunctionAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._ScriptFunctionSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isScriptFunction(node: AstNode): node is ScriptFunction { + return node instanceof ScriptFunction +} +if (!nodeByType.has(59)) { + nodeByType.set(59, ScriptFunction) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/SequenceExpression.ts b/koala-wrapper/src/generated/peers/SequenceExpression.ts new file mode 100644 index 000000000..fb0f1a9c0 --- /dev/null +++ b/koala-wrapper/src/generated/peers/SequenceExpression.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class SequenceExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 60) + super(pointer) + + } + static createSequenceExpression(sequence_arg: readonly Expression[]): SequenceExpression { + return new SequenceExpression(global.generatedEs2panda._CreateSequenceExpression(global.context, passNodeArray(sequence_arg), sequence_arg.length)) + } + static updateSequenceExpression(original: SequenceExpression | undefined, sequence_arg: readonly Expression[]): SequenceExpression { + return new SequenceExpression(global.generatedEs2panda._UpdateSequenceExpression(global.context, passNode(original), passNodeArray(sequence_arg), sequence_arg.length)) + } + get sequence(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._SequenceExpressionSequenceConst(global.context, this.peer)) + } +} +export function isSequenceExpression(node: AstNode): node is SequenceExpression { + return node instanceof SequenceExpression +} +if (!nodeByType.has(60)) { + nodeByType.set(60, SequenceExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/SpreadElement.ts b/koala-wrapper/src/generated/peers/SpreadElement.ts new file mode 100644 index 000000000..4b721b993 --- /dev/null +++ b/koala-wrapper/src/generated/peers/SpreadElement.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Expression } from "./Expression" +import { Decorator } from "./Decorator" +import { ValidationInfo } from "./ValidationInfo" +import { TypeNode } from "./TypeNode" +export class SpreadElement extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + super(pointer) + + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._SpreadElementArgumentConst(global.context, this.peer)) + } + get isOptional(): boolean { + return global.generatedEs2panda._SpreadElementIsOptionalConst(global.context, this.peer) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._SpreadElementDecoratorsConst(global.context, this.peer)) + } + /** @deprecated */ + setOptional(optional_arg: boolean): this { + global.generatedEs2panda._SpreadElementSetOptional(global.context, this.peer, optional_arg) + return this + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._SpreadElementTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._SpreadElementSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isSpreadElement(node: AstNode): node is SpreadElement { + return node instanceof SpreadElement +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/SrcDumper.ts b/koala-wrapper/src/generated/peers/SrcDumper.ts new file mode 100644 index 000000000..cb17a8868 --- /dev/null +++ b/koala-wrapper/src/generated/peers/SrcDumper.ts @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class SrcDumper extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + + } + static createSrcDumper(node?: AstNode): SrcDumper { + return new SrcDumper(global.generatedEs2panda._CreateSrcDumper(global.context, passNode(node))) + } + /** @deprecated */ + add(str: string): this { + global.generatedEs2panda._SrcDumperAdd(global.context, this.peer, str) + return this + } + /** @deprecated */ + add1(i: number): this { + global.generatedEs2panda._SrcDumperAdd1(global.context, this.peer, i) + return this + } + /** @deprecated */ + add2(l: number): this { + global.generatedEs2panda._SrcDumperAdd2(global.context, this.peer, l) + return this + } + /** @deprecated */ + add3(f: number): this { + global.generatedEs2panda._SrcDumperAdd3(global.context, this.peer, f) + return this + } + /** @deprecated */ + add4(d: number): this { + global.generatedEs2panda._SrcDumperAdd4(global.context, this.peer, d) + return this + } + get str(): string { + return unpackString(global.generatedEs2panda._SrcDumperStrConst(global.context, this.peer)) + } + /** @deprecated */ + incrIndent(): this { + global.generatedEs2panda._SrcDumperIncrIndent(global.context, this.peer) + return this + } + /** @deprecated */ + decrIndent(): this { + global.generatedEs2panda._SrcDumperDecrIndent(global.context, this.peer) + return this + } + /** @deprecated */ + endl(num: number): this { + global.generatedEs2panda._SrcDumperEndl(global.context, this.peer, num) + return this + } +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/Statement.ts b/koala-wrapper/src/generated/peers/Statement.ts new file mode 100644 index 000000000..ace0ee9dc --- /dev/null +++ b/koala-wrapper/src/generated/peers/Statement.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class Statement extends AstNode { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isStatement(node: AstNode): node is Statement { + return node instanceof Statement +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/StringLiteral.ts b/koala-wrapper/src/generated/peers/StringLiteral.ts new file mode 100644 index 000000000..6eed3c9e4 --- /dev/null +++ b/koala-wrapper/src/generated/peers/StringLiteral.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + unpackString +} from "../../reexport-for-generated" + +import { Literal } from "./Literal" +export class StringLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 61) + super(pointer) + + } + static createStringLiteral(): StringLiteral { + return new StringLiteral(global.generatedEs2panda._CreateStringLiteral(global.context)) + } + static updateStringLiteral(original?: StringLiteral): StringLiteral { + return new StringLiteral(global.generatedEs2panda._UpdateStringLiteral(global.context, passNode(original))) + } + static create1StringLiteral(str: string): StringLiteral { + return new StringLiteral(global.generatedEs2panda._CreateStringLiteral1(global.context, str)) + } + static update1StringLiteral(original: StringLiteral | undefined, str: string): StringLiteral { + return new StringLiteral(global.generatedEs2panda._UpdateStringLiteral1(global.context, passNode(original), str)) + } + get str(): string { + return unpackString(global.generatedEs2panda._StringLiteralStrConst(global.context, this.peer)) + } +} +export function isStringLiteral(node: AstNode): node is StringLiteral { + return node instanceof StringLiteral +} +if (!nodeByType.has(61)) { + nodeByType.set(61, StringLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/SuperExpression.ts b/koala-wrapper/src/generated/peers/SuperExpression.ts new file mode 100644 index 000000000..57b35074d --- /dev/null +++ b/koala-wrapper/src/generated/peers/SuperExpression.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class SuperExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 83) + super(pointer) + + } + static createSuperExpression(): SuperExpression { + return new SuperExpression(global.generatedEs2panda._CreateSuperExpression(global.context)) + } + static updateSuperExpression(original?: SuperExpression): SuperExpression { + return new SuperExpression(global.generatedEs2panda._UpdateSuperExpression(global.context, passNode(original))) + } +} +export function isSuperExpression(node: AstNode): node is SuperExpression { + return node instanceof SuperExpression +} +if (!nodeByType.has(83)) { + nodeByType.set(83, SuperExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/SwitchCaseStatement.ts b/koala-wrapper/src/generated/peers/SwitchCaseStatement.ts new file mode 100644 index 000000000..93ff25f08 --- /dev/null +++ b/koala-wrapper/src/generated/peers/SwitchCaseStatement.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class SwitchCaseStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 85) + super(pointer) + + } + static createSwitchCaseStatement(test: Expression | undefined, consequent: readonly Statement[]): SwitchCaseStatement { + return new SwitchCaseStatement(global.generatedEs2panda._CreateSwitchCaseStatement(global.context, passNode(test), passNodeArray(consequent), consequent.length)) + } + static updateSwitchCaseStatement(original: SwitchCaseStatement | undefined, test: Expression | undefined, consequent: readonly Statement[]): SwitchCaseStatement { + return new SwitchCaseStatement(global.generatedEs2panda._UpdateSwitchCaseStatement(global.context, passNode(original), passNode(test), passNodeArray(consequent), consequent.length)) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._SwitchCaseStatementTestConst(global.context, this.peer)) + } + get consequent(): readonly Statement[] { + return unpackNodeArray(global.generatedEs2panda._SwitchCaseStatementConsequentConst(global.context, this.peer)) + } +} +export function isSwitchCaseStatement(node: AstNode): node is SwitchCaseStatement { + return node instanceof SwitchCaseStatement +} +if (!nodeByType.has(85)) { + nodeByType.set(85, SwitchCaseStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/SwitchStatement.ts b/koala-wrapper/src/generated/peers/SwitchStatement.ts new file mode 100644 index 000000000..d11afaf4a --- /dev/null +++ b/koala-wrapper/src/generated/peers/SwitchStatement.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +import { SwitchCaseStatement } from "./SwitchCaseStatement" +export class SwitchStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 86) + super(pointer) + + } + static createSwitchStatement(discriminant: Expression | undefined, cases: readonly SwitchCaseStatement[]): SwitchStatement { + return new SwitchStatement(global.generatedEs2panda._CreateSwitchStatement(global.context, passNode(discriminant), passNodeArray(cases), cases.length)) + } + static updateSwitchStatement(original: SwitchStatement | undefined, discriminant: Expression | undefined, cases: readonly SwitchCaseStatement[]): SwitchStatement { + return new SwitchStatement(global.generatedEs2panda._UpdateSwitchStatement(global.context, passNode(original), passNode(discriminant), passNodeArray(cases), cases.length)) + } + get discriminant(): Expression | undefined { + return unpackNode(global.generatedEs2panda._SwitchStatementDiscriminantConst(global.context, this.peer)) + } + get cases(): readonly SwitchCaseStatement[] { + return unpackNodeArray(global.generatedEs2panda._SwitchStatementCasesConst(global.context, this.peer)) + } +} +export function isSwitchStatement(node: AstNode): node is SwitchStatement { + return node instanceof SwitchStatement +} +if (!nodeByType.has(86)) { + nodeByType.set(86, SwitchStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSAnyKeyword.ts b/koala-wrapper/src/generated/peers/TSAnyKeyword.ts new file mode 100644 index 000000000..ffb19bebf --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSAnyKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSAnyKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 91) + super(pointer) + + } + static createTSAnyKeyword(): TSAnyKeyword { + return new TSAnyKeyword(global.generatedEs2panda._CreateTSAnyKeyword(global.context)) + } + static updateTSAnyKeyword(original?: TSAnyKeyword): TSAnyKeyword { + return new TSAnyKeyword(global.generatedEs2panda._UpdateTSAnyKeyword(global.context, passNode(original))) + } +} +export function isTSAnyKeyword(node: AstNode): node is TSAnyKeyword { + return node instanceof TSAnyKeyword +} +if (!nodeByType.has(91)) { + nodeByType.set(91, TSAnyKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSArrayType.ts b/koala-wrapper/src/generated/peers/TSArrayType.ts new file mode 100644 index 000000000..a727d24fc --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSArrayType.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSArrayType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 102) + super(pointer) + + } + static createTSArrayType(elementType?: TypeNode): TSArrayType { + return new TSArrayType(global.generatedEs2panda._CreateTSArrayType(global.context, passNode(elementType))) + } + static updateTSArrayType(original?: TSArrayType, elementType?: TypeNode): TSArrayType { + return new TSArrayType(global.generatedEs2panda._UpdateTSArrayType(global.context, passNode(original), passNode(elementType))) + } + get elementType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSArrayTypeElementTypeConst(global.context, this.peer)) + } +} +export function isTSArrayType(node: AstNode): node is TSArrayType { + return node instanceof TSArrayType +} +if (!nodeByType.has(102)) { + nodeByType.set(102, TSArrayType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSAsExpression.ts b/koala-wrapper/src/generated/peers/TSAsExpression.ts new file mode 100644 index 000000000..718b9427b --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSAsExpression.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSAsExpression extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 138) + super(pointer) + + } + static createTSAsExpression(expression: Expression | undefined, typeAnnotation: TypeNode | undefined, isConst: boolean): TSAsExpression { + return new TSAsExpression(global.generatedEs2panda._CreateTSAsExpression(global.context, passNode(expression), passNode(typeAnnotation), isConst)) + } + static updateTSAsExpression(original: TSAsExpression | undefined, expression: Expression | undefined, typeAnnotation: TypeNode | undefined, isConst: boolean): TSAsExpression { + return new TSAsExpression(global.generatedEs2panda._UpdateTSAsExpression(global.context, passNode(original), passNode(expression), passNode(typeAnnotation), isConst)) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSAsExpressionExprConst(global.context, this.peer)) + } + /** @deprecated */ + setExpr(expr: Expression): this { + global.generatedEs2panda._TSAsExpressionSetExpr(global.context, this.peer, passNode(expr)) + return this + } + get isConst(): boolean { + return global.generatedEs2panda._TSAsExpressionIsConstConst(global.context, this.peer) + } + /** @deprecated */ + setUncheckedCast(isUncheckedCast: boolean): this { + global.generatedEs2panda._TSAsExpressionSetUncheckedCast(global.context, this.peer, isUncheckedCast) + return this + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSAsExpressionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._TSAsExpressionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isTSAsExpression(node: AstNode): node is TSAsExpression { + return node instanceof TSAsExpression +} +if (!nodeByType.has(138)) { + nodeByType.set(138, TSAsExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSBigintKeyword.ts b/koala-wrapper/src/generated/peers/TSBigintKeyword.ts new file mode 100644 index 000000000..371719a14 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSBigintKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSBigintKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 98) + super(pointer) + + } + static createTSBigintKeyword(): TSBigintKeyword { + return new TSBigintKeyword(global.generatedEs2panda._CreateTSBigintKeyword(global.context)) + } + static updateTSBigintKeyword(original?: TSBigintKeyword): TSBigintKeyword { + return new TSBigintKeyword(global.generatedEs2panda._UpdateTSBigintKeyword(global.context, passNode(original))) + } +} +export function isTSBigintKeyword(node: AstNode): node is TSBigintKeyword { + return node instanceof TSBigintKeyword +} +if (!nodeByType.has(98)) { + nodeByType.set(98, TSBigintKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSBooleanKeyword.ts b/koala-wrapper/src/generated/peers/TSBooleanKeyword.ts new file mode 100644 index 000000000..cc4c077b3 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSBooleanKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSBooleanKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 93) + super(pointer) + + } + static createTSBooleanKeyword(): TSBooleanKeyword { + return new TSBooleanKeyword(global.generatedEs2panda._CreateTSBooleanKeyword(global.context)) + } + static updateTSBooleanKeyword(original?: TSBooleanKeyword): TSBooleanKeyword { + return new TSBooleanKeyword(global.generatedEs2panda._UpdateTSBooleanKeyword(global.context, passNode(original))) + } +} +export function isTSBooleanKeyword(node: AstNode): node is TSBooleanKeyword { + return node instanceof TSBooleanKeyword +} +if (!nodeByType.has(93)) { + nodeByType.set(93, TSBooleanKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSClassImplements.ts b/koala-wrapper/src/generated/peers/TSClassImplements.ts new file mode 100644 index 000000000..b06a578a1 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSClassImplements.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +export class TSClassImplements extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 139) + super(pointer) + + } + static createTSClassImplements(expression?: Expression, typeParameters?: TSTypeParameterInstantiation): TSClassImplements { + return new TSClassImplements(global.generatedEs2panda._CreateTSClassImplements(global.context, passNode(expression), passNode(typeParameters))) + } + static updateTSClassImplements(original?: TSClassImplements, expression?: Expression, typeParameters?: TSTypeParameterInstantiation): TSClassImplements { + return new TSClassImplements(global.generatedEs2panda._UpdateTSClassImplements(global.context, passNode(original), passNode(expression), passNode(typeParameters))) + } + static create1TSClassImplements(expression?: Expression): TSClassImplements { + return new TSClassImplements(global.generatedEs2panda._CreateTSClassImplements1(global.context, passNode(expression))) + } + static update1TSClassImplements(original?: TSClassImplements, expression?: Expression): TSClassImplements { + return new TSClassImplements(global.generatedEs2panda._UpdateTSClassImplements1(global.context, passNode(original), passNode(expression))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSClassImplementsExprConst(global.context, this.peer)) + } + get typeParameters(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._TSClassImplementsTypeParametersConst(global.context, this.peer)) + } +} +export function isTSClassImplements(node: AstNode): node is TSClassImplements { + return node instanceof TSClassImplements +} +if (!nodeByType.has(139)) { + nodeByType.set(139, TSClassImplements) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSConditionalType.ts b/koala-wrapper/src/generated/peers/TSConditionalType.ts new file mode 100644 index 000000000..f03de8600 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSConditionalType.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +export class TSConditionalType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 111) + super(pointer) + + } + static createTSConditionalType(checkType?: Expression, extendsType?: Expression, trueType?: Expression, falseType?: Expression): TSConditionalType { + return new TSConditionalType(global.generatedEs2panda._CreateTSConditionalType(global.context, passNode(checkType), passNode(extendsType), passNode(trueType), passNode(falseType))) + } + static updateTSConditionalType(original?: TSConditionalType, checkType?: Expression, extendsType?: Expression, trueType?: Expression, falseType?: Expression): TSConditionalType { + return new TSConditionalType(global.generatedEs2panda._UpdateTSConditionalType(global.context, passNode(original), passNode(checkType), passNode(extendsType), passNode(trueType), passNode(falseType))) + } + get checkType(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSConditionalTypeCheckTypeConst(global.context, this.peer)) + } + get extendsType(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSConditionalTypeExtendsTypeConst(global.context, this.peer)) + } + get trueType(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSConditionalTypeTrueTypeConst(global.context, this.peer)) + } + get falseType(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSConditionalTypeFalseTypeConst(global.context, this.peer)) + } +} +export function isTSConditionalType(node: AstNode): node is TSConditionalType { + return node instanceof TSConditionalType +} +if (!nodeByType.has(111)) { + nodeByType.set(111, TSConditionalType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSConstructorType.ts b/koala-wrapper/src/generated/peers/TSConstructorType.ts new file mode 100644 index 000000000..896ccf390 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSConstructorType.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { FunctionSignature } from "./FunctionSignature" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { Expression } from "./Expression" +export class TSConstructorType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 126) + super(pointer) + + } + static createTSConstructorType(signature: FunctionSignature | undefined, abstract: boolean): TSConstructorType { + return new TSConstructorType(global.generatedEs2panda._CreateTSConstructorType(global.context, passNode(signature), abstract)) + } + static updateTSConstructorType(original: TSConstructorType | undefined, signature: FunctionSignature | undefined, abstract: boolean): TSConstructorType { + return new TSConstructorType(global.generatedEs2panda._UpdateTSConstructorType(global.context, passNode(original), passNode(signature), abstract)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSConstructorTypeTypeParamsConst(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSConstructorTypeParamsConst(global.context, this.peer)) + } + get returnType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSConstructorTypeReturnTypeConst(global.context, this.peer)) + } + get abstract(): boolean { + return global.generatedEs2panda._TSConstructorTypeAbstractConst(global.context, this.peer) + } +} +export function isTSConstructorType(node: AstNode): node is TSConstructorType { + return node instanceof TSConstructorType +} +if (!nodeByType.has(126)) { + nodeByType.set(126, TSConstructorType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSEnumDeclaration.ts b/koala-wrapper/src/generated/peers/TSEnumDeclaration.ts new file mode 100644 index 000000000..ecebdceed --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSEnumDeclaration.ts @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypedStatement } from "./TypedStatement" +import { Identifier } from "./Identifier" +import { ClassDefinition } from "./ClassDefinition" +import { Decorator } from "./Decorator" +export class TSEnumDeclaration extends TypedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 87) + super(pointer) + + } + static createTSEnumDeclaration(key: Identifier | undefined, members: readonly AstNode[], isConst: boolean, isStatic: boolean, isDeclare: boolean): TSEnumDeclaration { + return new TSEnumDeclaration(global.generatedEs2panda._CreateTSEnumDeclaration(global.context, passNode(key), passNodeArray(members), members.length, isConst, isStatic, isDeclare)) + } + static updateTSEnumDeclaration(original: TSEnumDeclaration | undefined, key: Identifier | undefined, members: readonly AstNode[], isConst: boolean, isStatic: boolean, isDeclare: boolean): TSEnumDeclaration { + return new TSEnumDeclaration(global.generatedEs2panda._UpdateTSEnumDeclaration(global.context, passNode(original), passNode(key), passNodeArray(members), members.length, isConst, isStatic, isDeclare)) + } + get key(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSEnumDeclarationKeyConst(global.context, this.peer)) + } + get members(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._TSEnumDeclarationMembersConst(global.context, this.peer)) + } + get internalName(): string { + return unpackString(global.generatedEs2panda._TSEnumDeclarationInternalNameConst(global.context, this.peer)) + } + /** @deprecated */ + setInternalName(internalName: string): this { + global.generatedEs2panda._TSEnumDeclarationSetInternalName(global.context, this.peer, internalName) + return this + } + get boxedClass(): ClassDefinition | undefined { + return unpackNode(global.generatedEs2panda._TSEnumDeclarationBoxedClassConst(global.context, this.peer)) + } + /** @deprecated */ + setBoxedClass(wrapperClass: ClassDefinition): this { + global.generatedEs2panda._TSEnumDeclarationSetBoxedClass(global.context, this.peer, passNode(wrapperClass)) + return this + } + get isConst(): boolean { + return global.generatedEs2panda._TSEnumDeclarationIsConstConst(global.context, this.peer) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._TSEnumDeclarationDecoratorsConst(global.context, this.peer)) + } +} +export function isTSEnumDeclaration(node: AstNode): node is TSEnumDeclaration { + return node instanceof TSEnumDeclaration +} +if (!nodeByType.has(87)) { + nodeByType.set(87, TSEnumDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSEnumMember.ts b/koala-wrapper/src/generated/peers/TSEnumMember.ts new file mode 100644 index 000000000..c0332c509 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSEnumMember.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class TSEnumMember extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 88) + super(pointer) + + } + static createTSEnumMember(key?: Expression, init?: Expression): TSEnumMember { + return new TSEnumMember(global.generatedEs2panda._CreateTSEnumMember(global.context, passNode(key), passNode(init))) + } + static updateTSEnumMember(original?: TSEnumMember, key?: Expression, init?: Expression): TSEnumMember { + return new TSEnumMember(global.generatedEs2panda._UpdateTSEnumMember(global.context, passNode(original), passNode(key), passNode(init))) + } + static create1TSEnumMember(key: Expression | undefined, init: Expression | undefined, isGenerated: boolean): TSEnumMember { + return new TSEnumMember(global.generatedEs2panda._CreateTSEnumMember1(global.context, passNode(key), passNode(init), isGenerated)) + } + static update1TSEnumMember(original: TSEnumMember | undefined, key: Expression | undefined, init: Expression | undefined, isGenerated: boolean): TSEnumMember { + return new TSEnumMember(global.generatedEs2panda._UpdateTSEnumMember1(global.context, passNode(original), passNode(key), passNode(init), isGenerated)) + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSEnumMemberKeyConst(global.context, this.peer)) + } + get init(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSEnumMemberInitConst(global.context, this.peer)) + } + get isGenerated(): boolean { + return global.generatedEs2panda._TSEnumMemberIsGeneratedConst(global.context, this.peer) + } +} +export function isTSEnumMember(node: AstNode): node is TSEnumMember { + return node instanceof TSEnumMember +} +if (!nodeByType.has(88)) { + nodeByType.set(88, TSEnumMember) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSExternalModuleReference.ts b/koala-wrapper/src/generated/peers/TSExternalModuleReference.ts new file mode 100644 index 000000000..eae8cfabc --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSExternalModuleReference.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class TSExternalModuleReference extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 89) + super(pointer) + + } + static createTSExternalModuleReference(expr?: Expression): TSExternalModuleReference { + return new TSExternalModuleReference(global.generatedEs2panda._CreateTSExternalModuleReference(global.context, passNode(expr))) + } + static updateTSExternalModuleReference(original?: TSExternalModuleReference, expr?: Expression): TSExternalModuleReference { + return new TSExternalModuleReference(global.generatedEs2panda._UpdateTSExternalModuleReference(global.context, passNode(original), passNode(expr))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSExternalModuleReferenceExprConst(global.context, this.peer)) + } +} +export function isTSExternalModuleReference(node: AstNode): node is TSExternalModuleReference { + return node instanceof TSExternalModuleReference +} +if (!nodeByType.has(89)) { + nodeByType.set(89, TSExternalModuleReference) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSFunctionType.ts b/koala-wrapper/src/generated/peers/TSFunctionType.ts new file mode 100644 index 000000000..f65d2fa56 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSFunctionType.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { FunctionSignature } from "./FunctionSignature" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { Expression } from "./Expression" +export class TSFunctionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 125) + super(pointer) + + } + static createTSFunctionType(signature?: FunctionSignature): TSFunctionType { + return new TSFunctionType(global.generatedEs2panda._CreateTSFunctionType(global.context, passNode(signature))) + } + static updateTSFunctionType(original?: TSFunctionType, signature?: FunctionSignature): TSFunctionType { + return new TSFunctionType(global.generatedEs2panda._UpdateTSFunctionType(global.context, passNode(original), passNode(signature))) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSFunctionTypeTypeParamsConst(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSFunctionTypeParamsConst(global.context, this.peer)) + } + get returnType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSFunctionTypeReturnTypeConst(global.context, this.peer)) + } + /** @deprecated */ + setNullable(nullable: boolean): this { + global.generatedEs2panda._TSFunctionTypeSetNullable(global.context, this.peer, nullable) + return this + } +} +export function isTSFunctionType(node: AstNode): node is TSFunctionType { + return node instanceof TSFunctionType +} +if (!nodeByType.has(125)) { + nodeByType.set(125, TSFunctionType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSImportEqualsDeclaration.ts b/koala-wrapper/src/generated/peers/TSImportEqualsDeclaration.ts new file mode 100644 index 000000000..a04b88379 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSImportEqualsDeclaration.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Identifier } from "./Identifier" +import { Expression } from "./Expression" +export class TSImportEqualsDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 124) + super(pointer) + + } + static createTSImportEqualsDeclaration(id: Identifier | undefined, moduleReference: Expression | undefined, isExport: boolean): TSImportEqualsDeclaration { + return new TSImportEqualsDeclaration(global.generatedEs2panda._CreateTSImportEqualsDeclaration(global.context, passNode(id), passNode(moduleReference), isExport)) + } + static updateTSImportEqualsDeclaration(original: TSImportEqualsDeclaration | undefined, id: Identifier | undefined, moduleReference: Expression | undefined, isExport: boolean): TSImportEqualsDeclaration { + return new TSImportEqualsDeclaration(global.generatedEs2panda._UpdateTSImportEqualsDeclaration(global.context, passNode(original), passNode(id), passNode(moduleReference), isExport)) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSImportEqualsDeclarationIdConst(global.context, this.peer)) + } + get moduleReference(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSImportEqualsDeclarationModuleReferenceConst(global.context, this.peer)) + } + get isExport(): boolean { + return global.generatedEs2panda._TSImportEqualsDeclarationIsExportConst(global.context, this.peer) + } +} +export function isTSImportEqualsDeclaration(node: AstNode): node is TSImportEqualsDeclaration { + return node instanceof TSImportEqualsDeclaration +} +if (!nodeByType.has(124)) { + nodeByType.set(124, TSImportEqualsDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSImportType.ts b/koala-wrapper/src/generated/peers/TSImportType.ts new file mode 100644 index 000000000..43e08e49a --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSImportType.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +export class TSImportType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 112) + super(pointer) + + } + static createTSImportType(param: Expression | undefined, typeParams: TSTypeParameterInstantiation | undefined, qualifier: Expression | undefined, isTypeof: boolean): TSImportType { + return new TSImportType(global.generatedEs2panda._CreateTSImportType(global.context, passNode(param), passNode(typeParams), passNode(qualifier), isTypeof)) + } + static updateTSImportType(original: TSImportType | undefined, param: Expression | undefined, typeParams: TSTypeParameterInstantiation | undefined, qualifier: Expression | undefined, isTypeof: boolean): TSImportType { + return new TSImportType(global.generatedEs2panda._UpdateTSImportType(global.context, passNode(original), passNode(param), passNode(typeParams), passNode(qualifier), isTypeof)) + } + get param(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSImportTypeParamConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._TSImportTypeTypeParamsConst(global.context, this.peer)) + } + get qualifier(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSImportTypeQualifierConst(global.context, this.peer)) + } + get isTypeof(): boolean { + return global.generatedEs2panda._TSImportTypeIsTypeofConst(global.context, this.peer) + } +} +export function isTSImportType(node: AstNode): node is TSImportType { + return node instanceof TSImportType +} +if (!nodeByType.has(112)) { + nodeByType.set(112, TSImportType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSIndexSignature.ts b/koala-wrapper/src/generated/peers/TSIndexSignature.ts new file mode 100644 index 000000000..6a7bf5ea9 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSIndexSignature.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypedAstNode } from "./TypedAstNode" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +import { Es2pandaTSIndexSignatureKind } from "./../Es2pandaEnums" +export class TSIndexSignature extends TypedAstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 136) + super(pointer) + + } + static createTSIndexSignature(param: Expression | undefined, typeAnnotation: TypeNode | undefined, readonly_arg: boolean): TSIndexSignature { + return new TSIndexSignature(global.generatedEs2panda._CreateTSIndexSignature(global.context, passNode(param), passNode(typeAnnotation), readonly_arg)) + } + static updateTSIndexSignature(original: TSIndexSignature | undefined, param: Expression | undefined, typeAnnotation: TypeNode | undefined, readonly_arg: boolean): TSIndexSignature { + return new TSIndexSignature(global.generatedEs2panda._UpdateTSIndexSignature(global.context, passNode(original), passNode(param), passNode(typeAnnotation), readonly_arg)) + } + get param(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSIndexSignatureParamConst(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSIndexSignatureTypeAnnotationConst(global.context, this.peer)) + } + get readonly(): boolean { + return global.generatedEs2panda._TSIndexSignatureReadonlyConst(global.context, this.peer) + } +} +export function isTSIndexSignature(node: AstNode): node is TSIndexSignature { + return node instanceof TSIndexSignature +} +if (!nodeByType.has(136)) { + nodeByType.set(136, TSIndexSignature) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSIndexedAccessType.ts b/koala-wrapper/src/generated/peers/TSIndexedAccessType.ts new file mode 100644 index 000000000..edb3a5c1f --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSIndexedAccessType.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSIndexedAccessType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 130) + super(pointer) + + } + static createTSIndexedAccessType(objectType?: TypeNode, indexType?: TypeNode): TSIndexedAccessType { + return new TSIndexedAccessType(global.generatedEs2panda._CreateTSIndexedAccessType(global.context, passNode(objectType), passNode(indexType))) + } + static updateTSIndexedAccessType(original?: TSIndexedAccessType, objectType?: TypeNode, indexType?: TypeNode): TSIndexedAccessType { + return new TSIndexedAccessType(global.generatedEs2panda._UpdateTSIndexedAccessType(global.context, passNode(original), passNode(objectType), passNode(indexType))) + } + get objectType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSIndexedAccessTypeObjectTypeConst(global.context, this.peer)) + } + get indexType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSIndexedAccessTypeIndexTypeConst(global.context, this.peer)) + } +} +export function isTSIndexedAccessType(node: AstNode): node is TSIndexedAccessType { + return node instanceof TSIndexedAccessType +} +if (!nodeByType.has(130)) { + nodeByType.set(130, TSIndexedAccessType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSInferType.ts b/koala-wrapper/src/generated/peers/TSInferType.ts new file mode 100644 index 000000000..f2a5d6597 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSInferType.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { TSTypeParameter } from "./TSTypeParameter" +export class TSInferType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 110) + super(pointer) + + } + static createTSInferType(typeParam?: TSTypeParameter): TSInferType { + return new TSInferType(global.generatedEs2panda._CreateTSInferType(global.context, passNode(typeParam))) + } + static updateTSInferType(original?: TSInferType, typeParam?: TSTypeParameter): TSInferType { + return new TSInferType(global.generatedEs2panda._UpdateTSInferType(global.context, passNode(original), passNode(typeParam))) + } + get typeParam(): TSTypeParameter | undefined { + return unpackNode(global.generatedEs2panda._TSInferTypeTypeParamConst(global.context, this.peer)) + } +} +export function isTSInferType(node: AstNode): node is TSInferType { + return node instanceof TSInferType +} +if (!nodeByType.has(110)) { + nodeByType.set(110, TSInferType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSInterfaceBody.ts b/koala-wrapper/src/generated/peers/TSInterfaceBody.ts new file mode 100644 index 000000000..103fa4a1a --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSInterfaceBody.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class TSInterfaceBody extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 132) + super(pointer) + + } + static createTSInterfaceBody(body: readonly AstNode[]): TSInterfaceBody { + return new TSInterfaceBody(global.generatedEs2panda._CreateTSInterfaceBody(global.context, passNodeArray(body), body.length)) + } + static updateTSInterfaceBody(original: TSInterfaceBody | undefined, body: readonly AstNode[]): TSInterfaceBody { + return new TSInterfaceBody(global.generatedEs2panda._UpdateTSInterfaceBody(global.context, passNode(original), passNodeArray(body), body.length)) + } + get bodyPtr(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._TSInterfaceBodyBodyPtr(global.context, this.peer)) + } + get body(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._TSInterfaceBodyBodyConst(global.context, this.peer)) + } +} +export function isTSInterfaceBody(node: AstNode): node is TSInterfaceBody { + return node instanceof TSInterfaceBody +} +if (!nodeByType.has(132)) { + nodeByType.set(132, TSInterfaceBody) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSInterfaceDeclaration.ts b/koala-wrapper/src/generated/peers/TSInterfaceDeclaration.ts new file mode 100644 index 000000000..21c064fcf --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSInterfaceDeclaration.ts @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypedStatement } from "./TypedStatement" +import { TSInterfaceHeritage } from "./TSInterfaceHeritage" +import { TSInterfaceBody } from "./TSInterfaceBody" +import { Identifier } from "./Identifier" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { Decorator } from "./Decorator" +import { ClassDeclaration } from "./ClassDeclaration" +import { AnnotationUsage } from "./AnnotationUsage" +export class TSInterfaceDeclaration extends TypedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 131) + super(pointer) + + } + static createTSInterfaceDeclaration(_extends: readonly TSInterfaceHeritage[], id: AstNode | undefined, typeParams: AstNode | undefined, body: AstNode | undefined, isStatic: boolean, isExternal: boolean): TSInterfaceDeclaration { + return new TSInterfaceDeclaration(global.generatedEs2panda._CreateTSInterfaceDeclaration(global.context, passNodeArray(_extends), _extends.length, passNode(id), passNode(typeParams), passNode(body), isStatic, isExternal)) + } + static updateTSInterfaceDeclaration(original: TSInterfaceDeclaration | undefined, _extends: readonly TSInterfaceHeritage[], id: AstNode | undefined, typeParams: AstNode | undefined, body: AstNode | undefined, isStatic: boolean, isExternal: boolean): TSInterfaceDeclaration { + return new TSInterfaceDeclaration(global.generatedEs2panda._UpdateTSInterfaceDeclaration(global.context, passNode(original), passNodeArray(_extends), _extends.length, passNode(id), passNode(typeParams), passNode(body), isStatic, isExternal)) + } + get body(): TSInterfaceBody | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationBodyConst(global.context, this.peer)) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationIdConst(global.context, this.peer)) + } + get internalName(): string { + return unpackString(global.generatedEs2panda._TSInterfaceDeclarationInternalNameConst(global.context, this.peer)) + } + /** @deprecated */ + setInternalName(internalName: string): this { + global.generatedEs2panda._TSInterfaceDeclarationSetInternalName(global.context, this.peer, internalName) + return this + } + get isStatic(): boolean { + return global.generatedEs2panda._TSInterfaceDeclarationIsStaticConst(global.context, this.peer) + } + get isFromExternal(): boolean { + return global.generatedEs2panda._TSInterfaceDeclarationIsFromExternalConst(global.context, this.peer) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationTypeParamsConst(global.context, this.peer)) + } + get extends(): readonly TSInterfaceHeritage[] { + return unpackNodeArray(global.generatedEs2panda._TSInterfaceDeclarationExtendsConst(global.context, this.peer)) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._TSInterfaceDeclarationDecoratorsConst(global.context, this.peer)) + } + get getAnonClass(): ClassDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceDeclarationGetAnonClassConst(global.context, this.peer)) + } + /** @deprecated */ + setAnonClass(anonClass: ClassDeclaration): this { + global.generatedEs2panda._TSInterfaceDeclarationSetAnonClass(global.context, this.peer, passNode(anonClass)) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._TSInterfaceDeclarationAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._TSInterfaceDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isTSInterfaceDeclaration(node: AstNode): node is TSInterfaceDeclaration { + return node instanceof TSInterfaceDeclaration +} +if (!nodeByType.has(131)) { + nodeByType.set(131, TSInterfaceDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSInterfaceHeritage.ts b/koala-wrapper/src/generated/peers/TSInterfaceHeritage.ts new file mode 100644 index 000000000..4af6bfb0f --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSInterfaceHeritage.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSInterfaceHeritage extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 133) + super(pointer) + + } + static createTSInterfaceHeritage(expr?: TypeNode): TSInterfaceHeritage { + return new TSInterfaceHeritage(global.generatedEs2panda._CreateTSInterfaceHeritage(global.context, passNode(expr))) + } + static updateTSInterfaceHeritage(original?: TSInterfaceHeritage, expr?: TypeNode): TSInterfaceHeritage { + return new TSInterfaceHeritage(global.generatedEs2panda._UpdateTSInterfaceHeritage(global.context, passNode(original), passNode(expr))) + } + get expr(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSInterfaceHeritageExprConst(global.context, this.peer)) + } +} +export function isTSInterfaceHeritage(node: AstNode): node is TSInterfaceHeritage { + return node instanceof TSInterfaceHeritage +} +if (!nodeByType.has(133)) { + nodeByType.set(133, TSInterfaceHeritage) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSIntersectionType.ts b/koala-wrapper/src/generated/peers/TSIntersectionType.ts new file mode 100644 index 000000000..d21f48d7a --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSIntersectionType.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +export class TSIntersectionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 113) + super(pointer) + + } + static createTSIntersectionType(types: readonly Expression[]): TSIntersectionType { + return new TSIntersectionType(global.generatedEs2panda._CreateTSIntersectionType(global.context, passNodeArray(types), types.length)) + } + static updateTSIntersectionType(original: TSIntersectionType | undefined, types: readonly Expression[]): TSIntersectionType { + return new TSIntersectionType(global.generatedEs2panda._UpdateTSIntersectionType(global.context, passNode(original), passNodeArray(types), types.length)) + } + get types(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSIntersectionTypeTypesConst(global.context, this.peer)) + } +} +export function isTSIntersectionType(node: AstNode): node is TSIntersectionType { + return node instanceof TSIntersectionType +} +if (!nodeByType.has(113)) { + nodeByType.set(113, TSIntersectionType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSLiteralType.ts b/koala-wrapper/src/generated/peers/TSLiteralType.ts new file mode 100644 index 000000000..f9ecdf774 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSLiteralType.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +export class TSLiteralType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 109) + super(pointer) + + } + static createTSLiteralType(literal?: Expression): TSLiteralType { + return new TSLiteralType(global.generatedEs2panda._CreateTSLiteralType(global.context, passNode(literal))) + } + static updateTSLiteralType(original?: TSLiteralType, literal?: Expression): TSLiteralType { + return new TSLiteralType(global.generatedEs2panda._UpdateTSLiteralType(global.context, passNode(original), passNode(literal))) + } + get literal(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSLiteralTypeLiteralConst(global.context, this.peer)) + } +} +export function isTSLiteralType(node: AstNode): node is TSLiteralType { + return node instanceof TSLiteralType +} +if (!nodeByType.has(109)) { + nodeByType.set(109, TSLiteralType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSMappedType.ts b/koala-wrapper/src/generated/peers/TSMappedType.ts new file mode 100644 index 000000000..e8a2202dc --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSMappedType.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { TSTypeParameter } from "./TSTypeParameter" +import { Es2pandaMappedOption } from "./../Es2pandaEnums" +export class TSMappedType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 114) + super(pointer) + + } + static createTSMappedType(typeParameter: TSTypeParameter | undefined, typeAnnotation: TypeNode | undefined, readonly_arg: Es2pandaMappedOption, optional_arg: Es2pandaMappedOption): TSMappedType { + return new TSMappedType(global.generatedEs2panda._CreateTSMappedType(global.context, passNode(typeParameter), passNode(typeAnnotation), readonly_arg, optional_arg)) + } + static updateTSMappedType(original: TSMappedType | undefined, typeParameter: TSTypeParameter | undefined, typeAnnotation: TypeNode | undefined, readonly_arg: Es2pandaMappedOption, optional_arg: Es2pandaMappedOption): TSMappedType { + return new TSMappedType(global.generatedEs2panda._UpdateTSMappedType(global.context, passNode(original), passNode(typeParameter), passNode(typeAnnotation), readonly_arg, optional_arg)) + } + get typeParameter(): TSTypeParameter | undefined { + return unpackNode(global.generatedEs2panda._TSMappedTypeTypeParameter(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSMappedTypeTypeAnnotation(global.context, this.peer)) + } + get readonly(): Es2pandaMappedOption { + return global.generatedEs2panda._TSMappedTypeReadonly(global.context, this.peer) + } + get optional(): Es2pandaMappedOption { + return global.generatedEs2panda._TSMappedTypeOptional(global.context, this.peer) + } +} +export function isTSMappedType(node: AstNode): node is TSMappedType { + return node instanceof TSMappedType +} +if (!nodeByType.has(114)) { + nodeByType.set(114, TSMappedType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSMethodSignature.ts b/koala-wrapper/src/generated/peers/TSMethodSignature.ts new file mode 100644 index 000000000..d16351da0 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSMethodSignature.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { FunctionSignature } from "./FunctionSignature" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +export class TSMethodSignature extends AstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 106) + super(pointer) + + } + static createTSMethodSignature(key: Expression | undefined, signature: FunctionSignature | undefined, computed: boolean, optional_arg: boolean): TSMethodSignature { + return new TSMethodSignature(global.generatedEs2panda._CreateTSMethodSignature(global.context, passNode(key), passNode(signature), computed, optional_arg)) + } + static updateTSMethodSignature(original: TSMethodSignature | undefined, key: Expression | undefined, signature: FunctionSignature | undefined, computed: boolean, optional_arg: boolean): TSMethodSignature { + return new TSMethodSignature(global.generatedEs2panda._UpdateTSMethodSignature(global.context, passNode(original), passNode(key), passNode(signature), computed, optional_arg)) + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSMethodSignatureKeyConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSMethodSignatureTypeParamsConst(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSMethodSignatureParamsConst(global.context, this.peer)) + } + get returnTypeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSMethodSignatureReturnTypeAnnotationConst(global.context, this.peer)) + } + get computed(): boolean { + return global.generatedEs2panda._TSMethodSignatureComputedConst(global.context, this.peer) + } + get optional(): boolean { + return global.generatedEs2panda._TSMethodSignatureOptionalConst(global.context, this.peer) + } +} +export function isTSMethodSignature(node: AstNode): node is TSMethodSignature { + return node instanceof TSMethodSignature +} +if (!nodeByType.has(106)) { + nodeByType.set(106, TSMethodSignature) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSModuleBlock.ts b/koala-wrapper/src/generated/peers/TSModuleBlock.ts new file mode 100644 index 000000000..d25d54f36 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSModuleBlock.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class TSModuleBlock extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 115) + super(pointer) + + } + static createTSModuleBlock(statements: readonly Statement[]): TSModuleBlock { + return new TSModuleBlock(global.generatedEs2panda._CreateTSModuleBlock(global.context, passNodeArray(statements), statements.length)) + } + static updateTSModuleBlock(original: TSModuleBlock | undefined, statements: readonly Statement[]): TSModuleBlock { + return new TSModuleBlock(global.generatedEs2panda._UpdateTSModuleBlock(global.context, passNode(original), passNodeArray(statements), statements.length)) + } + get statements(): readonly Statement[] { + return unpackNodeArray(global.generatedEs2panda._TSModuleBlockStatementsConst(global.context, this.peer)) + } +} +export function isTSModuleBlock(node: AstNode): node is TSModuleBlock { + return node instanceof TSModuleBlock +} +if (!nodeByType.has(115)) { + nodeByType.set(115, TSModuleBlock) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSModuleDeclaration.ts b/koala-wrapper/src/generated/peers/TSModuleDeclaration.ts new file mode 100644 index 000000000..c4582a84c --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSModuleDeclaration.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class TSModuleDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 123) + super(pointer) + + } + static createTSModuleDeclaration(name: Expression | undefined, body: Statement | undefined, declare: boolean, _global: boolean): TSModuleDeclaration { + return new TSModuleDeclaration(global.generatedEs2panda._CreateTSModuleDeclaration(global.context, passNode(name), passNode(body), declare, _global)) + } + static updateTSModuleDeclaration(original: TSModuleDeclaration | undefined, name: Expression | undefined, body: Statement | undefined, declare: boolean, _global: boolean): TSModuleDeclaration { + return new TSModuleDeclaration(global.generatedEs2panda._UpdateTSModuleDeclaration(global.context, passNode(original), passNode(name), passNode(body), declare, _global)) + } + get name(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSModuleDeclarationNameConst(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._TSModuleDeclarationBodyConst(global.context, this.peer)) + } + get global(): boolean { + return global.generatedEs2panda._TSModuleDeclarationGlobalConst(global.context, this.peer) + } + get isExternalOrAmbient(): boolean { + return global.generatedEs2panda._TSModuleDeclarationIsExternalOrAmbientConst(global.context, this.peer) + } +} +export function isTSModuleDeclaration(node: AstNode): node is TSModuleDeclaration { + return node instanceof TSModuleDeclaration +} +if (!nodeByType.has(123)) { + nodeByType.set(123, TSModuleDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSNamedTupleMember.ts b/koala-wrapper/src/generated/peers/TSNamedTupleMember.ts new file mode 100644 index 000000000..3252f8a47 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSNamedTupleMember.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +export class TSNamedTupleMember extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 135) + super(pointer) + + } + static createTSNamedTupleMember(label: Expression | undefined, elementType: TypeNode | undefined, optional_arg: boolean): TSNamedTupleMember { + return new TSNamedTupleMember(global.generatedEs2panda._CreateTSNamedTupleMember(global.context, passNode(label), passNode(elementType), optional_arg)) + } + static updateTSNamedTupleMember(original: TSNamedTupleMember | undefined, label: Expression | undefined, elementType: TypeNode | undefined, optional_arg: boolean): TSNamedTupleMember { + return new TSNamedTupleMember(global.generatedEs2panda._UpdateTSNamedTupleMember(global.context, passNode(original), passNode(label), passNode(elementType), optional_arg)) + } + get label(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSNamedTupleMemberLabelConst(global.context, this.peer)) + } + get elementType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSNamedTupleMemberElementTypeConst(global.context, this.peer)) + } + get isOptional(): boolean { + return global.generatedEs2panda._TSNamedTupleMemberIsOptionalConst(global.context, this.peer) + } +} +export function isTSNamedTupleMember(node: AstNode): node is TSNamedTupleMember { + return node instanceof TSNamedTupleMember +} +if (!nodeByType.has(135)) { + nodeByType.set(135, TSNamedTupleMember) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSNeverKeyword.ts b/koala-wrapper/src/generated/peers/TSNeverKeyword.ts new file mode 100644 index 000000000..39b7de7ff --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSNeverKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSNeverKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 99) + super(pointer) + + } + static createTSNeverKeyword(): TSNeverKeyword { + return new TSNeverKeyword(global.generatedEs2panda._CreateTSNeverKeyword(global.context)) + } + static updateTSNeverKeyword(original?: TSNeverKeyword): TSNeverKeyword { + return new TSNeverKeyword(global.generatedEs2panda._UpdateTSNeverKeyword(global.context, passNode(original))) + } +} +export function isTSNeverKeyword(node: AstNode): node is TSNeverKeyword { + return node instanceof TSNeverKeyword +} +if (!nodeByType.has(99)) { + nodeByType.set(99, TSNeverKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSNonNullExpression.ts b/koala-wrapper/src/generated/peers/TSNonNullExpression.ts new file mode 100644 index 000000000..21bc3e670 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSNonNullExpression.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class TSNonNullExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 100) + super(pointer) + + } + static createTSNonNullExpression(expr?: Expression): TSNonNullExpression { + return new TSNonNullExpression(global.generatedEs2panda._CreateTSNonNullExpression(global.context, passNode(expr))) + } + static updateTSNonNullExpression(original?: TSNonNullExpression, expr?: Expression): TSNonNullExpression { + return new TSNonNullExpression(global.generatedEs2panda._UpdateTSNonNullExpression(global.context, passNode(original), passNode(expr))) + } + get expr(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSNonNullExpressionExprConst(global.context, this.peer)) + } + /** @deprecated */ + setExpr(expr: Expression): this { + global.generatedEs2panda._TSNonNullExpressionSetExpr(global.context, this.peer, passNode(expr)) + return this + } +} +export function isTSNonNullExpression(node: AstNode): node is TSNonNullExpression { + return node instanceof TSNonNullExpression +} +if (!nodeByType.has(100)) { + nodeByType.set(100, TSNonNullExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSNullKeyword.ts b/koala-wrapper/src/generated/peers/TSNullKeyword.ts new file mode 100644 index 000000000..c3b161938 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSNullKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSNullKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 101) + super(pointer) + + } + static createTSNullKeyword(): TSNullKeyword { + return new TSNullKeyword(global.generatedEs2panda._CreateTSNullKeyword(global.context)) + } + static updateTSNullKeyword(original?: TSNullKeyword): TSNullKeyword { + return new TSNullKeyword(global.generatedEs2panda._UpdateTSNullKeyword(global.context, passNode(original))) + } +} +export function isTSNullKeyword(node: AstNode): node is TSNullKeyword { + return node instanceof TSNullKeyword +} +if (!nodeByType.has(101)) { + nodeByType.set(101, TSNullKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSNumberKeyword.ts b/koala-wrapper/src/generated/peers/TSNumberKeyword.ts new file mode 100644 index 000000000..ff3c783af --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSNumberKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSNumberKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 90) + super(pointer) + + } + static createTSNumberKeyword(): TSNumberKeyword { + return new TSNumberKeyword(global.generatedEs2panda._CreateTSNumberKeyword(global.context)) + } + static updateTSNumberKeyword(original?: TSNumberKeyword): TSNumberKeyword { + return new TSNumberKeyword(global.generatedEs2panda._UpdateTSNumberKeyword(global.context, passNode(original))) + } +} +export function isTSNumberKeyword(node: AstNode): node is TSNumberKeyword { + return node instanceof TSNumberKeyword +} +if (!nodeByType.has(90)) { + nodeByType.set(90, TSNumberKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSObjectKeyword.ts b/koala-wrapper/src/generated/peers/TSObjectKeyword.ts new file mode 100644 index 000000000..2279f62af --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSObjectKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSObjectKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 97) + super(pointer) + + } + static createTSObjectKeyword(): TSObjectKeyword { + return new TSObjectKeyword(global.generatedEs2panda._CreateTSObjectKeyword(global.context)) + } + static updateTSObjectKeyword(original?: TSObjectKeyword): TSObjectKeyword { + return new TSObjectKeyword(global.generatedEs2panda._UpdateTSObjectKeyword(global.context, passNode(original))) + } +} +export function isTSObjectKeyword(node: AstNode): node is TSObjectKeyword { + return node instanceof TSObjectKeyword +} +if (!nodeByType.has(97)) { + nodeByType.set(97, TSObjectKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSParameterProperty.ts b/koala-wrapper/src/generated/peers/TSParameterProperty.ts new file mode 100644 index 000000000..9efa642c8 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSParameterProperty.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Es2pandaAccessibilityOption } from "./../Es2pandaEnums" +export class TSParameterProperty extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 122) + super(pointer) + + } + static createTSParameterProperty(accessibility: Es2pandaAccessibilityOption, parameter: Expression | undefined, readonly_arg: boolean, isStatic: boolean, isExport: boolean): TSParameterProperty { + return new TSParameterProperty(global.generatedEs2panda._CreateTSParameterProperty(global.context, accessibility, passNode(parameter), readonly_arg, isStatic, isExport)) + } + static updateTSParameterProperty(original: TSParameterProperty | undefined, accessibility: Es2pandaAccessibilityOption, parameter: Expression | undefined, readonly_arg: boolean, isStatic: boolean, isExport: boolean): TSParameterProperty { + return new TSParameterProperty(global.generatedEs2panda._UpdateTSParameterProperty(global.context, passNode(original), accessibility, passNode(parameter), readonly_arg, isStatic, isExport)) + } + get accessibility(): Es2pandaAccessibilityOption { + return global.generatedEs2panda._TSParameterPropertyAccessibilityConst(global.context, this.peer) + } + get readonly(): boolean { + return global.generatedEs2panda._TSParameterPropertyReadonlyConst(global.context, this.peer) + } + get isStatic(): boolean { + return global.generatedEs2panda._TSParameterPropertyIsStaticConst(global.context, this.peer) + } + get isExport(): boolean { + return global.generatedEs2panda._TSParameterPropertyIsExportConst(global.context, this.peer) + } + get parameter(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSParameterPropertyParameterConst(global.context, this.peer)) + } +} +export function isTSParameterProperty(node: AstNode): node is TSParameterProperty { + return node instanceof TSParameterProperty +} +if (!nodeByType.has(122)) { + nodeByType.set(122, TSParameterProperty) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSParenthesizedType.ts b/koala-wrapper/src/generated/peers/TSParenthesizedType.ts new file mode 100644 index 000000000..043431f71 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSParenthesizedType.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +export class TSParenthesizedType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 108) + super(pointer) + + } + static createTSParenthesizedType(type?: TypeNode): TSParenthesizedType { + return new TSParenthesizedType(global.generatedEs2panda._CreateTSParenthesizedType(global.context, passNode(type))) + } + static updateTSParenthesizedType(original?: TSParenthesizedType, type?: TypeNode): TSParenthesizedType { + return new TSParenthesizedType(global.generatedEs2panda._UpdateTSParenthesizedType(global.context, passNode(original), passNode(type))) + } + get type(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSParenthesizedTypeTypeConst(global.context, this.peer)) + } +} +export function isTSParenthesizedType(node: AstNode): node is TSParenthesizedType { + return node instanceof TSParenthesizedType +} +if (!nodeByType.has(108)) { + nodeByType.set(108, TSParenthesizedType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSPropertySignature.ts b/koala-wrapper/src/generated/peers/TSPropertySignature.ts new file mode 100644 index 000000000..b2725a964 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSPropertySignature.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedAstNode } from "./AnnotatedAstNode" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSPropertySignature extends AnnotatedAstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 105) + super(pointer) + + } + static createTSPropertySignature(key: Expression | undefined, typeAnnotation: TypeNode | undefined, computed: boolean, optional_arg: boolean, readonly_arg: boolean): TSPropertySignature { + return new TSPropertySignature(global.generatedEs2panda._CreateTSPropertySignature(global.context, passNode(key), passNode(typeAnnotation), computed, optional_arg, readonly_arg)) + } + static updateTSPropertySignature(original: TSPropertySignature | undefined, key: Expression | undefined, typeAnnotation: TypeNode | undefined, computed: boolean, optional_arg: boolean, readonly_arg: boolean): TSPropertySignature { + return new TSPropertySignature(global.generatedEs2panda._UpdateTSPropertySignature(global.context, passNode(original), passNode(key), passNode(typeAnnotation), computed, optional_arg, readonly_arg)) + } + get key(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSPropertySignatureKeyConst(global.context, this.peer)) + } + get computed(): boolean { + return global.generatedEs2panda._TSPropertySignatureComputedConst(global.context, this.peer) + } + get optional(): boolean { + return global.generatedEs2panda._TSPropertySignatureOptionalConst(global.context, this.peer) + } + get readonly(): boolean { + return global.generatedEs2panda._TSPropertySignatureReadonlyConst(global.context, this.peer) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSPropertySignatureTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._TSPropertySignatureSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isTSPropertySignature(node: AstNode): node is TSPropertySignature { + return node instanceof TSPropertySignature +} +if (!nodeByType.has(105)) { + nodeByType.set(105, TSPropertySignature) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSQualifiedName.ts b/koala-wrapper/src/generated/peers/TSQualifiedName.ts new file mode 100644 index 000000000..e0f4d87ea --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSQualifiedName.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +export class TSQualifiedName extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 129) + super(pointer) + + } + static createTSQualifiedName(left?: Expression, right?: Identifier): TSQualifiedName { + return new TSQualifiedName(global.generatedEs2panda._CreateTSQualifiedName(global.context, passNode(left), passNode(right))) + } + static updateTSQualifiedName(original?: TSQualifiedName, left?: Expression, right?: Identifier): TSQualifiedName { + return new TSQualifiedName(global.generatedEs2panda._UpdateTSQualifiedName(global.context, passNode(original), passNode(left), passNode(right))) + } + get left(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSQualifiedNameLeftConst(global.context, this.peer)) + } + get right(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSQualifiedNameRightConst(global.context, this.peer)) + } +} +export function isTSQualifiedName(node: AstNode): node is TSQualifiedName { + return node instanceof TSQualifiedName +} +if (!nodeByType.has(129)) { + nodeByType.set(129, TSQualifiedName) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSSignatureDeclaration.ts b/koala-wrapper/src/generated/peers/TSSignatureDeclaration.ts new file mode 100644 index 000000000..e70bbf176 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSSignatureDeclaration.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypedAstNode } from "./TypedAstNode" +import { Es2pandaTSSignatureDeclarationKind } from "./../Es2pandaEnums" +import { FunctionSignature } from "./FunctionSignature" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSSignatureDeclaration extends TypedAstNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 107) + super(pointer) + + } + static createTSSignatureDeclaration(kind: Es2pandaTSSignatureDeclarationKind, signature?: FunctionSignature): TSSignatureDeclaration { + return new TSSignatureDeclaration(global.generatedEs2panda._CreateTSSignatureDeclaration(global.context, kind, passNode(signature))) + } + static updateTSSignatureDeclaration(original: TSSignatureDeclaration | undefined, kind: Es2pandaTSSignatureDeclarationKind, signature?: FunctionSignature): TSSignatureDeclaration { + return new TSSignatureDeclaration(global.generatedEs2panda._UpdateTSSignatureDeclaration(global.context, passNode(original), kind, passNode(signature))) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSSignatureDeclarationTypeParamsConst(global.context, this.peer)) + } + get params(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TSSignatureDeclarationParamsConst(global.context, this.peer)) + } + get returnTypeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSSignatureDeclarationReturnTypeAnnotationConst(global.context, this.peer)) + } + get kind(): Es2pandaTSSignatureDeclarationKind { + return global.generatedEs2panda._TSSignatureDeclarationKindConst(global.context, this.peer) + } +} +export function isTSSignatureDeclaration(node: AstNode): node is TSSignatureDeclaration { + return node instanceof TSSignatureDeclaration +} +if (!nodeByType.has(107)) { + nodeByType.set(107, TSSignatureDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSStringKeyword.ts b/koala-wrapper/src/generated/peers/TSStringKeyword.ts new file mode 100644 index 000000000..6f749be33 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSStringKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSStringKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 92) + super(pointer) + + } + static createTSStringKeyword(): TSStringKeyword { + return new TSStringKeyword(global.generatedEs2panda._CreateTSStringKeyword(global.context)) + } + static updateTSStringKeyword(original?: TSStringKeyword): TSStringKeyword { + return new TSStringKeyword(global.generatedEs2panda._UpdateTSStringKeyword(global.context, passNode(original))) + } +} +export function isTSStringKeyword(node: AstNode): node is TSStringKeyword { + return node instanceof TSStringKeyword +} +if (!nodeByType.has(92)) { + nodeByType.set(92, TSStringKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSThisType.ts b/koala-wrapper/src/generated/peers/TSThisType.ts new file mode 100644 index 000000000..e57be0ab0 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSThisType.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSThisType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 116) + super(pointer) + + } + static createTSThisType(): TSThisType { + return new TSThisType(global.generatedEs2panda._CreateTSThisType(global.context)) + } + static updateTSThisType(original?: TSThisType): TSThisType { + return new TSThisType(global.generatedEs2panda._UpdateTSThisType(global.context, passNode(original))) + } +} +export function isTSThisType(node: AstNode): node is TSThisType { + return node instanceof TSThisType +} +if (!nodeByType.has(116)) { + nodeByType.set(116, TSThisType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTupleType.ts b/koala-wrapper/src/generated/peers/TSTupleType.ts new file mode 100644 index 000000000..11bafff08 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTupleType.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSTupleType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 134) + super(pointer) + + } + static createTSTupleType(elementTypes: readonly TypeNode[]): TSTupleType { + return new TSTupleType(global.generatedEs2panda._CreateTSTupleType(global.context, passNodeArray(elementTypes), elementTypes.length)) + } + static updateTSTupleType(original: TSTupleType | undefined, elementTypes: readonly TypeNode[]): TSTupleType { + return new TSTupleType(global.generatedEs2panda._UpdateTSTupleType(global.context, passNode(original), passNodeArray(elementTypes), elementTypes.length)) + } + get elementType(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._TSTupleTypeElementTypeConst(global.context, this.peer)) + } +} +export function isTSTupleType(node: AstNode): node is TSTupleType { + return node instanceof TSTupleType +} +if (!nodeByType.has(134)) { + nodeByType.set(134, TSTupleType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypeAliasDeclaration.ts b/koala-wrapper/src/generated/peers/TSTypeAliasDeclaration.ts new file mode 100644 index 000000000..58e381c2d --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypeAliasDeclaration.ts @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedStatement } from "./AnnotatedStatement" +import { Identifier } from "./Identifier" +import { TSTypeParameterDeclaration } from "./TSTypeParameterDeclaration" +import { TypeNode } from "./TypeNode" +import { Decorator } from "./Decorator" +import { AnnotationUsage } from "./AnnotationUsage" +export class TSTypeAliasDeclaration extends AnnotatedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 127) + super(pointer) + + } + static createTSTypeAliasDeclaration(id?: Identifier, typeParams?: TSTypeParameterDeclaration, typeAnnotation?: TypeNode): TSTypeAliasDeclaration { + return new TSTypeAliasDeclaration(global.generatedEs2panda._CreateTSTypeAliasDeclaration(global.context, passNode(id), passNode(typeParams), passNode(typeAnnotation))) + } + static updateTSTypeAliasDeclaration(original?: TSTypeAliasDeclaration, id?: Identifier, typeParams?: TSTypeParameterDeclaration, typeAnnotation?: TypeNode): TSTypeAliasDeclaration { + return new TSTypeAliasDeclaration(global.generatedEs2panda._UpdateTSTypeAliasDeclaration(global.context, passNode(original), passNode(id), passNode(typeParams), passNode(typeAnnotation))) + } + static create1TSTypeAliasDeclaration(id?: Identifier): TSTypeAliasDeclaration { + return new TSTypeAliasDeclaration(global.generatedEs2panda._CreateTSTypeAliasDeclaration1(global.context, passNode(id))) + } + static update1TSTypeAliasDeclaration(original?: TSTypeAliasDeclaration, id?: Identifier): TSTypeAliasDeclaration { + return new TSTypeAliasDeclaration(global.generatedEs2panda._UpdateTSTypeAliasDeclaration1(global.context, passNode(original), passNode(id))) + } + get id(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSTypeAliasDeclarationIdConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterDeclaration | undefined { + return unpackNode(global.generatedEs2panda._TSTypeAliasDeclarationTypeParamsConst(global.context, this.peer)) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeAliasDeclarationDecoratorsConst(global.context, this.peer)) + } + /** @deprecated */ + setTypeParameters(typeParams: TSTypeParameterDeclaration): this { + global.generatedEs2panda._TSTypeAliasDeclarationSetTypeParameters(global.context, this.peer, passNode(typeParams)) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeAliasDeclarationAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._TSTypeAliasDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypeAliasDeclarationTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._TSTypeAliasDeclarationSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isTSTypeAliasDeclaration(node: AstNode): node is TSTypeAliasDeclaration { + return node instanceof TSTypeAliasDeclaration +} +if (!nodeByType.has(127)) { + nodeByType.set(127, TSTypeAliasDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypeAssertion.ts b/koala-wrapper/src/generated/peers/TSTypeAssertion.ts new file mode 100644 index 000000000..e01615f9b --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypeAssertion.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { AnnotatedExpression } from "./AnnotatedExpression" +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +export class TSTypeAssertion extends AnnotatedExpression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 140) + super(pointer) + + } + static createTSTypeAssertion(typeAnnotation?: TypeNode, expression?: Expression): TSTypeAssertion { + return new TSTypeAssertion(global.generatedEs2panda._CreateTSTypeAssertion(global.context, passNode(typeAnnotation), passNode(expression))) + } + static updateTSTypeAssertion(original?: TSTypeAssertion, typeAnnotation?: TypeNode, expression?: Expression): TSTypeAssertion { + return new TSTypeAssertion(global.generatedEs2panda._UpdateTSTypeAssertion(global.context, passNode(original), passNode(typeAnnotation), passNode(expression))) + } + get getExpression(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSTypeAssertionGetExpressionConst(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypeAssertionTypeAnnotationConst(global.context, this.peer)) + } + /** @deprecated */ + setTsTypeAnnotation(typeAnnotation: TypeNode): this { + global.generatedEs2panda._TSTypeAssertionSetTsTypeAnnotation(global.context, this.peer, passNode(typeAnnotation)) + return this + } +} +export function isTSTypeAssertion(node: AstNode): node is TSTypeAssertion { + return node instanceof TSTypeAssertion +} +if (!nodeByType.has(140)) { + nodeByType.set(140, TSTypeAssertion) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypeLiteral.ts b/koala-wrapper/src/generated/peers/TSTypeLiteral.ts new file mode 100644 index 000000000..20e3a4f22 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypeLiteral.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSTypeLiteral extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 104) + super(pointer) + + } + static createTSTypeLiteral(members: readonly AstNode[]): TSTypeLiteral { + return new TSTypeLiteral(global.generatedEs2panda._CreateTSTypeLiteral(global.context, passNodeArray(members), members.length)) + } + static updateTSTypeLiteral(original: TSTypeLiteral | undefined, members: readonly AstNode[]): TSTypeLiteral { + return new TSTypeLiteral(global.generatedEs2panda._UpdateTSTypeLiteral(global.context, passNode(original), passNodeArray(members), members.length)) + } + get members(): readonly AstNode[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeLiteralMembersConst(global.context, this.peer)) + } +} +export function isTSTypeLiteral(node: AstNode): node is TSTypeLiteral { + return node instanceof TSTypeLiteral +} +if (!nodeByType.has(104)) { + nodeByType.set(104, TSTypeLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypeOperator.ts b/koala-wrapper/src/generated/peers/TSTypeOperator.ts new file mode 100644 index 000000000..3f94d244f --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypeOperator.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Es2pandaTSOperatorType } from "./../Es2pandaEnums" +export class TSTypeOperator extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 117) + super(pointer) + + } + static createTSTypeOperator(type: TypeNode | undefined, operatorType: Es2pandaTSOperatorType): TSTypeOperator { + return new TSTypeOperator(global.generatedEs2panda._CreateTSTypeOperator(global.context, passNode(type), operatorType)) + } + static updateTSTypeOperator(original: TSTypeOperator | undefined, type: TypeNode | undefined, operatorType: Es2pandaTSOperatorType): TSTypeOperator { + return new TSTypeOperator(global.generatedEs2panda._UpdateTSTypeOperator(global.context, passNode(original), passNode(type), operatorType)) + } + get type(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypeOperatorTypeConst(global.context, this.peer)) + } + get isReadonly(): boolean { + return global.generatedEs2panda._TSTypeOperatorIsReadonlyConst(global.context, this.peer) + } + get isKeyof(): boolean { + return global.generatedEs2panda._TSTypeOperatorIsKeyofConst(global.context, this.peer) + } + get isUnique(): boolean { + return global.generatedEs2panda._TSTypeOperatorIsUniqueConst(global.context, this.peer) + } +} +export function isTSTypeOperator(node: AstNode): node is TSTypeOperator { + return node instanceof TSTypeOperator +} +if (!nodeByType.has(117)) { + nodeByType.set(117, TSTypeOperator) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypeParameter.ts b/koala-wrapper/src/generated/peers/TSTypeParameter.ts new file mode 100644 index 000000000..28012faf1 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypeParameter.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Identifier } from "./Identifier" +import { TypeNode } from "./TypeNode" +import { Es2pandaModifierFlags } from "./../Es2pandaEnums" +import { AnnotationUsage } from "./AnnotationUsage" +export class TSTypeParameter extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 118) + super(pointer) + + } + static createTSTypeParameter(name?: Identifier, constraint?: TypeNode, defaultType?: TypeNode): TSTypeParameter { + return new TSTypeParameter(global.generatedEs2panda._CreateTSTypeParameter(global.context, passNode(name), passNode(constraint), passNode(defaultType))) + } + static updateTSTypeParameter(original?: TSTypeParameter, name?: Identifier, constraint?: TypeNode, defaultType?: TypeNode): TSTypeParameter { + return new TSTypeParameter(global.generatedEs2panda._UpdateTSTypeParameter(global.context, passNode(original), passNode(name), passNode(constraint), passNode(defaultType))) + } + static create1TSTypeParameter(name: Identifier | undefined, constraint: TypeNode | undefined, defaultType: TypeNode | undefined, flags: Es2pandaModifierFlags): TSTypeParameter { + return new TSTypeParameter(global.generatedEs2panda._CreateTSTypeParameter1(global.context, passNode(name), passNode(constraint), passNode(defaultType), flags)) + } + static update1TSTypeParameter(original: TSTypeParameter | undefined, name: Identifier | undefined, constraint: TypeNode | undefined, defaultType: TypeNode | undefined, flags: Es2pandaModifierFlags): TSTypeParameter { + return new TSTypeParameter(global.generatedEs2panda._UpdateTSTypeParameter1(global.context, passNode(original), passNode(name), passNode(constraint), passNode(defaultType), flags)) + } + get name(): Identifier | undefined { + return unpackNode(global.generatedEs2panda._TSTypeParameterNameConst(global.context, this.peer)) + } + get constraint(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypeParameterConstraintConst(global.context, this.peer)) + } + /** @deprecated */ + setConstraint(constraint: TypeNode): this { + global.generatedEs2panda._TSTypeParameterSetConstraint(global.context, this.peer, passNode(constraint)) + return this + } + get defaultType(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypeParameterDefaultTypeConst(global.context, this.peer)) + } + /** @deprecated */ + setDefaultType(defaultType: TypeNode): this { + global.generatedEs2panda._TSTypeParameterSetDefaultType(global.context, this.peer, passNode(defaultType)) + return this + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeParameterAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._TSTypeParameterSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isTSTypeParameter(node: AstNode): node is TSTypeParameter { + return node instanceof TSTypeParameter +} +if (!nodeByType.has(118)) { + nodeByType.set(118, TSTypeParameter) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypeParameterDeclaration.ts b/koala-wrapper/src/generated/peers/TSTypeParameterDeclaration.ts new file mode 100644 index 000000000..59f4ab594 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypeParameterDeclaration.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TSTypeParameter } from "./TSTypeParameter" +export class TSTypeParameterDeclaration extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 119) + super(pointer) + + } + static createTSTypeParameterDeclaration(params: readonly TSTypeParameter[], requiredParams: number): TSTypeParameterDeclaration { + return new TSTypeParameterDeclaration(global.generatedEs2panda._CreateTSTypeParameterDeclaration(global.context, passNodeArray(params), params.length, requiredParams)) + } + static updateTSTypeParameterDeclaration(original: TSTypeParameterDeclaration | undefined, params: readonly TSTypeParameter[], requiredParams: number): TSTypeParameterDeclaration { + return new TSTypeParameterDeclaration(global.generatedEs2panda._UpdateTSTypeParameterDeclaration(global.context, passNode(original), passNodeArray(params), params.length, requiredParams)) + } + get params(): readonly TSTypeParameter[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeParameterDeclarationParamsConst(global.context, this.peer)) + } + /** @deprecated */ + addParam(param: TSTypeParameter): this { + global.generatedEs2panda._TSTypeParameterDeclarationAddParam(global.context, this.peer, passNode(param)) + return this + } + get requiredParams(): number { + return global.generatedEs2panda._TSTypeParameterDeclarationRequiredParamsConst(global.context, this.peer) + } +} +export function isTSTypeParameterDeclaration(node: AstNode): node is TSTypeParameterDeclaration { + return node instanceof TSTypeParameterDeclaration +} +if (!nodeByType.has(119)) { + nodeByType.set(119, TSTypeParameterDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypeParameterInstantiation.ts b/koala-wrapper/src/generated/peers/TSTypeParameterInstantiation.ts new file mode 100644 index 000000000..b6a23b329 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypeParameterInstantiation.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TypeNode } from "./TypeNode" +export class TSTypeParameterInstantiation extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 120) + super(pointer) + + } + static createTSTypeParameterInstantiation(params: readonly TypeNode[]): TSTypeParameterInstantiation { + return new TSTypeParameterInstantiation(global.generatedEs2panda._CreateTSTypeParameterInstantiation(global.context, passNodeArray(params), params.length)) + } + static updateTSTypeParameterInstantiation(original: TSTypeParameterInstantiation | undefined, params: readonly TypeNode[]): TSTypeParameterInstantiation { + return new TSTypeParameterInstantiation(global.generatedEs2panda._UpdateTSTypeParameterInstantiation(global.context, passNode(original), passNodeArray(params), params.length)) + } + get params(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._TSTypeParameterInstantiationParamsConst(global.context, this.peer)) + } +} +export function isTSTypeParameterInstantiation(node: AstNode): node is TSTypeParameterInstantiation { + return node instanceof TSTypeParameterInstantiation +} +if (!nodeByType.has(120)) { + nodeByType.set(120, TSTypeParameterInstantiation) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypePredicate.ts b/koala-wrapper/src/generated/peers/TSTypePredicate.ts new file mode 100644 index 000000000..551d62f98 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypePredicate.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +export class TSTypePredicate extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 121) + super(pointer) + + } + static createTSTypePredicate(parameterName: Expression | undefined, typeAnnotation: TypeNode | undefined, asserts: boolean): TSTypePredicate { + return new TSTypePredicate(global.generatedEs2panda._CreateTSTypePredicate(global.context, passNode(parameterName), passNode(typeAnnotation), asserts)) + } + static updateTSTypePredicate(original: TSTypePredicate | undefined, parameterName: Expression | undefined, typeAnnotation: TypeNode | undefined, asserts: boolean): TSTypePredicate { + return new TSTypePredicate(global.generatedEs2panda._UpdateTSTypePredicate(global.context, passNode(original), passNode(parameterName), passNode(typeAnnotation), asserts)) + } + get parameterName(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSTypePredicateParameterNameConst(global.context, this.peer)) + } + get typeAnnotation(): TypeNode | undefined { + return unpackNode(global.generatedEs2panda._TSTypePredicateTypeAnnotationConst(global.context, this.peer)) + } + get asserts(): boolean { + return global.generatedEs2panda._TSTypePredicateAssertsConst(global.context, this.peer) + } +} +export function isTSTypePredicate(node: AstNode): node is TSTypePredicate { + return node instanceof TSTypePredicate +} +if (!nodeByType.has(121)) { + nodeByType.set(121, TSTypePredicate) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypeQuery.ts b/koala-wrapper/src/generated/peers/TSTypeQuery.ts new file mode 100644 index 000000000..d4576d1fa --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypeQuery.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +export class TSTypeQuery extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 137) + super(pointer) + + } + static createTSTypeQuery(exprName?: Expression): TSTypeQuery { + return new TSTypeQuery(global.generatedEs2panda._CreateTSTypeQuery(global.context, passNode(exprName))) + } + static updateTSTypeQuery(original?: TSTypeQuery, exprName?: Expression): TSTypeQuery { + return new TSTypeQuery(global.generatedEs2panda._UpdateTSTypeQuery(global.context, passNode(original), passNode(exprName))) + } + get exprName(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSTypeQueryExprNameConst(global.context, this.peer)) + } +} +export function isTSTypeQuery(node: AstNode): node is TSTypeQuery { + return node instanceof TSTypeQuery +} +if (!nodeByType.has(137)) { + nodeByType.set(137, TSTypeQuery) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSTypeReference.ts b/koala-wrapper/src/generated/peers/TSTypeReference.ts new file mode 100644 index 000000000..50e62aafb --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSTypeReference.ts @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +import { Expression } from "./Expression" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +import { Identifier } from "./Identifier" +export class TSTypeReference extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 128) + super(pointer) + + } + static createTSTypeReference(typeName?: Expression, typeParams?: TSTypeParameterInstantiation): TSTypeReference { + return new TSTypeReference(global.generatedEs2panda._CreateTSTypeReference(global.context, passNode(typeName), passNode(typeParams))) + } + static updateTSTypeReference(original?: TSTypeReference, typeName?: Expression, typeParams?: TSTypeParameterInstantiation): TSTypeReference { + return new TSTypeReference(global.generatedEs2panda._UpdateTSTypeReference(global.context, passNode(original), passNode(typeName), passNode(typeParams))) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._TSTypeReferenceTypeParamsConst(global.context, this.peer)) + } + get typeName(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TSTypeReferenceTypeNameConst(global.context, this.peer)) + } +} +export function isTSTypeReference(node: AstNode): node is TSTypeReference { + return node instanceof TSTypeReference +} +if (!nodeByType.has(128)) { + nodeByType.set(128, TSTypeReference) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSUndefinedKeyword.ts b/koala-wrapper/src/generated/peers/TSUndefinedKeyword.ts new file mode 100644 index 000000000..9129d02d9 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSUndefinedKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSUndefinedKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 95) + super(pointer) + + } + static createTSUndefinedKeyword(): TSUndefinedKeyword { + return new TSUndefinedKeyword(global.generatedEs2panda._CreateTSUndefinedKeyword(global.context)) + } + static updateTSUndefinedKeyword(original?: TSUndefinedKeyword): TSUndefinedKeyword { + return new TSUndefinedKeyword(global.generatedEs2panda._UpdateTSUndefinedKeyword(global.context, passNode(original))) + } +} +export function isTSUndefinedKeyword(node: AstNode): node is TSUndefinedKeyword { + return node instanceof TSUndefinedKeyword +} +if (!nodeByType.has(95)) { + nodeByType.set(95, TSUndefinedKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSUnionType.ts b/koala-wrapper/src/generated/peers/TSUnionType.ts new file mode 100644 index 000000000..406ecc416 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSUnionType.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSUnionType extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 103) + super(pointer) + + } + static createTSUnionType(types: readonly TypeNode[]): TSUnionType { + return new TSUnionType(global.generatedEs2panda._CreateTSUnionType(global.context, passNodeArray(types), types.length)) + } + static updateTSUnionType(original: TSUnionType | undefined, types: readonly TypeNode[]): TSUnionType { + return new TSUnionType(global.generatedEs2panda._UpdateTSUnionType(global.context, passNode(original), passNodeArray(types), types.length)) + } + get types(): readonly TypeNode[] { + return unpackNodeArray(global.generatedEs2panda._TSUnionTypeTypesConst(global.context, this.peer)) + } +} +export function isTSUnionType(node: AstNode): node is TSUnionType { + return node instanceof TSUnionType +} +if (!nodeByType.has(103)) { + nodeByType.set(103, TSUnionType) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSUnknownKeyword.ts b/koala-wrapper/src/generated/peers/TSUnknownKeyword.ts new file mode 100644 index 000000000..0371b243c --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSUnknownKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSUnknownKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 96) + super(pointer) + + } + static createTSUnknownKeyword(): TSUnknownKeyword { + return new TSUnknownKeyword(global.generatedEs2panda._CreateTSUnknownKeyword(global.context)) + } + static updateTSUnknownKeyword(original?: TSUnknownKeyword): TSUnknownKeyword { + return new TSUnknownKeyword(global.generatedEs2panda._UpdateTSUnknownKeyword(global.context, passNode(original))) + } +} +export function isTSUnknownKeyword(node: AstNode): node is TSUnknownKeyword { + return node instanceof TSUnknownKeyword +} +if (!nodeByType.has(96)) { + nodeByType.set(96, TSUnknownKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TSVoidKeyword.ts b/koala-wrapper/src/generated/peers/TSVoidKeyword.ts new file mode 100644 index 000000000..605cceb11 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TSVoidKeyword.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypeNode } from "./TypeNode" +export class TSVoidKeyword extends TypeNode { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 94) + super(pointer) + + } + static createTSVoidKeyword(): TSVoidKeyword { + return new TSVoidKeyword(global.generatedEs2panda._CreateTSVoidKeyword(global.context)) + } + static updateTSVoidKeyword(original?: TSVoidKeyword): TSVoidKeyword { + return new TSVoidKeyword(global.generatedEs2panda._UpdateTSVoidKeyword(global.context, passNode(original))) + } +} +export function isTSVoidKeyword(node: AstNode): node is TSVoidKeyword { + return node instanceof TSVoidKeyword +} +if (!nodeByType.has(94)) { + nodeByType.set(94, TSVoidKeyword) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TaggedTemplateExpression.ts b/koala-wrapper/src/generated/peers/TaggedTemplateExpression.ts new file mode 100644 index 000000000..0ccbf0f08 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TaggedTemplateExpression.ts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TemplateLiteral } from "./TemplateLiteral" +import { TSTypeParameterInstantiation } from "./TSTypeParameterInstantiation" +export class TaggedTemplateExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 141) + super(pointer) + + } + static createTaggedTemplateExpression(tag?: Expression, quasi?: TemplateLiteral, typeParams?: TSTypeParameterInstantiation): TaggedTemplateExpression { + return new TaggedTemplateExpression(global.generatedEs2panda._CreateTaggedTemplateExpression(global.context, passNode(tag), passNode(quasi), passNode(typeParams))) + } + static updateTaggedTemplateExpression(original?: TaggedTemplateExpression, tag?: Expression, quasi?: TemplateLiteral, typeParams?: TSTypeParameterInstantiation): TaggedTemplateExpression { + return new TaggedTemplateExpression(global.generatedEs2panda._UpdateTaggedTemplateExpression(global.context, passNode(original), passNode(tag), passNode(quasi), passNode(typeParams))) + } + get tag(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TaggedTemplateExpressionTagConst(global.context, this.peer)) + } + get quasi(): TemplateLiteral | undefined { + return unpackNode(global.generatedEs2panda._TaggedTemplateExpressionQuasiConst(global.context, this.peer)) + } + get typeParams(): TSTypeParameterInstantiation | undefined { + return unpackNode(global.generatedEs2panda._TaggedTemplateExpressionTypeParamsConst(global.context, this.peer)) + } +} +export function isTaggedTemplateExpression(node: AstNode): node is TaggedTemplateExpression { + return node instanceof TaggedTemplateExpression +} +if (!nodeByType.has(141)) { + nodeByType.set(141, TaggedTemplateExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TemplateElement.ts b/koala-wrapper/src/generated/peers/TemplateElement.ts new file mode 100644 index 000000000..0c4108f47 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TemplateElement.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class TemplateElement extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 142) + super(pointer) + + } + static createTemplateElement(): TemplateElement { + return new TemplateElement(global.generatedEs2panda._CreateTemplateElement(global.context)) + } + static updateTemplateElement(original?: TemplateElement): TemplateElement { + return new TemplateElement(global.generatedEs2panda._UpdateTemplateElement(global.context, passNode(original))) + } + static create1TemplateElement(raw: string, cooked: string): TemplateElement { + return new TemplateElement(global.generatedEs2panda._CreateTemplateElement1(global.context, raw, cooked)) + } + static update1TemplateElement(original: TemplateElement | undefined, raw: string, cooked: string): TemplateElement { + return new TemplateElement(global.generatedEs2panda._UpdateTemplateElement1(global.context, passNode(original), raw, cooked)) + } + get raw(): string { + return unpackString(global.generatedEs2panda._TemplateElementRawConst(global.context, this.peer)) + } + get cooked(): string { + return unpackString(global.generatedEs2panda._TemplateElementCookedConst(global.context, this.peer)) + } +} +export function isTemplateElement(node: AstNode): node is TemplateElement { + return node instanceof TemplateElement +} +if (!nodeByType.has(142)) { + nodeByType.set(142, TemplateElement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TemplateLiteral.ts b/koala-wrapper/src/generated/peers/TemplateLiteral.ts new file mode 100644 index 000000000..58039a87e --- /dev/null +++ b/koala-wrapper/src/generated/peers/TemplateLiteral.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { TemplateElement } from "./TemplateElement" +export class TemplateLiteral extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 143) + super(pointer) + + } + static createTemplateLiteral(quasis: readonly TemplateElement[], expressions: readonly Expression[], multilineString: string): TemplateLiteral { + return new TemplateLiteral(global.generatedEs2panda._CreateTemplateLiteral(global.context, passNodeArray(quasis), quasis.length, passNodeArray(expressions), expressions.length, multilineString)) + } + static updateTemplateLiteral(original: TemplateLiteral | undefined, quasis: readonly TemplateElement[], expressions: readonly Expression[], multilineString: string): TemplateLiteral { + return new TemplateLiteral(global.generatedEs2panda._UpdateTemplateLiteral(global.context, passNode(original), passNodeArray(quasis), quasis.length, passNodeArray(expressions), expressions.length, multilineString)) + } + get quasis(): readonly TemplateElement[] { + return unpackNodeArray(global.generatedEs2panda._TemplateLiteralQuasisConst(global.context, this.peer)) + } + get expressions(): readonly Expression[] { + return unpackNodeArray(global.generatedEs2panda._TemplateLiteralExpressionsConst(global.context, this.peer)) + } +} +export function isTemplateLiteral(node: AstNode): node is TemplateLiteral { + return node instanceof TemplateLiteral +} +if (!nodeByType.has(143)) { + nodeByType.set(143, TemplateLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ThisExpression.ts b/koala-wrapper/src/generated/peers/ThisExpression.ts new file mode 100644 index 000000000..1ec6476d8 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ThisExpression.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class ThisExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 144) + super(pointer) + + } + static createThisExpression(): ThisExpression { + return new ThisExpression(global.generatedEs2panda._CreateThisExpression(global.context)) + } + static updateThisExpression(original?: ThisExpression): ThisExpression { + return new ThisExpression(global.generatedEs2panda._UpdateThisExpression(global.context, passNode(original))) + } +} +export function isThisExpression(node: AstNode): node is ThisExpression { + return node instanceof ThisExpression +} +if (!nodeByType.has(144)) { + nodeByType.set(144, ThisExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ThrowStatement.ts b/koala-wrapper/src/generated/peers/ThrowStatement.ts new file mode 100644 index 000000000..74cc30e59 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ThrowStatement.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Expression } from "./Expression" +export class ThrowStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 146) + super(pointer) + + } + static createThrowStatement(argument?: Expression): ThrowStatement { + return new ThrowStatement(global.generatedEs2panda._CreateThrowStatement(global.context, passNode(argument))) + } + static updateThrowStatement(original?: ThrowStatement, argument?: Expression): ThrowStatement { + return new ThrowStatement(global.generatedEs2panda._UpdateThrowStatement(global.context, passNode(original), passNode(argument))) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._ThrowStatementArgumentConst(global.context, this.peer)) + } +} +export function isThrowStatement(node: AstNode): node is ThrowStatement { + return node instanceof ThrowStatement +} +if (!nodeByType.has(146)) { + nodeByType.set(146, ThrowStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TryStatement.ts b/koala-wrapper/src/generated/peers/TryStatement.ts new file mode 100644 index 000000000..c855b8bfa --- /dev/null +++ b/koala-wrapper/src/generated/peers/TryStatement.ts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { BlockStatement } from "./BlockStatement" +import { CatchClause } from "./CatchClause" +export class TryStatement extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 147) + super(pointer) + + } + get finallyBlock(): BlockStatement | undefined { + return unpackNode(global.generatedEs2panda._TryStatementFinallyBlockConst(global.context, this.peer)) + } + get block(): BlockStatement | undefined { + return unpackNode(global.generatedEs2panda._TryStatementBlockConst(global.context, this.peer)) + } + get hasFinalizer(): boolean { + return global.generatedEs2panda._TryStatementHasFinalizerConst(global.context, this.peer) + } + get catchClauses(): readonly CatchClause[] { + return unpackNodeArray(global.generatedEs2panda._TryStatementCatchClausesConst(global.context, this.peer)) + } + get finallyCanCompleteNormally(): boolean { + return global.generatedEs2panda._TryStatementFinallyCanCompleteNormallyConst(global.context, this.peer) + } + /** @deprecated */ + setFinallyCanCompleteNormally(finallyCanCompleteNormally: boolean): this { + global.generatedEs2panda._TryStatementSetFinallyCanCompleteNormally(global.context, this.peer, finallyCanCompleteNormally) + return this + } +} +export function isTryStatement(node: AstNode): node is TryStatement { + return node instanceof TryStatement +} +if (!nodeByType.has(147)) { + nodeByType.set(147, TryStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TypeNode.ts b/koala-wrapper/src/generated/peers/TypeNode.ts new file mode 100644 index 000000000..18b915e47 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TypeNode.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { AnnotationUsage } from "./AnnotationUsage" +export class TypeNode extends Expression { + constructor(pointer: KNativePointer) { + super(pointer) + + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._TypeNodeAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._TypeNodeSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isTypeNode(node: AstNode): node is TypeNode { + return node instanceof TypeNode +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TypedAstNode.ts b/koala-wrapper/src/generated/peers/TypedAstNode.ts new file mode 100644 index 000000000..d749fe3be --- /dev/null +++ b/koala-wrapper/src/generated/peers/TypedAstNode.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class TypedAstNode extends AstNode { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isTypedAstNode(node: AstNode): node is TypedAstNode { + return node instanceof TypedAstNode +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TypedStatement.ts b/koala-wrapper/src/generated/peers/TypedStatement.ts new file mode 100644 index 000000000..a87344b96 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TypedStatement.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +export class TypedStatement extends Statement { + constructor(pointer: KNativePointer) { + super(pointer) + + } +} +export function isTypedStatement(node: AstNode): node is TypedStatement { + return node instanceof TypedStatement +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/TypeofExpression.ts b/koala-wrapper/src/generated/peers/TypeofExpression.ts new file mode 100644 index 000000000..0c80ae8e8 --- /dev/null +++ b/koala-wrapper/src/generated/peers/TypeofExpression.ts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class TypeofExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 145) + super(pointer) + + } + static createTypeofExpression(argument?: Expression): TypeofExpression { + return new TypeofExpression(global.generatedEs2panda._CreateTypeofExpression(global.context, passNode(argument))) + } + static updateTypeofExpression(original?: TypeofExpression, argument?: Expression): TypeofExpression { + return new TypeofExpression(global.generatedEs2panda._UpdateTypeofExpression(global.context, passNode(original), passNode(argument))) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._TypeofExpressionArgumentConst(global.context, this.peer)) + } +} +export function isTypeofExpression(node: AstNode): node is TypeofExpression { + return node instanceof TypeofExpression +} +if (!nodeByType.has(145)) { + nodeByType.set(145, TypeofExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/UnaryExpression.ts b/koala-wrapper/src/generated/peers/UnaryExpression.ts new file mode 100644 index 000000000..2b2d1aec7 --- /dev/null +++ b/koala-wrapper/src/generated/peers/UnaryExpression.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Es2pandaTokenType } from "./../Es2pandaEnums" +export class UnaryExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 148) + super(pointer) + + } + static createUnaryExpression(argument: Expression | undefined, unaryOperator: Es2pandaTokenType): UnaryExpression { + return new UnaryExpression(global.generatedEs2panda._CreateUnaryExpression(global.context, passNode(argument), unaryOperator)) + } + static updateUnaryExpression(original: UnaryExpression | undefined, argument: Expression | undefined, unaryOperator: Es2pandaTokenType): UnaryExpression { + return new UnaryExpression(global.generatedEs2panda._UpdateUnaryExpression(global.context, passNode(original), passNode(argument), unaryOperator)) + } + get operatorType(): Es2pandaTokenType { + return global.generatedEs2panda._UnaryExpressionOperatorTypeConst(global.context, this.peer) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._UnaryExpressionArgumentConst(global.context, this.peer)) + } +} +export function isUnaryExpression(node: AstNode): node is UnaryExpression { + return node instanceof UnaryExpression +} +if (!nodeByType.has(148)) { + nodeByType.set(148, UnaryExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/UndefinedLiteral.ts b/koala-wrapper/src/generated/peers/UndefinedLiteral.ts new file mode 100644 index 000000000..833805c1f --- /dev/null +++ b/koala-wrapper/src/generated/peers/UndefinedLiteral.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Literal } from "./Literal" +export class UndefinedLiteral extends Literal { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 51) + super(pointer) + + } + static createUndefinedLiteral(): UndefinedLiteral { + return new UndefinedLiteral(global.generatedEs2panda._CreateUndefinedLiteral(global.context)) + } + static updateUndefinedLiteral(original?: UndefinedLiteral): UndefinedLiteral { + return new UndefinedLiteral(global.generatedEs2panda._UpdateUndefinedLiteral(global.context, passNode(original))) + } +} +export function isUndefinedLiteral(node: AstNode): node is UndefinedLiteral { + return node instanceof UndefinedLiteral +} +if (!nodeByType.has(51)) { + nodeByType.set(51, UndefinedLiteral) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/UpdateExpression.ts b/koala-wrapper/src/generated/peers/UpdateExpression.ts new file mode 100644 index 000000000..5c1b8d6f1 --- /dev/null +++ b/koala-wrapper/src/generated/peers/UpdateExpression.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +import { Es2pandaTokenType } from "./../Es2pandaEnums" +export class UpdateExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 149) + super(pointer) + + } + static createUpdateExpression(argument: Expression | undefined, updateOperator: Es2pandaTokenType, isPrefix: boolean): UpdateExpression { + return new UpdateExpression(global.generatedEs2panda._CreateUpdateExpression(global.context, passNode(argument), updateOperator, isPrefix)) + } + static updateUpdateExpression(original: UpdateExpression | undefined, argument: Expression | undefined, updateOperator: Es2pandaTokenType, isPrefix: boolean): UpdateExpression { + return new UpdateExpression(global.generatedEs2panda._UpdateUpdateExpression(global.context, passNode(original), passNode(argument), updateOperator, isPrefix)) + } + get operatorType(): Es2pandaTokenType { + return global.generatedEs2panda._UpdateExpressionOperatorTypeConst(global.context, this.peer) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._UpdateExpressionArgumentConst(global.context, this.peer)) + } + get isPrefix(): boolean { + return global.generatedEs2panda._UpdateExpressionIsPrefixConst(global.context, this.peer) + } +} +export function isUpdateExpression(node: AstNode): node is UpdateExpression { + return node instanceof UpdateExpression +} +if (!nodeByType.has(149)) { + nodeByType.set(149, UpdateExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/ValidationInfo.ts b/koala-wrapper/src/generated/peers/ValidationInfo.ts new file mode 100644 index 000000000..45e6b8212 --- /dev/null +++ b/koala-wrapper/src/generated/peers/ValidationInfo.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +export class ValidationInfo extends ArktsObject { + constructor(pointer: KNativePointer) { + super(pointer) + + } + static createValidationInfo(): ValidationInfo { + return new ValidationInfo(global.generatedEs2panda._CreateValidationInfo(global.context)) + } + get fail(): boolean { + return global.generatedEs2panda._ValidationInfoFailConst(global.context, this.peer) + } +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/VariableDeclaration.ts b/koala-wrapper/src/generated/peers/VariableDeclaration.ts new file mode 100644 index 000000000..751968ae5 --- /dev/null +++ b/koala-wrapper/src/generated/peers/VariableDeclaration.ts @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Statement } from "./Statement" +import { Es2pandaVariableDeclarationKind } from "./../Es2pandaEnums" +import { VariableDeclarator } from "./VariableDeclarator" +import { Decorator } from "./Decorator" +import { AnnotationUsage } from "./AnnotationUsage" +export class VariableDeclaration extends Statement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 150) + super(pointer) + + } + static createVariableDeclaration(kind: Es2pandaVariableDeclarationKind, declarators: readonly VariableDeclarator[]): VariableDeclaration { + return new VariableDeclaration(global.generatedEs2panda._CreateVariableDeclaration(global.context, kind, passNodeArray(declarators), declarators.length)) + } + static updateVariableDeclaration(original: VariableDeclaration | undefined, kind: Es2pandaVariableDeclarationKind, declarators: readonly VariableDeclarator[]): VariableDeclaration { + return new VariableDeclaration(global.generatedEs2panda._UpdateVariableDeclaration(global.context, passNode(original), kind, passNodeArray(declarators), declarators.length)) + } + get declarators(): readonly VariableDeclarator[] { + return unpackNodeArray(global.generatedEs2panda._VariableDeclarationDeclaratorsConst(global.context, this.peer)) + } + get kind(): Es2pandaVariableDeclarationKind { + return global.generatedEs2panda._VariableDeclarationKindConst(global.context, this.peer) + } + get decorators(): readonly Decorator[] { + return unpackNodeArray(global.generatedEs2panda._VariableDeclarationDecoratorsConst(global.context, this.peer)) + } + get annotations(): readonly AnnotationUsage[] { + return unpackNodeArray(global.generatedEs2panda._VariableDeclarationAnnotationsConst(global.context, this.peer)) + } + /** @deprecated */ + setAnnotations(annotations: readonly AnnotationUsage[]): this { + global.generatedEs2panda._VariableDeclarationSetAnnotations(global.context, this.peer, passNodeArray(annotations), annotations.length) + return this + } +} +export function isVariableDeclaration(node: AstNode): node is VariableDeclaration { + return node instanceof VariableDeclaration +} +if (!nodeByType.has(150)) { + nodeByType.set(150, VariableDeclaration) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/VariableDeclarator.ts b/koala-wrapper/src/generated/peers/VariableDeclarator.ts new file mode 100644 index 000000000..e0d9cb077 --- /dev/null +++ b/koala-wrapper/src/generated/peers/VariableDeclarator.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { TypedStatement } from "./TypedStatement" +import { Es2pandaVariableDeclaratorFlag } from "./../Es2pandaEnums" +import { Expression } from "./Expression" +export class VariableDeclarator extends TypedStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 151) + super(pointer) + + } + static createVariableDeclarator(flag: Es2pandaVariableDeclaratorFlag, ident?: Expression): VariableDeclarator { + return new VariableDeclarator(global.generatedEs2panda._CreateVariableDeclarator(global.context, flag, passNode(ident))) + } + static updateVariableDeclarator(original: VariableDeclarator | undefined, flag: Es2pandaVariableDeclaratorFlag, ident?: Expression): VariableDeclarator { + return new VariableDeclarator(global.generatedEs2panda._UpdateVariableDeclarator(global.context, passNode(original), flag, passNode(ident))) + } + static create1VariableDeclarator(flag: Es2pandaVariableDeclaratorFlag, ident?: Expression, init?: Expression): VariableDeclarator { + return new VariableDeclarator(global.generatedEs2panda._CreateVariableDeclarator1(global.context, flag, passNode(ident), passNode(init))) + } + static update1VariableDeclarator(original: VariableDeclarator | undefined, flag: Es2pandaVariableDeclaratorFlag, ident?: Expression, init?: Expression): VariableDeclarator { + return new VariableDeclarator(global.generatedEs2panda._UpdateVariableDeclarator1(global.context, passNode(original), flag, passNode(ident), passNode(init))) + } + get init(): Expression | undefined { + return unpackNode(global.generatedEs2panda._VariableDeclaratorInitConst(global.context, this.peer)) + } + /** @deprecated */ + setInit(init: Expression): this { + global.generatedEs2panda._VariableDeclaratorSetInit(global.context, this.peer, passNode(init)) + return this + } + get id(): Expression | undefined { + return unpackNode(global.generatedEs2panda._VariableDeclaratorIdConst(global.context, this.peer)) + } + get flag(): Es2pandaVariableDeclaratorFlag { + return global.generatedEs2panda._VariableDeclaratorFlag(global.context, this.peer) + } +} +export function isVariableDeclarator(node: AstNode): node is VariableDeclarator { + return node instanceof VariableDeclarator +} +if (!nodeByType.has(151)) { + nodeByType.set(151, VariableDeclarator) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/WhileStatement.ts b/koala-wrapper/src/generated/peers/WhileStatement.ts new file mode 100644 index 000000000..f71a1d5dd --- /dev/null +++ b/koala-wrapper/src/generated/peers/WhileStatement.ts @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { LoopStatement } from "./LoopStatement" +import { Expression } from "./Expression" +import { Statement } from "./Statement" +export class WhileStatement extends LoopStatement { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 152) + super(pointer) + + } + static createWhileStatement(test?: Expression, body?: Statement): WhileStatement { + return new WhileStatement(global.generatedEs2panda._CreateWhileStatement(global.context, passNode(test), passNode(body))) + } + static updateWhileStatement(original?: WhileStatement, test?: Expression, body?: Statement): WhileStatement { + return new WhileStatement(global.generatedEs2panda._UpdateWhileStatement(global.context, passNode(original), passNode(test), passNode(body))) + } + get test(): Expression | undefined { + return unpackNode(global.generatedEs2panda._WhileStatementTestConst(global.context, this.peer)) + } + get body(): Statement | undefined { + return unpackNode(global.generatedEs2panda._WhileStatementBodyConst(global.context, this.peer)) + } +} +export function isWhileStatement(node: AstNode): node is WhileStatement { + return node instanceof WhileStatement +} +if (!nodeByType.has(152)) { + nodeByType.set(152, WhileStatement) +} \ No newline at end of file diff --git a/koala-wrapper/src/generated/peers/YieldExpression.ts b/koala-wrapper/src/generated/peers/YieldExpression.ts new file mode 100644 index 000000000..55c0b9022 --- /dev/null +++ b/koala-wrapper/src/generated/peers/YieldExpression.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 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 { + global, + passNode, + passNodeArray, + unpackNonNullableNode, + unpackNode, + unpackNodeArray, + assertValidPeer, + AstNode, + Es2pandaAstNodeType, + KNativePointer, + nodeByType, + ArktsObject, + unpackString +} from "../../reexport-for-generated" + +import { Expression } from "./Expression" +export class YieldExpression extends Expression { + constructor(pointer: KNativePointer) { + assertValidPeer(pointer, 153) + super(pointer) + + } + static createYieldExpression(argument: Expression | undefined, isDelegate: boolean): YieldExpression { + return new YieldExpression(global.generatedEs2panda._CreateYieldExpression(global.context, passNode(argument), isDelegate)) + } + static updateYieldExpression(original: YieldExpression | undefined, argument: Expression | undefined, isDelegate: boolean): YieldExpression { + return new YieldExpression(global.generatedEs2panda._UpdateYieldExpression(global.context, passNode(original), passNode(argument), isDelegate)) + } + get hasDelegate(): boolean { + return global.generatedEs2panda._YieldExpressionHasDelegateConst(global.context, this.peer) + } + get argument(): Expression | undefined { + return unpackNode(global.generatedEs2panda._YieldExpressionArgumentConst(global.context, this.peer)) + } +} +export function isYieldExpression(node: AstNode): node is YieldExpression { + return node instanceof YieldExpression +} +if (!nodeByType.has(153)) { + nodeByType.set(153, YieldExpression) +} \ No newline at end of file diff --git a/koala-wrapper/src/reexport-for-generated.ts b/koala-wrapper/src/reexport-for-generated.ts new file mode 100644 index 000000000..37e3c6f56 --- /dev/null +++ b/koala-wrapper/src/reexport-for-generated.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 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 { KNativePointer } from "@koalaui/interop" +export { AstNode } from "./arkts-api/peers/AstNode" +export { ArktsObject } from "./arkts-api/peers/ArktsObject" +export { Es2pandaAstNodeType } from "./Es2pandaEnums" +export { + passNode, + unpackNonNullableNode, + unpackNodeArray, + passNodeArray, + unpackNode, + unpackNonNullableObject, + unpackString, + unpackObject, + assertValidPeer +} from "./arkts-api/utilities/private" +export { nodeByType } from "./arkts-api/class-by-peer" +export { global } from "./arkts-api/static/global" +export { Es2pandaMemberExpressionKind } from "./generated/Es2pandaEnums" diff --git a/koala-wrapper/src/utils.ts b/koala-wrapper/src/utils.ts new file mode 100644 index 000000000..9ef0b4d51 --- /dev/null +++ b/koala-wrapper/src/utils.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022-2025 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 throwError(error: string): never { + throw new Error(error) +} + +export function withWarning(value: T, message: string): T { + console.warn(message) + return value +} + +export function isNumber(value: any): value is number { + return typeof value === `number` +} + +function replacePercentOutsideStrings(code: string): string { + const stringPattern = /("[^"]*"|'[^']*'|`[^`]*`)/g; + const percentPattern = /(?(); + strings.forEach((string) => { + const placeholder = `__STRING_PLACEHOLDER_${placeholderCounter++}__`; + placeholderMap.set(placeholder, string); + code = code.replace(string, placeholder); + }); + + code = code.replace(percentPattern, '_'); + + placeholderMap.forEach((originalString, placeholder) => { + code = code.replace(new RegExp(placeholder, 'g'), originalString); + }); + + return code; +} + +function replaceIllegalHashes(code: string): string { + const stringPattern = /("[^"]*"|'[^']*'|`[^`]*`)/g; + const strings = code.match(stringPattern) || []; + + let placeholderCounter = 0; + const placeholderMap = new Map(); + strings.forEach((string) => { + const placeholder = `__STRING_PLACEHOLDER_${placeholderCounter++}__`; + placeholderMap.set(placeholder, string); + code = code.replace(string, placeholder); + }); + + code = code.replace(/#/g, '_'); + + placeholderMap.forEach((originalString, placeholder) => { + code = code.replace(new RegExp(placeholder, 'g'), originalString); + }); + + return code; +} + +/* + TODO: + The lowerings insert %% and other special symbols into names of temporary variables. + Until we keep feeding ast dumps back to the parser this function is needed. + */ +export function filterSource(text: string): string { + const filtered = replaceIllegalHashes(replacePercentOutsideStrings(text)) + .replaceAll("", "_cctor_") + + return filtered +} + +export function getEnumName(enumType: any, value: number): string | undefined { + return enumType[value]; +} \ No newline at end of file diff --git a/koala-wrapper/tools/issue_gen.mjs b/koala-wrapper/tools/issue_gen.mjs new file mode 100644 index 000000000..7d2e24fd4 --- /dev/null +++ b/koala-wrapper/tools/issue_gen.mjs @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022-2025 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 * as fs from 'fs' +import * as path from 'path' + +process.chdir(path.resolve('./')) + +const issue_src = fs.readFileSync('../playground/src/playground.cc', { encoding: 'utf8', flag: 'r' }) + +const component_src = +` +### Component + +Plugin API + +` + +const revision_src = +` +### Revision + +"@panda/sdk": "1.5.0-dev.9184" + +` + +const reproduction_src = +` +### Reproduction + +\`\`\` +${issue_src} +\`\`\` + +` + +// TODO: +const log = `` + +const log_src = +` +### Log + +\`\`\` +${log} +\`\`\` +` + +console.log( + component_src + + revision_src + + reproduction_src + + log_src +) diff --git a/koala-wrapper/tsconfig.json b/koala-wrapper/tsconfig.json new file mode 100644 index 000000000..bb0b7b59b --- /dev/null +++ b/koala-wrapper/tsconfig.json @@ -0,0 +1,38 @@ +{ + "compilerOptions": { + "target": "es2017", + "lib": ["ESNext", "ESNext.WeakRef", "DOM"], + "moduleResolution": "node", + "composite": true, + "incremental": true, + "declarationMap": true, + "sourceMap": true, + "declaration": true, + "noEmitOnError": true, + "strict": true, + "skipLibCheck": true, + "removeComments": false, + "outDir": "build", + "baseUrl": ".", + "rootDir": ".", + "module": "CommonJS", + "paths": { + "@koalaui/interop": [ + "./koalaui/interop/dist/lib/src/interop/" + ], + "@koalaui/common": [ + "./koalaui/common/dist/lib/src/" + ], + "@koalaui/compat": [ + "./koalaui/compat/dist/src/" + ] + } + }, + "include": [ + "./src/**/*.ts", + ], + "exclude": [ + "./src/ts-api/**/*.ts", + "./koalaui" + ] +} -- Gitee From bd8361571f5f97abd35f303aab19ee57bff892bc Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Thu, 5 Jun 2025 21:35:14 +0800 Subject: [PATCH 092/140] =?UTF-8?q?codecheck=E5=91=8A=E8=AD=A6=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../userIntents_parser/parseUserIntents.ts | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index 081f3234c..1554f107e 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -105,7 +105,7 @@ class ParseIntent { detectInsightIntent(node: ts.ClassDeclaration, metaInfo: object, filePath: string, eventOrEventFactory: CompileEvent | undefined): ts.Node { const eventParseIntentTime: CompileEvent | undefined = createAndStartEvent(eventOrEventFactory, 'parseIntentTime'); if (!this.isInitCache && projectConfig.cachePath) { - const cacheSourceMapPath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); + const cacheSourceMapPath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); // The user's intents configuration file this.isUpdateCompile = fs.existsSync(cacheSourceMapPath); this.isInitCache = true; } @@ -316,7 +316,7 @@ class ParseIntent { } } else { throw Error(`${INVALID_BASE_CLASS_ERROR.toString()}, - The custom intent must be ultimately inherited to InsightIntentEntryExecutor, invalidDecoratorPath: ${this.currentFilePath}`); + The user's custom intents must be ultimately inherited to InsightIntentEntryExecutor, invalidDecoratorPath: ${this.currentFilePath}`); } } @@ -388,7 +388,7 @@ class ParseIntent { if (isGlobalPath) { if (parentClassName !== 'InsightIntentEntryExecutor') { throw Error(`${INVALID_BASE_CLASS_ERROR.toString()}, - The custom intent must be ultimately inherited to InsightIntentEntryExecutor, invalidDecoratorPath: ${this.currentFilePath}`); + The user's custom intents must be ultimately inherited to InsightIntentEntryExecutor, invalidDecoratorPath: ${this.currentFilePath}`); } } this.heritageClassSet.add(baseClassName + '_' + `@normalized:${baseRecordName}`); @@ -985,11 +985,38 @@ class ParseIntent { } writeUserIntentJsonFile(): void { + const writeJsonData: object = this.processIntentData(); + const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'insight_intent.json'); // The user's intents configuration file + const cachePath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); // Compiled cache file + try { + if (this.intentData.length > 0) { + fs.writeFileSync(cacheSourceMapPath, JSON.stringify(writeJsonData, null, 2), 'utf-8'); + fs.writeFileSync(cachePath, JSON.stringify({'extractInsightIntents': this.intentData}, null, 2), 'utf-8'); + } else if (fs.existsSync(cacheSourceMapPath)) { + fs.unlinkSync(cacheSourceMapPath); + } + const normalizedPath: string = path.normalize(projectConfig.aceProfilePath); + const fullPath: string = path.join(normalizedPath, '../../../module.json'); + if (fs.existsSync(fullPath)) { + const rawData: string = fs.readFileSync(fullPath, 'utf8'); + const jsonData: object = JSON.parse(rawData); + if (jsonData?.module) { + jsonData.module.hasInsightIntent = this.intentData.length > 0 ? true : undefined; + } + const updatedJson: string = JSON.stringify(jsonData, null, 2); + fs.writeFileSync(fullPath, updatedJson, 'utf8'); + } + } catch (e) { + throw Error(`${INTERNAL_ERROR}, writeFile failed: ${e}`); + } + } + + processIntentData(): object { if (!projectConfig.aceProfilePath) { throw Error(`${INTERNAL_ERROR.toString()}, aceProfilePath not found, invalidDecoratorPath: ${this.currentFilePath}`); } - const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'insight_intent.json'); - const cachePath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); + const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'insight_intent.json'); // The user's intents configuration file + const cachePath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); // Compiled cache file if (!fs.existsSync(projectConfig.aceProfilePath)) { fs.mkdirSync(projectConfig.aceProfilePath, {recursive: true}); } @@ -1018,23 +1045,7 @@ class ParseIntent { }); } this.validateIntentIntentName(writeJsonData); - if (this.intentData.length > 0) { - fs.writeFileSync(cacheSourceMapPath, JSON.stringify(writeJsonData, null, 2), 'utf-8'); - fs.writeFileSync(cachePath, JSON.stringify({'extractInsightIntents': this.intentData}, null, 2), 'utf-8'); - } else if (fs.existsSync(cacheSourceMapPath)) { - fs.unlinkSync(cacheSourceMapPath); - } - const normalizedPath: string = path.normalize(projectConfig.aceProfilePath); - const fullPath: string = path.join(normalizedPath, '../../../module.json'); - if (fs.existsSync(fullPath)) { - const rawData: string = fs.readFileSync(fullPath, 'utf8'); - const jsonData: object = JSON.parse(rawData); - if (jsonData?.module) { - jsonData.module.hasInsightIntent = this.intentData.length > 0 ? true : undefined; - } - const updatedJson: string = JSON.stringify(jsonData, null, 2); - fs.writeFileSync(fullPath, updatedJson, 'utf8'); - } + return writeJsonData; } validateIntentIntentName(writeJsonData: object): void { -- Gitee From ae95d2298b05931c879c91b5d40d7d5d23ad7a07 Mon Sep 17 00:00:00 2001 From: shitao Date: Sat, 7 Jun 2025 13:59:36 +0800 Subject: [PATCH 093/140] Error of no sourcemap no file Issue: ICDBLD Signed-off-by: shitao Change-Id: I49fbbf8733674547dc4ec6bbe7a067d71efef551 --- .../ark_compiler/generate_sourcemap.ts | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index 522df4094..28862e9c0 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -328,15 +328,29 @@ export class SourceMapGenerator { stopEvent(eventWriteCachedSourceMaps); } + public checkAndWriteEnd(): void { + if (!this.isFirstAppend) { + this.writeOrigin('\n}'); + } + //no collect sourcemap + if (!fs.existsSync(this.sourceMapPath)) { + this.writeOrigin('{}'); + } + if (!fs.existsSync(this.sourceMapPathTmp)) { + this.writeTemp(''); + } + this.closeFd(); + if (fs.existsSync(this.cacheSourceMapPath)) { + fs.unlinkSync(this.cacheSourceMapPath); + } + fs.renameSync(this.sourceMapPathTmp, this.cacheSourceMapPath); + } + public async writeUsedAndUnmodifiedSourceMapToFile(parentEvent: CompileEvent | undefined): Promise { const eventMergeCachedSourceMaps = createAndStartEvent(parentEvent, 'merge cached source maps'); let cacheSourceMapInfo: Object = this.getCacheSourceMapInfo(); if (!cacheSourceMapInfo.exist) { - if (!this.isFirstAppend) { - this.writeOrigin('\n}'); - } - this.closeFd(); - fs.renameSync(this.sourceMapPathTmp, this.cacheSourceMapPath); + this.checkAndWriteEnd(); stopEvent(eventMergeCachedSourceMaps); return; } @@ -361,17 +375,15 @@ export class SourceMapGenerator { this.writeTemp(`\n${this.formatTemp(smObj.key, smObj.val)}`); } } - if (!this.isFirstAppend) { - this.writeOrigin('\n}'); - } - this.closeFd(); - fs.unlinkSync(this.cacheSourceMapPath); - fs.renameSync(this.sourceMapPathTmp, this.cacheSourceMapPath); + this.checkAndWriteEnd(); })(); stopEvent(eventMergeCachedSourceMaps); } public buildModuleSourceMapInfoSingle(parentEvent: CompileEvent | undefined): void { + if (this.projectConfig.widgetCompile) { + return; + } if (!this.isCompileSingle) { return; } @@ -382,14 +394,6 @@ export class SourceMapGenerator { } public buildModuleSourceMapInfo(parentEvent: CompileEvent | undefined): void { - if (this.isCompileSingle) { - this.writeUsedAndUnmodifiedSourceMapToFile(parentEvent); - } else { - this.buildModuleSourceMapInfoAll(parentEvent); - } - } - - public buildModuleSourceMapInfoAll(parentEvent: CompileEvent | undefined): void { if (this.projectConfig.widgetCompile) { return; } -- Gitee From a06e70dcfbcabed24b4b1d98a7714985f886c9c7 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Tue, 10 Jun 2025 09:49:38 +0800 Subject: [PATCH 094/140] jiangbo91@huawei.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 静态检查修复 Signed-off-by: Bojiang Change-Id: I7a868962ffc23b3fd822b3096e268fe45a22f64e --- compiler/src/process_component_build.ts | 4 ++-- compiler/src/validate_ui_syntax.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 670b5cb0a..1a9cabc42 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -2774,7 +2774,7 @@ class StyleResult { } function isDoubleBind(styleResult: StyleResult, isStylesAttr: boolean, identifierNode: ts.Identifier, - propName: string, temp: any): boolean { + propName: string, temp: ts.CallExpression): boolean { if (isDoubleDollarToChange(isStylesAttr, identifierNode, propName, temp)) { styleResult.doubleDollar = true; return true; @@ -3053,7 +3053,7 @@ function classifyArgumentsNum(args, argumentsArr: ts.Expression[], propName: str } } -function classifyArgumentsNumV2(args: any, argumentsArr: ts.Expression[], propName: string, +function classifyArgumentsNumV2(args: ts.Expression[], argumentsArr: ts.Expression[], propName: string, identifierNode: ts.Identifier): void { const componentName: string = identifierNode.escapedText.toString(); if (STYLE_ADD_DOUBLE_EXCLAMATION.has(propName) && args.length || diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index cbb3844a7..4543facef 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -1337,7 +1337,7 @@ function isNonspecificChildBlock(blockNode: ts.Block, specificChildSet: Set Date: Fri, 6 Jun 2025 00:04:15 +0800 Subject: [PATCH 095/140] Check obj not empty Issue: ICCZQ4 Signed-off-by: shitao Change-Id: I1d5a5fa78a66f5f225aec559a9d17287fc794432 --- compiler/src/ark_utils.ts | 3 +- .../module/ohmUrl/ohmUrl.test.ts | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index 52bba5f82..3adf3e710 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -452,7 +452,8 @@ export function getNormalizedOhmUrlByAliasName(aliasName: string, projectConfig: export function getOhmUrlByByteCodeHar(moduleRequest: string, projectConfig: Object, rollupObject: Object, logger?: Object): string | undefined { - if (projectConfig.byteCodeHarInfo) { + if (projectConfig.useNormalizedOHMUrl && + projectConfig.byteCodeHarInfo && Object.keys(projectConfig.byteCodeHarInfo).length > 0) { const moduleInfoByModuleRequest: Object = rollupObject.share?.importResolver?.(moduleRequest); if (moduleInfoByModuleRequest) { return getNormalizedOhmUrlByModuleRequest(moduleInfoByModuleRequest, projectConfig, logger); diff --git a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts index fb70f5f06..4b0fe6851 100644 --- a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts +++ b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts @@ -1323,6 +1323,44 @@ mocha.describe('generate ohmUrl', function () { loggerStub.restore(); }); + mocha.it('the error message of processPackageDir when useNormalizedOHMUrl is false', function () { + this.rollup.build(); + this.rollup.share.projectConfig.useNormalizedOHMUrl = false; + this.rollup.share.projectConfig.byteCodeHarInfo = {}; + const indexFilePath: string = 'Hsp/////'; + const importerFile: string = '/testHap/entry/src/main/ets/pages/index.ets'; + const importByPkgName = 'Hsp/////'; + for (let file of [indexFilePath]) { + const moduleInfo = { + id: file, + meta: { + hostDependencyName: 'Hsp/////', + hostModuleName: 'entry' + } + } + this.rollup.moduleInfos.push(moduleInfo); + } + + const errInfo: LogData = LogDataFactory.newInstance( + ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, + ArkTSErrorDescription, + 'Failed to resolve OhmUrl. ' + + `Failed to get a resolved OhmUrl for "${indexFilePath}" imported by "${importerFile}".`, + '', + [`Check whether the module which ${indexFilePath} belongs to is correctly configured.`, + `Check if the corresponding file name "${indexFilePath}" is correct(including case-sensitivity).`] + ); + const logger = CommonLogger.getInstance(this.rollup); + const loggerStub = sinon.stub(logger.getLoggerFromErrorCode(errInfo.code), 'printError'); + + const moduleSourceFile: string = new ModuleSourceFile(); + ModuleSourceFile.initPluginEnv(this.rollup); + moduleSourceFile.getOhmUrl(this.rollup, importByPkgName, indexFilePath, importerFile); + + expect(loggerStub.getCall(0).calledWithMatch(errInfo)).to.be.true; + loggerStub.restore(); + }); + mocha.it('the error message of getNormalizedOhmUrlByAliasName', function () { this.rollup.build(); this.rollup.share.projectConfig.useNormalizedOHMUrl = true; -- Gitee From 566fcb3e360cfc116d1fd5a4c7b41675ff8dfabd Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Sat, 7 Jun 2025 18:39:09 +0800 Subject: [PATCH 096/140] =?UTF-8?q?=E6=98=93=E7=94=A8=E6=80=A7result=20bug?= =?UTF-8?q?fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/userIntents_parser/parseUserIntents.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index 1554f107e..572579f49 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -873,6 +873,8 @@ class ParseIntent { intentObj.llmDescription = schemaObj.llmDescription; intentObj.keywords = schemaObj.keywords; intentObj.intentName = schemaObj.intentName; + intentObj.result = schemaObj.result; + intentObj.example = schemaObj.example; } } } -- Gitee From 9270c580577a27ef4701aca38bbe8aded9d21240 Mon Sep 17 00:00:00 2001 From: Yenan Date: Tue, 10 Jun 2025 21:13:43 +0800 Subject: [PATCH 097/140] =?UTF-8?q?Consume=E8=A3=85=E9=A5=B0=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E6=94=AF=E6=8C=81=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- compiler/src/process_component_member.ts | 15 +- .../@consume_with_defaultValue.js.sample | 201 ++++++++++++++++++ .../@consume_with_defaultValue.ets | 58 +++++ .../validateForbiddenSpecifyDefaultValue.ets | 54 +++++ .../test/transform_ut/helpers/pathConfig.ts | 2 + compiler/test/transform_ut_error.json | 14 ++ 6 files changed, 340 insertions(+), 4 deletions(-) create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.js.sample create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.ets create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/process_component_member/validateForbiddenSpecifyDefaultValue.ets diff --git a/compiler/src/process_component_member.ts b/compiler/src/process_component_member.ts index dc65a1c1c..c41bcda12 100644 --- a/compiler/src/process_component_member.ts +++ b/compiler/src/process_component_member.ts @@ -147,7 +147,7 @@ export const requireCanReleaseMandatoryDecorators: Set = ...observedPropertyDecorators]); export const forbiddenSpecifyDefaultValueDecorators: Set = - new Set([COMPONENT_LINK_DECORATOR, COMPONENT_CONSUME_DECORATOR, COMPONENT_OBJECT_LINK_DECORATOR]); + new Set([COMPONENT_LINK_DECORATOR, COMPONENT_OBJECT_LINK_DECORATOR]); export const mandatoryToInitViaParamDecorators: Set = new Set([...propAndLinkDecorators, COMPONENT_OBJECT_LINK_DECORATOR]); @@ -872,12 +872,19 @@ function updateConsumeProperty(node: ts.PropertyDeclaration, } else { propertyOrAliasName = name; } + // '4' means that the property has aliasName and '2' represents the argument node + const callExpressionArgs: readonly ts.Expression[] | undefined = + node.initializer ? [ + propertyAndStringKey.length === 0 ? ts.factory.createStringLiteral(propertyOrAliasName) : + propertyAndStringKey.length === 4 && propertyAndStringKey[2] as ts.Expression, ts.factory.createStringLiteral(name), + node.initializer] : + [ + propertyAndStringKey.length === 0 ? ts.factory.createStringLiteral(propertyOrAliasName) : + propertyAndStringKey.length === 4 && propertyAndStringKey[2] as ts.Expression, ts.factory.createStringLiteral(name)]; return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression( createPropertyAccessExpressionWithThis(`__${name}`), ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createCallExpression( - createPropertyAccessExpressionWithThis(INITIALIZE_CONSUME_FUNCTION), undefined, [ - propertyAndStringKey.length === 0 ? ts.factory.createStringLiteral(propertyOrAliasName) : - propertyAndStringKey.length === 4 && propertyAndStringKey[2] as ts.Expression, ts.factory.createStringLiteral(name)]))); + createPropertyAccessExpressionWithThis(INITIALIZE_CONSUME_FUNCTION), undefined, callExpressionArgs))); } function updateBuilderParamProperty(node: ts.PropertyDeclaration, diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.js.sample new file mode 100644 index 000000000..9a71526f6 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.js.sample @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2022-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. + */ +"use strict"; +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +class CompA extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__reviewVotes = new ObservedPropertySimplePU(0, this, "reviewVotes"); + this.addProvidedVar("reviewVote", this.__reviewVotes, false); + this.addProvidedVar("reviewVotes", this.__reviewVotes, false); + this.__message = new ObservedPropertySimplePU('1111', this, "message"); + this.addProvidedVar('aliasName', this.__message, true); + this.addProvidedVar("message", this.__message, true); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + if (params.reviewVotes !== undefined) { + this.reviewVotes = params.reviewVotes; + } + if (params.message !== undefined) { + this.message = params.message; + } + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__reviewVotes.purgeDependencyOnElmtId(rmElmtId); + this.__message.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__reviewVotes.aboutToBeDeleted(); + this.__message.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get reviewVotes() { + return this.__reviewVotes.get(); + } + set reviewVotes(newValue) { + this.__reviewVotes.set(newValue); + } + get message() { + return this.__message.get(); + } + set message(newValue) { + this.__message.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new CompB(this, {}, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.ets", line: 23, col: 7 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return {}; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "CompB" }); + } + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithChild(); + Button.onClick(() => { + this.reviewVotes += 1; + }); + }, Button); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('' + this.reviewVotes); + Text.fontSize(30); + }, Text); + Text.pop(); + Button.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName() { + return "CompA"; + } +} +class CompB extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new CompC(this, {}, undefined, elmtId, () => { }, { page: "test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.ets", line: 39, col: 7 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return {}; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "CompC" }); + } + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +class CompC extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__reviewVotes = this.initializeConsume("reviewVote", "reviewVotes"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__reviewVotes.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__reviewVotes.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get reviewVotes() { + return this.__reviewVotes.get(); + } + set reviewVotes(newValue) { + this.__reviewVotes.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithChild(); + Button.onClick(() => { + this.reviewVotes += 1; + }); + }, Button); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('' + this.reviewVotes); + Text.fontSize(30); + }, Text); + Text.pop(); + Button.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +registerNamedRoute(() => new CompA(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue", integratedHsp: "false", moduleType: "followWithHap" }); +//# sourceMappingURL=@consume_with_defaultValue.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.ets new file mode 100644 index 000000000..5c5da8217 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022-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. + */ +@Entry +@Component +struct CompA { + @Provide("reviewVote") reviewVotes : number = 0; + @Provide({allowOverride: 'aliasName'}) message: string = '1111' + + build() { + Column() { + CompB() + Button() { + Text('' + this.reviewVotes) + .fontSize(30) + } + .onClick(() => { + this.reviewVotes += 1; + }) + } + } +} + +@Component +struct CompB { + build() { + Column() { + CompC() + } + } +} + +@Component +struct CompC { + @Consume("reviewVote") reviewVotes : number = 15; + build() { + Column() { + Button() { + Text('' + this.reviewVotes) + .fontSize(30) + } + .onClick(() => { + this.reviewVotes += 1; + }) + } + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/process_component_member/validateForbiddenSpecifyDefaultValue.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/process_component_member/validateForbiddenSpecifyDefaultValue.ets new file mode 100644 index 000000000..65664138a --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForValidate/Decorators/process_component_member/validateForbiddenSpecifyDefaultValue.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022-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. + */ + // To validate the rule that variables decorated by specified decorators can not have default value + @Observed + class Info { + public info: number =0; + + constructor(info: number) { + this.info = info; + } + } + + @Component + struct child { + @Consume('trial') bulubulu: string = 'bulubulu'; + @Link linkProperty : number = 4; + @ObjectLink objectProperty: Info = new Info(32); + + build(){ + Row(){ + Text(this.bulubulu) + } + } + } + + @Entry + @Component + struct parent { + @State stateProperty: number = 6; + @Provide provideProperty: Info = new Info(33); + + build(){ + Row(){ + child({ + linkProperty:this.stateProperty, + objectProperty:this.provideProperty + }) + Blank() + Text(this.stateProperty) + } + } + } \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/pathConfig.ts b/compiler/test/transform_ut/helpers/pathConfig.ts index 9ed688e8a..936ccfdc3 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -178,6 +178,7 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'ui_state_management/inner_struct_state_management/@state/@state', 'ui_state_management/inner_struct_state_management/@state/@state1', 'ui_state_management/others/@consume_@provide/@consume_@provide', + 'ui_state_management/others/@consume_@provide/@consume_with_defaultValue', 'ui_state_management/others/@observed_@objectLink/@observed_@objectLink', 'ui_state_management/others/@observed_@objectLink/@observed_@objectLink1', 'ui_state_management/others/@watch/@watch', @@ -244,6 +245,7 @@ export const UT_VALIDATE_PAGES: string[] = [ 'Decorators/process_component_member/updateBuilderParamProperty', 'Decorators/process_component_member/validateCustomDecorator', 'Decorators/process_component_member/validateDuplicateDecorator', + 'Decorators/process_component_member/validateForbiddenSpecifyDefaultValue', 'Decorators/process_component_member/validateForbiddenUseStateType', 'Decorators/process_component_member/validateHasIllegalDecoratorInEntry', 'Decorators/process_component_member/validateHasIllegalQuestionToken', diff --git a/compiler/test/transform_ut_error.json b/compiler/test/transform_ut_error.json index a6a0320c0..c799dbb29 100644 --- a/compiler/test/transform_ut_error.json +++ b/compiler/test/transform_ut_error.json @@ -157,6 +157,20 @@ "type": "ERROR", "code": "10905311" }, + "validateForbiddenSpecifyDefaultValue": [ + { + "message": "The '@Link' property cannot be specified a default value.", + "type": "ERROR", + "code": "10905304", + "solutions": ["Please initialize the rules according to the decorator."] + }, + { + "message": "The '@ObjectLink' property cannot be specified a default value.", + "type": "ERROR", + "code": "10905304", + "solutions": ["Please initialize the rules according to the decorator."] + } + ], "validateCustomDecorator": { "message": "The inner decorator '@State' cannot be used together with custom decorator.", "type": "ERROR", -- Gitee From 3cb5505a01504ceb2ff625cced01669a9b8af31b Mon Sep 17 00:00:00 2001 From: yangcan Date: Thu, 12 Jun 2025 14:34:49 +0800 Subject: [PATCH 098/140] =?UTF-8?q?=E5=88=A0=E9=99=A4linearindicator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangcan Change-Id: I8eec2811be1d4c3dd73c8b9db0d6b9f0dacb64f4 --- compiler/build_declarations_file.js | 2 +- compiler/components/linearindicator.json | 7 ------- compiler/tsconfig.esm.json | 6 ------ compiler/tsconfig.json | 6 ------ 4 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 compiler/components/linearindicator.json diff --git a/compiler/build_declarations_file.js b/compiler/build_declarations_file.js index 695d29691..ad2bb05fd 100644 --- a/compiler/build_declarations_file.js +++ b/compiler/build_declarations_file.js @@ -23,7 +23,7 @@ const addTSInterfaceSet = ['ForEach', 'LazyForEach', 'TapGesture', 'LongPressGes const addTSAttributeSet = ['AlphabetIndexer', 'Animator', 'Badge', 'Blank', 'Button', 'Calendar', 'CalendarPicker', 'Canvas', 'Checkbox', 'CheckboxGroup', 'Circle', 'Column', 'ColumnSplit', 'Counter', 'DataPanel', 'DatePicker', 'Divider', 'Ellipse', 'Flex', 'FormComponent', 'Gauge', 'Grid', 'GridItem', 'GridContainer', 'Image', - 'ImageAnimator', 'IndicatorComponent', 'LazyVGridLayout', 'Line', 'LinearIndicator', + 'ImageAnimator', 'IndicatorComponent', 'LazyVGridLayout', 'Line', 'List', 'ListItem', 'ListItemGroup', 'LoadingProgress', 'Marquee', 'Navigation', 'Navigator', 'Panel', 'Path', 'PatternLock', 'Piece', 'PluginComponent', 'Polygon', 'Polyline', 'Progress', 'QRCode', 'Radio', 'Rating', 'Rect', 'Refresh', 'Row', 'RowSplit', 'Scroll', 'ScrollBar', 'Search', diff --git a/compiler/components/linearindicator.json b/compiler/components/linearindicator.json deleted file mode 100644 index 7a6672ff2..000000000 --- a/compiler/components/linearindicator.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "LinearIndicator", - "atomic": true, - "attrs": [ - "indicatorStyle", "indicatorLoop", "onChange" - ] -} \ No newline at end of file diff --git a/compiler/tsconfig.esm.json b/compiler/tsconfig.esm.json index 2e20f130e..fb496acd6 100755 --- a/compiler/tsconfig.esm.json +++ b/compiler/tsconfig.esm.json @@ -199,7 +199,6 @@ "IndicatorComponent", "LazyVGridLayout", "Line", - "LinearIndicator", "List", "ListItem", "ListItemGroup", @@ -486,11 +485,6 @@ "type": "LineAttribute", "instance": "LineInstance" }, - { - "name": "LinearIndicator", - "type": "LinearIndicatorAttribute", - "instance": "LinearIndicatorInstance" - }, { "name": "List", "type": "ListAttribute", diff --git a/compiler/tsconfig.json b/compiler/tsconfig.json index 96c81984e..98511d623 100644 --- a/compiler/tsconfig.json +++ b/compiler/tsconfig.json @@ -202,7 +202,6 @@ "IndicatorComponent", "LazyVGridLayout", "Line", - "LinearIndicator", "List", "ListItem", "ListItemGroup", @@ -505,11 +504,6 @@ "type": "LineAttribute", "instance": "LineInstance" }, - { - "name": "LinearIndicator", - "type": "LinearIndicatorAttribute", - "instance": "LinearIndicatorInstance" - }, { "name": "List", "type": "ListAttribute", -- Gitee From 2340aa9a297cd947a83b74b6ab5c4a3a8763df27 Mon Sep 17 00:00:00 2001 From: Yenan Date: Thu, 12 Jun 2025 17:47:52 +0800 Subject: [PATCH 099/140] =?UTF-8?q?Consume=E8=A3=85=E9=A5=B0=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E6=94=AF=E6=8C=81=E9=BB=98=E8=AE=A4=E5=80=BCUT?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yenan --- .../@consume_@provide/@consume_with_defaultValue.js.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.js.sample index 9a71526f6..4da6762d5 100644 --- a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.js.sample +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_with_defaultValue.js.sample @@ -153,7 +153,7 @@ class CompC extends ViewPU { if (typeof paramsLambda === "function") { this.paramsGenerator_ = paramsLambda; } - this.__reviewVotes = this.initializeConsume("reviewVote", "reviewVotes"); + this.__reviewVotes = this.initializeConsume("reviewVote", "reviewVotes", 15); this.setInitiallyProvidedValue(params); this.finalizeConstruction(); } -- Gitee From a39355d49ef0919ddfc763b4791fc4de3f938d0c Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Mon, 9 Jun 2025 21:20:36 +0800 Subject: [PATCH 100/140] =?UTF-8?q?=E4=B8=8B=E6=B2=89=E6=84=8F=E5=9B=BETop?= =?UTF-8?q?10JSONSchema=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../userIntents_parser/parseUserIntents.ts | 2 +- .../schema/ControlPlayback_1.0.1.json | 27 ++- .../schema/PlayVideo_1.0.2.json | 61 +++++++ .../schema/RechargeCallFee_1.0.1.json | 48 ++++++ .../schema/RideHailing_1.0.2.json | 134 +++++++++++++++ .../schema/SendLogistics_1.0.1.json | 43 +++++ .../schema/StartNavigate_1.0.1.json | 157 ++++++++++++++++++ .../schema/ViewFlightTicket_1.0.1.json | 57 +++++++ .../schema/ViewLogistics_1.0.1.json | 50 ++++++ .../schema/ViewMap_1.0.1.json | 49 ++++++ .../schema/ViewTrainTicket_1.0.1.json | 64 +++++++ .../schema/ViewTravelCardCode_1.0.1.json | 52 ++++++ 12 files changed, 741 insertions(+), 3 deletions(-) create mode 100644 compiler/src/userIntents_parser/schema/PlayVideo_1.0.2.json create mode 100644 compiler/src/userIntents_parser/schema/RechargeCallFee_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/RideHailing_1.0.2.json create mode 100644 compiler/src/userIntents_parser/schema/SendLogistics_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/StartNavigate_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewFlightTicket_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewLogistics_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewMap_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewTrainTicket_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewTravelCardCode_1.0.1.json diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index 1554f107e..a5c970a40 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -869,7 +869,7 @@ class ParseIntent { if (fs.existsSync(schemaPath)) { const schemaContent: string = fs.readFileSync(schemaPath, 'utf-8'); const schemaObj: object = JSON.parse(schemaContent); - intentObj.parameters = schemaObj.params; + intentObj.parameters = schemaObj.parameters; intentObj.llmDescription = schemaObj.llmDescription; intentObj.keywords = schemaObj.keywords; intentObj.intentName = schemaObj.intentName; diff --git a/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json b/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json index 4619ef885..fa749ead2 100644 --- a/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json +++ b/compiler/src/userIntents_parser/schema/ControlPlayback_1.0.1.json @@ -3,7 +3,7 @@ "intentVersion": "1.0.1", "llmDescription": "播放音乐控制", "keywords": ["ControlPlayback"], - "params": { + "parameters": { "type": "object", "propertyNames": { "enum": [ @@ -37,9 +37,32 @@ ] }, "playbackProgress": { - "description": "播放进度,单位秒", + "description": "播放进度,单位秒。", "type": "number" } } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } } } diff --git a/compiler/src/userIntents_parser/schema/PlayVideo_1.0.2.json b/compiler/src/userIntents_parser/schema/PlayVideo_1.0.2.json new file mode 100644 index 000000000..3f556732c --- /dev/null +++ b/compiler/src/userIntents_parser/schema/PlayVideo_1.0.2.json @@ -0,0 +1,61 @@ +{ + "intentName": "PlayVideo", + "intentVersion": "1.0.2", + "llmDescription": "播放视频", + "keywords": ["PlayVideo"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "episodeId", + "episodeNumber", + "extras" + ] + }, + "required": [ + "entityId" + ], + "properties": { + "entityId": { + "description": "视频的唯一实体id。", + "type": "string" + }, + "episodeId": { + "description": "集数的唯一标识。", + "type": "string" + }, + "episodeNumber": { + "description": "视频的目标集数。", + "type": "number" + }, + "extras": { + "description": "其他信息扩展参数,具体由接入业务定义。", + "type": "object" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/RechargeCallFee_1.0.1.json b/compiler/src/userIntents_parser/schema/RechargeCallFee_1.0.1.json new file mode 100644 index 000000000..a66663a6e --- /dev/null +++ b/compiler/src/userIntents_parser/schema/RechargeCallFee_1.0.1.json @@ -0,0 +1,48 @@ +{ + "intentName": "RechargeCallFee", + "intentVersion": "1.0.1", + "llmDescription": "充值话费", + "keywords": ["RechargeCallFee"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "phoneNumber", + "amount" + ] + }, + "properties": { + "phoneNumber": { + "description": "手机号", + "type": "number" + }, + "amount": { + "description": "金额", + "type": "number" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "返回结果列表对象(列表Key名默认items),如果无内容则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/RideHailing_1.0.2.json b/compiler/src/userIntents_parser/schema/RideHailing_1.0.2.json new file mode 100644 index 000000000..19583d8ba --- /dev/null +++ b/compiler/src/userIntents_parser/schema/RideHailing_1.0.2.json @@ -0,0 +1,134 @@ +{ + "intentName": "RideHailing", + "intentVersion": "1.0.2", + "llmDescription": "开始打车", + "keywords": ["RideHailing"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "srcLocation", + "dstLocation", + "dstLocationType", + "hwChannelId", + "taxiType" + ] + }, + "properties": { + "entityId": { + "description": "视频的唯一实体id。", + "type": "string" + }, + "srcLocation": { + "description": "出发地信息,包括坐标系(缺省默认GCJ02),poi唯一标识,地点名称,经纬度,详细地址信息。", + "type": "object", + "properties": { + "poiId": { + "description": "唯一标识", + "type": "string" + }, + "locationName": { + "description": "地点名称", + "type": "string" + }, + "locationSystem": { + "description": "指定坐标系,(默认使用中国火星坐标系GCJ02)。", + "type": "string" + }, + "longitude": { + "description": "经度", + "type": "string" + }, + "latitude": { + "description": "纬度", + "type": "string" + }, + "address": { + "description": "详细地址信息", + "type": "string" + } + } + }, + "dstLocation": { + "description": "目的地的信息,包括坐标系(缺省默认GCJ02),poi的唯一标识,地点名称,经纬度,详细地址信息。", + "type": "object", + "properties": { + "poiId": { + "description": "唯一标识", + "type": "string" + }, + "locationName": { + "description": "地点名称", + "type": "string" + }, + "locationSystem": { + "description": "指定坐标系,(默认使用中国火星坐标系GCJ02)。", + "type": "string" + }, + "longitude": { + "description": "经度", + "type": "string" + }, + "latitude": { + "description": "纬度", + "type": "string" + }, + "address": { + "description": "详细地址信息", + "type": "string" + } + } + }, + "dstLocationType": { + "description": "目的地类型,比如'家'、'公司'。", + "type": "string" + }, + "hwChannelId": { + "description": "标识入口的渠道标识,0x00000100:小艺建议,0x00000200:小艺语音,0x00000300:拖拽入口。", + "type": "string", + "enum": [ + "0x00000100", + "0x00000200", + "0x00000300" + ] + }, + "taxiType": { + "description": "车型,0:默认,1:快车,2:出租车,3:拼车,4:顺风车,5:专车。", + "type": "number", + "default": 0, + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ] + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/SendLogistics_1.0.1.json b/compiler/src/userIntents_parser/schema/SendLogistics_1.0.1.json new file mode 100644 index 000000000..2e5b6a7c9 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/SendLogistics_1.0.1.json @@ -0,0 +1,43 @@ +{ + "intentName": "SendLogistics", + "intentVersion": "1.0.1", + "llmDescription": "寄快递", + "keywords": ["SendLogistics"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "sendContent" + ] + }, + "properties": { + "sendContent": { + "description": "寄件信息。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "返回结果列表对象(列表Key名默认items),如果无内容则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/StartNavigate_1.0.1.json b/compiler/src/userIntents_parser/schema/StartNavigate_1.0.1.json new file mode 100644 index 000000000..53a888639 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/StartNavigate_1.0.1.json @@ -0,0 +1,157 @@ +{ + "intentName": "StartNavigate", + "intentVersion": "1.0.1", + "llmDescription": "出行导航", + "keywords": ["StartNavigate"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "srcLocation", + "dstLocation", + "wayPoints", + "dstLocationType", + "trafficType" + ] + }, + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "string" + }, + "srcLocation": { + "description": "出发地信息,包括坐标系(缺省默认GCJ02),poi唯一标识,地点名称,经纬度,详细地址信息。", + "type": "object", + "properties": { + "poiId": { + "description": "唯一标识", + "type": "string" + }, + "locationName": { + "description": "地点名称", + "type": "string" + }, + "locationSystem": { + "description": "指定坐标系,(默认使用中国火星坐标系GCJ02)。", + "type": "string" + }, + "longitude": { + "description": "经度", + "type": "string" + }, + "latitude": { + "description": "纬度", + "type": "string" + }, + "address": { + "description": "详细地址信息。", + "type": "string" + } + } + }, + "dstLocation": { + "description": "目的地的信息,包括坐标系(缺省默认GCJ02),poi的唯一标识,地点名称,经纬度,详细地址信息。", + "type": "object", + "properties": { + "poiId": { + "description": "唯一标识", + "type": "string" + }, + "locationName": { + "description": "地点名称", + "type": "string" + }, + "locationSystem": { + "description": "指定坐标系,(默认使用中国火星坐标系GCJ02)。", + "type": "string" + }, + "longitude": { + "description": "经度", + "type": "string" + }, + "latitude": { + "description": "纬度", + "type": "string" + }, + "address": { + "description": "详细地址信息", + "type": "string" + } + } + }, + "wayPoints": { + "description": "途经点列表,最多传5个。", + "type": "array", + "items": { + "type": "object", + "properties": { + "poiId": { + "description": "唯一标识", + "type": "string" + }, + "locationName": { + "description": "地点名称", + "type": "string" + }, + "locationSystem": { + "description": "坐标系", + "type": "string" + }, + "longitude": { + "description": "经度", + "type": "string" + }, + "latitude": { + "description": "纬度", + "type": "string" + }, + "address": { + "description": "详细地址信息", + "type": "string" + } + } + } + }, + "dstLocationType": { + "description": "目的地类型,比如'家'、'公司'。", + "type": "string" + }, + "trafficType": { + "description": "交通方式(类型),包括驾车、步行、骑行、公交地铁。", + "type": "string", + "enum": [ + "Drive", + "Walk", + "Cycle", + "Bus", + "Subway" + ], + "default":"Drive" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewFlightTicket_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewFlightTicket_1.0.1.json new file mode 100644 index 000000000..43d22c690 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewFlightTicket_1.0.1.json @@ -0,0 +1,57 @@ +{ + "intentName": "ViewFlightTicket", + "intentVersion": "1.0.1", + "llmDescription": "查看机票", + "keywords": ["ViewFlightTicket"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "cabin" + ] + }, + "required": [ + "entityId" + ], + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "number" + }, + "cabin": { + "description": "舱位:经济舱、头等舱、公务舱、超级经济舱。", + "type": "string", + "enum": [ + "经济舱", + "头等舱", + "公务舱", + "超级经济舱" + ] + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewLogistics_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewLogistics_1.0.1.json new file mode 100644 index 000000000..efe5fac4d --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewLogistics_1.0.1.json @@ -0,0 +1,50 @@ +{ + "intentName": "ViewLogistics", + "intentVersion": "1.0.1", + "llmDescription": "查看快递", + "keywords": ["ViewLogistics"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "trackingNo", + "entityId" + ] + }, + "properties": { + "trackingNo": { + "description": "快递单号,空则停留在首页。", + "maxLength": 64, + "type": "string" + }, + "entityId": { + "description": "快递实体ID,查询场景下默认使用该字段回传打开。", + "maxLength": 64, + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "返回结果列表对象(列表Key名默认items),如果无内容则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewMap_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewMap_1.0.1.json new file mode 100644 index 000000000..61e8833e7 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewMap_1.0.1.json @@ -0,0 +1,49 @@ +{ + "intentName": "ViewMap", + "intentVersion": "1.0.1", + "llmDescription": "查看地图", + "keywords": ["ViewMap"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "mapType" + ] + }, + "properties": { + "mapType": { + "description": "地图类型,枚举,Satellite:卫星地图,Standard:标准地图(默认),3D:3D地图。", + "type": "string", + "enum": [ + "Satellite", + "Standard", + "3D" + ], + "default": "Standard" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewTrainTicket_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewTrainTicket_1.0.1.json new file mode 100644 index 000000000..61f935f9a --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewTrainTicket_1.0.1.json @@ -0,0 +1,64 @@ +{ + "intentName": "ViewTrainTicket", + "intentVersion": "1.0.1", + "llmDescription": "查看火车票", + "keywords": ["ViewTrainTicket"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "seatLevelShow" + ] + }, + "required": [ + "entityId" + ], + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "number" + }, + "seatLevelShow": { + "description": "座位类型", + "type": "string", + "enum": [ + "二等座", + "二等卧", + "一等座", + "一等卧", + "商务座", + "硬座", + "软座", + "硬卧", + "软卧", + "高软", + "无座" + ] + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewTravelCardCode_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewTravelCardCode_1.0.1.json new file mode 100644 index 000000000..2bfc0204d --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewTravelCardCode_1.0.1.json @@ -0,0 +1,52 @@ +{ + "intentName": "ViewTravelCardCode", + "intentVersion": "1.0.1", + "llmDescription": "查看乘车码", + "keywords": ["ViewTravelCardCode"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "travelCardType", + "adminCode" + ] + }, + "properties": { + "travelCardType": { + "description": "缺省上次用户查看(由APP自行实现逻辑),枚举,Metro:地铁,Bus:公交。", + "type": "string", + "enum": [ + "Metro", + "Bus" + ] + }, + "adminCode": { + "description": "用户所在城市(未传时默认为APP自行获取用户当前位置城市),使用中国城市编码,定义参考https://developer.huawei.com/consumer/cn/doc/HMSCore-References/city-code-value-0000001540077092。", + "type": "number" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} -- Gitee From 07002d44d4e63ed9f724e1623badc839b6c59535 Mon Sep 17 00:00:00 2001 From: seaside_wu Date: Fri, 13 Jun 2025 17:57:44 +0800 Subject: [PATCH 101/140] add uiplugin package-lock Signed-off-by: seaside_wu Change-Id: I61e3794f2aa8ccc91b455fcbcad2f93dad6464a6 --- arkui-plugins/package-lock.json | 5871 +++++++++++++++++++++++++++++++ koala-wrapper/package-lock.json | 2730 ++++++++++++++ 2 files changed, 8601 insertions(+) create mode 100644 arkui-plugins/package-lock.json create mode 100644 koala-wrapper/package-lock.json diff --git a/arkui-plugins/package-lock.json b/arkui-plugins/package-lock.json new file mode 100644 index 000000000..ec5de14b4 --- /dev/null +++ b/arkui-plugins/package-lock.json @@ -0,0 +1,5871 @@ +{ + "name": "arkui-plugin", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "arkui-plugin", + "version": "1.0.0", + "workspaces": [ + "./test" + ], + "dependencies": { + "@koalaui/libarkts": "../koala-wrapper" + }, + "devDependencies": { + "@babel/cli": "7.20.7", + "@babel/core": "7.20.12", + "@babel/plugin-proposal-class-properties": "7.18.6", + "@babel/preset-env": "7.20.2", + "@babel/preset-typescript": "7.18.6", + "@babel/runtime": "7.20.13", + "@types/jest": "^29.5.14", + "@types/node": "^22.13.9", + "jest": "^29.7.0", + "ts-jest": "^29.2.0", + "ts-node": "^10.9.0", + "typescript": "^5.0.0" + } + }, + "../koala-wrapper": { + "name": "@koalaui/libarkts", + "version": "1.0.0", + "devDependencies": { + "@babel/cli": "7.20.7", + "@babel/core": "7.20.12", + "@babel/plugin-proposal-class-properties": "7.18.6", + "@babel/preset-env": "7.20.2", + "@babel/preset-typescript": "7.18.6", + "@babel/runtime": "7.20.13", + "@tsconfig/recommended": "1.0.8", + "@types/node": "^18.0.0", + "node-addon-api": "^8.3.0", + "typescript": "^5.0.0" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/cli": { + "version": "7.20.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/cli/-/cli-7.20.7.tgz", + "integrity": "sha512-WylgcELHB66WwQqItxNILsMlaTd8/SO6SgTTjMp4uCI7P4QyH1r3nqgFmO3BfM4AtfniHgFMH3EpYFj/zynBkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.8", + "commander": "^4.0.1", + "convert-source-map": "^1.1.0", + "fs-readdir-recursive": "^1.1.0", + "glob": "^7.2.0", + "make-dir": "^2.1.0", + "slash": "^2.0.0" + }, + "bin": { + "babel": "bin/babel.js", + "babel-external-helpers": "bin/babel-external-helpers.js" + }, + "engines": { + "node": ">=6.9.0" + }, + "optionalDependencies": { + "@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents.3", + "chokidar": "^3.4.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.27.1", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/compat-data/-/compat-data-7.27.5.tgz", + "integrity": "sha512-KiRAp/VoJaWkkte84TvUd9qjdbZAdiqyvMxrGl1N6vzFogKmaLgoM3L1kgtLicp2HP5fBJS8JrZKLVIZGVJAVg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.20.12", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/core/-/core-7.20.12.tgz", + "integrity": "sha512-XsMfHovsUYHFMdrIHkZphTN/2Hzzi78R08NuHfDBehym2VsPDL6Zn/JAD/JQdnRvbSsbQc4mVaU1m6JgtTEElg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.1.0", + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.20.7", + "@babel/helper-compilation-targets": "^7.20.7", + "@babel/helper-module-transforms": "^7.20.11", + "@babel/helpers": "^7.20.7", + "@babel/parser": "^7.20.7", + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.20.12", + "@babel/types": "^7.20.7", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.2", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/generator/-/generator-7.27.5.tgz", + "integrity": "sha512-ZGhA37l0e/g2s1Cnzdix0O3aLYm66eF8aufiVteOgnwxgnRP8GoyMj7VWsgWnQbVKXyge7hqrFh2K2TQM6t1Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.27.5", + "@babel/types": "^7.27.3", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.27.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.27.3.tgz", + "integrity": "sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.27.3" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.27.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz", + "integrity": "sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.27.2", + "@babel/helper-validator-option": "^7.27.1", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-create-class-features-plugin": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.27.1.tgz", + "integrity": "sha512-QwGAmuvM17btKU5VqXfb+Giw4JcN0hjuufz3DYnpeVDvZLAObloM77bhMXiqry3Iio+Ai4phVRDwl6WU10+r5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "@babel/helper-member-expression-to-functions": "^7.27.1", + "@babel/helper-optimise-call-expression": "^7.27.1", + "@babel/helper-replace-supers": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1", + "@babel/traverse": "^7.27.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-create-regexp-features-plugin": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.27.1.tgz", + "integrity": "sha512-uVDC72XVf8UbrH5qQTc18Agb8emwjTiZrQE11Nv3CuBEZmVvTwwE9CBUEvHku06gQCAyYf8Nv6ja1IN+6LMbxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "regexpu-core": "^6.2.0", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-define-polyfill-provider": { + "version": "0.3.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz", + "integrity": "sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-compilation-targets": "^7.17.7", + "@babel/helper-plugin-utils": "^7.16.7", + "debug": "^4.1.1", + "lodash.debounce": "^4.0.8", + "resolve": "^1.14.2", + "semver": "^6.1.2" + }, + "peerDependencies": { + "@babel/core": "^7.4.0-0" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.24.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz", + "integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-member-expression-to-functions": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.27.1.tgz", + "integrity": "sha512-E5chM8eWjTp/aNoVpcbfM7mLxu9XGLWYise2eBKGQomAk/Mb4XoxyqXTZbuTohbsl8EKqdlMhnDI2CCLfcs9wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz", + "integrity": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.27.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-module-transforms/-/helper-module-transforms-7.27.3.tgz", + "integrity": "sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1", + "@babel/traverse": "^7.27.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-optimise-call-expression": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.27.1.tgz", + "integrity": "sha512-URMGH08NzYFhubNSGJrpUEphGKQwMQYBySzat5cAByY1/YgIRkULnIy3tAMeszlL/so2HbeilYloUmSpd7GdVw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz", + "integrity": "sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-remap-async-to-generator": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.27.1.tgz", + "integrity": "sha512-7fiA521aVw8lSPeI4ZOD3vRFkoqkJcS+z4hFo82bFSH/2tNd6eJ5qCVMS5OzDmZh/kaHQeBaeyxK6wljcPtveA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "@babel/helper-wrap-function": "^7.27.1", + "@babel/traverse": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-replace-supers": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-replace-supers/-/helper-replace-supers-7.27.1.tgz", + "integrity": "sha512-7EHz6qDZc8RYS5ElPoShMheWvEgERonFCs7IAonWLLUTXW59DP14bCZt89/GKyreYn8g3S83m21FelHKbeDCKA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-member-expression-to-functions": "^7.27.1", + "@babel/helper-optimise-call-expression": "^7.27.1", + "@babel/traverse": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-skip-transparent-expression-wrappers": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.27.1.tgz", + "integrity": "sha512-Tub4ZKEXqbPjXgWLl2+3JpQAYBJ8+ikpQ2Ocj/q/r0LwE3UhENh7EUabyHjz2kCEsrRY83ew2DQdHluuiDQFzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", + "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-wrap-function": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-wrap-function/-/helper-wrap-function-7.27.1.tgz", + "integrity": "sha512-NFJK2sHUvrjo8wAU/nQTWU890/zB2jj0qBcCbZbbf+005cAsv6tMjXz31fBign6M5ov1o0Bllu+9nbqkfsjjJQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.27.1", + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.27.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helpers/-/helpers-7.27.6.tgz", + "integrity": "sha512-muE8Tt8M22638HU31A3CgfSUciwz1fhATfoVai05aPXGor//CdWDCbnlY1yvBPo07njuVOCNGCSp/GTt12lIug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.27.2", + "@babel/types": "^7.27.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/parser/-/parser-7.27.5.tgz", + "integrity": "sha512-OsQd175SxWkGlzbny8J3K8TnnDD0N3lrIUtB92xwyRpzaenGZhxDvxN/JgU00U3CDZNj9tPuDJ5H0WS4Nt3vKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.27.3" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.27.1.tgz", + "integrity": "sha512-g4L7OYun04N1WyqMNjldFwlfPCLVkgB54A/YCXICZYBsvJJE3kByKv9c9+R/nAfmIfjl2rKYLNyMHboYbZaWaA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.27.1.tgz", + "integrity": "sha512-oO02gcONcD5O1iTLi/6frMJBIwWEHceWGSGqrpCmEL8nogiS6J9PBlE48CaK20/Jx1LuRml9aDftLgdjXT8+Cw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1", + "@babel/plugin-transform-optional-chaining": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.13.0" + } + }, + "node_modules/@babel/plugin-proposal-async-generator-functions": { + "version": "7.20.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.20.7.tgz", + "integrity": "sha512-xMbiLsn/8RK7Wq7VeVytytS2L6qE69bXPB10YCmMdDZbKF4okCqY74pI/jJQ/8U0b/F6NrT2+14b8/P9/3AMGA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/helper-remap-async-to-generator": "^7.18.9", + "@babel/plugin-syntax-async-generators": "^7.8.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-class-properties": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz", + "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-class-static-block": { + "version": "7.21.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.21.0.tgz", + "integrity": "sha512-XP5G9MWNUskFuP30IfFSEFB0Z6HzLIUcjYM4bYOPHXl7eiJ9HFv8tWj6TXTN5QODiEhDZAeI4hLok2iHFFV4hw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-static-block instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-class-static-block": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.12.0" + } + }, + "node_modules/@babel/plugin-proposal-dynamic-import": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz", + "integrity": "sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-dynamic-import instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-dynamic-import": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-export-namespace-from": { + "version": "7.18.9", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz", + "integrity": "sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.9", + "@babel/plugin-syntax-export-namespace-from": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-json-strings": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.18.6.tgz", + "integrity": "sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-json-strings instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-json-strings": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-logical-assignment-operators": { + "version": "7.20.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.20.7.tgz", + "integrity": "sha512-y7C7cZgpMIjWlKE5T7eJwp+tnRYM89HmRvWM5EQuB5BoHEONjmQ8lSNmBUwOyy/GFRsohJED51YBF79hE1djug==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-nullish-coalescing-operator": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz", + "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-numeric-separator": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.18.6.tgz", + "integrity": "sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-numeric-separator": "^7.10.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-object-rest-spread": { + "version": "7.20.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz", + "integrity": "sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.20.5", + "@babel/helper-compilation-targets": "^7.20.7", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-transform-parameters": "^7.20.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-optional-catch-binding": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.18.6.tgz", + "integrity": "sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-optional-chaining": { + "version": "7.21.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz", + "integrity": "sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", + "@babel/plugin-syntax-optional-chaining": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-private-methods": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.18.6.tgz", + "integrity": "sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-unicode-property-regex": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz", + "integrity": "sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-unicode-property-regex instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-static-block": { + "version": "7.14.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", + "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-dynamic-import": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", + "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-export-namespace-from": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz", + "integrity": "sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-assertions": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.27.1.tgz", + "integrity": "sha512-UT/Jrhw57xg4ILHLFnzFpPDlMbcdEicaAtjPQpbj9wa8T4r5KVWCimHcL/460g8Ht0DMxDyjsLgiWSkVjnwPFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-attributes": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.27.1.tgz", + "integrity": "sha512-oFT0FrKHgF53f4vOsZGi2Hh3I35PfSmVs4IBFLFj4dnafP+hIWDLg3VyKmUHfLoLHlyxY4C7DGtmHuJgn+IGww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.27.1.tgz", + "integrity": "sha512-y8YTNIeKoyhGd9O0Jiyzyyqk8gdjnumGTQPsz0xOZOQ2RmkVJeZ1vmmfIvFEKqucBG6axJGBZDE/7iI5suUI/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-private-property-in-object": { + "version": "7.14.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", + "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.27.1.tgz", + "integrity": "sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-arrow-functions": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.27.1.tgz", + "integrity": "sha512-8Z4TGic6xW70FKThA5HYEKKyBpOOsucTOD1DjU3fZxDg+K3zBJcXMFnt/4yQiZnf5+MiOMSXQ9PaEK/Ilh1DeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-async-to-generator": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.27.1.tgz", + "integrity": "sha512-NREkZsZVJS4xmTr8qzE5y8AfIPqsdQfRuUiLRTEzb7Qii8iFWCyDKaUV2c0rCuh4ljDZ98ALHP/PetiBV2nddA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-remap-async-to-generator": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoped-functions": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.27.1.tgz", + "integrity": "sha512-cnqkuOtZLapWYZUYM5rVIdv1nXYuFVIltZ6ZJ7nIj585QsjKM5dhL2Fu/lICXZ1OyIAFc7Qy+bvDAtTXqGrlhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoping": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.27.5.tgz", + "integrity": "sha512-JF6uE2s67f0y2RZcm2kpAUEbD50vH62TyWVebxwHAlbSdM49VqPz8t4a1uIjp4NIOIZ4xzLfjY5emt/RCyC7TQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-classes": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-classes/-/plugin-transform-classes-7.27.1.tgz", + "integrity": "sha512-7iLhfFAubmpeJe/Wo2TVuDrykh/zlWXLzPNdL0Jqn/Xu8R3QQ8h9ff8FQoISZOsw74/HFqFI7NX63HN7QFIHKA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "@babel/helper-compilation-targets": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-replace-supers": "^7.27.1", + "@babel/traverse": "^7.27.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-computed-properties": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.27.1.tgz", + "integrity": "sha512-lj9PGWvMTVksbWiDT2tW68zGS/cyo4AkZ/QTp0sQT0mjPopCmrSkzxeXkznjqBxzDI6TclZhOJbBmbBLjuOZUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/template": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-destructuring": { + "version": "7.27.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.27.3.tgz", + "integrity": "sha512-s4Jrok82JpiaIprtY2nHsYmrThKvvwgHwjgd7UMiYhZaN0asdXNLr0y+NjTfkA7SyQE5i2Fb7eawUOZmLvyqOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-dotall-regex": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.27.1.tgz", + "integrity": "sha512-gEbkDVGRvjj7+T1ivxrfgygpT7GUd4vmODtYpbs0gZATdkX8/iSnOtZSxiZnsgm1YjTgjI6VKBGSJJevkrclzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-duplicate-keys": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.27.1.tgz", + "integrity": "sha512-MTyJk98sHvSs+cvZ4nOauwTTG1JeonDjSGvGGUNHreGQns+Mpt6WX/dVzWBHgg+dYZhkC4X+zTDfkTU+Vy9y7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-exponentiation-operator": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.27.1.tgz", + "integrity": "sha512-uspvXnhHvGKf2r4VVtBpeFnuDWsJLQ6MF6lGJLC89jBR1uoVeqM416AZtTuhTezOfgHicpJQmoD5YUakO/YmXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-for-of": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.27.1.tgz", + "integrity": "sha512-BfbWFFEJFQzLCQ5N8VocnCtA8J1CLkNTe2Ms2wocj75dd6VpiqS5Z5quTYcUoo4Yq+DN0rtikODccuv7RU81sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-function-name": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.27.1.tgz", + "integrity": "sha512-1bQeydJF9Nr1eBCMMbC+hdwmRlsv5XYOMu03YSWFwNs0HsAmtSxxF1fyuYPqemVldVyFmlCU7w8UE14LupUSZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-compilation-targets": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/traverse": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-literals": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-literals/-/plugin-transform-literals-7.27.1.tgz", + "integrity": "sha512-0HCFSepIpLTkLcsi86GG3mTUzxV5jpmbv97hTETW3yzrAij8aqlD36toB1D0daVFJM8NK6GvKO0gslVQmm+zZA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-member-expression-literals": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.27.1.tgz", + "integrity": "sha512-hqoBX4dcZ1I33jCSWcXrP+1Ku7kdqXf1oeah7ooKOIiAdKQ+uqftgCFNOSzA5AMS2XIHEYeGFg4cKRCdpxzVOQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-amd": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.27.1.tgz", + "integrity": "sha512-iCsytMg/N9/oFq6n+gFTvUYDZQOMK5kEdeYxmxt91fcJGycfxVP9CnrxoliM0oumFERba2i8ZtwRUCMhvP1LnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-commonjs": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.27.1.tgz", + "integrity": "sha512-OJguuwlTYlN0gBZFRPqwOGNWssZjfIUdS7HMYtN8c1KmwpwHFBwTeFZrg9XZa+DFTitWOW5iTAG7tyCUPsCCyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-systemjs": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.27.1.tgz", + "integrity": "sha512-w5N1XzsRbc0PQStASMksmUeqECuzKuTJer7kFagK8AXgpCMkeDMO5S+aaFb7A51ZYDF7XI34qsTX+fkHiIm5yA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1", + "@babel/traverse": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-umd": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.27.1.tgz", + "integrity": "sha512-iQBE/xC5BV1OxJbp6WG7jq9IWiD+xxlZhLrdwpPkTX3ydmXdvoCpyfJN7acaIBZaOqTfr76pgzqBJflNbeRK+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.27.1.tgz", + "integrity": "sha512-SstR5JYy8ddZvD6MhV0tM/j16Qds4mIpJTOd1Yu9J9pJjH93bxHECF7pgtc28XvkzTD6Pxcm/0Z73Hvk7kb3Ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-transform-new-target": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.27.1.tgz", + "integrity": "sha512-f6PiYeqXQ05lYq3TIfIDu/MtliKUbNwkGApPUvyo6+tc7uaR4cPjPe7DFPr15Uyycg2lZU6btZ575CuQoYh7MQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-object-super": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.27.1.tgz", + "integrity": "sha512-SFy8S9plRPbIcxlJ8A6mT/CxFdJx/c04JEctz4jf8YZaVS2px34j7NXRrlGlHkN/M2gnpL37ZpGRGVFLd3l8Ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-replace-supers": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-optional-chaining": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.27.1.tgz", + "integrity": "sha512-BQmKPPIuc8EkZgNKsv0X4bPmOoayeu4F1YCwx2/CfmDSXDbp7GnzlUH+/ul5VGfRg1AoFPsrIThlEBj2xb4CAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-parameters": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.27.1.tgz", + "integrity": "sha512-018KRk76HWKeZ5l4oTj2zPpSh+NbGdt0st5S6x0pga6HgrjBOJb24mMDHorFopOOd6YHkLgOZ+zaCjZGPO4aKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-property-literals": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.27.1.tgz", + "integrity": "sha512-oThy3BCuCha8kDZ8ZkgOg2exvPYUlprMukKQXI1r1pJ47NCvxfkEy8vK+r/hT9nF0Aa4H1WUPZZjHTFtAhGfmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-regenerator": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.27.5.tgz", + "integrity": "sha512-uhB8yHerfe3MWnuLAhEbeQ4afVoqv8BQsPqrTv7e/jZ9y00kJL6l9a/f4OWaKxotmjzewfEyXE1vgDJenkQ2/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-reserved-words": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.27.1.tgz", + "integrity": "sha512-V2ABPHIJX4kC7HegLkYoDpfg9PVmuWy/i6vUM5eGK22bx4YVFD3M5F0QQnWQoDs6AGsUWTVOopBiMFQgHaSkVw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-shorthand-properties": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.27.1.tgz", + "integrity": "sha512-N/wH1vcn4oYawbJ13Y/FxcQrWk63jhfNa7jef0ih7PHSIHX2LB7GWE1rkPrOnka9kwMxb6hMl19p7lidA+EHmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-spread": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-spread/-/plugin-transform-spread-7.27.1.tgz", + "integrity": "sha512-kpb3HUqaILBJcRFVhFUs6Trdd4mkrzcGXss+6/mxUd273PfbWqSDHRzMT2234gIg2QYfAjvXLSquP1xECSg09Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-sticky-regex": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.27.1.tgz", + "integrity": "sha512-lhInBO5bi/Kowe2/aLdBAawijx+q1pQzicSgnkB6dUPc1+RC8QmJHKf2OjvU+NZWitguJHEaEmbV6VWEouT58g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-template-literals": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.27.1.tgz", + "integrity": "sha512-fBJKiV7F2DxZUkg5EtHKXQdbsbURW3DZKQUWphDum0uRP6eHGGa/He9mc0mypL680pb+e/lDIthRohlv8NCHkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-typeof-symbol": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.27.1.tgz", + "integrity": "sha512-RiSILC+nRJM7FY5srIyc4/fGIwUhyDuuBSdWn4y6yT6gm652DpCHZjIipgn6B7MQ1ITOUnAKWixEUjQRIBIcLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-typescript": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.27.1.tgz", + "integrity": "sha512-Q5sT5+O4QUebHdbwKedFBEwRLb02zJ7r4A5Gg2hUoLuU3FjdMcyqcywqUrLCaDsFCxzokf7u9kuy7qz51YUuAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "@babel/helper-create-class-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1", + "@babel/plugin-syntax-typescript": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-escapes": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.27.1.tgz", + "integrity": "sha512-Ysg4v6AmF26k9vpfFuTZg8HRfVWzsh1kVfowA23y9j/Gu6dOuahdUVhkLqpObp3JIv27MLSii6noRnuKN8H0Mg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-regex": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.27.1.tgz", + "integrity": "sha512-xvINq24TRojDuyt6JGtHmkVkrfVV3FPT16uytxImLeBZqW3/H52yN+kM1MGuyPkIQxrzKwPHs5U/MP3qKyzkGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/preset-env": { + "version": "7.20.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/preset-env/-/preset-env-7.20.2.tgz", + "integrity": "sha512-1G0efQEWR1EHkKvKHqbG+IN/QdgwfByUpM5V5QroDzGV2t3S/WXNQd693cHiHTlCFMpr9B6FkPFXDA2lQcKoDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.20.1", + "@babel/helper-compilation-targets": "^7.20.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/helper-validator-option": "^7.18.6", + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.18.6", + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.18.9", + "@babel/plugin-proposal-async-generator-functions": "^7.20.1", + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/plugin-proposal-class-static-block": "^7.18.6", + "@babel/plugin-proposal-dynamic-import": "^7.18.6", + "@babel/plugin-proposal-export-namespace-from": "^7.18.9", + "@babel/plugin-proposal-json-strings": "^7.18.6", + "@babel/plugin-proposal-logical-assignment-operators": "^7.18.9", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", + "@babel/plugin-proposal-numeric-separator": "^7.18.6", + "@babel/plugin-proposal-object-rest-spread": "^7.20.2", + "@babel/plugin-proposal-optional-catch-binding": "^7.18.6", + "@babel/plugin-proposal-optional-chaining": "^7.18.9", + "@babel/plugin-proposal-private-methods": "^7.18.6", + "@babel/plugin-proposal-private-property-in-object": "^7.18.6", + "@babel/plugin-proposal-unicode-property-regex": "^7.18.6", + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-class-static-block": "^7.14.5", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-syntax-export-namespace-from": "^7.8.3", + "@babel/plugin-syntax-import-assertions": "^7.20.0", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5", + "@babel/plugin-syntax-top-level-await": "^7.14.5", + "@babel/plugin-transform-arrow-functions": "^7.18.6", + "@babel/plugin-transform-async-to-generator": "^7.18.6", + "@babel/plugin-transform-block-scoped-functions": "^7.18.6", + "@babel/plugin-transform-block-scoping": "^7.20.2", + "@babel/plugin-transform-classes": "^7.20.2", + "@babel/plugin-transform-computed-properties": "^7.18.9", + "@babel/plugin-transform-destructuring": "^7.20.2", + "@babel/plugin-transform-dotall-regex": "^7.18.6", + "@babel/plugin-transform-duplicate-keys": "^7.18.9", + "@babel/plugin-transform-exponentiation-operator": "^7.18.6", + "@babel/plugin-transform-for-of": "^7.18.8", + "@babel/plugin-transform-function-name": "^7.18.9", + "@babel/plugin-transform-literals": "^7.18.9", + "@babel/plugin-transform-member-expression-literals": "^7.18.6", + "@babel/plugin-transform-modules-amd": "^7.19.6", + "@babel/plugin-transform-modules-commonjs": "^7.19.6", + "@babel/plugin-transform-modules-systemjs": "^7.19.6", + "@babel/plugin-transform-modules-umd": "^7.18.6", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.19.1", + "@babel/plugin-transform-new-target": "^7.18.6", + "@babel/plugin-transform-object-super": "^7.18.6", + "@babel/plugin-transform-parameters": "^7.20.1", + "@babel/plugin-transform-property-literals": "^7.18.6", + "@babel/plugin-transform-regenerator": "^7.18.6", + "@babel/plugin-transform-reserved-words": "^7.18.6", + "@babel/plugin-transform-shorthand-properties": "^7.18.6", + "@babel/plugin-transform-spread": "^7.19.0", + "@babel/plugin-transform-sticky-regex": "^7.18.6", + "@babel/plugin-transform-template-literals": "^7.18.9", + "@babel/plugin-transform-typeof-symbol": "^7.18.9", + "@babel/plugin-transform-unicode-escapes": "^7.18.10", + "@babel/plugin-transform-unicode-regex": "^7.18.6", + "@babel/preset-modules": "^0.1.5", + "@babel/types": "^7.20.2", + "babel-plugin-polyfill-corejs2": "^0.3.3", + "babel-plugin-polyfill-corejs3": "^0.6.0", + "babel-plugin-polyfill-regenerator": "^0.4.1", + "core-js-compat": "^3.25.1", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/preset-modules": { + "version": "0.1.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/preset-modules/-/preset-modules-0.1.6.tgz", + "integrity": "sha512-ID2yj6K/4lKfhuU3+EX4UvNbIt7eACFbHmNUjzA+ep+B5971CknnA/9DEWKbRokfbbtblxxxXFJJrH47UEAMVg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", + "@babel/plugin-transform-dotall-regex": "^7.4.4", + "@babel/types": "^7.4.4", + "esutils": "^2.0.2" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" + } + }, + "node_modules/@babel/preset-typescript": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/preset-typescript/-/preset-typescript-7.18.6.tgz", + "integrity": "sha512-s9ik86kXBAnD760aybBucdpnLsAt0jK1xqJn2juOn9lkOvSHV60os5hxoVJsPzMQxvnUJFAlkont2DvvaYEBtQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/helper-validator-option": "^7.18.6", + "@babel/plugin-transform-typescript": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.20.13", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/runtime/-/runtime-7.20.13.tgz", + "integrity": "sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.27.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/template/-/template-7.27.2.tgz", + "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/parser": "^7.27.2", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.27.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/traverse/-/traverse-7.27.4.tgz", + "integrity": "sha512-oNcu2QbHqts9BtOWJosOVJapWjBDSxGCpFvikNR5TGDYDQf3JwpIoMzIKrvfoti93cLfPJEG4tH9SPVeyCGgdA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.27.3", + "@babel/parser": "^7.27.4", + "@babel/template": "^7.27.2", + "@babel/types": "^7.27.3", + "debug": "^4.3.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.27.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/types/-/types-7.27.6.tgz", + "integrity": "sha512-ETyHEk2VHHvl9b9jZP5IHPavHYk57EhanlRRuae9XCpb/j5bDCbPPMOBfCWhnl/7EDJz0jEMCi/RhccCE8r1+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/console/-/console-29.7.0.tgz", + "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/console/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/core": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/core/-/core-29.7.0.tgz", + "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/reporters": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.7.0", + "jest-config": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-resolve-dependencies": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "jest-watcher": "^29.7.0", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/core/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/environment": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/environment/-/environment-29.7.0.tgz", + "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "expect": "^29.7.0", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/expect-utils/-/expect-utils-29.7.0.tgz", + "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/fake-timers/-/fake-timers-29.7.0.tgz", + "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@sinonjs/fake-timers": "^10.0.2", + "@types/node": "*", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/globals/-/globals-29.7.0.tgz", + "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/types": "^29.6.3", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/reporters/-/reporters-29.7.0.tgz", + "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^6.0.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "v8-to-istanbul": "^9.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/reporters/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map": { + "version": "29.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/source-map/-/source-map-29.6.3.tgz", + "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.18", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-result": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/test-result/-/test-result-29.7.0.tgz", + "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz", + "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/test-result": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/transform": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jest/transform/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@koalaui/libarkts": { + "resolved": "../koala-wrapper", + "link": true + }, + "node_modules/@nicolo-ribaudo/chokidar-2": { + "version": "2.1.8-no-fsevents.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz", + "integrity": "sha512-s88O1aVtXftvp5bCPB7WnmXc5IwOZZ7YPuwNPt+GtOOXpPvad1LfbmjYv+qII7zP6RU2QGnqve27dnLycEnyEQ==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@sinonjs/commons": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@sinonjs/commons/-/commons-3.0.1.tgz", + "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.27.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/babel__generator/-/babel__generator-7.27.0.tgz", + "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/babel__traverse/-/babel__traverse-7.20.7.tgz", + "integrity": "sha512-dkO5fhS7+/oos4ciWxyEyjWe48zmG6wbCheo/G2ZnHx4fs3EU6YC6UM8rk56gAjNJ9P3MTH2jo5jb92/K6wbng==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.20.7" + } + }, + "node_modules/@types/graceful-fs": { + "version": "4.1.9", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", + "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz", + "integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } + }, + "node_modules/@types/istanbul-reports": { + "version": "3.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz", + "integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, + "node_modules/@types/jest": { + "version": "29.5.14", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/jest/-/jest-29.5.14.tgz", + "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/node": { + "version": "22.15.31", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/node/-/node-22.15.31.tgz", + "integrity": "sha512-jnVe5ULKl6tijxUhvQeNbQG/84fHfg+yMak02cT8QVhBx/F05rAVxCGBYYTh2EKz22D6JF5ktXuNwdx7b9iEGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/stack-utils": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/stack-utils/-/stack-utils-2.0.3.tgz", + "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/yargs": { + "version": "17.0.33", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/yargs/-/yargs-17.0.33.tgz", + "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/acorn": { + "version": "8.15.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true, + "license": "MIT" + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://repo.huaweicloud.com/repository/npm/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/arkui-plugins-test": { + "resolved": "test", + "link": true + }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "dev": true, + "license": "MIT" + }, + "node_modules/babel-jest": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-jest/-/babel-jest-29.7.0.tgz", + "integrity": "sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/transform": "^29.7.0", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.6.3", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.8.0" + } + }, + "node_modules/babel-jest/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-jest-hoist": { + "version": "29.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", + "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/babel-plugin-polyfill-corejs2": { + "version": "0.3.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz", + "integrity": "sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.17.7", + "@babel/helper-define-polyfill-provider": "^0.3.3", + "semver": "^6.1.1" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/babel-plugin-polyfill-corejs3": { + "version": "0.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.6.0.tgz", + "integrity": "sha512-+eHqR6OPcBhJOGgsIar7xoAB1GcSwVUA3XjAd7HJNzOXT4wv6/H7KIdA/Nc60cvUlDbKApmqNvD1B1bzOt4nyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.3.3", + "core-js-compat": "^3.25.1" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/babel-plugin-polyfill-regenerator": { + "version": "0.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.1.tgz", + "integrity": "sha512-NtQGmyQDXjQqQ+IzRkBVwEOz9lQ4zxAQZgoAYEtU9dJjnl1Oc98qnN7jcp+bE7O7aYzVpavXE3/VKXNzUbh7aw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.3.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.1.0.tgz", + "integrity": "sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-class-static-block": "^7.14.5", + "@babel/plugin-syntax-import-attributes": "^7.24.7", + "@babel/plugin-syntax-import-meta": "^7.10.4", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5", + "@babel/plugin-syntax-top-level-await": "^7.14.5" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-preset-jest": { + "version": "29.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz", + "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==", + "dev": true, + "license": "MIT", + "dependencies": { + "babel-plugin-jest-hoist": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://repo.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.25.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/browserslist/-/browserslist-4.25.0.tgz", + "integrity": "sha512-PJ8gYKeS5e/whHBh8xrwYK+dAvEj7JXtz6uTucnMRB8OiGTsKccFekoRrjajPBHV8oOY+2tI4uxeceSimKwMFA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "caniuse-lite": "^1.0.30001718", + "electron-to-chromium": "^1.5.160", + "node-releases": "^2.0.19", + "update-browserslist-db": "^1.1.3" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "node-int64": "^0.4.0" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001723", + "resolved": "https://repo.huaweicloud.com/repository/npm/caniuse-lite/-/caniuse-lite-1.0.30001723.tgz", + "integrity": "sha512-1R/elMjtehrFejxwmexeXAtae5UO9iSyFn6G/I806CYC/BLyyBk1EPhrKBkWhy6wM6Xnm47dSJQec+tLJ39WHw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/char-regex": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cjs-module-lexer": { + "version": "1.4.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/cjs-module-lexer/-/cjs-module-lexer-1.4.3.tgz", + "integrity": "sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/collect-v8-coverage": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/commander": { + "version": "4.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true, + "license": "MIT" + }, + "node_modules/core-js-compat": { + "version": "3.43.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/core-js-compat/-/core-js-compat-3.43.0.tgz", + "integrity": "sha512-2GML2ZsCc5LR7hZYz4AXmjQw8zuy2T//2QntwdnpuYI7jteT6GVYJL7F6C2C57R7gSYrcqVW3lAALefdbhBLDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "browserslist": "^4.25.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/create-jest": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/create-jest/-/create-jest-29.7.0.tgz", + "integrity": "sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "prompts": "^2.0.1" + }, + "bin": { + "create-jest": "bin/create-jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dedent": { + "version": "1.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/dedent/-/dedent-1.6.0.tgz", + "integrity": "sha512-F1Z+5UCFpmQUzJa11agbyPVMbpgT/qA3/SKyJ1jyBgm7dUcUEa8v9JwDkerSQXfakBwFljIxhOJqGkjUwZ9FSA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/ejs": { + "version": "3.1.10", + "resolved": "https://repo.huaweicloud.com/repository/npm/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "jake": "^10.8.5" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.167", + "resolved": "https://repo.huaweicloud.com/repository/npm/electron-to-chromium/-/electron-to-chromium-1.5.167.tgz", + "integrity": "sha512-LxcRvnYO5ez2bMOFpbuuVuAI5QNeY1ncVytE/KXaL6ZNfzX1yPlAO0nSOyIHx2fVAuUprMqPs/TdVhUFZy7SIQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/emittery": { + "version": "0.13.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/emittery/-/emittery-0.13.1.tgz", + "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expect": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/expect-utils": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bser": "2.1.1" + } + }, + "node_modules/filelist": { + "version": "1.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "minimatch": "^5.0.1" + } + }, + "node_modules/filelist/node_modules/brace-expansion": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/filelist/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs-readdir-recursive": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", + "integrity": "sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==", + "dev": true, + "license": "MIT" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "optional": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/import-local": { + "version": "3.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/import-local/-/import-local-3.2.0.tgz", + "integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-fn": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/@babel/core": { + "version": "7.27.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/core/-/core-7.27.4.tgz", + "integrity": "sha512-bXYxrXFubeYdvB0NhD/NBB3Qi6aZeV20GOWVI47t2dkecCEoneR4NPVcb7abpXDEvejgrUfFtG6vG/zxAKmg+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.27.3", + "@babel/helper-compilation-targets": "^7.27.2", + "@babel/helper-module-transforms": "^7.27.3", + "@babel/helpers": "^7.27.4", + "@babel/parser": "^7.27.4", + "@babel/template": "^7.27.2", + "@babel/traverse": "^7.27.4", + "@babel/types": "^7.27.3", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/istanbul-lib-instrument/node_modules/semver": { + "version": "7.7.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report/node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/istanbul-lib-report/node_modules/semver": { + "version": "7.7.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jake": { + "version": "10.9.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/jake/-/jake-10.9.2.tgz", + "integrity": "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "async": "^3.2.3", + "chalk": "^4.0.2", + "filelist": "^1.0.4", + "minimatch": "^3.1.2" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest/-/jest-29.7.0.tgz", + "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/types": "^29.6.3", + "import-local": "^3.0.2", + "jest-cli": "^29.7.0" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-changed-files": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-changed-files/-/jest-changed-files-29.7.0.tgz", + "integrity": "sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "execa": "^5.0.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-circus/-/jest-circus-29.7.0.tgz", + "integrity": "sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^1.0.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.7.0", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0", + "pretty-format": "^29.7.0", + "pure-rand": "^6.0.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-cli": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-cli/-/jest-cli-29.7.0.tgz", + "integrity": "sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "create-jest": "^29.7.0", + "exit": "^0.1.2", + "import-local": "^3.0.2", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-config": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-config/-/jest-config-29.7.0.tgz", + "integrity": "sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-jest": "^29.7.0", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/jest-config/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-diff": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-diff/-/jest-diff-29.7.0.tgz", + "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-docblock": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-docblock/-/jest-docblock-29.7.0.tgz", + "integrity": "sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "detect-newline": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-each/-/jest-each-29.7.0.tgz", + "integrity": "sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "jest-util": "^29.7.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-node": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-environment-node/-/jest-environment-node-29.7.0.tgz", + "integrity": "sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-leak-detector": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz", + "integrity": "sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz", + "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-message-util/-/jest-message-util-29.7.0.tgz", + "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-mock": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-mock/-/jest-mock-29.7.0.tgz", + "integrity": "sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-pnp-resolver": { + "version": "1.2.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "jest-resolve": "*" + }, + "peerDependenciesMeta": { + "jest-resolve": { + "optional": true + } + } + }, + "node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-resolve/-/jest-resolve-29.7.0.tgz", + "integrity": "sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "resolve": "^1.20.0", + "resolve.exports": "^2.0.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve-dependencies": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz", + "integrity": "sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-regex-util": "^29.6.3", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-runner": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-runner/-/jest-runner-29.7.0.tgz", + "integrity": "sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/environment": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-leak-detector": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-resolve": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-util": "^29.7.0", + "jest-watcher": "^29.7.0", + "jest-worker": "^29.7.0", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-runtime/-/jest-runtime-29.7.0.tgz", + "integrity": "sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/globals": "^29.7.0", + "@jest/source-map": "^29.6.3", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-snapshot": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-snapshot/-/jest-snapshot-29.7.0.tgz", + "integrity": "sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "natural-compare": "^1.4.0", + "pretty-format": "^29.7.0", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot/node_modules/semver": { + "version": "7.7.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-validate/-/jest-validate-29.7.0.tgz", + "integrity": "sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "leven": "^3.1.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-watcher": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-watcher/-/jest-watcher-29.7.0.tgz", + "integrity": "sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "jest-util": "^29.7.0", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jest-worker/-/jest-worker-29.7.0.tgz", + "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "jest-util": "^29.7.0", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true, + "license": "MIT" + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash.debounce": { + "version": "4.0.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pify": "^4.0.1", + "semver": "^5.6.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true, + "license": "ISC" + }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://repo.huaweicloud.com/repository/npm/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tmpl": "1.0.5" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-releases": { + "version": "2.0.19", + "resolved": "https://repo.huaweicloud.com/repository/npm/node-releases/-/node-releases-2.0.19.tgz", + "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pify": { + "version": "4.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/pirates": { + "version": "4.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/pirates/-/pirates-4.0.7.tgz", + "integrity": "sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pretty-format": { + "version": "29.7.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pure-rand": { + "version": "6.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/pure-rand/-/pure-rand-6.1.0.tgz", + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ], + "license": "MIT" + }, + "node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", + "dev": true, + "license": "MIT" + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/regenerate": { + "version": "1.4.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/regenerate/-/regenerate-1.4.2.tgz", + "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", + "dev": true, + "license": "MIT" + }, + "node_modules/regenerate-unicode-properties": { + "version": "10.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/regenerate-unicode-properties/-/regenerate-unicode-properties-10.2.0.tgz", + "integrity": "sha512-DqHn3DwbmmPVzeKj9woBadqmXxLvQoQIwu7nopMc72ztvxVmVk2SBhSnx67zuye5TP+lJsb/TBQsjLKhnDf3MA==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerate": "^1.4.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "dev": true, + "license": "MIT" + }, + "node_modules/regexpu-core": { + "version": "6.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/regexpu-core/-/regexpu-core-6.2.0.tgz", + "integrity": "sha512-H66BPQMrv+V16t8xtmq+UC0CBpiTBA60V8ibS1QVReIp8T1z8hwFxqcGzm9K6lgsN7sB5edVH8a+ze6Fqm4weA==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerate": "^1.4.2", + "regenerate-unicode-properties": "^10.2.0", + "regjsgen": "^0.8.0", + "regjsparser": "^0.12.0", + "unicode-match-property-ecmascript": "^2.0.0", + "unicode-match-property-value-ecmascript": "^2.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regjsgen": { + "version": "0.8.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/regjsgen/-/regjsgen-0.8.0.tgz", + "integrity": "sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/regjsparser": { + "version": "0.12.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/regjsparser/-/regjsparser-0.12.0.tgz", + "integrity": "sha512-cnE+y8bz4NhMjISKbgeVJtqNbtf5QpjZP+Bslo+UqkIt9QPnX9q095eiRRASJG1/tz6dlNr6Z5NsBiWYokp6EQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "jsesc": "~3.0.2" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/regjsparser/node_modules/jsesc": { + "version": "3.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.10", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve.exports": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve.exports/-/resolve.exports-2.0.3.tgz", + "integrity": "sha512-OcXjMsGdhL4XnbShKpAcSqPMzQoYkYyhbEaeSko47MjRP9NfEQMhZkXL1DoFlt9LWQn4YttrdnV6X2OiyzBi+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/slash": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.13", + "resolved": "https://repo.huaweicloud.com/repository/npm/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-length": { + "version": "4.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-jest": { + "version": "29.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ts-jest/-/ts-jest-29.4.0.tgz", + "integrity": "sha512-d423TJMnJGu80/eSgfQ5w/R+0zFJvdtTxwtF9KzFFunOpSeD+79lHJQIiAhluJoyGRbvj9NZJsl9WjCUo0ND7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "bs-logger": "^0.2.6", + "ejs": "^3.1.10", + "fast-json-stable-stringify": "^2.1.0", + "json5": "^2.2.3", + "lodash.memoize": "^4.1.2", + "make-error": "^1.3.6", + "semver": "^7.7.2", + "type-fest": "^4.41.0", + "yargs-parser": "^21.1.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/transform": "^29.0.0 || ^30.0.0", + "@jest/types": "^29.0.0 || ^30.0.0", + "babel-jest": "^29.0.0 || ^30.0.0", + "jest": "^29.0.0 || ^30.0.0", + "jest-util": "^29.0.0 || ^30.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/transform": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jest-util": { + "optional": true + } + } + }, + "node_modules/ts-jest/node_modules/semver": { + "version": "7.7.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-jest/node_modules/type-fest": { + "version": "4.41.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/type-fest/-/type-fest-4.41.0.tgz", + "integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/unicode-canonical-property-names-ecmascript": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz", + "integrity": "sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-ecmascript": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", + "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "unicode-canonical-property-names-ecmascript": "^2.0.0", + "unicode-property-aliases-ecmascript": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-value-ecmascript": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.2.0.tgz", + "integrity": "sha512-4IehN3V/+kkr5YeSSDDQG8QLqO26XpL2XP3GQtqwlT/QYSECAwFztxVHjlbh0+gjJ3XmNLS0zDsbgs9jWKExLg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-property-aliases-ecmascript": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz", + "integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz", + "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true, + "license": "MIT" + }, + "node_modules/v8-to-istanbul": { + "version": "9.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", + "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==", + "dev": true, + "license": "ISC", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "makeerror": "1.0.12" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "license": "ISC", + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "test": { + "name": "arkui-plugins-test", + "version": "1.0.0" + } + } +} diff --git a/koala-wrapper/package-lock.json b/koala-wrapper/package-lock.json new file mode 100644 index 000000000..1dff8be51 --- /dev/null +++ b/koala-wrapper/package-lock.json @@ -0,0 +1,2730 @@ +{ + "name": "@koalaui/libarkts", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@koalaui/libarkts", + "version": "1.0.0", + "devDependencies": { + "@babel/cli": "7.20.7", + "@babel/core": "7.20.12", + "@babel/plugin-proposal-class-properties": "7.18.6", + "@babel/preset-env": "7.20.2", + "@babel/preset-typescript": "7.18.6", + "@babel/runtime": "7.20.13", + "@tsconfig/recommended": "1.0.8", + "@types/node": "^18.0.0", + "node-addon-api": "^8.3.0", + "typescript": "^5.0.0" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/cli": { + "version": "7.20.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/cli/-/cli-7.20.7.tgz", + "integrity": "sha512-WylgcELHB66WwQqItxNILsMlaTd8/SO6SgTTjMp4uCI7P4QyH1r3nqgFmO3BfM4AtfniHgFMH3EpYFj/zynBkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.8", + "commander": "^4.0.1", + "convert-source-map": "^1.1.0", + "fs-readdir-recursive": "^1.1.0", + "glob": "^7.2.0", + "make-dir": "^2.1.0", + "slash": "^2.0.0" + }, + "bin": { + "babel": "bin/babel.js", + "babel-external-helpers": "bin/babel-external-helpers.js" + }, + "engines": { + "node": ">=6.9.0" + }, + "optionalDependencies": { + "@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents.3", + "chokidar": "^3.4.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.27.1", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/compat-data/-/compat-data-7.27.5.tgz", + "integrity": "sha512-KiRAp/VoJaWkkte84TvUd9qjdbZAdiqyvMxrGl1N6vzFogKmaLgoM3L1kgtLicp2HP5fBJS8JrZKLVIZGVJAVg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.20.12", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/core/-/core-7.20.12.tgz", + "integrity": "sha512-XsMfHovsUYHFMdrIHkZphTN/2Hzzi78R08NuHfDBehym2VsPDL6Zn/JAD/JQdnRvbSsbQc4mVaU1m6JgtTEElg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.1.0", + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.20.7", + "@babel/helper-compilation-targets": "^7.20.7", + "@babel/helper-module-transforms": "^7.20.11", + "@babel/helpers": "^7.20.7", + "@babel/parser": "^7.20.7", + "@babel/template": "^7.20.7", + "@babel/traverse": "^7.20.12", + "@babel/types": "^7.20.7", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.2", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/generator/-/generator-7.27.5.tgz", + "integrity": "sha512-ZGhA37l0e/g2s1Cnzdix0O3aLYm66eF8aufiVteOgnwxgnRP8GoyMj7VWsgWnQbVKXyge7hqrFh2K2TQM6t1Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.27.5", + "@babel/types": "^7.27.3", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.27.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.27.3.tgz", + "integrity": "sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.27.3" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.27.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz", + "integrity": "sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.27.2", + "@babel/helper-validator-option": "^7.27.1", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-create-class-features-plugin": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.27.1.tgz", + "integrity": "sha512-QwGAmuvM17btKU5VqXfb+Giw4JcN0hjuufz3DYnpeVDvZLAObloM77bhMXiqry3Iio+Ai4phVRDwl6WU10+r5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "@babel/helper-member-expression-to-functions": "^7.27.1", + "@babel/helper-optimise-call-expression": "^7.27.1", + "@babel/helper-replace-supers": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1", + "@babel/traverse": "^7.27.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-create-regexp-features-plugin": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.27.1.tgz", + "integrity": "sha512-uVDC72XVf8UbrH5qQTc18Agb8emwjTiZrQE11Nv3CuBEZmVvTwwE9CBUEvHku06gQCAyYf8Nv6ja1IN+6LMbxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "regexpu-core": "^6.2.0", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-define-polyfill-provider": { + "version": "0.3.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz", + "integrity": "sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-compilation-targets": "^7.17.7", + "@babel/helper-plugin-utils": "^7.16.7", + "debug": "^4.1.1", + "lodash.debounce": "^4.0.8", + "resolve": "^1.14.2", + "semver": "^6.1.2" + }, + "peerDependencies": { + "@babel/core": "^7.4.0-0" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.24.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz", + "integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-member-expression-to-functions": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.27.1.tgz", + "integrity": "sha512-E5chM8eWjTp/aNoVpcbfM7mLxu9XGLWYise2eBKGQomAk/Mb4XoxyqXTZbuTohbsl8EKqdlMhnDI2CCLfcs9wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz", + "integrity": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.27.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-module-transforms/-/helper-module-transforms-7.27.3.tgz", + "integrity": "sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1", + "@babel/traverse": "^7.27.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-optimise-call-expression": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.27.1.tgz", + "integrity": "sha512-URMGH08NzYFhubNSGJrpUEphGKQwMQYBySzat5cAByY1/YgIRkULnIy3tAMeszlL/so2HbeilYloUmSpd7GdVw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz", + "integrity": "sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-remap-async-to-generator": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.27.1.tgz", + "integrity": "sha512-7fiA521aVw8lSPeI4ZOD3vRFkoqkJcS+z4hFo82bFSH/2tNd6eJ5qCVMS5OzDmZh/kaHQeBaeyxK6wljcPtveA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "@babel/helper-wrap-function": "^7.27.1", + "@babel/traverse": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-replace-supers": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-replace-supers/-/helper-replace-supers-7.27.1.tgz", + "integrity": "sha512-7EHz6qDZc8RYS5ElPoShMheWvEgERonFCs7IAonWLLUTXW59DP14bCZt89/GKyreYn8g3S83m21FelHKbeDCKA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-member-expression-to-functions": "^7.27.1", + "@babel/helper-optimise-call-expression": "^7.27.1", + "@babel/traverse": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-skip-transparent-expression-wrappers": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.27.1.tgz", + "integrity": "sha512-Tub4ZKEXqbPjXgWLl2+3JpQAYBJ8+ikpQ2Ocj/q/r0LwE3UhENh7EUabyHjz2kCEsrRY83ew2DQdHluuiDQFzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", + "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-wrap-function": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helper-wrap-function/-/helper-wrap-function-7.27.1.tgz", + "integrity": "sha512-NFJK2sHUvrjo8wAU/nQTWU890/zB2jj0qBcCbZbbf+005cAsv6tMjXz31fBign6M5ov1o0Bllu+9nbqkfsjjJQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.27.1", + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.27.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/helpers/-/helpers-7.27.6.tgz", + "integrity": "sha512-muE8Tt8M22638HU31A3CgfSUciwz1fhATfoVai05aPXGor//CdWDCbnlY1yvBPo07njuVOCNGCSp/GTt12lIug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.27.2", + "@babel/types": "^7.27.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/parser/-/parser-7.27.5.tgz", + "integrity": "sha512-OsQd175SxWkGlzbny8J3K8TnnDD0N3lrIUtB92xwyRpzaenGZhxDvxN/JgU00U3CDZNj9tPuDJ5H0WS4Nt3vKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.27.3" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.27.1.tgz", + "integrity": "sha512-g4L7OYun04N1WyqMNjldFwlfPCLVkgB54A/YCXICZYBsvJJE3kByKv9c9+R/nAfmIfjl2rKYLNyMHboYbZaWaA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.27.1.tgz", + "integrity": "sha512-oO02gcONcD5O1iTLi/6frMJBIwWEHceWGSGqrpCmEL8nogiS6J9PBlE48CaK20/Jx1LuRml9aDftLgdjXT8+Cw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1", + "@babel/plugin-transform-optional-chaining": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.13.0" + } + }, + "node_modules/@babel/plugin-proposal-async-generator-functions": { + "version": "7.20.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.20.7.tgz", + "integrity": "sha512-xMbiLsn/8RK7Wq7VeVytytS2L6qE69bXPB10YCmMdDZbKF4okCqY74pI/jJQ/8U0b/F6NrT2+14b8/P9/3AMGA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/helper-remap-async-to-generator": "^7.18.9", + "@babel/plugin-syntax-async-generators": "^7.8.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-class-properties": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz", + "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-class-static-block": { + "version": "7.21.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.21.0.tgz", + "integrity": "sha512-XP5G9MWNUskFuP30IfFSEFB0Z6HzLIUcjYM4bYOPHXl7eiJ9HFv8tWj6TXTN5QODiEhDZAeI4hLok2iHFFV4hw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-static-block instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-class-static-block": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.12.0" + } + }, + "node_modules/@babel/plugin-proposal-dynamic-import": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz", + "integrity": "sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-dynamic-import instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-dynamic-import": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-export-namespace-from": { + "version": "7.18.9", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz", + "integrity": "sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.9", + "@babel/plugin-syntax-export-namespace-from": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-json-strings": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.18.6.tgz", + "integrity": "sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-json-strings instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-json-strings": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-logical-assignment-operators": { + "version": "7.20.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.20.7.tgz", + "integrity": "sha512-y7C7cZgpMIjWlKE5T7eJwp+tnRYM89HmRvWM5EQuB5BoHEONjmQ8lSNmBUwOyy/GFRsohJED51YBF79hE1djug==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-nullish-coalescing-operator": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz", + "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-numeric-separator": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.18.6.tgz", + "integrity": "sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-numeric-separator": "^7.10.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-object-rest-spread": { + "version": "7.20.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz", + "integrity": "sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.20.5", + "@babel/helper-compilation-targets": "^7.20.7", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-transform-parameters": "^7.20.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-optional-catch-binding": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.18.6.tgz", + "integrity": "sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-optional-chaining": { + "version": "7.21.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz", + "integrity": "sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", + "@babel/plugin-syntax-optional-chaining": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-private-methods": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.18.6.tgz", + "integrity": "sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-methods instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-unicode-property-regex": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz", + "integrity": "sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-unicode-property-regex instead.", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-static-block": { + "version": "7.14.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", + "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-dynamic-import": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", + "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-export-namespace-from": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz", + "integrity": "sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-assertions": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.27.1.tgz", + "integrity": "sha512-UT/Jrhw57xg4ILHLFnzFpPDlMbcdEicaAtjPQpbj9wa8T4r5KVWCimHcL/460g8Ht0DMxDyjsLgiWSkVjnwPFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-private-property-in-object": { + "version": "7.14.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", + "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.27.1.tgz", + "integrity": "sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-arrow-functions": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.27.1.tgz", + "integrity": "sha512-8Z4TGic6xW70FKThA5HYEKKyBpOOsucTOD1DjU3fZxDg+K3zBJcXMFnt/4yQiZnf5+MiOMSXQ9PaEK/Ilh1DeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-async-to-generator": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.27.1.tgz", + "integrity": "sha512-NREkZsZVJS4xmTr8qzE5y8AfIPqsdQfRuUiLRTEzb7Qii8iFWCyDKaUV2c0rCuh4ljDZ98ALHP/PetiBV2nddA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-remap-async-to-generator": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoped-functions": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.27.1.tgz", + "integrity": "sha512-cnqkuOtZLapWYZUYM5rVIdv1nXYuFVIltZ6ZJ7nIj585QsjKM5dhL2Fu/lICXZ1OyIAFc7Qy+bvDAtTXqGrlhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoping": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.27.5.tgz", + "integrity": "sha512-JF6uE2s67f0y2RZcm2kpAUEbD50vH62TyWVebxwHAlbSdM49VqPz8t4a1uIjp4NIOIZ4xzLfjY5emt/RCyC7TQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-classes": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-classes/-/plugin-transform-classes-7.27.1.tgz", + "integrity": "sha512-7iLhfFAubmpeJe/Wo2TVuDrykh/zlWXLzPNdL0Jqn/Xu8R3QQ8h9ff8FQoISZOsw74/HFqFI7NX63HN7QFIHKA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "@babel/helper-compilation-targets": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-replace-supers": "^7.27.1", + "@babel/traverse": "^7.27.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-computed-properties": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.27.1.tgz", + "integrity": "sha512-lj9PGWvMTVksbWiDT2tW68zGS/cyo4AkZ/QTp0sQT0mjPopCmrSkzxeXkznjqBxzDI6TclZhOJbBmbBLjuOZUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/template": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-destructuring": { + "version": "7.27.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.27.3.tgz", + "integrity": "sha512-s4Jrok82JpiaIprtY2nHsYmrThKvvwgHwjgd7UMiYhZaN0asdXNLr0y+NjTfkA7SyQE5i2Fb7eawUOZmLvyqOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-dotall-regex": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.27.1.tgz", + "integrity": "sha512-gEbkDVGRvjj7+T1ivxrfgygpT7GUd4vmODtYpbs0gZATdkX8/iSnOtZSxiZnsgm1YjTgjI6VKBGSJJevkrclzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-duplicate-keys": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.27.1.tgz", + "integrity": "sha512-MTyJk98sHvSs+cvZ4nOauwTTG1JeonDjSGvGGUNHreGQns+Mpt6WX/dVzWBHgg+dYZhkC4X+zTDfkTU+Vy9y7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-exponentiation-operator": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.27.1.tgz", + "integrity": "sha512-uspvXnhHvGKf2r4VVtBpeFnuDWsJLQ6MF6lGJLC89jBR1uoVeqM416AZtTuhTezOfgHicpJQmoD5YUakO/YmXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-for-of": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.27.1.tgz", + "integrity": "sha512-BfbWFFEJFQzLCQ5N8VocnCtA8J1CLkNTe2Ms2wocj75dd6VpiqS5Z5quTYcUoo4Yq+DN0rtikODccuv7RU81sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-function-name": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.27.1.tgz", + "integrity": "sha512-1bQeydJF9Nr1eBCMMbC+hdwmRlsv5XYOMu03YSWFwNs0HsAmtSxxF1fyuYPqemVldVyFmlCU7w8UE14LupUSZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-compilation-targets": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/traverse": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-literals": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-literals/-/plugin-transform-literals-7.27.1.tgz", + "integrity": "sha512-0HCFSepIpLTkLcsi86GG3mTUzxV5jpmbv97hTETW3yzrAij8aqlD36toB1D0daVFJM8NK6GvKO0gslVQmm+zZA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-member-expression-literals": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.27.1.tgz", + "integrity": "sha512-hqoBX4dcZ1I33jCSWcXrP+1Ku7kdqXf1oeah7ooKOIiAdKQ+uqftgCFNOSzA5AMS2XIHEYeGFg4cKRCdpxzVOQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-amd": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.27.1.tgz", + "integrity": "sha512-iCsytMg/N9/oFq6n+gFTvUYDZQOMK5kEdeYxmxt91fcJGycfxVP9CnrxoliM0oumFERba2i8ZtwRUCMhvP1LnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-commonjs": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.27.1.tgz", + "integrity": "sha512-OJguuwlTYlN0gBZFRPqwOGNWssZjfIUdS7HMYtN8c1KmwpwHFBwTeFZrg9XZa+DFTitWOW5iTAG7tyCUPsCCyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-systemjs": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.27.1.tgz", + "integrity": "sha512-w5N1XzsRbc0PQStASMksmUeqECuzKuTJer7kFagK8AXgpCMkeDMO5S+aaFb7A51ZYDF7XI34qsTX+fkHiIm5yA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1", + "@babel/traverse": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-umd": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.27.1.tgz", + "integrity": "sha512-iQBE/xC5BV1OxJbp6WG7jq9IWiD+xxlZhLrdwpPkTX3ydmXdvoCpyfJN7acaIBZaOqTfr76pgzqBJflNbeRK+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.27.1.tgz", + "integrity": "sha512-SstR5JYy8ddZvD6MhV0tM/j16Qds4mIpJTOd1Yu9J9pJjH93bxHECF7pgtc28XvkzTD6Pxcm/0Z73Hvk7kb3Ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-transform-new-target": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.27.1.tgz", + "integrity": "sha512-f6PiYeqXQ05lYq3TIfIDu/MtliKUbNwkGApPUvyo6+tc7uaR4cPjPe7DFPr15Uyycg2lZU6btZ575CuQoYh7MQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-object-super": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.27.1.tgz", + "integrity": "sha512-SFy8S9plRPbIcxlJ8A6mT/CxFdJx/c04JEctz4jf8YZaVS2px34j7NXRrlGlHkN/M2gnpL37ZpGRGVFLd3l8Ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-replace-supers": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-optional-chaining": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.27.1.tgz", + "integrity": "sha512-BQmKPPIuc8EkZgNKsv0X4bPmOoayeu4F1YCwx2/CfmDSXDbp7GnzlUH+/ul5VGfRg1AoFPsrIThlEBj2xb4CAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-parameters": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.27.1.tgz", + "integrity": "sha512-018KRk76HWKeZ5l4oTj2zPpSh+NbGdt0st5S6x0pga6HgrjBOJb24mMDHorFopOOd6YHkLgOZ+zaCjZGPO4aKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-property-literals": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.27.1.tgz", + "integrity": "sha512-oThy3BCuCha8kDZ8ZkgOg2exvPYUlprMukKQXI1r1pJ47NCvxfkEy8vK+r/hT9nF0Aa4H1WUPZZjHTFtAhGfmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-regenerator": { + "version": "7.27.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.27.5.tgz", + "integrity": "sha512-uhB8yHerfe3MWnuLAhEbeQ4afVoqv8BQsPqrTv7e/jZ9y00kJL6l9a/f4OWaKxotmjzewfEyXE1vgDJenkQ2/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-reserved-words": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.27.1.tgz", + "integrity": "sha512-V2ABPHIJX4kC7HegLkYoDpfg9PVmuWy/i6vUM5eGK22bx4YVFD3M5F0QQnWQoDs6AGsUWTVOopBiMFQgHaSkVw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-shorthand-properties": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.27.1.tgz", + "integrity": "sha512-N/wH1vcn4oYawbJ13Y/FxcQrWk63jhfNa7jef0ih7PHSIHX2LB7GWE1rkPrOnka9kwMxb6hMl19p7lidA+EHmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-spread": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-spread/-/plugin-transform-spread-7.27.1.tgz", + "integrity": "sha512-kpb3HUqaILBJcRFVhFUs6Trdd4mkrzcGXss+6/mxUd273PfbWqSDHRzMT2234gIg2QYfAjvXLSquP1xECSg09Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-sticky-regex": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.27.1.tgz", + "integrity": "sha512-lhInBO5bi/Kowe2/aLdBAawijx+q1pQzicSgnkB6dUPc1+RC8QmJHKf2OjvU+NZWitguJHEaEmbV6VWEouT58g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-template-literals": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.27.1.tgz", + "integrity": "sha512-fBJKiV7F2DxZUkg5EtHKXQdbsbURW3DZKQUWphDum0uRP6eHGGa/He9mc0mypL680pb+e/lDIthRohlv8NCHkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-typeof-symbol": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.27.1.tgz", + "integrity": "sha512-RiSILC+nRJM7FY5srIyc4/fGIwUhyDuuBSdWn4y6yT6gm652DpCHZjIipgn6B7MQ1ITOUnAKWixEUjQRIBIcLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-typescript": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.27.1.tgz", + "integrity": "sha512-Q5sT5+O4QUebHdbwKedFBEwRLb02zJ7r4A5Gg2hUoLuU3FjdMcyqcywqUrLCaDsFCxzokf7u9kuy7qz51YUuAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.27.1", + "@babel/helper-create-class-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/helper-skip-transparent-expression-wrappers": "^7.27.1", + "@babel/plugin-syntax-typescript": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-escapes": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.27.1.tgz", + "integrity": "sha512-Ysg4v6AmF26k9vpfFuTZg8HRfVWzsh1kVfowA23y9j/Gu6dOuahdUVhkLqpObp3JIv27MLSii6noRnuKN8H0Mg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-regex": { + "version": "7.27.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.27.1.tgz", + "integrity": "sha512-xvINq24TRojDuyt6JGtHmkVkrfVV3FPT16uytxImLeBZqW3/H52yN+kM1MGuyPkIQxrzKwPHs5U/MP3qKyzkGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/preset-env": { + "version": "7.20.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/preset-env/-/preset-env-7.20.2.tgz", + "integrity": "sha512-1G0efQEWR1EHkKvKHqbG+IN/QdgwfByUpM5V5QroDzGV2t3S/WXNQd693cHiHTlCFMpr9B6FkPFXDA2lQcKoDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.20.1", + "@babel/helper-compilation-targets": "^7.20.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/helper-validator-option": "^7.18.6", + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.18.6", + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.18.9", + "@babel/plugin-proposal-async-generator-functions": "^7.20.1", + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/plugin-proposal-class-static-block": "^7.18.6", + "@babel/plugin-proposal-dynamic-import": "^7.18.6", + "@babel/plugin-proposal-export-namespace-from": "^7.18.9", + "@babel/plugin-proposal-json-strings": "^7.18.6", + "@babel/plugin-proposal-logical-assignment-operators": "^7.18.9", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", + "@babel/plugin-proposal-numeric-separator": "^7.18.6", + "@babel/plugin-proposal-object-rest-spread": "^7.20.2", + "@babel/plugin-proposal-optional-catch-binding": "^7.18.6", + "@babel/plugin-proposal-optional-chaining": "^7.18.9", + "@babel/plugin-proposal-private-methods": "^7.18.6", + "@babel/plugin-proposal-private-property-in-object": "^7.18.6", + "@babel/plugin-proposal-unicode-property-regex": "^7.18.6", + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-class-static-block": "^7.14.5", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-syntax-export-namespace-from": "^7.8.3", + "@babel/plugin-syntax-import-assertions": "^7.20.0", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5", + "@babel/plugin-syntax-top-level-await": "^7.14.5", + "@babel/plugin-transform-arrow-functions": "^7.18.6", + "@babel/plugin-transform-async-to-generator": "^7.18.6", + "@babel/plugin-transform-block-scoped-functions": "^7.18.6", + "@babel/plugin-transform-block-scoping": "^7.20.2", + "@babel/plugin-transform-classes": "^7.20.2", + "@babel/plugin-transform-computed-properties": "^7.18.9", + "@babel/plugin-transform-destructuring": "^7.20.2", + "@babel/plugin-transform-dotall-regex": "^7.18.6", + "@babel/plugin-transform-duplicate-keys": "^7.18.9", + "@babel/plugin-transform-exponentiation-operator": "^7.18.6", + "@babel/plugin-transform-for-of": "^7.18.8", + "@babel/plugin-transform-function-name": "^7.18.9", + "@babel/plugin-transform-literals": "^7.18.9", + "@babel/plugin-transform-member-expression-literals": "^7.18.6", + "@babel/plugin-transform-modules-amd": "^7.19.6", + "@babel/plugin-transform-modules-commonjs": "^7.19.6", + "@babel/plugin-transform-modules-systemjs": "^7.19.6", + "@babel/plugin-transform-modules-umd": "^7.18.6", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.19.1", + "@babel/plugin-transform-new-target": "^7.18.6", + "@babel/plugin-transform-object-super": "^7.18.6", + "@babel/plugin-transform-parameters": "^7.20.1", + "@babel/plugin-transform-property-literals": "^7.18.6", + "@babel/plugin-transform-regenerator": "^7.18.6", + "@babel/plugin-transform-reserved-words": "^7.18.6", + "@babel/plugin-transform-shorthand-properties": "^7.18.6", + "@babel/plugin-transform-spread": "^7.19.0", + "@babel/plugin-transform-sticky-regex": "^7.18.6", + "@babel/plugin-transform-template-literals": "^7.18.9", + "@babel/plugin-transform-typeof-symbol": "^7.18.9", + "@babel/plugin-transform-unicode-escapes": "^7.18.10", + "@babel/plugin-transform-unicode-regex": "^7.18.6", + "@babel/preset-modules": "^0.1.5", + "@babel/types": "^7.20.2", + "babel-plugin-polyfill-corejs2": "^0.3.3", + "babel-plugin-polyfill-corejs3": "^0.6.0", + "babel-plugin-polyfill-regenerator": "^0.4.1", + "core-js-compat": "^3.25.1", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/preset-modules": { + "version": "0.1.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/preset-modules/-/preset-modules-0.1.6.tgz", + "integrity": "sha512-ID2yj6K/4lKfhuU3+EX4UvNbIt7eACFbHmNUjzA+ep+B5971CknnA/9DEWKbRokfbbtblxxxXFJJrH47UEAMVg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", + "@babel/plugin-transform-dotall-regex": "^7.4.4", + "@babel/types": "^7.4.4", + "esutils": "^2.0.2" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" + } + }, + "node_modules/@babel/preset-typescript": { + "version": "7.18.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/preset-typescript/-/preset-typescript-7.18.6.tgz", + "integrity": "sha512-s9ik86kXBAnD760aybBucdpnLsAt0jK1xqJn2juOn9lkOvSHV60os5hxoVJsPzMQxvnUJFAlkont2DvvaYEBtQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/helper-validator-option": "^7.18.6", + "@babel/plugin-transform-typescript": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.20.13", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/runtime/-/runtime-7.20.13.tgz", + "integrity": "sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.27.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/template/-/template-7.27.2.tgz", + "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/parser": "^7.27.2", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.27.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/traverse/-/traverse-7.27.4.tgz", + "integrity": "sha512-oNcu2QbHqts9BtOWJosOVJapWjBDSxGCpFvikNR5TGDYDQf3JwpIoMzIKrvfoti93cLfPJEG4tH9SPVeyCGgdA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.27.3", + "@babel/parser": "^7.27.4", + "@babel/template": "^7.27.2", + "@babel/types": "^7.27.3", + "debug": "^4.3.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.27.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/@babel/types/-/types-7.27.6.tgz", + "integrity": "sha512-ETyHEk2VHHvl9b9jZP5IHPavHYk57EhanlRRuae9XCpb/j5bDCbPPMOBfCWhnl/7EDJz0jEMCi/RhccCE8r1+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://repo.huaweicloud.com/repository/npm/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@nicolo-ribaudo/chokidar-2": { + "version": "2.1.8-no-fsevents.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz", + "integrity": "sha512-s88O1aVtXftvp5bCPB7WnmXc5IwOZZ7YPuwNPt+GtOOXpPvad1LfbmjYv+qII7zP6RU2QGnqve27dnLycEnyEQ==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@tsconfig/recommended": { + "version": "1.0.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/@tsconfig/recommended/-/recommended-1.0.8.tgz", + "integrity": "sha512-TotjFaaXveVUdsrXCdalyF6E5RyG6+7hHHQVZonQtdlk1rJZ1myDIvPUUKPhoYv+JAzThb2lQJh9+9ZfF46hsA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "18.19.111", + "resolved": "https://repo.huaweicloud.com/repository/npm/@types/node/-/node-18.19.111.tgz", + "integrity": "sha512-90sGdgA+QLJr1F9X79tQuEut0gEYIfkX9pydI4XGRgvFo9g2JWswefI+WUSUHPYVBHYSEfTEqBxA5hQvAZB3Mw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "optional": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/babel-plugin-polyfill-corejs2": { + "version": "0.3.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz", + "integrity": "sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.17.7", + "@babel/helper-define-polyfill-provider": "^0.3.3", + "semver": "^6.1.1" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/babel-plugin-polyfill-corejs3": { + "version": "0.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.6.0.tgz", + "integrity": "sha512-+eHqR6OPcBhJOGgsIar7xoAB1GcSwVUA3XjAd7HJNzOXT4wv6/H7KIdA/Nc60cvUlDbKApmqNvD1B1bzOt4nyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.3.3", + "core-js-compat": "^3.25.1" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/babel-plugin-polyfill-regenerator": { + "version": "0.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.1.tgz", + "integrity": "sha512-NtQGmyQDXjQqQ+IzRkBVwEOz9lQ4zxAQZgoAYEtU9dJjnl1Oc98qnN7jcp+bE7O7aYzVpavXE3/VKXNzUbh7aw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.3.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://repo.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.25.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/browserslist/-/browserslist-4.25.0.tgz", + "integrity": "sha512-PJ8gYKeS5e/whHBh8xrwYK+dAvEj7JXtz6uTucnMRB8OiGTsKccFekoRrjajPBHV8oOY+2tI4uxeceSimKwMFA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "caniuse-lite": "^1.0.30001718", + "electron-to-chromium": "^1.5.160", + "node-releases": "^2.0.19", + "update-browserslist-db": "^1.1.3" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001723", + "resolved": "https://repo.huaweicloud.com/repository/npm/caniuse-lite/-/caniuse-lite-1.0.30001723.tgz", + "integrity": "sha512-1R/elMjtehrFejxwmexeXAtae5UO9iSyFn6G/I806CYC/BLyyBk1EPhrKBkWhy6wM6Xnm47dSJQec+tLJ39WHw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/commander": { + "version": "4.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true, + "license": "MIT" + }, + "node_modules/core-js-compat": { + "version": "3.43.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/core-js-compat/-/core-js-compat-3.43.0.tgz", + "integrity": "sha512-2GML2ZsCc5LR7hZYz4AXmjQw8zuy2T//2QntwdnpuYI7jteT6GVYJL7F6C2C57R7gSYrcqVW3lAALefdbhBLDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "browserslist": "^4.25.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/debug": { + "version": "4.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/debug/-/debug-4.4.1.tgz", + "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.167", + "resolved": "https://repo.huaweicloud.com/repository/npm/electron-to-chromium/-/electron-to-chromium-1.5.167.tgz", + "integrity": "sha512-LxcRvnYO5ez2bMOFpbuuVuAI5QNeY1ncVytE/KXaL6ZNfzX1yPlAO0nSOyIHx2fVAuUprMqPs/TdVhUFZy7SIQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs-readdir-recursive": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", + "integrity": "sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==", + "dev": true, + "license": "MIT" + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "optional": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/lodash.debounce": { + "version": "4.0.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pify": "^4.0.1", + "semver": "^5.6.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-addon-api": { + "version": "8.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/node-addon-api/-/node-addon-api-8.3.1.tgz", + "integrity": "sha512-lytcDEdxKjGJPTLEfW4mYMigRezMlyJY8W4wxJK8zE533Jlb8L8dRuObJFWg2P+AuOIxoCgKF+2Oq4d4Zd0OUA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18 || ^20 || >= 21" + } + }, + "node_modules/node-releases": { + "version": "2.0.19", + "resolved": "https://repo.huaweicloud.com/repository/npm/node-releases/-/node-releases-2.0.19.tgz", + "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pify": { + "version": "4.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/regenerate": { + "version": "1.4.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/regenerate/-/regenerate-1.4.2.tgz", + "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", + "dev": true, + "license": "MIT" + }, + "node_modules/regenerate-unicode-properties": { + "version": "10.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/regenerate-unicode-properties/-/regenerate-unicode-properties-10.2.0.tgz", + "integrity": "sha512-DqHn3DwbmmPVzeKj9woBadqmXxLvQoQIwu7nopMc72ztvxVmVk2SBhSnx67zuye5TP+lJsb/TBQsjLKhnDf3MA==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerate": "^1.4.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "dev": true, + "license": "MIT" + }, + "node_modules/regexpu-core": { + "version": "6.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/regexpu-core/-/regexpu-core-6.2.0.tgz", + "integrity": "sha512-H66BPQMrv+V16t8xtmq+UC0CBpiTBA60V8ibS1QVReIp8T1z8hwFxqcGzm9K6lgsN7sB5edVH8a+ze6Fqm4weA==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerate": "^1.4.2", + "regenerate-unicode-properties": "^10.2.0", + "regjsgen": "^0.8.0", + "regjsparser": "^0.12.0", + "unicode-match-property-ecmascript": "^2.0.0", + "unicode-match-property-value-ecmascript": "^2.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regjsgen": { + "version": "0.8.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/regjsgen/-/regjsgen-0.8.0.tgz", + "integrity": "sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/regjsparser": { + "version": "0.12.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/regjsparser/-/regjsparser-0.12.0.tgz", + "integrity": "sha512-cnE+y8bz4NhMjISKbgeVJtqNbtf5QpjZP+Bslo+UqkIt9QPnX9q095eiRRASJG1/tz6dlNr6Z5NsBiWYokp6EQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "jsesc": "~3.0.2" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/regjsparser/node_modules/jsesc": { + "version": "3.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/resolve": { + "version": "1.22.10", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/slash": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + }, + "node_modules/unicode-canonical-property-names-ecmascript": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz", + "integrity": "sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-ecmascript": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", + "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "unicode-canonical-property-names-ecmascript": "^2.0.0", + "unicode-property-aliases-ecmascript": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-value-ecmascript": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.2.0.tgz", + "integrity": "sha512-4IehN3V/+kkr5YeSSDDQG8QLqO26XpL2XP3GQtqwlT/QYSECAwFztxVHjlbh0+gjJ3XmNLS0zDsbgs9jWKExLg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-property-aliases-ecmascript": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz", + "integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz", + "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + } + } +} -- Gitee From 53b08cb83202eaa7a1a4dd429fe31a4ed10581b0 Mon Sep 17 00:00:00 2001 From: lihao Date: Fri, 13 Jun 2025 18:12:04 +0800 Subject: [PATCH 102/140] add install declgen script Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/ICF3P5 Signed-off-by: lihao --- compiler/script/install_declgen.sh | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 compiler/script/install_declgen.sh diff --git a/compiler/script/install_declgen.sh b/compiler/script/install_declgen.sh new file mode 100644 index 000000000..ca35365e4 --- /dev/null +++ b/compiler/script/install_declgen.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Copyright (c) 2025 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. + +#!/bin/bash +set -e + +if [ ! -d "../compiler" ]; then + echo "Error: must run this script in ace_ets2bundle/compiler root directory" + exit 1 +fi + +oriDir=$(pwd) + +DECLGEN_ROOT_DIR="../../../arkcompiler/runtime_core/static_core/plugins/ets/tools/declgen_ts2sts" + +cd "$DECLGEN_ROOT_DIR" || { echo "Failed to change directory to $DECLGEN_ROOT_DIR"; exit 1; } + +npm install +npm run build + +# Generate the npm package using `npm pack` +if npm pack; then + tarball=$(ls *.tgz) # Get the generated tarball file name + if [ -f "$tarball" ]; then + # Move the tarball to the original directory + mv "$tarball" "$oriDir/" + + # Go back to the original directory and extract the tarball + cd "$oriDir" + tar -xvzf "$tarball" + + # Rename the extracted directory (assuming it is named after the package) + extracted_dir=$(tar -tf "$tarball" | head -n 1 | cut -f1 -d"/") # Get the extracted folder name + mv "$extracted_dir" "./node_modules/declgen" # Rename to 'declgen' + + # Optionally, remove the tarball after extraction + rm "$tarball" + + echo "Build successfully packed, extracted, and renamed to 'declgen' in $oriDir" + else + echo "Error: No tarball found, cannot proceed" + exit 1 + fi +else + echo "Error: npm pack failed" + exit 1 +fi -- Gitee From 657a963a72765842db1bcedefad9307e4ddb704c Mon Sep 17 00:00:00 2001 From: Bojiang Date: Tue, 1 Apr 2025 20:46:35 +0800 Subject: [PATCH 103/140] jiangbo91@huawei.com fix $r $rawfile `` Signed-off-by: Bojiang Change-Id: I3dac930d0e4b71a513a007e3b209f4ca3a26d2aa --- compiler/src/process_ui_syntax.ts | 2 +- .../resource/resourceTest.js.sample | 58 +++++++++++++++++++ .../resource/resourceTest.ets | 25 ++++++++ .../test/transform_ut/helpers/pathConfig.ts | 2 + 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 745b53a78..cada4b755 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -736,7 +736,7 @@ export function isAnimateToOrImmediately(node: ts.Node): boolean { export function processResourceData(node: ts.CallExpression, filePath: string, previewLog: {isAcceleratePreview: boolean, log: LogInfo[]} = {isAcceleratePreview: false, log: []}): ts.Node { - if (ts.isStringLiteral(node.arguments[0])) { + if (ts.isStringLiteral(node.arguments[0]) || ts.isNoSubstitutionTemplateLiteral(node.arguments[0])) { const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.'); const isResourceModule: boolean = resourceData.length && /^\[.*\]$/g.test(resourceData[0]); if (node.expression.getText() === RESOURCE_RAWFILE) { diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample new file mode 100644 index 000000000..f3d898bf4 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022-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. + */ +"use strict"; +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +class Index extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Image.create({ "id": 0, "type": 30000, params: ['foreground.png'], "bundleName": "com.example.application", "moduleName": "application" }); + }, Image); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Image.create({ "id": 0, "type": 30000, params: [`foreground.png`], "bundleName": "com.example.application", "moduleName": "application" }); + }, Image); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName() { + return "Index"; + } +} +registerNamedRoute(() => new Index(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/resource/resourceTest", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest", integratedHsp: "false", moduleType: "followWithHap" }); +//# sourceMappingURL=resourceTest.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets new file mode 100644 index 000000000..57402fbdb --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-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. + */ +// Reusable test +@Entry +@Component +struct Index { + build() { + Row() { + Image($rawfile('foreground.png')) + Image($rawfile(`foreground.png`)) + } + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/pathConfig.ts b/compiler/test/transform_ut/helpers/pathConfig.ts index 9ed688e8a..8e000937f 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -212,6 +212,8 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'v2_component_decorator/reusableV2/reusableV2_initialRender', 'v2_component_decorator/reusableV2/reusableV2_members', 'v2_component_decorator/reusableV2/reusableV2_component_nesting', + + 'resource/resourceTest', ]; export const UT_VALIDATE_PAGES_PREVIEW: string[] = []; -- Gitee From 770e8ed7e93475301f3777db69eb15cd1f095b39 Mon Sep 17 00:00:00 2001 From: zenghang Date: Tue, 4 Feb 2025 16:31:51 +0800 Subject: [PATCH 104/140] Integrate declgen to ets2bundle Issue: IBNHVK Signed-off-by: zenghang Change-Id: I8911bde90e5f1d7f9737a3711f639a2ae7852eec --- BUILD.gn | 14 +++-- compiler/script/install_declgen.sh | 58 ------------------- compiler/src/ets_checker.ts | 34 +++++++++++ ..._tsc.py => install_arkguard_tsc_declgen.py | 3 +- 4 files changed, 45 insertions(+), 64 deletions(-) delete mode 100644 compiler/script/install_declgen.sh rename install_arkguard_tsc.py => install_arkguard_tsc_declgen.py (96%) diff --git a/BUILD.gn b/BUILD.gn index f97a5eb55..22af53086 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -41,7 +41,7 @@ action("build_ets_loader_library") { deps = [ ":components", ":form_components", - ":install_arkguard_tsc", + ":install_arkguard_tsc_declgen", ":server", "//interface/sdk-js:bundle_arkts", "//interface/sdk-js:bundle_kits", @@ -173,7 +173,7 @@ ets_loader_sources = [ ohos_copy("ets_loader") { deps = [ ":build_ets_loader_library", - ":install_arkguard_tsc", + ":install_arkguard_tsc_declgen", ] sources = ets_loader_sources deps += [ ":build_ets_sysResource" ] @@ -260,7 +260,7 @@ ohos_copy("ets_loader_declaration") { ohos_copy("ets_loader_ark") { deps = [ ":build_ets_loader_library", - ":install_arkguard_tsc", + ":install_arkguard_tsc_declgen", ] sources = ets_loader_sources deps += [ ":build_ets_sysResource" ] @@ -347,18 +347,22 @@ group("ets_loader_ark_hap") { typescript_dir = get_label_info("//third_party/typescript:build_typescript", "target_out_dir") -action("install_arkguard_tsc") { +action("install_arkguard_tsc_declgen") { + static_core = "//arkcompiler/runtime_core/static_core" deps = [ + "${static_core}/plugins/ets/tools/declgen_ts2sts:build_declgen", "//arkcompiler/ets_frontend/arkguard:build_arkguard", "//third_party/typescript:build_typescript", ] - script = "install_arkguard_tsc.py" + script = "install_arkguard_tsc_declgen.py" args = [ rebase_path("${typescript_dir}/ohos-typescript-4.9.5-r4.tgz"), rebase_path( "${root_out_dir}/obj/arkcompiler/ets_frontend/arkguard/arkguard-1.1.3.tgz"), rebase_path("//developtools/ace_ets2bundle/compiler"), current_os, + rebase_path( + "${root_out_dir}/obj/arkcompiler/runtime_core/static_core/plugins/ets/tools/declgen_ts2sts/panda-declgen-1.0.0.tgz"), ] outputs = [ "${target_out_dir}/${target_name}.stamp" ] } diff --git a/compiler/script/install_declgen.sh b/compiler/script/install_declgen.sh deleted file mode 100644 index ca35365e4..000000000 --- a/compiler/script/install_declgen.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# Copyright (c) 2025 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. - -#!/bin/bash -set -e - -if [ ! -d "../compiler" ]; then - echo "Error: must run this script in ace_ets2bundle/compiler root directory" - exit 1 -fi - -oriDir=$(pwd) - -DECLGEN_ROOT_DIR="../../../arkcompiler/runtime_core/static_core/plugins/ets/tools/declgen_ts2sts" - -cd "$DECLGEN_ROOT_DIR" || { echo "Failed to change directory to $DECLGEN_ROOT_DIR"; exit 1; } - -npm install -npm run build - -# Generate the npm package using `npm pack` -if npm pack; then - tarball=$(ls *.tgz) # Get the generated tarball file name - if [ -f "$tarball" ]; then - # Move the tarball to the original directory - mv "$tarball" "$oriDir/" - - # Go back to the original directory and extract the tarball - cd "$oriDir" - tar -xvzf "$tarball" - - # Rename the extracted directory (assuming it is named after the package) - extracted_dir=$(tar -tf "$tarball" | head -n 1 | cut -f1 -d"/") # Get the extracted folder name - mv "$extracted_dir" "./node_modules/declgen" # Rename to 'declgen' - - # Optionally, remove the tarball after extraction - rm "$tarball" - - echo "Build successfully packed, extracted, and renamed to 'declgen' in $oriDir" - else - echo "Error: No tarball found, cannot proceed" - exit 1 - fi -else - echo "Error: npm pack failed" - exit 1 -fi diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 31c906433..24cdb30ee 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -103,6 +103,10 @@ import { import { ErrorCodeModule } from './hvigor_error_code/const/error_code_module'; import { buildErrorInfoFromDiagnostic } from './hvigor_error_code/utils'; import { concatenateEtsOptions, getExternalComponentPaths } from './external_component_map'; +import { + RunnerParms, + generateInteropDecls +} from '../node_modules/declgen/build/src/generateInteropDecls' export interface LanguageServiceCache { service?: ts.LanguageService; @@ -601,6 +605,10 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null MemoryMonitor.stopRecordStage(processBuildHaprrecordInfo); } + if (rollupShareObject?.projectConfig.mixCompile) { + generateDeclarationFileForSTS(rootFileNames, allResolvedModules); + } + maxMemoryInServiceChecker = process.memoryUsage().heapUsed; // Release the typeChecker early and perform GC in the following scenarios: // In memory-priority mode or default mode, when the preview mode is disabled in a full compilation scenario, @@ -1869,3 +1877,29 @@ export function resetEtsCheck(): void { fileToIgnoreDiagnostics = undefined; maxMemoryInServiceChecker = 0; } + +export function generateDeclarationFileForSTS(rootFileNames: string[], allResolvedModules: Set) { + if (!(projectConfig.compileHar || projectConfig.compileShared)) { + return; + } + const unixRootFileNames = rootFileNames.map(path => { + return toUnixPath(path); + }); + + const uniqueFiles = Array.from(new Set([ + ...unixRootFileNames, + ...allResolvedModules + ])); + + const config: RunnerParms = { + inputDirs: [], + inputFiles: uniqueFiles, + outDir: path.resolve(projectConfig.aceModuleBuild, '../etsFortgz/ets'), + rootDir: projectConfig.projectRootPath, + customResolveModuleNames: resolveModuleNames + }; + if (fs.existsSync(config.outDir)) { + fs.rmSync(config.outDir, { recursive: true, force: true }); + } + generateInteropDecls(config); +} \ No newline at end of file diff --git a/install_arkguard_tsc.py b/install_arkguard_tsc_declgen.py similarity index 96% rename from install_arkguard_tsc.py rename to install_arkguard_tsc_declgen.py index 61284e51e..5fb5d0c1b 100755 --- a/install_arkguard_tsc.py +++ b/install_arkguard_tsc_declgen.py @@ -54,10 +54,11 @@ def run(args): arkguard_path = args[1] source_path = args[2] current_os = args[3] + declgen_path = args[4] node_modules_path = os.path.join(source_path, "node_modules") extract(tsc_path, node_modules_path, 'typescript', current_os) extract(arkguard_path, node_modules_path, 'arkguard', current_os) - + extract(declgen_path, node_modules_path, 'declgen', current_os) if __name__ == "__main__": run(sys.argv[1:]) \ No newline at end of file -- Gitee From c5ff1feb45f09635bf679ac068d40374e6892f77 Mon Sep 17 00:00:00 2001 From: zenghang Date: Wed, 5 Feb 2025 10:26:16 +0800 Subject: [PATCH 105/140] Extract es2abc from rollup toolchain Issue: IBK3CK Signed-off-by: zenghang Change-Id: I155ffea638e5767f727736f4e268683f59dc5d57 --- .../ark_compiler/common/ark_define.ts | 3 + .../ark_compiler/module/module_mode.ts | 13 +- .../ark_compiler/run_es2abc_standalone.ts | 175 ++++++++++++++++++ .../run_es2abc_standalone.test.ts | 124 +++++++++++++ .../expect/compileContextInfo.json | 14 ++ .../mergeCacheData/expect/sourceMaps.map | 100 ++++++++++ .../originCacheDir1/compileContextInfo.json | 9 + .../originCacheDir1/filesInfo.txt | 3 + .../originCacheDir1/npmEntries.txt | 7 + .../originCacheDir1/sourceMaps.map | 56 ++++++ .../originCacheDir2/compileContextInfo.json | 11 ++ .../originCacheDir2/filesInfo.txt | 3 + .../originCacheDir2/npmEntries.txt | 7 + .../originCacheDir2/sourceMaps.json | 46 +++++ 14 files changed, 570 insertions(+), 1 deletion(-) create mode 100644 compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts create mode 100644 compiler/test/ark_compiler_ut/run_es2abc_standalone.test.ts create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/expect/compileContextInfo.json create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/expect/sourceMaps.map create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/compileContextInfo.json create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/filesInfo.txt create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/npmEntries.txt create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/sourceMaps.map create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/compileContextInfo.json create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/filesInfo.txt create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/npmEntries.txt create mode 100644 compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/sourceMaps.json diff --git a/compiler/src/fast_build/ark_compiler/common/ark_define.ts b/compiler/src/fast_build/ark_compiler/common/ark_define.ts index 385d49f18..9bbbb62fc 100644 --- a/compiler/src/fast_build/ark_compiler/common/ark_define.ts +++ b/compiler/src/fast_build/ark_compiler/common/ark_define.ts @@ -123,6 +123,9 @@ export const SEPARATOR_BITWISE_AND: string = '&'; export const SEPARATOR_AT: string = '@'; export const SEPARATOR_SLASH: string = '/'; +export const GEN_ABC_CMD: string = "genAbcCmd"; +export const GEN_ABC_CMD_FILE_PATH: string = "genAbcCmd.json"; + export const ES_ANNOTATIONS = [ '_ESConcurrentModuleRequestsAnnotation', '_ESSlotNumberAnnotation', diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index a619cb2ef..821252cbd 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -54,7 +54,8 @@ import { ETS, TS, JS, - PERFREPORT_JSON + PERFREPORT_JSON, + GEN_ABC_CMD } from '../common/ark_define'; import { needAotCompiler, @@ -175,6 +176,7 @@ export class ModuleMode extends CommonMode { abcPaths: string[] = []; byteCodeHar: boolean; perfReportPath: string; + rollupCache: Object; constructor(rollupObject: Object) { super(rollupObject); @@ -208,6 +210,7 @@ export class ModuleMode extends CommonMode { if (this.useNormalizedOHMUrl) { this.compileContextInfoPath = this.generateCompileContextInfo(rollupObject); } + this.rollupCache = rollupObject.cache; } private generateCompileContextInfo(rollupObject: Object): string { @@ -674,6 +677,14 @@ export class ModuleMode extends CommonMode { // collect data error from subprocess let logDataList: Object[] = []; let errMsg: string = ''; + const eventGenDescriptionsForMergedEs2abc = createAndStartEvent(parentEvent, 'generate descriptions for merged es2abc'); + stopEvent(eventGenDescriptionsForMergedEs2abc); + + if (this.projectConfig.invokeEs2abcByHvigor) { + this.rollupCache.set(GEN_ABC_CMD, this.cmdArgs); + return; + } + const genAbcCmd: string = this.cmdArgs.join(' '); let eventGenAbc: CompileEvent; try { diff --git a/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts b/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts new file mode 100644 index 000000000..8ec011349 --- /dev/null +++ b/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2025 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 fs from 'fs'; +import path from 'path'; +import childProcess from 'child_process'; +import { + COMPILE_CONTEXT_INFO_JSON, + FILESINFO_TXT, + GEN_ABC_CMD_FILE_PATH, + MODULES_ABC, + MODULES_CACHE, + NPMENTRIES_TXT, + SOURCEMAPS, + SOURCEMAPS_JSON +} from './common/ark_define'; + +/** + * A script is called by hvigor in a mixed compilation scenario which 1.0 module is not main module,np + * such as module1.2-> module1.0-> module1.2 -> module1.0, compile all 1.0 modules + * and has nothing to do with the ace_ets2bundle process. + */ + +/** + * + * @param cachePathList projectConfig.cachePath of the modules to be merged + * @param targetCachePath The merged target cache directory + * @param aceModuleBuild The aceModuleBuild path of the target module is used to write the abc file to the disk + * @returns erro.toString() + */ +export function run(cachePathList: string[], targetCachePath: string, aceModuleBuild: string): void { + if (!cachePathList || cachePathList.length == 0) { + return + } + mergeCacheData(cachePathList, targetCachePath, FILESINFO_TXT); + mergeCacheData(cachePathList, targetCachePath, MODULES_CACHE); + mergeCacheData(cachePathList, targetCachePath, NPMENTRIES_TXT); + mergeCompileContextInfo(cachePathList, targetCachePath); + mergeSourceMap(cachePathList, targetCachePath); + const cmd: string[] = JSON.parse(fs.readFileSync(path.join(cachePathList[0], GEN_ABC_CMD_FILE_PATH), 'utf-8')); + updateCmd(cmd, targetCachePath, aceModuleBuild); + execCmd(cmd); +} + +export function mergeCacheData(cachePathList: string[], targetCachePath: string, fileName: string): void { + const dataSet: Set = new Set(); + cachePathList.forEach(cachePath => { + const inputFilePath: string = path.join(cachePath, fileName); + if (fs.existsSync(inputFilePath)) { + const fileData: string = fs.readFileSync(inputFilePath).toString(); + fileData.split('\n').forEach(data => { + //eat blank line + if (data) { + dataSet.add(data); + } + }); + } + }); + + const outputFilePath: string = path.join(targetCachePath, fileName); + fs.writeFileSync(outputFilePath, Array.from(dataSet).join('\n')); +} + +function execCmd(cmd: string[]): string { + try { + const result = childProcess.execSync(cmd.join(' '), { + windowsHide: true, + encoding: 'utf-8' + }); + return result; + } catch (error) { + return error.toString(); + } +} + +export function updateCmd(cmd: string[], targetCachePath: string, aceModuleBuild: string) { + for (let i = 0; i < cmd.length; i++) { + if (cmd[i].indexOf("filesInfo.txt") != -1) { + const filesInfoPath: string = path.join(targetCachePath, FILESINFO_TXT); + cmd[i] = `"@${filesInfoPath}"`; + continue; + } + if (cmd[i] === ('--output')) { + const moduleAbcPath = path.join(aceModuleBuild, MODULES_ABC); + cmd[++i] = `"${moduleAbcPath}"`; + continue; + } + if (cmd[i] === ('--cache-file')) { + const cacheFilePath = path.join(targetCachePath, MODULES_CACHE); + cmd[++i] = `"@${cacheFilePath}"`; + continue; + } + if (cmd[i] === ('--npm-module-entry-list')) { + const npmEntriesInfoPath = path.join(targetCachePath, NPMENTRIES_TXT); + cmd[++i] = `"@${npmEntriesInfoPath}"`; + continue; + } + if (cmd[i] === (`--compile-context-info`)) { + const compileContextInfoPath = path.join(targetCachePath, COMPILE_CONTEXT_INFO_JSON); + cmd[++i] = `"${compileContextInfoPath}"`; + continue; + } + } +} + +function deepMerge(target: Object, source: Object): Object { + for (const key of Object.keys(source)) { + if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) { + target[key] = deepMerge(target[key] || {}, source[key]); + } else { + target[key] = source[key]; + } + } + return target; +} + +export function mergeCompileContextInfo(cachePathList: string[], targetCachePath: string) { + const mergedData = { + hspPkgNames: [], + compileEntries: [], + updateVersionInfo: {} + }; + + cachePathList.forEach(cachePath => { + const compileContextPath = path.join(cachePath, COMPILE_CONTEXT_INFO_JSON); + + if (fs.existsSync(compileContextPath)) { + const data = JSON.parse(fs.readFileSync(compileContextPath, 'utf-8')); + + mergedData.hspPkgNames = [...mergedData.hspPkgNames, ...data.hspPkgNames]; + mergedData.compileEntries = [...mergedData.compileEntries, ...data.compileEntries]; + + mergedData.updateVersionInfo = deepMerge(mergedData.updateVersionInfo, data.updateVersionInfo); + } + }); + + const targetPath = path.join(targetCachePath, COMPILE_CONTEXT_INFO_JSON); + fs.writeFileSync(targetPath, JSON.stringify(mergedData, null, 2)); +} + +export function mergeSourceMap(cachePathList: string[], targetCachePath: string) { + const mergedMap: Record = {}; + cachePathList.forEach((item) => { + /** + * Prevent sourcemap.json file from not being generated. + * Some bug scenarios only have one file written to disk. + */ + const possiblePaths = [ + path.join(item, SOURCEMAPS), + path.join(item, SOURCEMAPS_JSON), + ]; + + const sourceMapPath = possiblePaths.find(fs.existsSync); + if (!sourceMapPath) { + return; + } + const sourceMap = JSON.parse(fs.readFileSync(sourceMapPath, 'utf-8')); + Object.assign(mergedMap, sourceMap); + }); + + const outputPath = path.join(targetCachePath, SOURCEMAPS); + fs.writeFileSync(outputPath, JSON.stringify(mergedMap, null, 2), 'utf-8'); +} diff --git a/compiler/test/ark_compiler_ut/run_es2abc_standalone.test.ts b/compiler/test/ark_compiler_ut/run_es2abc_standalone.test.ts new file mode 100644 index 000000000..108aba948 --- /dev/null +++ b/compiler/test/ark_compiler_ut/run_es2abc_standalone.test.ts @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use rollupObject 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 mocha from 'mocha'; +import path from 'path'; +import fs from 'fs'; +import { + expect +} from 'chai'; +import { + COMPILE_CONTEXT_INFO_JSON, + FILESINFO_TXT, + MODULES_CACHE, + NPMENTRIES_TXT, + RELEASE, + SOURCEMAPS, +} from '../../lib/fast_build/ark_compiler/common/ark_define'; +import { + mergeCacheData, + mergeCompileContextInfo, + mergeSourceMap, +} from '../../lib/fast_build/ark_compiler/run_es2abc_standalone'; +import RollUpPluginMock from './mock/rollup_mock/rollup_plugin_mock'; + +let MERGE_CACHE_PATH; +let targetCachePath; + +mocha.describe('test run_es2abc_standalone file api', function () { + mocha.before(function () { + this.rollup = new RollUpPluginMock(); + this.rollup.build(); + MERGE_CACHE_PATH=path.join(this.rollup.share.projectConfig.projectRootPath, '/mergeCacheData') + targetCachePath=path.join(MERGE_CACHE_PATH,'/targetCacheDir') + if (!fs.existsSync(targetCachePath)) { + fs.mkdirSync(targetCachePath, { recursive: true }); + } + }); + + mocha.after(function () { + if (fs.existsSync(targetCachePath)) { + fs.rmSync(targetCachePath, { recursive: true, force: true }); + } + }) + + mocha.it('1-1: test mergeCacheData', function () { + + const cachePathList = [ + path.resolve(MERGE_CACHE_PATH, './originCacheDir1'), + path.resolve(MERGE_CACHE_PATH, './originCacheDir2'), + ]; + const fileNameList = [ + FILESINFO_TXT, + NPMENTRIES_TXT + ] + fileNameList.forEach(fileName => { + mergeCacheData(cachePathList, targetCachePath, fileName); + }) + + fileNameList.forEach(fileName => { + + const targetFilePath = path.resolve(targetCachePath, fileName); + const targetLineCount = countLines(targetFilePath); + + let sumOriginLineCount = 0; + cachePathList.forEach(cacheDir => { + const originFilePath = path.resolve(cacheDir, fileName); + if (fs.existsSync(originFilePath)) { + sumOriginLineCount += countLines(originFilePath); + } + }); + expect(targetLineCount).to.equal(sumOriginLineCount); + }); + }); + + mocha.it('1-2: test mergeSourceMap', function () { + const cachePathList = [ + path.resolve(MERGE_CACHE_PATH, './originCacheDir1'), + path.resolve(MERGE_CACHE_PATH, './originCacheDir2'), + ]; + + mergeSourceMap(cachePathList, targetCachePath) + + const mergedSourceMap = JSON.parse(fs.readFileSync(path.resolve(targetCachePath, SOURCEMAPS), 'utf-8')); + const expectSourceMap = JSON.parse(fs.readFileSync(path.join(MERGE_CACHE_PATH, './expect', SOURCEMAPS), 'utf-8')); + + expect(mergedSourceMap).to.deep.equal(expectSourceMap); + }); + + mocha.it('1-3: test mergeCompileContextInfo', function () { + const cachePathList = [ + path.resolve(MERGE_CACHE_PATH, './originCacheDir1'), + path.resolve(MERGE_CACHE_PATH, './originCacheDir2'), + ]; + + mergeCompileContextInfo(cachePathList, targetCachePath); + + const mergedCompileContext = JSON.parse( + fs.readFileSync(path.resolve(targetCachePath, COMPILE_CONTEXT_INFO_JSON), 'utf-8') + ); + + const expectCompileContext = JSON.parse( + fs.readFileSync(path.join(MERGE_CACHE_PATH, './expect',COMPILE_CONTEXT_INFO_JSON), 'utf-8') + ); + + expect(mergedCompileContext).to.deep.equal(expectCompileContext); + }); +}); + +function countLines(filePath) { + const content = fs.readFileSync(filePath, 'utf-8'); + return content.split(/\r?\n/).filter(line => line !== '').length; +} \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/expect/compileContextInfo.json b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/expect/compileContextInfo.json new file mode 100644 index 000000000..07f011f3c --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/expect/compileContextInfo.json @@ -0,0 +1,14 @@ +{ + "hspPkgNames": [], + "compileEntries": [ + "&entry/src/main/ets/entryability/EntryAbility&", + "&entry/src/main/ets/entrybackupability/EntryBackupAbility&", + "&entry/src/main/ets/pages/Index&", + "&har/src/main/ets/components/a&1.0.0", + "&har/src/main/ets/components/aaa&1.0.0", + "&har/src/main/ets/components/MainPage&1.0.0", + "&har/build/default/generated/profile/default/ModuleInfo&1.0.0", + "&har/Index&1.0.0" + ], + "updateVersionInfo": {} +} \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/expect/sourceMaps.map b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/expect/sourceMaps.map new file mode 100644 index 000000000..f8a55a78b --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/expect/sourceMaps.map @@ -0,0 +1,100 @@ +{ + "har|har|1.0.0|build/default/generated/profile/default/ModuleInfo.js": { + "version": 3, + "file": "ModuleInfo.ts", + "sources": [ + "har/build/default/generated/profile/default/ModuleInfo.ts" + ], + "names": [], + "mappings": "AACA,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAwB,EAAE,CAAA,CAAA;AACjE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAwB,EAAE,CAAA,CAAA;", + "entry-package-info": "har|1.0.0" + }, + "har|har|1.0.0|Index.ts": { + "version": 3, + "file": "Index.ets", + "sourceRoot": "", + "sources": [ + "har/Index.ets" + ], + "names": [], + "mappings": "OAAO,EAAE,QAAQ,EAAC,MAAM,EAAE;OACnB,EAAC,CAAC,EAAC", + "entry-package-info": "har|1.0.0" + }, + "har|har|1.0.0|src/main/ets/components/a.ts": { + "version": 3, + "file": "a.ts", + "sourceRoot": "", + "sources": [ + "har/src/main/ets/components/a.ts" + ], + "names": [], + "mappings": "AAEA,MAAM,CAAC,MAAM,IAAI,EAAC,MAAM,GAAC,OAAO,CAAA;AAGhC,MAAM,QAAQ,CAAC,CAAA;IACb,MAAM,CAAC,MAAM,EAAE,GAAC,KAAK,CAAC;IACtB,MAAM,CAAC,MAAM,EAAE,EAAC,MAAM,GAAC,CAAC,CAAC;CAC1B;AAED,MAAM,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AAC5B,MAAM,CAAC,IAAI,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC;AAG9B,SAAS,EAAE,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC,IAAE,CAAC;AACpB,SAAS,EAAE,CAAC,CAAC,EAAC,CAAC,GAAC,CAAC,EAAC,GAAG,CAAC;AAEtB,CAAC;AACD,EAAE,CAAC,CAAC,CAAC,CAAA;AACL,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,CAAA;AACP,MAAM,SAAS;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAGD,MAAM,UAAU;IACd,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC;QACnC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,OAAO;YACL,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC;gBAC5B,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE;oBACvB,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;iBAC9C;qBAAM;oBACL,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;iBACzC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAC;AAClC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;IAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,mBAAmB;CACnD;AAED,UAAU,GAAG,CAAC,CAAC;IACb,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,IAAI,CAAC,CAAC;CACf;AAED,MAAM,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG;IAC7B,KAAK,EAAE,EAAE;IACT,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF,CAAC;AAEF,MAAM,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG;IAC7B,KAAK,EAAE,oBAAoB;IAC3B,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF,CAAC;AACF,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,MAAM,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC,iBAAiB;AAE7C,UAAU,CAAC,CAAA;IACT,MAAM,WAAW,CAAC,CAAA;QAChB,MAAM,UAAU,GAAG,IAAG,IAAI,GAAC,CAAC;KAC7B;IACD,MAAM,CAAC,MAAM,MAAM,EAAC,MAAM,GAAC,CAAC,CAAC;IAC7B,MAAM,SAAS;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB;IACD,UAAU,GAAG,CAAC,CAAC;QACb,KAAK,EAAE,CAAC,CAAC;QACT,QAAQ,IAAI,CAAC,CAAC;KACf;IACD,KAAK,MAAM,SAAS;QAClB,EAAE,IAAA;QACF,IAAI,IAAA;QACJ,IAAI,IAAA;QACJ,KAAK,IAAA;KACN;CAEF;AACD,UAAU;AACV,KAAK,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1B,UAAU;AACV,KAAK,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAEnD,MAAM,GAAG,EAAE,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAExC,UAAU;AACV,KAAK,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/B,KAAK,GAAG,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAEpD,UAAU;AACV,KAAK,WAAW,GAAG;IAAC,MAAM;IAAE,MAAM;CAAC,CAAC;AAEpC,MAAM,KAAK,EAAE,WAAW,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAEpC,UAAU;AACV,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,OAAO,EAAE,OAAO,GAAG;IACvB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,IAAI;CACZ,CAAC;AACF,SAAS;AACT,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAE9D,MAAM;AACN,6CAA6C;AAC7C,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM;IAC5C,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,WAAW,CAAC,CAAA;IAChB,MAAM,WAAW,CAAC,CAAA;QAChB,MAAM,UAAU,CAAC,KAAG,CAAC;QACrB,SAAS,CAAC,KAAG,CAAC;KACf;IACD,UAAU,EAAE,CAAA,GAAE;CACf;AAED,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAEP,UAAU,EAAE,CAAC;IACX,MAAM,KAAK,GAAG,CAAC,CAAC;CACjB;AAED,KAAK,MAAM;IACT,GAAG,IAAA;IACH,GAAG,IAAA;CACJ;AAED,OAAO,EAAC,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,IAAI,OAAO,EAAC,CAAC;AAGrD,OAAO,UAAU,IAAI,CAAC,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACtD,EAAE,EAAE,EAAE,GACL,GAAG,CAAC;AAGP,SAAS,GAAG,CAAC,GAAG,IAAI;AAEpB,CAAC;AAGD,MAAM,QAAQ,CAAC,CAAC;IACd,MAAM,UAAU,CAAC,KAAI,CAAC;IACtB,SAAU,CAAC,KAAG,CAAC;CAChB;AAED,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC;AAG3C,MAAM,CAAC,IAAI,KAAK,EAAC;IAAC,IAAI,EAAC,MAAM,CAAC;IAAA,GAAG,EAAC,MAAM,CAAA;CAAC,GAAC;IACxC,IAAI,EAAC,QAAQ;IACb,GAAG,EAAC,EAAE;CACP,CAAA;AAGD,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAA", + "entry-package-info": "har|1.0.0" + }, + "har|har|1.0.0|src/main/ets/components/aaa.ts": { + "version": 3, + "file": "aaa.ts", + "sourceRoot": "", + "sources": [ + "har/src/main/ets/components/aaa.ts" + ], + "names": [], + "mappings": "", + "entry-package-info": "har|1.0.0" + }, + "har|har|1.0.0|src/main/ets/components/MainPage.ts": { + "version": 3, + "file": "MainPage.ets", + "sourceRoot": "", + "sources": [ + "har/src/main/ets/components/MainPage.ets" + ], + "names": [], + "mappings": ";;;;IAIS,OAAO,GAAE,MAAM;;OAJjB,EAAE,IAAI,EAAE;AAGf,MAAM,OAAQ,QAAQ;IADtB;;;;;sDAE2B,IAAI;;;KAJJ;;;;;;;;;;;;;;;;IAIzB,4CAAgB,MAAM,EAAQ;QAAvB,OAAO;;;QAAP,OAAO,WAAE,MAAM;;;IAEtB;;YACE,GAAG;YAAH,GAAG,CAQF,MAAM,CAAC,MAAM;;;YAPZ,MAAM;YAAN,MAAM,CAKL,KAAK,CAAC,MAAM;;;YAJX,IAAI,QAAC,IAAI,CAAC,OAAO;YAAjB,IAAI,CACD,QAAQ,CAAC,EAAE;YADd,IAAI,CAED,UAAU,CAAC,UAAU,CAAC,IAAI;;QAF7B,IAAI;QADN,MAAM;QADR,GAAG;KASJ;;;;;AAIH,MAAM,CAAC,MAAM,MAAM,EAAC,MAAM,GAAC,YAAY,CAAC", + "entry-package-info": "har|1.0.0" + }, + "entry|entry|1.0.0|src/main/ets/entryability/EntryAbility.ts": { + "version": 3, + "file": "EntryAbility.ets", + "sources": [ + "entry/src/main/ets/entryability/EntryAbility.ets" + ], + "names": [], + "mappings": "YAAS,eAAe,MAAA,mCAAA,CAAA;OAAE,qBAAqB,MAAA,yCAAA,CAAA;OAAE,SAAS,MAAA,6BAAA,CAAA;YAAE,IAAI,MAAA,wBAAA,CAAA;OACvD,KAAK,MAAA,aAAA,CAAA;YACL,MAAM,MAAA,cAAA,CAAA;AAEf,MAAM,CAAC,OAAO,iBAA4B,SAAS;IACjD,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC,WAAW,GAAG,IAAI;QAClE,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,YAAY,CAAC,qBAAqB,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;QACtG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAAC;IAClE,CAAC;IAED,SAAS,IAAI,IAAI;QACf,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;IACnE,CAAC;IAED,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,GAAG,IAAI;QAExD,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,6BAA6B,CAAC,CAAC;QAE3E,WAAW,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE;YAC7C,IAAI,GAAG,CAAC,IAAI,EAAE;gBACZ,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,+CAA+C,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC3G,OAAO;aACR;YACD,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,mCAAmC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACL,CAAC;IAED,oBAAoB,IAAI,IAAI;QAE1B,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,8BAA8B,CAAC,CAAC;IAC9E,CAAC;IAED,YAAY,IAAI,IAAI;QAElB,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,CAAC,CAAC;IACtE,CAAC;IAED,YAAY,IAAI,IAAI;QAElB,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,CAAC,CAAC;IACtE,CAAC;CACF", + "sourceRoot": "", + "entry-package-info": "entry|1.0.0" + }, + "entry|entry|1.0.0|src/main/ets/entrybackupability/EntryBackupAbility.ts": { + "version": 3, + "file": "EntryBackupAbility.ets", + "sources": [ + "entry/src/main/ets/entrybackupability/EntryBackupAbility.ets" + ], + "names": [], + "mappings": "OAAS,KAAK,MAAA,aAAA,CAAA;OACL,sBAAsB,MAAA,0CAAA,CAAA;AAAE,OAAA,KAAA,EAAA,iBAAA,aAAa,EAAA,MAAA,0CAAA,CAAA;AAE9C,MAAM,CAAC,OAAO,iBAAkC,sBAAsB;IACpE,KAAK,CAAC,QAAQ;QACZ,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,aAAa,EAAE,aAAa;QAC1C,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,yBAAyB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;IAC1F,CAAC;CACF", + "sourceRoot": "", + "entry-package-info": "entry|1.0.0" + }, + "entry|entry|1.0.0|src/main/ets/pages/Index.ts": { + "version": 3, + "file": "Index.ets", + "sources": [ + "entry/src/main/ets/pages/Index.ets" + ], + "names": [], + "mappings": ";;;;IAWS,OAAO,GAAE,MAAM,CAAA;;OAXjB,KAAK,EAAE,GAAG,EAAE,oDAAA;AAEnB,MAAM,aAAiB;IACrB,MAAM,CAAC,MAAM,IAAO,MAAM,GAAC,QAAQ,CAAA;IACnC,MAAM,WAAS,MAAM,CAAA;CACtB;AACD,IAAI,KAAK,EAAC,IAAS,GAAC,IAAa,CAAA;OAIrB,SAAA,MAAA;IAFZ,YAAA,MAAA,EAAA,MAAA,EAAA,EAAA,EAAA,KAAA,CAAA,CAAA,EAAA,KAAA,SAAA,EAAA,SAAA;;;;;sDAG2B,GAAG,EAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;;IALG,CAAA;;;;;;;;;;;;;;;;IAK/B,OAAA,CAAA,SAAA,EAAA,wBAAA,CAAgB,MAAM,CAAO,CAAA;QAAtB,OAAO;;;IAAP,IAAA,OAAO,WAAE,MAAM;;;IAEtB,aAAA;;YACE,iBAAiB,CAAA,MAAA,EAAA,CAAA;YAAjB,iBAAiB,CAUhB,MAAM,CAAC,MAAM,CAAA,CAAA;YAVd,iBAAiB,CAWhB,KAAK,CAAC,MAAM,CAAA,CAAA;;;YAVX,IAAI,CAAA,MAAA,CAAC,IAAI,CAAC,OAAO,CAAA,CAAA;YAAjB,IAAI,CACD,EAAE,CAAC,YAAY,CAAA,CAAA;YADlB,IAAI,CAED,QAAQ,CAAC,EAAE,CAAA,CAAA;YAFd,IAAI,CAGD,UAAU,CAAC,UAAU,CAAC,IAAI,CAAA,CAAA;YAH7B,IAAI,CAID,UAAU,CAAC;gBACV,MAAM,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,CAAC,MAAM,EAAE;gBAChE,MAAM,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE;aACnE,CAAA,CAAA;;QAPH,IAAI,CAAA,GAAA,EAAA,CAAA;QADN,iBAAiB,CAAA,GAAA,EAAA,CAAA;IAYlB,CAAA;;;;;;;;", + "sourceRoot": "", + "entry-package-info": "entry|1.0.0" + }, + "entry|entry|1.0.0|src/main/ets/pages/a.ts": { + "version": 3, + "file": "test.ts", + "sources": [ + "entry/src/main/ets/pages/test.ts" + ], + "names": [], + "mappings": "AAAA,MAAM,CAAE,MAAM,GAAG,EAAC,MAAM,GAAC,QAAQ,CAAA;AAEjC,QAAQ;IACN,QAAQ,MAAO;CAChB;AACD,UAAU,CAAC,CAAA;CAEV", + "sourceRoot": "", + "entry-package-info": "entry|1.0.0" + } +} \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/compileContextInfo.json b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/compileContextInfo.json new file mode 100644 index 000000000..1e66f2546 --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/compileContextInfo.json @@ -0,0 +1,9 @@ +{ + "hspPkgNames": [], + "compileEntries": [ + "&entry/src/main/ets/entryability/EntryAbility&", + "&entry/src/main/ets/entrybackupability/EntryBackupAbility&", + "&entry/src/main/ets/pages/Index&" + ], + "updateVersionInfo": {} +} \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/filesInfo.txt b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/filesInfo.txt new file mode 100644 index 000000000..238c11ab4 --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/filesInfo.txt @@ -0,0 +1,3 @@ +har22/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/har22/Index.ts;&har22/Index&1.0.0;esm;har22|har22|1.0.0|Index.ts;har22;false +har22/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/har22/src/main/ets/components/MainPage.ts;&har22/src/main/ets/components/MainPage&1.0.0;esm;har22|har22|1.0.0|src/main/ets/components/MainPage.ts;har22;false +har22/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/har22/build/default/generated/profile/default/ModuleInfo.js;&har22/build/default/generated/profile/default/ModuleInfo&1.0.0;esm;har22|har22|1.0.0|build/default/generated/profile/default/ModuleInfo.js;har22;false diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/npmEntries.txt b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/npmEntries.txt new file mode 100644 index 000000000..40520cb91 --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/npmEntries.txt @@ -0,0 +1,7 @@ +@system.app:@native.system.app1 +@ohos.app:@native.ohos.app1 +@system.router:@native.system.router1 +@system.curves:@native.system.curves1 +@ohos.curves:@native.ohos.curves1 +@system.matrix4:@native.system.matrix41 +@ohos.matrix4:@native.ohos.matrix41 diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/sourceMaps.map b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/sourceMaps.map new file mode 100644 index 000000000..c54517a7f --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir1/sourceMaps.map @@ -0,0 +1,56 @@ +{ + "har|har|1.0.0|build/default/generated/profile/default/ModuleInfo.js": { + "version": 3, + "file": "ModuleInfo.ts", + "sources": [ + "har/build/default/generated/profile/default/ModuleInfo.ts" + ], + "names": [], + "mappings": "AACA,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAwB,EAAE,CAAA,CAAA;AACjE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAwB,EAAE,CAAA,CAAA;", + "entry-package-info": "har|1.0.0" + }, + "har|har|1.0.0|Index.ts": { + "version": 3, + "file": "Index.ets", + "sourceRoot": "", + "sources": [ + "har/Index.ets" + ], + "names": [], + "mappings": "OAAO,EAAE,QAAQ,EAAC,MAAM,EAAE;OACnB,EAAC,CAAC,EAAC", + "entry-package-info": "har|1.0.0" + }, + "har|har|1.0.0|src/main/ets/components/a.ts": { + "version": 3, + "file": "a.ts", + "sourceRoot": "", + "sources": [ + "har/src/main/ets/components/a.ts" + ], + "names": [], + "mappings": "AAEA,MAAM,CAAC,MAAM,IAAI,EAAC,MAAM,GAAC,OAAO,CAAA;AAGhC,MAAM,QAAQ,CAAC,CAAA;IACb,MAAM,CAAC,MAAM,EAAE,GAAC,KAAK,CAAC;IACtB,MAAM,CAAC,MAAM,EAAE,EAAC,MAAM,GAAC,CAAC,CAAC;CAC1B;AAED,MAAM,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AAC5B,MAAM,CAAC,IAAI,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC;AAG9B,SAAS,EAAE,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC,IAAE,CAAC;AACpB,SAAS,EAAE,CAAC,CAAC,EAAC,CAAC,GAAC,CAAC,EAAC,GAAG,CAAC;AAEtB,CAAC;AACD,EAAE,CAAC,CAAC,CAAC,CAAA;AACL,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,CAAA;AACP,MAAM,SAAS;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAGD,MAAM,UAAU;IACd,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC;QACnC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,OAAO;YACL,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC;gBAC5B,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE;oBACvB,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;iBAC9C;qBAAM;oBACL,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;iBACzC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAC;AAClC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;IAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,mBAAmB;CACnD;AAED,UAAU,GAAG,CAAC,CAAC;IACb,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,IAAI,CAAC,CAAC;CACf;AAED,MAAM,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG;IAC7B,KAAK,EAAE,EAAE;IACT,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF,CAAC;AAEF,MAAM,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG;IAC7B,KAAK,EAAE,oBAAoB;IAC3B,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF,CAAC;AACF,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,MAAM,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC,iBAAiB;AAE7C,UAAU,CAAC,CAAA;IACT,MAAM,WAAW,CAAC,CAAA;QAChB,MAAM,UAAU,GAAG,IAAG,IAAI,GAAC,CAAC;KAC7B;IACD,MAAM,CAAC,MAAM,MAAM,EAAC,MAAM,GAAC,CAAC,CAAC;IAC7B,MAAM,SAAS;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB;IACD,UAAU,GAAG,CAAC,CAAC;QACb,KAAK,EAAE,CAAC,CAAC;QACT,QAAQ,IAAI,CAAC,CAAC;KACf;IACD,KAAK,MAAM,SAAS;QAClB,EAAE,IAAA;QACF,IAAI,IAAA;QACJ,IAAI,IAAA;QACJ,KAAK,IAAA;KACN;CAEF;AACD,UAAU;AACV,KAAK,EAAE,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1B,UAAU;AACV,KAAK,UAAU,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAEnD,MAAM,GAAG,EAAE,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAExC,UAAU;AACV,KAAK,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/B,KAAK,GAAG,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAEpD,UAAU;AACV,KAAK,WAAW,GAAG;IAAC,MAAM;IAAE,MAAM;CAAC,CAAC;AAEpC,MAAM,KAAK,EAAE,WAAW,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAEpC,UAAU;AACV,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,OAAO,EAAE,OAAO,GAAG;IACvB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,IAAI;CACZ,CAAC;AACF,SAAS;AACT,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAE9D,MAAM;AACN,6CAA6C;AAC7C,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM;IAC5C,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,WAAW,CAAC,CAAA;IAChB,MAAM,WAAW,CAAC,CAAA;QAChB,MAAM,UAAU,CAAC,KAAG,CAAC;QACrB,SAAS,CAAC,KAAG,CAAC;KACf;IACD,UAAU,EAAE,CAAA,GAAE;CACf;AAED,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAEP,UAAU,EAAE,CAAC;IACX,MAAM,KAAK,GAAG,CAAC,CAAC;CACjB;AAED,KAAK,MAAM;IACT,GAAG,IAAA;IACH,GAAG,IAAA;CACJ;AAED,OAAO,EAAC,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,IAAI,OAAO,EAAC,CAAC;AAGrD,OAAO,UAAU,IAAI,CAAC,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACtD,EAAE,EAAE,EAAE,GACL,GAAG,CAAC;AAGP,SAAS,GAAG,CAAC,GAAG,IAAI;AAEpB,CAAC;AAGD,MAAM,QAAQ,CAAC,CAAC;IACd,MAAM,UAAU,CAAC,KAAI,CAAC;IACtB,SAAU,CAAC,KAAG,CAAC;CAChB;AAED,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC;AAG3C,MAAM,CAAC,IAAI,KAAK,EAAC;IAAC,IAAI,EAAC,MAAM,CAAC;IAAA,GAAG,EAAC,MAAM,CAAA;CAAC,GAAC;IACxC,IAAI,EAAC,QAAQ;IACb,GAAG,EAAC,EAAE;CACP,CAAA;AAGD,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAA", + "entry-package-info": "har|1.0.0" + }, + "har|har|1.0.0|src/main/ets/components/aaa.ts": { + "version": 3, + "file": "aaa.ts", + "sourceRoot": "", + "sources": [ + "har/src/main/ets/components/aaa.ts" + ], + "names": [], + "mappings": "", + "entry-package-info": "har|1.0.0" + }, + "har|har|1.0.0|src/main/ets/components/MainPage.ts": { + "version": 3, + "file": "MainPage.ets", + "sourceRoot": "", + "sources": [ + "har/src/main/ets/components/MainPage.ets" + ], + "names": [], + "mappings": ";;;;IAIS,OAAO,GAAE,MAAM;;OAJjB,EAAE,IAAI,EAAE;AAGf,MAAM,OAAQ,QAAQ;IADtB;;;;;sDAE2B,IAAI;;;KAJJ;;;;;;;;;;;;;;;;IAIzB,4CAAgB,MAAM,EAAQ;QAAvB,OAAO;;;QAAP,OAAO,WAAE,MAAM;;;IAEtB;;YACE,GAAG;YAAH,GAAG,CAQF,MAAM,CAAC,MAAM;;;YAPZ,MAAM;YAAN,MAAM,CAKL,KAAK,CAAC,MAAM;;;YAJX,IAAI,QAAC,IAAI,CAAC,OAAO;YAAjB,IAAI,CACD,QAAQ,CAAC,EAAE;YADd,IAAI,CAED,UAAU,CAAC,UAAU,CAAC,IAAI;;QAF7B,IAAI;QADN,MAAM;QADR,GAAG;KASJ;;;;;AAIH,MAAM,CAAC,MAAM,MAAM,EAAC,MAAM,GAAC,YAAY,CAAC", + "entry-package-info": "har|1.0.0" + } +} \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/compileContextInfo.json b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/compileContextInfo.json new file mode 100644 index 000000000..c23a0a795 --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/compileContextInfo.json @@ -0,0 +1,11 @@ +{ + "hspPkgNames": [], + "compileEntries": [ + "&har/src/main/ets/components/a&1.0.0", + "&har/src/main/ets/components/aaa&1.0.0", + "&har/src/main/ets/components/MainPage&1.0.0", + "&har/build/default/generated/profile/default/ModuleInfo&1.0.0", + "&har/Index&1.0.0" + ], + "updateVersionInfo": {} +} \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/filesInfo.txt b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/filesInfo.txt new file mode 100644 index 000000000..da702d347 --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/filesInfo.txt @@ -0,0 +1,3 @@ +har33/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/har33/Index.ts;&har33/Index&1.0.0;esm;har33|har33|1.0.0|Index.ts;har33;false +har33/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/har33/src/main/ets/components/MainPage.ts;&har33/src/main/ets/components/MainPage&1.0.0;esm;har33|har33|1.0.0|src/main/ets/components/MainPage.ts;har33;false +har33/build/default/cache/default/default@HarCompileArkTS/esmodule/debug/har33/build/default/generated/profile/default/ModuleInfo.js;&har33/build/default/generated/profile/default/ModuleInfo&1.0.0;esm;har33|har33|1.0.0|build/default/generated/profile/default/ModuleInfo.js;har33;false diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/npmEntries.txt b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/npmEntries.txt new file mode 100644 index 000000000..5c9e7b7c8 --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/npmEntries.txt @@ -0,0 +1,7 @@ +@system.app:@native.system.app +@ohos.app:@native.ohos.app +@system.router:@native.system.router +@system.curves:@native.system.curves +@ohos.curves:@native.ohos.curves +@system.matrix4:@native.system.matrix4 +@ohos.matrix4:@native.ohos.matrix4 diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/sourceMaps.json b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/sourceMaps.json new file mode 100644 index 000000000..492661a46 --- /dev/null +++ b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/sourceMaps.json @@ -0,0 +1,46 @@ +{ + "entry|entry|1.0.0|src/main/ets/entryability/EntryAbility.ts": { + "version": 3, + "file": "EntryAbility.ets", + "sources": [ + "entry/src/main/ets/entryability/EntryAbility.ets" + ], + "names": [], + "mappings": "YAAS,eAAe,MAAA,mCAAA,CAAA;OAAE,qBAAqB,MAAA,yCAAA,CAAA;OAAE,SAAS,MAAA,6BAAA,CAAA;YAAE,IAAI,MAAA,wBAAA,CAAA;OACvD,KAAK,MAAA,aAAA,CAAA;YACL,MAAM,MAAA,cAAA,CAAA;AAEf,MAAM,CAAC,OAAO,iBAA4B,SAAS;IACjD,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC,WAAW,GAAG,IAAI;QAClE,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,YAAY,CAAC,qBAAqB,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;QACtG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,CAAC,CAAC;IAClE,CAAC;IAED,SAAS,IAAI,IAAI;QACf,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;IACnE,CAAC;IAED,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,GAAG,IAAI;QAExD,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,6BAA6B,CAAC,CAAC;QAE3E,WAAW,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE;YAC7C,IAAI,GAAG,CAAC,IAAI,EAAE;gBACZ,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,+CAA+C,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC3G,OAAO;aACR;YACD,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,mCAAmC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACL,CAAC;IAED,oBAAoB,IAAI,IAAI;QAE1B,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,8BAA8B,CAAC,CAAC;IAC9E,CAAC;IAED,YAAY,IAAI,IAAI;QAElB,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,CAAC,CAAC;IACtE,CAAC;IAED,YAAY,IAAI,IAAI;QAElB,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,CAAC,CAAC;IACtE,CAAC;CACF", + "sourceRoot": "", + "entry-package-info": "entry|1.0.0" + }, + "entry|entry|1.0.0|src/main/ets/entrybackupability/EntryBackupAbility.ts": { + "version": 3, + "file": "EntryBackupAbility.ets", + "sources": [ + "entry/src/main/ets/entrybackupability/EntryBackupAbility.ets" + ], + "names": [], + "mappings": "OAAS,KAAK,MAAA,aAAA,CAAA;OACL,sBAAsB,MAAA,0CAAA,CAAA;AAAE,OAAA,KAAA,EAAA,iBAAA,aAAa,EAAA,MAAA,0CAAA,CAAA;AAE9C,MAAM,CAAC,OAAO,iBAAkC,sBAAsB;IACpE,KAAK,CAAC,QAAQ;QACZ,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,aAAa,EAAE,aAAa;QAC1C,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,yBAAyB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;IAC1F,CAAC;CACF", + "sourceRoot": "", + "entry-package-info": "entry|1.0.0" + }, + "entry|entry|1.0.0|src/main/ets/pages/Index.ts": { + "version": 3, + "file": "Index.ets", + "sources": [ + "entry/src/main/ets/pages/Index.ets" + ], + "names": [], + "mappings": ";;;;IAWS,OAAO,GAAE,MAAM,CAAA;;OAXjB,KAAK,EAAE,GAAG,EAAE,oDAAA;AAEnB,MAAM,aAAiB;IACrB,MAAM,CAAC,MAAM,IAAO,MAAM,GAAC,QAAQ,CAAA;IACnC,MAAM,WAAS,MAAM,CAAA;CACtB;AACD,IAAI,KAAK,EAAC,IAAS,GAAC,IAAa,CAAA;OAIrB,SAAA,MAAA;IAFZ,YAAA,MAAA,EAAA,MAAA,EAAA,EAAA,EAAA,KAAA,CAAA,CAAA,EAAA,KAAA,SAAA,EAAA,SAAA;;;;;sDAG2B,GAAG,EAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;;IALG,CAAA;;;;;;;;;;;;;;;;IAK/B,OAAA,CAAA,SAAA,EAAA,wBAAA,CAAgB,MAAM,CAAO,CAAA;QAAtB,OAAO;;;IAAP,IAAA,OAAO,WAAE,MAAM;;;IAEtB,aAAA;;YACE,iBAAiB,CAAA,MAAA,EAAA,CAAA;YAAjB,iBAAiB,CAUhB,MAAM,CAAC,MAAM,CAAA,CAAA;YAVd,iBAAiB,CAWhB,KAAK,CAAC,MAAM,CAAA,CAAA;;;YAVX,IAAI,CAAA,MAAA,CAAC,IAAI,CAAC,OAAO,CAAA,CAAA;YAAjB,IAAI,CACD,EAAE,CAAC,YAAY,CAAA,CAAA;YADlB,IAAI,CAED,QAAQ,CAAC,EAAE,CAAA,CAAA;YAFd,IAAI,CAGD,UAAU,CAAC,UAAU,CAAC,IAAI,CAAA,CAAA;YAH7B,IAAI,CAID,UAAU,CAAC;gBACV,MAAM,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,CAAC,MAAM,EAAE;gBAChE,MAAM,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,CAAC,MAAM,EAAE;aACnE,CAAA,CAAA;;QAPH,IAAI,CAAA,GAAA,EAAA,CAAA;QADN,iBAAiB,CAAA,GAAA,EAAA,CAAA;IAYlB,CAAA;;;;;;;;", + "sourceRoot": "", + "entry-package-info": "entry|1.0.0" + }, + "entry|entry|1.0.0|src/main/ets/pages/a.ts": { + "version": 3, + "file": "test.ts", + "sources": [ + "entry/src/main/ets/pages/test.ts" + ], + "names": [], + "mappings": "AAAA,MAAM,CAAE,MAAM,GAAG,EAAC,MAAM,GAAC,QAAQ,CAAA;AAEjC,QAAQ;IACN,QAAQ,MAAO;CAChB;AACD,UAAU,CAAC,CAAA;CAEV", + "sourceRoot": "", + "entry-package-info": "entry|1.0.0" + } +} \ No newline at end of file -- Gitee From 173b5bdd65fb0a55d46b54202d735d403d281845 Mon Sep 17 00:00:00 2001 From: wuhailong Date: Thu, 20 Feb 2025 16:59:58 +0800 Subject: [PATCH 106/140] adapt arkts evolution Issue: #IBTQ0B Signed-off-by: wuhailong Change-Id: I37e1a651757203edc4a1c6a9e91e55178470933c --- compiler/package.json | 2 + compiler/src/ark_utils.ts | 64 ++++++++- compiler/src/ets_checker.ts | 51 +++++++ .../ark_compiler/module/module_mode.ts | 30 ++++- .../ark_compiler/module/module_source_file.ts | 6 +- .../ets_ui/rollup-plugin-ets-checker.ts | 23 +++- compiler/src/pre_define.ts | 4 +- compiler/src/process_module_files.ts | 7 +- .../test/ark_compiler_ut/ets_checker.test.ts | 124 +++++++++++++++++- .../mock/rollup_mock/common.ts | 5 +- .../mock/rollup_mock/project_config.ts | 21 ++- .../module/ohmUrl/ohmUrl.test.ts | 39 +++++- .../utils/processProjectConfig.ts | 1 + 13 files changed, 356 insertions(+), 21 deletions(-) diff --git a/compiler/package.json b/compiler/package.json index c9ebc37e3..bee0baf64 100644 --- a/compiler/package.json +++ b/compiler/package.json @@ -37,11 +37,13 @@ "@babel/preset-env": "7.20.2", "@babel/preset-typescript": "7.18.6", "@babel/runtime": "7.20.13", + "@types/proxyquire": "^1.3.31", "@typescript-eslint/parser": "5.51.0", "babel-loader": "9.1.2", "chai": "4.3.7", "eslint": "8.34.0", "mocha": "10.2.0", + "proxyquire": "^2.1.3", "uglify-js": "3.17.4" }, "dependencies": { diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index 3adf3e710..ea268e381 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -48,6 +48,7 @@ import { EXTNAME_CJS, EXTNAME_ABC, EXTNAME_ETS, + EXTNAME_D_ETS, EXTNAME_TS_MAP, EXTNAME_JS_MAP, ESMODULE, @@ -103,11 +104,36 @@ export const SRC_MAIN: string = 'src/main'; export let newSourceMaps: Object = {}; +interface DeclFileConfig { + declPath: string; + ohmUrl: string; +} + +interface DeclFilesConfig { + packageName: string; + files: { + [filePath: string]: DeclFileConfig; + } +} + +export interface ArkTsEvolutionModule { + language: string; // "1.1" | "1.2" + pkgName: string; + moduleName: string; + modulePath: string; + declgenV1OutPath?: string; + declgenV2OutPath?: string; + declgenBridgeCodePath?: string; + declFilesPath?: string; +} + +export let pkgDeclFilesConfig: { [pkgName: string]: DeclFilesConfig } = {} + export const packageCollection: Map> = new Map(); // Splicing ohmurl or record name based on filePath and context information table. export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: Object, logger: Object, pkgParams: Object, importerFile: string): string { - const { pkgName, pkgPath, isRecordName } = pkgParams; + const { pkgName, moduleName, pkgPath, isRecordName, isArkTsEvolution } = pkgParams; // rollup uses commonjs plugin to handle commonjs files, // the commonjs files are prefixed with '\x00' and need to be removed. if (filePath.startsWith('\x00')) { @@ -123,6 +149,7 @@ export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: O // case6: /library/index.ts // ---> @normalized:N&&&/entry/ets/xxx/yyy& let pkgInfo = projectConfig.pkgContextInfo[pkgName]; + let arkTsEvolutionModuleInfo = projectConfig.dependentModuleMap.get(moduleName); if (!pkgInfo || !pkgPath) { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, @@ -136,15 +163,45 @@ export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: O logger.printError(errInfo); return filePath; } - let projectFilePath: string = unixFilePath.replace(toUnixPath(pkgPath), ''); - let recordName = `${pkgInfo.bundleName}&${pkgName}${projectFilePath}&${pkgInfo.version}`; + let declgenBridgeCodePath: string; + let declgenV2OutPath: string; + let isNeedGenerateDeclFilesConfig: boolean = false; + if (isArkTsEvolution && arkTsEvolutionModuleInfo && arkTsEvolutionModuleInfo.declgenBridgeCodePath) { + declgenBridgeCodePath = toUnixPath(arkTsEvolutionModuleInfo.declgenBridgeCodePath); + } + if (!isArkTsEvolution && arkTsEvolutionModuleInfo && arkTsEvolutionModuleInfo.declgenV2OutPath) { + declgenV2OutPath = toUnixPath(arkTsEvolutionModuleInfo.declgenV2OutPath); + isNeedGenerateDeclFilesConfig = true; + } + let projectFilePath: string = declgenBridgeCodePath && unixFilePath.startsWith(declgenBridgeCodePath + '/') ? + unixFilePath.replace(toUnixPath(path.join(declgenBridgeCodePath, moduleName)) + '/', '') : + unixFilePath.replace(toUnixPath(pkgPath) + '/', ''); + const recordName: string = `${pkgInfo.bundleName}&${pkgName}/${projectFilePath}&${pkgInfo.version}`; if (isRecordName) { // record name style: &/entry/ets/xxx/yyy& + if (isNeedGenerateDeclFilesConfig) { + if (!pkgDeclFilesConfig[pkgName]) { + pkgDeclFilesConfig[pkgName] = { packageName: pkgName, files: {}} + } + const packageInfo = getPackageInfo(projectConfig.aceModuleJsonPath); + const ohmUrl: string = `${pkgInfo.isSO ? 'Y' : 'N'}&${moduleName}&${packageInfo[0]}&${pkgName}/${projectFilePath}&${pkgInfo.version}`; + const declFileInfo: Object = { projectFilePath, declgenV2OutPath, ohmUrl: `@normalized:${ohmUrl}` }; + addDeclFilesConfig(pkgDeclFilesConfig[pkgName], declFileInfo); + } return recordName; } return `${pkgInfo.isSO ? 'Y' : 'N'}&${pkgInfo.moduleName}&${recordName}`; } +function addDeclFilesConfig(declFilesConfig: DeclFilesConfig, declFileInfo: Object): void { + const { projectFilePath, declgenV2OutPath, ohmUrl } = declFileInfo; + if (declFilesConfig.files[projectFilePath]) { + return; + } + const declPath: string = path.join(declgenV2OutPath, projectFilePath) + EXTNAME_D_ETS; + declFilesConfig.files[projectFilePath] = { declPath, ohmUrl } +} + export function getOhmUrlByFilepath(filePath: string, projectConfig: Object, logger: Object, namespace?: string, importerFile?: string): string { // remove '\x00' from the rollup virtual commonjs file's filePath @@ -1004,6 +1061,7 @@ export function cleanUpUtilsObjects(): void { newSourceMaps = {}; nameCacheMap.clear(); packageCollection.clear(); + pkgDeclFilesConfig = {}; } export function compileToolIsRollUp(): boolean { diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 24cdb30ee..977e93505 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -46,6 +46,7 @@ import { ESMODULE, EXTNAME_D_ETS, EXTNAME_JS, + EXTNAME_ETS, FOREACH_LAZYFOREACH, COMPONENT_IF, TS_WATCH_END_MSG, @@ -107,6 +108,7 @@ import { RunnerParms, generateInteropDecls } from '../node_modules/declgen/build/src/generateInteropDecls' +import { ArkTsEvolutionModule } from './ark_utils'; export interface LanguageServiceCache { service?: ts.LanguageService; @@ -125,6 +127,8 @@ export const fileCache: Map = new Map(); export const MAX_FLOW_DEPTH_DEFAULT_VALUE = 2000; export const MAX_FLOW_DEPTH_MAXIMUM_VALUE = 65535; +export let arkTsEvolutionModuleMap: Map = new Map(); + export function readDeaclareFiles(): string[] { const declarationsFileNames: string[] = []; fs.readdirSync(path.resolve(__dirname, '../declarations')) @@ -1130,6 +1134,29 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string } else { resolvedModules.push(result.resolvedModule); } + } else if (result.resolvedModule.resolvedFileName && /\.ets$/.test(result.resolvedModule.resolvedFileName) && + !/\.d\.ets$/.test(result.resolvedModule.resolvedFileName) && arkTsEvolutionModuleMap.size !== 0) { + // When result has a value and the path parsed is the source code file path of module 1.2, + // the parsing result needs to be modified to the glue code path of module 1.2 + let staticDeclFileExist: boolean = false; + const resolvedFileName: string = toUnixPath(result.resolvedModule.resolvedFileName); + for (const [pkgName, arkTsEvolutionModuleInfo] of arkTsEvolutionModuleMap) { + const modulePath: string = toUnixPath(arkTsEvolutionModuleInfo.modulePath); + const declgenV1OutPath: string = toUnixPath(arkTsEvolutionModuleInfo.declgenV1OutPath); + const declgenBridgeCodePath: string = toUnixPath(arkTsEvolutionModuleInfo.declgenBridgeCodePath); + if (resolvedFileName.startsWith(modulePath + '/') && !resolvedFileName.startsWith(declgenBridgeCodePath + '/')) { + const resultDETSPath: string = + resolvedFileName.replace(modulePath, toUnixPath(path.join(declgenV1OutPath, pkgName))).replace(EXTNAME_ETS, EXTNAME_D_ETS); + if (ts.sys.fileExists(resultDETSPath)) { + resolvedModules.push(getResolveModule(resultDETSPath, EXTNAME_D_ETS)); + staticDeclFileExist = true; + break; + } + } + } + if (!staticDeclFileExist) { + resolvedModules.push(result.resolvedModule); + } } else { resolvedModules.push(result.resolvedModule); } @@ -1174,6 +1201,7 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string path.resolve(__dirname, '../node_modules', moduleName + '/index.js'); const DETSModulePath: string = path.resolve(path.dirname(containingFile), /\.d\.ets$/.test(moduleName) ? moduleName : moduleName + EXTNAME_D_ETS); + const arktsEvoDeclFilePath: string = getArktsEvoDeclFilePath(moduleName); if (ts.sys.fileExists(modulePath)) { resolvedModules.push(getResolveModule(modulePath, '.d.ts')); } else if (ts.sys.fileExists(systemDETSModulePath)) { @@ -1188,6 +1216,8 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string resolvedModules.push(getResolveModule(fileModulePath, '.js')); } else if (ts.sys.fileExists(DETSModulePath)) { resolvedModules.push(getResolveModule(DETSModulePath, '.d.ets')); + } else if (ts.sys.fileExists(arktsEvoDeclFilePath)) { + resolvedModules.push(getResolveModule(arktsEvoDeclFilePath, '.d.ets')); } else { const srcIndex: number = projectConfig.projectPath.indexOf('src' + path.sep + 'main'); let DETSModulePathFromModule: string; @@ -1223,6 +1253,26 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string return resolvedModulesCache.get(path.resolve(containingFile)); } +function getArktsEvoDeclFilePath(moduleRequest: string): string { + let staticDeclFilePath: string = moduleRequest; + for (const [moduleName, arkTsEvolutionModuleInfo] of arkTsEvolutionModuleMap) { + const declgenV1OutPath: string = toUnixPath(arkTsEvolutionModuleInfo.declgenV1OutPath); + if (moduleRequest === moduleName) { + staticDeclFilePath = path.join(declgenV1OutPath, moduleName, 'Index.d.ets'); + break; + } else if (moduleRequest.startsWith(moduleName + '/')) { + staticDeclFilePath = + moduleRequest.replace(moduleName, toUnixPath(path.join(declgenV1OutPath, moduleName, 'src/main/ets'))) + EXTNAME_D_ETS; + break; + } + } + return staticDeclFilePath; +} + +export function cleanUpArkTsEvolutionModuleMap(): void { + arkTsEvolutionModuleMap = new Map(); +} + export interface ResolveModuleInfo { modulePath: string; isEts: boolean; @@ -1876,6 +1926,7 @@ export function resetEtsCheck(): void { targetESVersionChanged = false; fileToIgnoreDiagnostics = undefined; maxMemoryInServiceChecker = 0; + cleanUpArkTsEvolutionModuleMap(); } export function generateDeclarationFileForSTS(rootFileNames: string[], allResolvedModules: Set) { diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index 821252cbd..cf24e77e3 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -91,13 +91,16 @@ import { isTs2Abc, isEs2Abc, transformOhmurlToPkgName, - transformOhmurlToRecordName + transformOhmurlToRecordName, + ArkTsEvolutionModule, + pkgDeclFilesConfig } from '../../../ark_utils'; import { generateAot, FaultHandler } from '../../../gen_aot'; import { + ARK_TS_1_2, NATIVE_MODULE } from '../../../pre_define'; import { @@ -254,8 +257,10 @@ export class ModuleMode extends CommonMode { } const pkgParams = { pkgName: metaInfo.pkgName, + moduleName: metaInfo.moduleName, pkgPath: metaInfo.pkgPath, - isRecordName: true + isRecordName: true, + isArkTsEvolution: metaInfo.language === ARK_TS_1_2 }; let recordName: string = getNormalizedOhmUrlByFilepath(moduleId, this.projectConfig, this.logger, pkgParams, undefined); @@ -310,10 +315,25 @@ export class ModuleMode extends CommonMode { prepareForCompilation(rollupObject: Object, parentEvent: CompileEvent): void { const eventPrepareForCompilation = createAndStartEvent(parentEvent, 'preparation for compilation'); + this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); + this.writeDeclFilesConfigJson(rollupObject.share.projectConfig.dependentModuleMap); this.removeCacheInfo(rollupObject); stopEvent(eventPrepareForCompilation); } + // Write the declaration file information of the 1.1 module file to the disk of the corresponding module + writeDeclFilesConfigJson(dependentModuleMap: Map): void { + for (const pkgName in pkgDeclFilesConfig) { + const arkTsEvolutionModuleInfo = dependentModuleMap.get(pkgName); + if (!arkTsEvolutionModuleInfo?.declFilesPath) { + return; + } + const declFilesConfigFile: string = toUnixPath(arkTsEvolutionModuleInfo.declFilesPath); + mkdirsSync(path.dirname(declFilesConfigFile)); + fs.writeFileSync(declFilesConfigFile, JSON.stringify(pkgDeclFilesConfig[pkgName], null, 2), 'utf-8'); + } + } + collectModuleFileList(module: Object, fileList: IterableIterator): void { const recordInfo = MemoryMonitor.recordStage(MemoryDefine.PKG_ENTRY_INFOS_MODULE_INFOS); let moduleInfos: Map = new Map(); @@ -503,7 +523,7 @@ export class ModuleMode extends CommonMode { let moduleName: string = metaInfo.moduleName; let recordName: string = ''; - let cacheFilePath: string = + let cacheFilePath: string = metaInfo.language === ARK_TS_1_2 ? originalFilePath : this.genFileCachePath(filePath, this.projectConfig.projectRootPath, this.projectConfig.cachePath, metaInfo); let packageName: string = ''; @@ -511,8 +531,10 @@ export class ModuleMode extends CommonMode { packageName = metaInfo.pkgName; const pkgParams = { pkgName: packageName, + moduleName: metaInfo.moduleName, pkgPath: metaInfo.pkgPath, - isRecordName: true + isRecordName: true, + isArkTsEvolution: metaInfo.language === ARK_TS_1_2 }; recordName = getNormalizedOhmUrlByFilepath(filePath, this.projectConfig, this.logger, pkgParams, undefined); } else { diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 2152ebdfe..2bccb59fd 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -47,6 +47,8 @@ import { } from '../common/ob_config_resolver'; import { ORIGIN_EXTENTION } from '../process_mock'; import { + ARK_TS_1_2, + ESMODULE, TRANSFORMED_MOCK_CONFIG, USER_DEFINE_MOCK_CONFIG } from '../../../pre_define'; @@ -503,8 +505,10 @@ export class ModuleSourceFile { private static spliceNormalizedOhmurl(moduleInfo: Object, filePath: string, importerFile?: string): string { const pkgParams = { pkgName: moduleInfo.meta.pkgName, + moduleName: moduleInfo.meta.moduleName, pkgPath: moduleInfo.meta.pkgPath, - isRecordName: false + isRecordName: false, + isArkTsEvolution: moduleInfo.meta.language === ARK_TS_1_2 }; const ohmUrl: string = getNormalizedOhmUrlByFilepath(filePath, ModuleSourceFile.projectConfig, ModuleSourceFile.logger, pkgParams, diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts index 24e3276e7..5d6f39b25 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts @@ -31,11 +31,16 @@ import { targetESVersionChanged, collectFileToIgnoreDiagnostics, TSC_SYSTEM_CODE, - traverseProgramSourceFiles + traverseProgramSourceFiles, + arkTsEvolutionModuleMap, + cleanUpArkTsEvolutionModuleMap, } from '../../ets_checker'; -import { TS_WATCH_END_MSG } from '../../pre_define'; import { - setChecker + ARK_TS_1_2, + TS_WATCH_END_MSG +} from '../../pre_define'; +import { + setChecker, } from '../../utils'; import { configureSyscapInfo, @@ -53,6 +58,7 @@ import { } from '../../performance'; import { LINTER_SUBSYSTEM_CODE } from '../../hvigor_error_code/hvigor_error_info'; import { ErrorCodeModule } from '../../hvigor_error_code/const/error_code_module'; +import { ArkTsEvolutionModule } from '../../ark_utils'; export let tsWatchEmitter: EventEmitter | undefined = undefined; export let tsWatchEndPromise: Promise; @@ -62,6 +68,9 @@ export function etsChecker() { return { name: 'etsChecker', buildStart() { + if (this.share.projectConfig.dependentModuleMap) { + collectArkTSEvolutionModuleInfo(this.share.projectConfig.dependentModuleMap); + } const recordInfo = MemoryMonitor.recordStage(MemoryDefine.ROLLUP_PLUGIN_BUILD_START); const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsChecker', 'buildStart'); const eventServiceChecker = createAndStartEvent(hookEventFactory, 'serviceChecker'); @@ -166,3 +175,11 @@ function rootFileNamesCollect(rootFileNames: string[]): void { rootFileNames.push(path.resolve(fileName)); }); } + +function collectArkTSEvolutionModuleInfo(dependentModuleMap: Map): void { + for (const [moduleName, arkTsEvolutionModuleInfo] of dependentModuleMap) { + if (arkTsEvolutionModuleInfo?.declgenV1OutPath && arkTsEvolutionModuleInfo.language === ARK_TS_1_2) { + arkTsEvolutionModuleMap.set(moduleName, arkTsEvolutionModuleInfo); + } + } +} \ No newline at end of file diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 7b041ad59..a30c54ad0 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -665,4 +665,6 @@ export const USE_SHARED_STORAGE: string = 'useSharedStorage'; export const ARKTS_MODULE_PREFIX: string = '@arkts'; export const ARKTS_MODULE_NAME: string = 'arkts'; export const COLD_RELOAD_MODE: string = 'coldReload'; -export const INTEGRATED_HSP: string = 'integratedHsp'; \ No newline at end of file +export const INTEGRATED_HSP: string = 'integratedHsp'; + +export const ARK_TS_1_2: string = '1.2'; \ No newline at end of file diff --git a/compiler/src/process_module_files.ts b/compiler/src/process_module_files.ts index 63b38aa1a..0a031ae56 100644 --- a/compiler/src/process_module_files.ts +++ b/compiler/src/process_module_files.ts @@ -21,6 +21,7 @@ import { SourceMapGenerator } from './fast_build/ark_compiler/generate_sourcemap import { EXTNAME_TS, EXTNAME_ETS, + ARK_TS_1_2 } from './pre_define'; import { genTemporaryPath, @@ -61,7 +62,9 @@ export async function writeFileSyncByNode(node: ts.SourceFile, projectConfig: Ob * Note: current realization is related to the moduleId mechanism in the rollup framework, which is needed to be reconsidered to improve the code robustness. * In the current realization, when moduleId mechanism is changed, there would be a compilation error. */ - let temporaryFile: string = genTemporaryPath(moduleId ? moduleId : node.fileName, projectConfig.projectPath, process.env.cachePath, + let filePath: string = moduleId ? moduleId : node.fileName; + // When the file is glue code for a ArkTS1.2 module, use the path to the glue code. + let temporaryFile: string = metaInfo.language === ARK_TS_1_2 ? filePath : genTemporaryPath(filePath, projectConfig.projectPath, process.env.cachePath, projectConfig, metaInfo); if (temporaryFile.length === 0) { return; @@ -69,7 +72,7 @@ export async function writeFileSyncByNode(node: ts.SourceFile, projectConfig: Ob if (temporaryFile.endsWith(EXTNAME_ETS)) { temporaryFile = temporaryFile.replace(/\.ets$/, EXTNAME_TS); } - let relativeFilePath = getRelativeSourcePath(moduleId ? moduleId : node.fileName, projectConfig.projectRootPath, metaInfo?.belongProjectPath); + let relativeFilePath = getRelativeSourcePath(filePath, projectConfig.projectRootPath, metaInfo?.belongProjectPath); let sourceMaps: Object; if (process.env.compileTool === 'rollup') { const key = sourceMapGenerator.isNewSourceMaps() ? moduleId! : relativeFilePath; diff --git a/compiler/test/ark_compiler_ut/ets_checker.test.ts b/compiler/test/ark_compiler_ut/ets_checker.test.ts index b46f43c04..ddbd81c48 100644 --- a/compiler/test/ark_compiler_ut/ets_checker.test.ts +++ b/compiler/test/ark_compiler_ut/ets_checker.test.ts @@ -17,10 +17,16 @@ import mocha from 'mocha'; import fs from 'fs'; import path from 'path'; import { expect } from 'chai'; -import * as sinon from 'sinon'; import * as ts from 'typescript'; +import sinon from 'sinon'; +import proxyquire from 'proxyquire'; -import { EXPECT_INDEX_ETS } from './mock/rollup_mock/path_config'; +import { + DEFAULT_ENTRY, + DEFAULT_PROJECT, + EXPECT_INDEX_ETS, + PROJECT_ROOT +} from './mock/rollup_mock/path_config'; import RollUpPluginMock from './mock/rollup_mock/rollup_plugin_mock'; import { addLocalPackageSet, @@ -29,6 +35,9 @@ import { needReCheckForChangedDepUsers, resetEtsCheck, serviceChecker, + resolveModuleNames as resolveModuleNamesMain, + arkTsEvolutionModuleMap, + cleanUpArkTsEvolutionModuleMap, getMaxFlowDepth, MAX_FLOW_DEPTH_DEFAULT_VALUE, fileCache, @@ -39,6 +48,7 @@ import { globalProgram, projectConfig } from '../../main'; +import { mkdirsSync } from '../../lib/utils'; mocha.describe('test ets_checker file api', function () { mocha.before(function () { @@ -190,6 +200,116 @@ mocha.describe('test ets_checker file api', function () { let program: ts.Program = ts.createProgram(fileNames, compilerOptions); expect(program.getEmitHost()).to.not.be.undefined; }); + + mocha.it('2-1: test resolveModuleNames parse 1.2 module declaration files', function () { + const code: string = 'import { a } from "har";\nconsole.log(a);\n'; + const moduleNames: string[] = [ + 'har', + 'har/test' + ]; + arkTsEvolutionModuleMap.set('har', { + language: '1.2', + packageName: 'har', + moduleName: 'har', + modulePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/har`, + declgenV1OutPath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/har/build/default/intermediates/declgen/default/declgenV1`, + declgenBridgeCodePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/har/build/default/intermediates/declgen/default/bridgecode` + }) + const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/${DEFAULT_ENTRY}/src/main/entryability/test.ets`; + const arktsEvoIndexDeclFilePath: string = `${arkTsEvolutionModuleMap.get('har').declgenV1OutPath}/har/Index.d.ets`; + const arktsEvoTestDeclFilePath: string = `${arkTsEvolutionModuleMap.get('har').declgenV1OutPath}/har/src/main/ets/test.d.ets`; + fs.writeFileSync(filePath, code); + mkdirsSync(path.dirname(arktsEvoIndexDeclFilePath)); + mkdirsSync(path.dirname(arktsEvoTestDeclFilePath)); + fs.writeFileSync(arktsEvoIndexDeclFilePath, ''); + fs.writeFileSync(arktsEvoTestDeclFilePath, ''); + const resolvedModules = resolveModuleNamesMain(moduleNames, filePath); + expect(resolvedModules[0].resolvedFileName === arktsEvoIndexDeclFilePath).to.be.true; + expect(resolvedModules[1].resolvedFileName === arktsEvoTestDeclFilePath).to.be.true; + fs.unlinkSync(filePath); + fs.unlinkSync(arktsEvoIndexDeclFilePath); + fs.unlinkSync(arktsEvoTestDeclFilePath); + cleanUpArkTsEvolutionModuleMap(); + }); + + mocha.it('2-2: test resolveModuleNames parse the 1.2 module declaration file that the 1.1 module depends on (packageName)', function () { + const moduleNames: string[] = ['testhar']; + arkTsEvolutionModuleMap.set('har', { + language: '1.2', + packageName: 'testhar', + moduleName: 'testhar', + modulePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar`, + declgenV1OutPath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/build/default/intermediates/declgen/default/declgenV1`, + declgenBridgeCodePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/build/default/intermediates/declgen/default/bridgecode` + }) + const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/${DEFAULT_ENTRY}/src/main/entryability/test.ets`; + const arktsEvoIndexFilePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/Index.ets`; + const arktsEvoIndexDeclFilePath: string = `${arkTsEvolutionModuleMap.get('har').declgenV1OutPath}/testhar/Index.d.ets`; + const resolveModuleNameStub = sinon.stub(ts, 'resolveModuleName').returns({ + resolvedModule: { + resolvedFileName: arktsEvoIndexFilePath, + extension: '.ets', + isExternalLibraryImport: false, + } + }); + const mockedTs = { + ...require('typescript'), + resolveModuleName: resolveModuleNameStub + }; + let resolveModuleNames; + ({ resolveModuleNames } = proxyquire('../../lib/ets_checker', { + 'typescript': mockedTs + })); + fs.writeFileSync(filePath, ''); + mkdirsSync(path.dirname(arktsEvoIndexFilePath)); + mkdirsSync(path.dirname(arktsEvoIndexDeclFilePath)); + fs.writeFileSync(arktsEvoIndexFilePath, ''); + fs.writeFileSync(arktsEvoIndexDeclFilePath, ''); + const resolvedModules = resolveModuleNames(moduleNames, filePath); + expect(resolvedModules[0].resolvedFileName === arktsEvoIndexDeclFilePath); + fs.unlinkSync(filePath); + fs.unlinkSync(arktsEvoIndexDeclFilePath); + resolveModuleNameStub.restore(); + }); + + mocha.it('2-3: test resolveModuleNames parse the 1.2 module declaration file that the 1.1 module depends on', function () { + const moduleNames: string[] = ['testhar/src/main/ets/test']; + arkTsEvolutionModuleMap.set('har', { + language: '1.2', + packageName: 'testhar', + moduleName: 'testhar', + modulePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar`, + declgenV1OutPath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/build/default/intermediates/declgen/default/declgenV1`, + declgenBridgeCodePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/build/default/intermediates/declgen/default/bridgecode` + }) + const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/${DEFAULT_ENTRY}/src/main/entryability/test.ets`; + const arktsEvoTestFilePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/src/main/ets/test.ets`; + const arktsEvoTestDeclFilePath: string = `${arkTsEvolutionModuleMap.get('har').declgenV1OutPath}/testhar/src/main/ets/test.d.ets`; + const resolveModuleNameStub = sinon.stub(ts, 'resolveModuleName').returns({ + resolvedModule: { + resolvedFileName: arktsEvoTestFilePath, + extension: '.ets', + isExternalLibraryImport: false, + } + }); + const mockedTs = { + ...require('typescript'), + resolveModuleName: resolveModuleNameStub + }; + let resolveModuleNames; + ({ resolveModuleNames } = proxyquire('../../lib/ets_checker', { 'typescript': mockedTs })); + + fs.writeFileSync(filePath, ''); + mkdirsSync(path.dirname(arktsEvoTestFilePath)); + mkdirsSync(path.dirname(arktsEvoTestDeclFilePath)); + fs.writeFileSync(arktsEvoTestFilePath, ''); + fs.writeFileSync(arktsEvoTestDeclFilePath, ''); + const resolvedModules = resolveModuleNames(moduleNames, filePath); + expect(resolvedModules[0].resolvedFileName === arktsEvoTestDeclFilePath); + fs.unlinkSync(filePath); + fs.unlinkSync(arktsEvoTestDeclFilePath); + resolveModuleNameStub.restore(); + }); }); mocha.describe('getMaxFlowDepth', () => { diff --git a/compiler/test/ark_compiler_ut/mock/rollup_mock/common.ts b/compiler/test/ark_compiler_ut/mock/rollup_mock/common.ts index 1feceb88e..aa0c7c34e 100644 --- a/compiler/test/ark_compiler_ut/mock/rollup_mock/common.ts +++ b/compiler/test/ark_compiler_ut/mock/rollup_mock/common.ts @@ -79,4 +79,7 @@ export const LOADER_AOTMODE: string = 'loader_aotMode.json'; export const UPDATESOURCEMAP: string = 'updateSourceMap.json'; export const ENTRYABILITY_JS: string = 'entry/src/main/entryability/EntryAbility.js'; export const TEST: string = 'test'; -export const NEWFILE: string = 'newFile'; \ No newline at end of file +export const NEWFILE: string = 'newFile'; + +export const DECLFILESPATH: string = '/entry/build/default/intermediates/loader_out/default/etsFortgz/decl-fileInfo.json'; +export const DECLGENV2OUTPATH: string = '/entry/build/default/intermediates/declgen/default/declgenV2'; \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/mock/rollup_mock/project_config.ts b/compiler/test/ark_compiler_ut/mock/rollup_mock/project_config.ts index 90fe1b8e2..243038c36 100644 --- a/compiler/test/ark_compiler_ut/mock/rollup_mock/project_config.ts +++ b/compiler/test/ark_compiler_ut/mock/rollup_mock/project_config.ts @@ -30,14 +30,16 @@ import { NODE_JS_PATH, PORT_DEFAULT, ENTRY_MODULE_VERSION_DEFAULT, - SDK_VERSION_STAGE + SDK_VERSION_STAGE, + DECLFILESPATH, + DECLGENV2OUTPATH } from "./common"; import { ESMODULE, OHPM, RELEASE } from "../../../../lib/fast_build/ark_compiler/common/ark_define"; -import EntryAbility from "../../testdata/expect/expect_EntryAbility"; +import { ArkTsEvolutionModule } from "../../../../lib/ark_utils"; interface IArkProjectConfig { projectRootPath: string, @@ -131,6 +133,7 @@ class ProjectConfig { widgetCompile: boolean; arkRouterMap: Array; declarationEntry: Array; + dependentModuleMap: Map; constructor(buildMode: string) { this.watchMode = 'false'; @@ -145,10 +148,12 @@ class ProjectConfig { this.hspNameOhmMap = {}; this.arkRouterMap = []; this.declarationEntry = []; + this.dependentModuleMap = new Map(); } public scan(testcase: string) { this.initPath(`${PROJECT_ROOT}/${testcase}`); + this.setDependentModuleMap(); } public setPreview(isPreview: boolean) { @@ -261,6 +266,18 @@ class ProjectConfig { this.port = PORT_DEFAULT; this.aceSoPath = `${this.projectTopDir}/entry/preview/cache/nativeDependencies.txt`; } + + private setDependentModuleMap() { + const arkTsEvolutionModuleInfo = { + language: '1.1', + pkgName: this.entryModuleName, + moduleName: this.entryModuleName, + modulePath: this.modulePath, + declgenV2OutPath: DECLGENV2OUTPATH, + declFilesPath: DECLFILESPATH + } + this.dependentModuleMap.set(this.entryModuleName, arkTsEvolutionModuleInfo) + } } export { ProjectConfig, IArkProjectConfig } diff --git a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts index 4b0fe6851..62d679b49 100644 --- a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts +++ b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts @@ -23,7 +23,8 @@ import { getOhmUrlBySystemApiOrLibRequest, getNormalizedOhmUrlByFilepath, getNormalizedOhmUrlByAliasName, - getNormalizedOhmUrlByModuleRequest + getNormalizedOhmUrlByModuleRequest, + pkgDeclFilesConfig } from '../../../../lib/ark_utils'; import { PACKAGES } from '../../../../lib/pre_define'; import projectConfig from '../../utils/processProjectConfig'; @@ -31,6 +32,7 @@ import { projectConfig as mainProjectConfig } from '../../../../main'; import RollUpPluginMock from '../../mock/rollup_mock/rollup_plugin_mock'; import { GEN_ABC_PLUGIN_NAME } from '../../../../lib/fast_build/ark_compiler/common/ark_define'; import { ModuleSourceFile } from '../../../../lib/fast_build/ark_compiler/module/module_source_file'; +import { DECLGENV2OUTPATH, INDEX_SOURCE_PATH } from '../../mock/rollup_mock/common'; import { ArkTSErrorDescription, ArkTSInternalErrorDescription, @@ -974,7 +976,6 @@ mocha.describe('generate ohmUrl', function () { 'json5': undefined }; const filePath: string = `${projectConfig.projectRootPath}/entry/oh_modules/json5/dist/index.js`; - const moduleName: string = 'entry'; const importerFile: string = 'importTest.ts'; const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, @@ -1474,4 +1475,38 @@ mocha.describe('generate ohmUrl', function () { this.rollup.share.getHvigorConsoleLogger = getHvigorConsoleLogger; loggerStub.restore(); }); + + mocha.it('generate declFilesInfo in mixed compilation', function () { + this.rollup.build(); + pkgDeclFilesConfig['entry'] = { + packageName: 'entry', + files: {} + }; + const pkgParams = { + pkgName: 'entry', + moduleName: 'entry', + pkgPath: `${projectConfig.projectRootPath}/entry`, + isRecordName: true, + isArkTsEvolution: false + }; + this.rollup.share.projectConfig.pkgContextInfo = { + 'entry': { + 'packageName': 'entry', + 'bundleName': '', + 'moduleName': '', + 'version': '', + 'entryPath': 'Index.ets', + 'isSO': false + } + }; + const filePath: string = `${projectConfig.projectRootPath}/${INDEX_SOURCE_PATH}`; + const logger = this.rollup.share.getLogger(GEN_ABC_PLUGIN_NAME); + const expectDeclPath: string = `${DECLGENV2OUTPATH}/src/main/pages/Index.d.ets`; + const expectOhmUrl: string = `@normalized:N&entry&com.example.app&entry/src/main/pages/Index&`; + getNormalizedOhmUrlByFilepath(filePath, this.rollup.share.projectConfig, logger, pkgParams); + expect(pkgDeclFilesConfig['entry'].files.length !== 0).to.be.true; + expect(pkgDeclFilesConfig['entry'].files['src/main/pages/Index'].length !== 0).to.be.true; + expect(pkgDeclFilesConfig['entry'].files['src/main/pages/Index'].declPath === expectDeclPath).to.be.true; + expect(pkgDeclFilesConfig['entry'].files['src/main/pages/Index'].ohmUrl === expectOhmUrl).to.be.true; + }); }); \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/utils/processProjectConfig.ts b/compiler/test/ark_compiler_ut/utils/processProjectConfig.ts index f98af7e8f..b7a643395 100644 --- a/compiler/test/ark_compiler_ut/utils/processProjectConfig.ts +++ b/compiler/test/ark_compiler_ut/utils/processProjectConfig.ts @@ -46,5 +46,6 @@ projectConfig.pkgContextInfo = { projectConfig.dependencyAliasMap = new Map([ ['library', '@bundle:UtTestApplication/sharedLibrary/ets/index'] ]); +projectConfig.dependentModuleMap = new Map(); export default projectConfig; \ No newline at end of file -- Gitee From e0ed0b8efd5440ab181f7995831d12a9aae00746 Mon Sep 17 00:00:00 2001 From: zenghang Date: Fri, 28 Feb 2025 10:48:58 +0800 Subject: [PATCH 107/140] Declgen supports setting CompilerOptions Issue: IBPM27 Signed-off-by: zenghang Change-Id: I78c03ca45918beac407c30de2f1cc63f22ba61bb --- compiler/src/ets_checker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 977e93505..046df8469 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -1937,17 +1937,19 @@ export function generateDeclarationFileForSTS(rootFileNames: string[], allResolv return toUnixPath(path); }); + const regex = new RegExp(projectConfig.packageDir); const uniqueFiles = Array.from(new Set([ ...unixRootFileNames, ...allResolvedModules - ])); + ])).filter(file => !regex.test(file)); const config: RunnerParms = { inputDirs: [], inputFiles: uniqueFiles, outDir: path.resolve(projectConfig.aceModuleBuild, '../etsFortgz/ets'), rootDir: projectConfig.projectRootPath, - customResolveModuleNames: resolveModuleNames + customResolveModuleNames: resolveModuleNames, + customCompilerOptions: compilerOptions }; if (fs.existsSync(config.outDir)) { fs.rmSync(config.outDir, { recursive: true, force: true }); -- Gitee From ee753c71a80abb9d1045eb6fb14dcdb2293d1702 Mon Sep 17 00:00:00 2001 From: zenghang Date: Mon, 3 Mar 2025 15:17:20 +0800 Subject: [PATCH 108/140] Add deaclare files for arkui Issue: IBQ5QI Signed-off-by: zenghang Change-Id: Ida7a0dca1d1641f4520cb867a58f3c69b37af351 --- compiler/src/ets_checker.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 046df8469..fcca1bc75 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -610,7 +610,7 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null } if (rollupShareObject?.projectConfig.mixCompile) { - generateDeclarationFileForSTS(rootFileNames, allResolvedModules); + generateDeclarationFileForSTS(rootFileNames); } maxMemoryInServiceChecker = process.memoryUsage().heapUsed; @@ -1929,7 +1929,7 @@ export function resetEtsCheck(): void { cleanUpArkTsEvolutionModuleMap(); } -export function generateDeclarationFileForSTS(rootFileNames: string[], allResolvedModules: Set) { +export function generateDeclarationFileForSTS(rootFileNames: string[]) { if (!(projectConfig.compileHar || projectConfig.compileShared)) { return; } @@ -1940,19 +1940,25 @@ export function generateDeclarationFileForSTS(rootFileNames: string[], allResolv const regex = new RegExp(projectConfig.packageDir); const uniqueFiles = Array.from(new Set([ ...unixRootFileNames, - ...allResolvedModules + /** + * arkui lacks explicit import statements and needs to be manually added to the global rootfile, + * otherwise an error will be reported during the tsc compilation of declgen + */ + ...readDeaclareFiles() ])).filter(file => !regex.test(file)); const config: RunnerParms = { inputDirs: [], inputFiles: uniqueFiles, - outDir: path.resolve(projectConfig.aceModuleBuild, '../etsFortgz/ets'), - rootDir: projectConfig.projectRootPath, + outDir: projectConfig.dependentModuleMap.get(projectConfig.moduleName).declgenV2OutPath, + // use package name as folder name + rootDir: projectConfig.moduleRootPath, customResolveModuleNames: resolveModuleNames, customCompilerOptions: compilerOptions }; if (fs.existsSync(config.outDir)) { fs.rmSync(config.outDir, { recursive: true, force: true }); } + fs.mkdirSync(config.outDir, { recursive: true }); generateInteropDecls(config); } \ No newline at end of file -- Gitee From 942844029155e2464155ba130c30ea484c7ee25e Mon Sep 17 00:00:00 2001 From: zenghang Date: Wed, 12 Mar 2025 21:47:09 +0800 Subject: [PATCH 109/140] Provide includePath for declgen Issue: IBSX85 Signed-off-by: zenghang Change-Id: Ic113909c1927808642c82f275cd8c3cffe7b3932 --- compiler/src/ets_checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index fcca1bc75..9d9ecab91 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -1954,7 +1954,8 @@ export function generateDeclarationFileForSTS(rootFileNames: string[]) { // use package name as folder name rootDir: projectConfig.moduleRootPath, customResolveModuleNames: resolveModuleNames, - customCompilerOptions: compilerOptions + customCompilerOptions: compilerOptions, + includePaths: [projectConfig.modulePath] }; if (fs.existsSync(config.outDir)) { fs.rmSync(config.outDir, { recursive: true, force: true }); -- Gitee From 2c311d1c7dea9d31f0f4ade4cffbc3105bf83d33 Mon Sep 17 00:00:00 2001 From: wuhailong Date: Sun, 23 Mar 2025 21:30:46 +0800 Subject: [PATCH 110/140] Solve issues of mix project compilation Issue: #IBVD8N Signed-off-by: wuhailong Change-Id: I0ccdb3380b40a767cef0139d5bfe4cb248eefa00 --- compiler/package.json | 1 - compiler/src/ark_utils.ts | 79 ++------ compiler/src/ets_checker.ts | 55 ++---- .../ark_compiler/module/module_mode.ts | 41 ++-- .../ark_compiler/module/module_source_file.ts | 34 +++- .../ark_compiler/rollup-plugin-gen-abc.ts | 2 + .../ets_ui/rollup-plugin-ets-checker.ts | 19 +- compiler/src/pre_define.ts | 3 +- compiler/src/process_arkts_evolution.ts | 186 ++++++++++++++++++ compiler/src/process_module_files.ts | 6 +- .../common/process_arkts_evolution.test.ts | 118 +++++++++++ .../test/ark_compiler_ut/ets_checker.test.ts | 22 ++- .../mock/rollup_mock/common.ts | 3 +- .../mock/rollup_mock/project_config.ts | 8 +- .../module/ohmUrl/ohmUrl.test.ts | 35 ---- 15 files changed, 409 insertions(+), 203 deletions(-) create mode 100644 compiler/src/process_arkts_evolution.ts create mode 100644 compiler/test/ark_compiler_ut/common/process_arkts_evolution.test.ts diff --git a/compiler/package.json b/compiler/package.json index bee0baf64..ccdb99ec2 100644 --- a/compiler/package.json +++ b/compiler/package.json @@ -37,7 +37,6 @@ "@babel/preset-env": "7.20.2", "@babel/preset-typescript": "7.18.6", "@babel/runtime": "7.20.13", - "@types/proxyquire": "^1.3.31", "@typescript-eslint/parser": "5.51.0", "babel-loader": "9.1.2", "chai": "4.3.7", diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index ea268e381..901755076 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -104,36 +104,22 @@ export const SRC_MAIN: string = 'src/main'; export let newSourceMaps: Object = {}; -interface DeclFileConfig { - declPath: string; - ohmUrl: string; -} - -interface DeclFilesConfig { - packageName: string; - files: { - [filePath: string]: DeclFileConfig; - } -} - -export interface ArkTsEvolutionModule { - language: string; // "1.1" | "1.2" - pkgName: string; - moduleName: string; - modulePath: string; - declgenV1OutPath?: string; - declgenV2OutPath?: string; - declgenBridgeCodePath?: string; - declFilesPath?: string; -} - -export let pkgDeclFilesConfig: { [pkgName: string]: DeclFilesConfig } = {} - export const packageCollection: Map> = new Map(); // Splicing ohmurl or record name based on filePath and context information table. export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: Object, logger: Object, pkgParams: Object, importerFile: string): string { - const { pkgName, moduleName, pkgPath, isRecordName, isArkTsEvolution } = pkgParams; + const { pkgName, pkgPath, isRecordName } = pkgParams; + const { projectFilePath, pkgInfo } = getPkgInfo(filePath, projectConfig, logger, pkgPath, pkgName, importerFile); + const recordName: string = `${pkgInfo.bundleName}&${pkgName}/${projectFilePath}&${pkgInfo.version}`; + if (isRecordName) { + // record name style: &/entry/ets/xxx/yyy& + return recordName; + } + return `${pkgInfo.isSO ? 'Y' : 'N'}&${pkgInfo.moduleName}&${recordName}`; +} + +export function getPkgInfo(filePath: string, projectConfig: Object, logger: Object, pkgPath: string, + pkgName: string, importerFile?: string): Object { // rollup uses commonjs plugin to handle commonjs files, // the commonjs files are prefixed with '\x00' and need to be removed. if (filePath.startsWith('\x00')) { @@ -149,7 +135,6 @@ export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: O // case6: /library/index.ts // ---> @normalized:N&&&/entry/ets/xxx/yyy& let pkgInfo = projectConfig.pkgContextInfo[pkgName]; - let arkTsEvolutionModuleInfo = projectConfig.dependentModuleMap.get(moduleName); if (!pkgInfo || !pkgPath) { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_EXTERNAL_FAILED_TO_RESOLVE_OHM_URL, @@ -163,43 +148,8 @@ export function getNormalizedOhmUrlByFilepath(filePath: string, projectConfig: O logger.printError(errInfo); return filePath; } - let declgenBridgeCodePath: string; - let declgenV2OutPath: string; - let isNeedGenerateDeclFilesConfig: boolean = false; - if (isArkTsEvolution && arkTsEvolutionModuleInfo && arkTsEvolutionModuleInfo.declgenBridgeCodePath) { - declgenBridgeCodePath = toUnixPath(arkTsEvolutionModuleInfo.declgenBridgeCodePath); - } - if (!isArkTsEvolution && arkTsEvolutionModuleInfo && arkTsEvolutionModuleInfo.declgenV2OutPath) { - declgenV2OutPath = toUnixPath(arkTsEvolutionModuleInfo.declgenV2OutPath); - isNeedGenerateDeclFilesConfig = true; - } - let projectFilePath: string = declgenBridgeCodePath && unixFilePath.startsWith(declgenBridgeCodePath + '/') ? - unixFilePath.replace(toUnixPath(path.join(declgenBridgeCodePath, moduleName)) + '/', '') : - unixFilePath.replace(toUnixPath(pkgPath) + '/', ''); - const recordName: string = `${pkgInfo.bundleName}&${pkgName}/${projectFilePath}&${pkgInfo.version}`; - if (isRecordName) { - // record name style: &/entry/ets/xxx/yyy& - if (isNeedGenerateDeclFilesConfig) { - if (!pkgDeclFilesConfig[pkgName]) { - pkgDeclFilesConfig[pkgName] = { packageName: pkgName, files: {}} - } - const packageInfo = getPackageInfo(projectConfig.aceModuleJsonPath); - const ohmUrl: string = `${pkgInfo.isSO ? 'Y' : 'N'}&${moduleName}&${packageInfo[0]}&${pkgName}/${projectFilePath}&${pkgInfo.version}`; - const declFileInfo: Object = { projectFilePath, declgenV2OutPath, ohmUrl: `@normalized:${ohmUrl}` }; - addDeclFilesConfig(pkgDeclFilesConfig[pkgName], declFileInfo); - } - return recordName; - } - return `${pkgInfo.isSO ? 'Y' : 'N'}&${pkgInfo.moduleName}&${recordName}`; -} - -function addDeclFilesConfig(declFilesConfig: DeclFilesConfig, declFileInfo: Object): void { - const { projectFilePath, declgenV2OutPath, ohmUrl } = declFileInfo; - if (declFilesConfig.files[projectFilePath]) { - return; - } - const declPath: string = path.join(declgenV2OutPath, projectFilePath) + EXTNAME_D_ETS; - declFilesConfig.files[projectFilePath] = { declPath, ohmUrl } + const projectFilePath: string = unixFilePath.replace(toUnixPath(pkgPath) + '/', ''); + return { projectFilePath, pkgInfo }; } export function getOhmUrlByFilepath(filePath: string, projectConfig: Object, logger: Object, namespace?: string, @@ -1061,7 +1011,6 @@ export function cleanUpUtilsObjects(): void { newSourceMaps = {}; nameCacheMap.clear(); packageCollection.clear(); - pkgDeclFilesConfig = {}; } export function compileToolIsRollUp(): boolean { diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 9d9ecab91..fe242f6ee 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -107,8 +107,11 @@ import { concatenateEtsOptions, getExternalComponentPaths } from './external_com import { RunnerParms, generateInteropDecls -} from '../node_modules/declgen/build/src/generateInteropDecls' -import { ArkTsEvolutionModule } from './ark_utils'; +} from '../node_modules/declgen/build/src/generateInteropDecls'; +import { + arkTSEvolutionModuleMap, + getArkTSEvoDeclFilePath +} from './process_arkts_evolution'; export interface LanguageServiceCache { service?: ts.LanguageService; @@ -127,8 +130,6 @@ export const fileCache: Map = new Map(); export const MAX_FLOW_DEPTH_DEFAULT_VALUE = 2000; export const MAX_FLOW_DEPTH_MAXIMUM_VALUE = 65535; -export let arkTsEvolutionModuleMap: Map = new Map(); - export function readDeaclareFiles(): string[] { const declarationsFileNames: string[] = []; fs.readdirSync(path.resolve(__dirname, '../declarations')) @@ -1135,26 +1136,17 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string resolvedModules.push(result.resolvedModule); } } else if (result.resolvedModule.resolvedFileName && /\.ets$/.test(result.resolvedModule.resolvedFileName) && - !/\.d\.ets$/.test(result.resolvedModule.resolvedFileName) && arkTsEvolutionModuleMap.size !== 0) { + !/\.d\.ets$/.test(result.resolvedModule.resolvedFileName) && arkTSEvolutionModuleMap.size !== 0) { // When result has a value and the path parsed is the source code file path of module 1.2, // the parsing result needs to be modified to the glue code path of module 1.2 - let staticDeclFileExist: boolean = false; + let arktsEvoDeclFilePathExist: boolean = false; const resolvedFileName: string = toUnixPath(result.resolvedModule.resolvedFileName); - for (const [pkgName, arkTsEvolutionModuleInfo] of arkTsEvolutionModuleMap) { - const modulePath: string = toUnixPath(arkTsEvolutionModuleInfo.modulePath); - const declgenV1OutPath: string = toUnixPath(arkTsEvolutionModuleInfo.declgenV1OutPath); - const declgenBridgeCodePath: string = toUnixPath(arkTsEvolutionModuleInfo.declgenBridgeCodePath); - if (resolvedFileName.startsWith(modulePath + '/') && !resolvedFileName.startsWith(declgenBridgeCodePath + '/')) { - const resultDETSPath: string = - resolvedFileName.replace(modulePath, toUnixPath(path.join(declgenV1OutPath, pkgName))).replace(EXTNAME_ETS, EXTNAME_D_ETS); - if (ts.sys.fileExists(resultDETSPath)) { - resolvedModules.push(getResolveModule(resultDETSPath, EXTNAME_D_ETS)); - staticDeclFileExist = true; - break; - } - } + const resultDETSPath: string = getArkTSEvoDeclFilePath({ moduleRequest: '', resolvedFileName }); + if (ts.sys.fileExists(resultDETSPath)) { + resolvedModules.push(getResolveModule(resultDETSPath, EXTNAME_D_ETS)); + arktsEvoDeclFilePathExist = true; } - if (!staticDeclFileExist) { + if (!arktsEvoDeclFilePathExist) { resolvedModules.push(result.resolvedModule); } } else { @@ -1201,7 +1193,7 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string path.resolve(__dirname, '../node_modules', moduleName + '/index.js'); const DETSModulePath: string = path.resolve(path.dirname(containingFile), /\.d\.ets$/.test(moduleName) ? moduleName : moduleName + EXTNAME_D_ETS); - const arktsEvoDeclFilePath: string = getArktsEvoDeclFilePath(moduleName); + const arktsEvoDeclFilePath: string = getArkTSEvoDeclFilePath({ moduleRequest: moduleName, resolvedFileName: '' }); if (ts.sys.fileExists(modulePath)) { resolvedModules.push(getResolveModule(modulePath, '.d.ts')); } else if (ts.sys.fileExists(systemDETSModulePath)) { @@ -1253,26 +1245,6 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string return resolvedModulesCache.get(path.resolve(containingFile)); } -function getArktsEvoDeclFilePath(moduleRequest: string): string { - let staticDeclFilePath: string = moduleRequest; - for (const [moduleName, arkTsEvolutionModuleInfo] of arkTsEvolutionModuleMap) { - const declgenV1OutPath: string = toUnixPath(arkTsEvolutionModuleInfo.declgenV1OutPath); - if (moduleRequest === moduleName) { - staticDeclFilePath = path.join(declgenV1OutPath, moduleName, 'Index.d.ets'); - break; - } else if (moduleRequest.startsWith(moduleName + '/')) { - staticDeclFilePath = - moduleRequest.replace(moduleName, toUnixPath(path.join(declgenV1OutPath, moduleName, 'src/main/ets'))) + EXTNAME_D_ETS; - break; - } - } - return staticDeclFilePath; -} - -export function cleanUpArkTsEvolutionModuleMap(): void { - arkTsEvolutionModuleMap = new Map(); -} - export interface ResolveModuleInfo { modulePath: string; isEts: boolean; @@ -1926,7 +1898,6 @@ export function resetEtsCheck(): void { targetESVersionChanged = false; fileToIgnoreDiagnostics = undefined; maxMemoryInServiceChecker = 0; - cleanUpArkTsEvolutionModuleMap(); } export function generateDeclarationFileForSTS(rootFileNames: string[]) { diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index cf24e77e3..a9edcb3b8 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -92,21 +92,25 @@ import { isEs2Abc, transformOhmurlToPkgName, transformOhmurlToRecordName, - ArkTsEvolutionModule, - pkgDeclFilesConfig } from '../../../ark_utils'; import { generateAot, FaultHandler } from '../../../gen_aot'; import { - ARK_TS_1_2, + ARKTS_1_2, NATIVE_MODULE } from '../../../pre_define'; import { sharedModuleSet } from '../check_shared_module'; import { SourceMapGenerator } from '../generate_sourcemap'; +import { + addDeclFilesConfig, + ArkTSEvolutionModule, + getDeclgenBridgeCodePath, + pkgDeclFilesConfig +} from '../../../process_arkts_evolution'; import { MemoryMonitor } from '../../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../../meomry_monitor/memory_define'; import { @@ -255,12 +259,13 @@ export class ModuleMode extends CommonMode { ); this.logger.printErrorAndExit(errInfo); } + const isArkTSEvolution: boolean = metaInfo.language === ARKTS_1_2; + const pkgPath: string = isArkTSEvolution ? + path.join(getDeclgenBridgeCodePath(metaInfo.moduleName), metaInfo.moduleName) : metaInfo.pkgPath; const pkgParams = { pkgName: metaInfo.pkgName, - moduleName: metaInfo.moduleName, - pkgPath: metaInfo.pkgPath, + pkgPath, isRecordName: true, - isArkTsEvolution: metaInfo.language === ARK_TS_1_2 }; let recordName: string = getNormalizedOhmUrlByFilepath(moduleId, this.projectConfig, this.logger, pkgParams, undefined); @@ -316,19 +321,21 @@ export class ModuleMode extends CommonMode { prepareForCompilation(rollupObject: Object, parentEvent: CompileEvent): void { const eventPrepareForCompilation = createAndStartEvent(parentEvent, 'preparation for compilation'); this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); - this.writeDeclFilesConfigJson(rollupObject.share.projectConfig.dependentModuleMap); + if (rollupObject.share.projectConfig.dependentModuleMap) { + this.writeDeclFilesConfigJson(rollupObject.share.projectConfig.dependentModuleMap); + } this.removeCacheInfo(rollupObject); stopEvent(eventPrepareForCompilation); } // Write the declaration file information of the 1.1 module file to the disk of the corresponding module - writeDeclFilesConfigJson(dependentModuleMap: Map): void { + writeDeclFilesConfigJson(dependentModuleMap: Map): void { for (const pkgName in pkgDeclFilesConfig) { - const arkTsEvolutionModuleInfo = dependentModuleMap.get(pkgName); - if (!arkTsEvolutionModuleInfo?.declFilesPath) { + const arkTSEvolutionModuleInfo = dependentModuleMap.get(pkgName); + if (!arkTSEvolutionModuleInfo?.declFilesPath) { return; } - const declFilesConfigFile: string = toUnixPath(arkTsEvolutionModuleInfo.declFilesPath); + const declFilesConfigFile: string = toUnixPath(arkTSEvolutionModuleInfo.declFilesPath); mkdirsSync(path.dirname(declFilesConfigFile)); fs.writeFileSync(declFilesConfigFile, JSON.stringify(pkgDeclFilesConfig[pkgName], null, 2), 'utf-8'); } @@ -523,20 +530,24 @@ export class ModuleMode extends CommonMode { let moduleName: string = metaInfo.moduleName; let recordName: string = ''; - let cacheFilePath: string = metaInfo.language === ARK_TS_1_2 ? originalFilePath : + let cacheFilePath: string = metaInfo.language === ARKTS_1_2 ? originalFilePath : this.genFileCachePath(filePath, this.projectConfig.projectRootPath, this.projectConfig.cachePath, metaInfo); let packageName: string = ''; if (this.useNormalizedOHMUrl) { packageName = metaInfo.pkgName; + const isArkTSEvolution: boolean = metaInfo.language === ARKTS_1_2; + const pkgPath: string = isArkTSEvolution ? + path.join(getDeclgenBridgeCodePath(metaInfo.moduleName), metaInfo.moduleName) : metaInfo.pkgPath; const pkgParams = { pkgName: packageName, - moduleName: metaInfo.moduleName, - pkgPath: metaInfo.pkgPath, + pkgPath, isRecordName: true, - isArkTsEvolution: metaInfo.language === ARK_TS_1_2 }; recordName = getNormalizedOhmUrlByFilepath(filePath, this.projectConfig, this.logger, pkgParams, undefined); + if (!isArkTSEvolution) { + addDeclFilesConfig(originalFilePath, metaInfo.moduleName, this.projectConfig, this.logger, pkgPath, packageName); + } } else { recordName = getOhmUrlByFilepath(filePath, this.projectConfig, this.logger, moduleName); if (isPackageModules) { diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 2bccb59fd..65a6e4d6f 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -47,7 +47,7 @@ import { } from '../common/ob_config_resolver'; import { ORIGIN_EXTENTION } from '../process_mock'; import { - ARK_TS_1_2, + ARKTS_1_2, ESMODULE, TRANSFORMED_MOCK_CONFIG, USER_DEFINE_MOCK_CONFIG @@ -79,6 +79,11 @@ import { createAndStartEvent, stopEvent } from '../../../performance'; +import { + getDeclgenBridgeCodePath, + writeBridgeCodeFileSyncByNode +} from '../../../process_arkts_evolution'; + const ROLLUP_IMPORT_NODE: string = 'ImportDeclaration'; const ROLLUP_EXPORTNAME_NODE: string = 'ExportNamedDeclaration'; const ROLLUP_EXPORTALL_NODE: string = 'ExportAllDeclaration'; @@ -92,6 +97,7 @@ export class ModuleSourceFile { private source: string | ts.SourceFile; private metaInfo: Object; private isSourceNode: boolean = false; + private isArkTSEvolution: boolean = false; private static projectConfig: Object; private static logger: CommonLogger; private static mockConfigInfo: Object = {}; @@ -111,6 +117,9 @@ export class ModuleSourceFile { if (typeof this.source !== 'string') { this.isSourceNode = true; } + if (metaInfo?.language === ARKTS_1_2) { + this.isArkTSEvolution = true; + } } static setProcessMock(rollupObject: Object): void { @@ -419,13 +428,17 @@ export class ModuleSourceFile { return this.moduleId; } - private async writeSourceFile(parentEvent: CompileEvent): Promise { - if (this.isSourceNode && !isJsSourceFile(this.moduleId)) { - await writeFileSyncByNode( this.source, ModuleSourceFile.projectConfig, this.metaInfo, - this.moduleId, parentEvent, printObfLogger); + private async writeSourceFile(parentEvent: Object): Promise { + if (!this.isArkTSEvolution) { + if (this.isSourceNode && !isJsSourceFile(this.moduleId)) { + await writeFileSyncByNode( this.source, ModuleSourceFile.projectConfig, this.metaInfo, + this.moduleId, parentEvent, ModuleSourceFile.logger); + } else { + await writeFileContentToTempDir(this.moduleId, this.source, ModuleSourceFile.projectConfig, + ModuleSourceFile.logger, parentEvent, this.metaInfo); + } } else { - await writeFileContentToTempDir(this.moduleId, this.source, ModuleSourceFile.projectConfig, - printObfLogger, parentEvent, this.metaInfo); + await writeBridgeCodeFileSyncByNode( this.source, this.moduleId); } } @@ -503,12 +516,13 @@ export class ModuleSourceFile { } private static spliceNormalizedOhmurl(moduleInfo: Object, filePath: string, importerFile?: string): string { + const isArkTSEvolution: boolean = moduleInfo.meta.language === ARKTS_1_2; + const pkgPath: string = isArkTSEvolution ? + path.join(getDeclgenBridgeCodePath(moduleInfo.meta.moduleName), moduleInfo.meta.moduleName) : moduleInfo.meta.pkgPath; const pkgParams = { pkgName: moduleInfo.meta.pkgName, - moduleName: moduleInfo.meta.moduleName, - pkgPath: moduleInfo.meta.pkgPath, + pkgPath, isRecordName: false, - isArkTsEvolution: moduleInfo.meta.language === ARK_TS_1_2 }; const ohmUrl: string = getNormalizedOhmUrlByFilepath(filePath, ModuleSourceFile.projectConfig, ModuleSourceFile.logger, pkgParams, diff --git a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts index f0f4b80e5..32df152df 100644 --- a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts +++ b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts @@ -26,6 +26,7 @@ import { SourceMapGenerator } from './generate_sourcemap'; import { cleanUpUtilsObjects, writeDeclarationFiles } from '../../ark_utils'; import { cleanUpKitImportObjects } from '../../process_kit_import'; import { cleanUpFilesList } from './utils'; +import { cleanUpProcessArkTSEvolutionObj } from '../../process_arkts_evolution'; import { CommonLogger } from './logger'; import { getHookEventFactory, @@ -83,6 +84,7 @@ export function genAbc() { CommonLogger.destroyInstance(); cleanUpAsyncEvents(); BytecodeObfuscator.cleanBcObfuscatorObject(); + cleanUpProcessArkTSEvolutionObj(); } }; } diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts index 5d6f39b25..68c96ec36 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts @@ -29,16 +29,13 @@ import { emitBuildInfo, runArkTSLinter, targetESVersionChanged, - collectFileToIgnoreDiagnostics, + collectFileToIgnoreDiagnostics TSC_SYSTEM_CODE, traverseProgramSourceFiles, arkTsEvolutionModuleMap, cleanUpArkTsEvolutionModuleMap, } from '../../ets_checker'; -import { - ARK_TS_1_2, - TS_WATCH_END_MSG -} from '../../pre_define'; +import { TS_WATCH_END_MSG } from '../../pre_define'; import { setChecker, } from '../../utils'; @@ -58,7 +55,7 @@ import { } from '../../performance'; import { LINTER_SUBSYSTEM_CODE } from '../../hvigor_error_code/hvigor_error_info'; import { ErrorCodeModule } from '../../hvigor_error_code/const/error_code_module'; -import { ArkTsEvolutionModule } from '../../ark_utils'; +import { collectArkTSEvolutionModuleInfo } from '../../process_arkts_evolution'; export let tsWatchEmitter: EventEmitter | undefined = undefined; export let tsWatchEndPromise: Promise; @@ -69,7 +66,7 @@ export function etsChecker() { name: 'etsChecker', buildStart() { if (this.share.projectConfig.dependentModuleMap) { - collectArkTSEvolutionModuleInfo(this.share.projectConfig.dependentModuleMap); + collectArkTSEvolutionModuleInfo(this.share); } const recordInfo = MemoryMonitor.recordStage(MemoryDefine.ROLLUP_PLUGIN_BUILD_START); const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsChecker', 'buildStart'); @@ -174,12 +171,4 @@ function rootFileNamesCollect(rootFileNames: string[]): void { entryFiles.forEach((fileName: string) => { rootFileNames.push(path.resolve(fileName)); }); -} - -function collectArkTSEvolutionModuleInfo(dependentModuleMap: Map): void { - for (const [moduleName, arkTsEvolutionModuleInfo] of dependentModuleMap) { - if (arkTsEvolutionModuleInfo?.declgenV1OutPath && arkTsEvolutionModuleInfo.language === ARK_TS_1_2) { - arkTsEvolutionModuleMap.set(moduleName, arkTsEvolutionModuleInfo); - } - } } \ No newline at end of file diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index a30c54ad0..d153bf444 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -667,4 +667,5 @@ export const ARKTS_MODULE_NAME: string = 'arkts'; export const COLD_RELOAD_MODE: string = 'coldReload'; export const INTEGRATED_HSP: string = 'integratedHsp'; -export const ARK_TS_1_2: string = '1.2'; \ No newline at end of file +export const ARKTS_1_2: string = '1.2'; +export const ARKTS_1_1: string = '1.1'; \ No newline at end of file diff --git a/compiler/src/process_arkts_evolution.ts b/compiler/src/process_arkts_evolution.ts new file mode 100644 index 000000000..a3a56b193 --- /dev/null +++ b/compiler/src/process_arkts_evolution.ts @@ -0,0 +1,186 @@ +/* + * Copyright (c) 2025 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 fs from 'fs'; +import path from 'path'; +import ts from 'typescript'; + +import { + EXTNAME_ETS, + EXTNAME_D_ETS, + ARKTS_1_1, + ARKTS_1_2 +} from './pre_define'; +import { + toUnixPath, + mkdirsSync +} from './utils'; +import { + red, + reset +} from './fast_build/ark_compiler/common/ark_define'; +import { getPkgInfo } from './ark_utils'; + +interface DeclFileConfig { + declPath: string; + ohmUrl: string; +} + +interface DeclFilesConfig { + packageName: string; + files: { + [filePath: string]: DeclFileConfig; + } +} + +export interface ArkTSEvolutionModule { + language: string; // "1.1" | "1.2" + pkgName: string; + moduleName: string; + modulePath: string; + declgenV1OutPath?: string; + declgenV2OutPath?: string; + declgenBridgeCodePath?: string; + declFilesPath?: string; +} + +interface ResolvedFileInfo { + moduleRequest: string; + resolvedFileName: string; +} + +export let pkgDeclFilesConfig: { [pkgName: string]: DeclFilesConfig } = {}; + +export let arkTSModuleMap: Map = new Map(); + +export let arkTSEvolutionModuleMap: Map = new Map(); + +export let arkTSHybridModuleMap: Map = new Map(); + +export function addDeclFilesConfig(filePath: string, moduleName: string, projectConfig: Object, + logger: Object, pkgPath: string, pkgName: string): void { + const { projectFilePath, pkgInfo } = getPkgInfo(filePath, projectConfig, logger, pkgPath, pkgName); + const declgenV2OutPath: string = getDeclgenV2OutPath(moduleName); + if (!declgenV2OutPath) { + return; + } + if (!pkgDeclFilesConfig[pkgName]) { + pkgDeclFilesConfig[pkgName] = { packageName: pkgName, files: {} }; + } + if (pkgDeclFilesConfig[pkgName].files[projectFilePath]) { + return; + } + const isSO: string = pkgInfo.isSO ? 'Y' : 'N'; + // The module name of the entry module of the project during the current compilation process. + const mainModuleName: string = projectConfig.mainModuleName; + const bundleName: string = projectConfig.bundleName; + const normalizedFilePath: string = `${pkgName}/${projectFilePath}`; + const declPath: string = path.join(toUnixPath(declgenV2OutPath), projectFilePath) + EXTNAME_D_ETS; + const ohmUrl: string = `${isSO}&${mainModuleName}&${bundleName}&${normalizedFilePath}&${pkgInfo.version}`; + pkgDeclFilesConfig[pkgName].files[projectFilePath] = { declPath, ohmUrl: `@normalized:${ohmUrl}` }; +} + +export function getArkTSEvoDeclFilePath(resolvedFileInfo: ResolvedFileInfo): string { + const { moduleRequest, resolvedFileName } = resolvedFileInfo; + let arktsEvoDeclFilePath: string = moduleRequest; + for (const [moduleName, arkTSEvolutionModuleInfo] of arkTSEvolutionModuleMap) { + const declgenV1OutPath: string = toUnixPath(arkTSEvolutionModuleInfo.declgenV1OutPath); + const modulePath: string = toUnixPath(arkTSEvolutionModuleInfo.modulePath); + const declgenBridgeCodePath: string = toUnixPath(arkTSEvolutionModuleInfo.declgenBridgeCodePath); + if (resolvedFileName && resolvedFileName.startsWith(modulePath + '/') && + !resolvedFileName.startsWith(declgenBridgeCodePath + '/')) { + arktsEvoDeclFilePath = resolvedFileName + .replace(modulePath, toUnixPath(path.join(declgenV1OutPath, moduleName))) + .replace(EXTNAME_ETS, EXTNAME_D_ETS); + break; + } + if (moduleRequest === moduleName) { + arktsEvoDeclFilePath = path.join(declgenV1OutPath, moduleName, 'Index.d.ets'); + break; + } + if (moduleRequest.startsWith(moduleName + '/')) { + arktsEvoDeclFilePath = moduleRequest.replace( + moduleName, + toUnixPath(path.join(declgenV1OutPath, moduleName, 'src/main/ets')) + ) + EXTNAME_D_ETS; + break; + } + } + return arktsEvoDeclFilePath; +} + +export function collectArkTSEvolutionModuleInfo(share: Object): void { + if (!share.projectConfig.useNormalizedOHMUrl) { + share.throwArkTsCompilerError(red, 'ArkTS:ERROR: Failed to compile mixed project.\n' + + 'Error Message: Failed to compile mixed project because useNormalizedOHMUrl is false.\n' + + 'Solutions: > Check whether useNormalizedOHMUrl is true.', reset); + } + // dependentModuleMap Contents eg. + // 1.2 hap -> 1.1 har: It contains the information of 1.1 har + // 1.1 hap -> 1.2 har -> 1.1 har : There is information about 3 modules. + for (const [moduleName, dependentModuleInfo] of share.projectConfig.dependentModuleMap) { + if (dependentModuleInfo.language === ARKTS_1_2) { + if (dependentModuleInfo.declgenV1OutPath && dependentModuleInfo.declgenBridgeCodePath) { + arkTSEvolutionModuleMap.set(moduleName, dependentModuleInfo); + } else { + share.throwArkTsCompilerError(red, 'ArkTS:INTERNAL ERROR: Failed to collect arkTs evolution module info.\n' + + `Error Message: Failed to collect arkTs evolution module "${moduleName}" info from rollup.`, reset); + } + } else if (dependentModuleInfo.language === ARKTS_1_1) { + if (dependentModuleInfo.declgenV2OutPath && dependentModuleInfo.declFilesPath) { + arkTSModuleMap.set(moduleName, dependentModuleInfo); + } else { + share.throwArkTsCompilerError(red, 'ArkTS:INTERNAL ERROR: Failed to collect arkTs evolution module info.\n' + + `Error Message: Failed to collect arkTs evolution module "${moduleName}" info from rollup.`, reset); + } + } else { + arkTSHybridModuleMap.set(moduleName, dependentModuleInfo); + } + } +} + +export function cleanUpProcessArkTSEvolutionObj(): void { + arkTSModuleMap = new Map(); + arkTSEvolutionModuleMap = new Map(); + arkTSHybridModuleMap = new Map(); + pkgDeclFilesConfig = {}; +} + +export async function writeBridgeCodeFileSyncByNode(node: ts.SourceFile, moduleId: string): Promise { + const printer: ts.Printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const writer: ts.EmitTextWriter = ts.createTextWriter( + // @ts-ignore + ts.getNewLineCharacter({ newLine: ts.NewLineKind.LineFeed, removeComments: false })); + printer.writeFile(node, writer, undefined); + mkdirsSync(path.dirname(moduleId)); + fs.writeFileSync(moduleId, writer.getText()); +} + +export function getDeclgenBridgeCodePath(moduleName: string): string { + if (arkTSEvolutionModuleMap.size && arkTSEvolutionModuleMap.get(moduleName)) { + const arkTSEvolutionModuleInfo: ArkTSEvolutionModule = arkTSEvolutionModuleMap.get(moduleName); + return arkTSEvolutionModuleInfo.declgenBridgeCodePath; + } + return ''; +} + +function getDeclgenV2OutPath(moduleName: string): string { + if (arkTSModuleMap.size && arkTSModuleMap.get(moduleName)) { + const arkTsModuleInfo: ArkTSEvolutionModule = arkTSModuleMap.get(moduleName); + return arkTsModuleInfo.declgenV2OutPath; + } + return ''; +} + diff --git a/compiler/src/process_module_files.ts b/compiler/src/process_module_files.ts index 0a031ae56..2a8e3a077 100644 --- a/compiler/src/process_module_files.ts +++ b/compiler/src/process_module_files.ts @@ -20,8 +20,7 @@ import fs from 'fs'; import { SourceMapGenerator } from './fast_build/ark_compiler/generate_sourcemap'; import { EXTNAME_TS, - EXTNAME_ETS, - ARK_TS_1_2 + EXTNAME_ETS } from './pre_define'; import { genTemporaryPath, @@ -63,8 +62,7 @@ export async function writeFileSyncByNode(node: ts.SourceFile, projectConfig: Ob * In the current realization, when moduleId mechanism is changed, there would be a compilation error. */ let filePath: string = moduleId ? moduleId : node.fileName; - // When the file is glue code for a ArkTS1.2 module, use the path to the glue code. - let temporaryFile: string = metaInfo.language === ARK_TS_1_2 ? filePath : genTemporaryPath(filePath, projectConfig.projectPath, process.env.cachePath, + let temporaryFile: string = genTemporaryPath(filePath, projectConfig.projectPath, process.env.cachePath, projectConfig, metaInfo); if (temporaryFile.length === 0) { return; diff --git a/compiler/test/ark_compiler_ut/common/process_arkts_evolution.test.ts b/compiler/test/ark_compiler_ut/common/process_arkts_evolution.test.ts new file mode 100644 index 000000000..cde7e4eae --- /dev/null +++ b/compiler/test/ark_compiler_ut/common/process_arkts_evolution.test.ts @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use rollupObject 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 { expect } from 'chai'; +import mocha from 'mocha'; +import sinon from 'sinon'; + +import { + collectArkTSEvolutionModuleInfo, + addDeclFilesConfig, + pkgDeclFilesConfig, + arkTSModuleMap +} from '../../../lib/process_arkts_evolution'; +import RollUpPluginMock from '../mock/rollup_mock/rollup_plugin_mock'; +import { + BUNDLE_NAME_DEFAULT, + HAR_DECLGENV2OUTPATH +} from '../mock/rollup_mock/common'; + +mocha.describe('process arkts evolution tests', function () { + mocha.before(function () { + this.rollup = new RollUpPluginMock(); + }); + + mocha.after(() => { + delete this.rollup; + }); + + mocha.it('1-1: test error message of collectArkTSEvolutionModuleInfo (useNormalizedOHMUrl is false)', function () { + this.rollup.build(); + this.rollup.share.projectConfig.useNormalizedOHMUrl = false; + this.rollup.share.projectConfig.dependentModuleMap.set('evohar', { language: '1.2' }); + const throwArkTsCompilerErrorStub = sinon.stub(this.rollup.share, 'throwArkTsCompilerError'); + try { + collectArkTSEvolutionModuleInfo(this.rollup.share); + } catch(e) { + } + const errMsg: string = 'ArkTS:ERROR: Failed to compile mixed project.\n' + + `Error Message: Failed to compile mixed project because useNormalizedOHMUrl is false.\n` + + 'Solutions: > Check whether useNormalizedOHMUrl is true.'; + expect(throwArkTsCompilerErrorStub.getCall(0).args[1] === errMsg).to.be.true; + throwArkTsCompilerErrorStub.restore(); + }); + + mocha.it('1-2: test error message of collectArkTSEvolutionModuleInfo (1.2 module information is incorrect)', function () { + this.rollup.build(); + this.rollup.share.projectConfig.useNormalizedOHMUrl = true; + this.rollup.share.projectConfig.dependentModuleMap.set('evohar', { language: '1.2' }); + const throwArkTsCompilerErrorStub = sinon.stub(this.rollup.share, 'throwArkTsCompilerError'); + try { + collectArkTSEvolutionModuleInfo(this.rollup.share); + } catch(e) { + } + const errMsg: string = 'ArkTS:INTERNAL ERROR: Failed to collect arkTs evolution module info.\n' + + `Error Message: Failed to collect arkTs evolution module "evohar" info from rollup.`; + expect(throwArkTsCompilerErrorStub.getCall(0).args[1] === errMsg).to.be.true; + throwArkTsCompilerErrorStub.restore(); + }); + + mocha.it('1-3: test error message of collectArkTSEvolutionModuleInfo (1.1 module information is incorrect)', function () { + this.rollup.build(); + this.rollup.share.projectConfig.useNormalizedOHMUrl = true; + this.rollup.share.projectConfig.dependentModuleMap.set('har', { language: '1.1' }); + const throwArkTsCompilerErrorStub = sinon.stub(this.rollup.share, 'throwArkTsCompilerError'); + try { + collectArkTSEvolutionModuleInfo(this.rollup.share); + } catch(e) { + } + const errMsg: string = 'ArkTS:INTERNAL ERROR: Failed to collect arkTs evolution module info.\n' + + `Error Message: Failed to collect arkTs evolution module "har" info from rollup.`; + expect(throwArkTsCompilerErrorStub.getCall(0).args[1] === errMsg).to.be.true; + throwArkTsCompilerErrorStub.restore(); + }); + + mocha.it('2-1: test generate declFilesInfo in mixed compilation', function () { + pkgDeclFilesConfig['har'] = { + packageName: 'har', + files: {} + }; + const filePath = '/har/Index.ets' + const projectConfig = { + mainModuleName: 'entry', + bundleName: BUNDLE_NAME_DEFAULT, + pkgContextInfo: { + 'har': { + packageName: 'har', + version: '1.0.0', + isSO: false + } + } + } + arkTSModuleMap.set('har', { + language: '1.1', + pkgName: 'har', + declgenV2OutPath: HAR_DECLGENV2OUTPATH + }) + addDeclFilesConfig(filePath, 'har', projectConfig, undefined, '/har', 'har'); + const expectDeclPath: string = `${HAR_DECLGENV2OUTPATH}/Index.d.ets`; + const expectOhmUrl: string = `@normalized:N&entry&${BUNDLE_NAME_DEFAULT}&har/Index&1.0.0`; + expect(pkgDeclFilesConfig['har'].files.length !== 0).to.be.true; + expect(pkgDeclFilesConfig['har'].files['Index'].length !== 0).to.be.true; + expect(pkgDeclFilesConfig['har'].files['Index'].declPath === expectDeclPath).to.be.true; + expect(pkgDeclFilesConfig['har'].files['Index'].ohmUrl === expectOhmUrl).to.be.true; + arkTSModuleMap.clear(); + }); +}); \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/ets_checker.test.ts b/compiler/test/ark_compiler_ut/ets_checker.test.ts index ddbd81c48..68443f478 100644 --- a/compiler/test/ark_compiler_ut/ets_checker.test.ts +++ b/compiler/test/ark_compiler_ut/ets_checker.test.ts @@ -36,8 +36,6 @@ import { resetEtsCheck, serviceChecker, resolveModuleNames as resolveModuleNamesMain, - arkTsEvolutionModuleMap, - cleanUpArkTsEvolutionModuleMap, getMaxFlowDepth, MAX_FLOW_DEPTH_DEFAULT_VALUE, fileCache, @@ -49,6 +47,10 @@ import { projectConfig } from '../../main'; import { mkdirsSync } from '../../lib/utils'; +import { + arkTSEvolutionModuleMap, + cleanUpProcessArkTSEvolutionObj +} from '../../lib/process_arkts_evolution'; mocha.describe('test ets_checker file api', function () { mocha.before(function () { @@ -207,7 +209,7 @@ mocha.describe('test ets_checker file api', function () { 'har', 'har/test' ]; - arkTsEvolutionModuleMap.set('har', { + arkTSEvolutionModuleMap.set('har', { language: '1.2', packageName: 'har', moduleName: 'har', @@ -216,8 +218,8 @@ mocha.describe('test ets_checker file api', function () { declgenBridgeCodePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/har/build/default/intermediates/declgen/default/bridgecode` }) const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/${DEFAULT_ENTRY}/src/main/entryability/test.ets`; - const arktsEvoIndexDeclFilePath: string = `${arkTsEvolutionModuleMap.get('har').declgenV1OutPath}/har/Index.d.ets`; - const arktsEvoTestDeclFilePath: string = `${arkTsEvolutionModuleMap.get('har').declgenV1OutPath}/har/src/main/ets/test.d.ets`; + const arktsEvoIndexDeclFilePath: string = `${arkTSEvolutionModuleMap.get('har').declgenV1OutPath}/har/Index.d.ets`; + const arktsEvoTestDeclFilePath: string = `${arkTSEvolutionModuleMap.get('har').declgenV1OutPath}/har/src/main/ets/test.d.ets`; fs.writeFileSync(filePath, code); mkdirsSync(path.dirname(arktsEvoIndexDeclFilePath)); mkdirsSync(path.dirname(arktsEvoTestDeclFilePath)); @@ -229,12 +231,12 @@ mocha.describe('test ets_checker file api', function () { fs.unlinkSync(filePath); fs.unlinkSync(arktsEvoIndexDeclFilePath); fs.unlinkSync(arktsEvoTestDeclFilePath); - cleanUpArkTsEvolutionModuleMap(); + cleanUpProcessArkTSEvolutionObj(); }); mocha.it('2-2: test resolveModuleNames parse the 1.2 module declaration file that the 1.1 module depends on (packageName)', function () { const moduleNames: string[] = ['testhar']; - arkTsEvolutionModuleMap.set('har', { + arkTSEvolutionModuleMap.set('har', { language: '1.2', packageName: 'testhar', moduleName: 'testhar', @@ -244,7 +246,7 @@ mocha.describe('test ets_checker file api', function () { }) const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/${DEFAULT_ENTRY}/src/main/entryability/test.ets`; const arktsEvoIndexFilePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/Index.ets`; - const arktsEvoIndexDeclFilePath: string = `${arkTsEvolutionModuleMap.get('har').declgenV1OutPath}/testhar/Index.d.ets`; + const arktsEvoIndexDeclFilePath: string = `${arkTSEvolutionModuleMap.get('har').declgenV1OutPath}/testhar/Index.d.ets`; const resolveModuleNameStub = sinon.stub(ts, 'resolveModuleName').returns({ resolvedModule: { resolvedFileName: arktsEvoIndexFilePath, @@ -274,7 +276,7 @@ mocha.describe('test ets_checker file api', function () { mocha.it('2-3: test resolveModuleNames parse the 1.2 module declaration file that the 1.1 module depends on', function () { const moduleNames: string[] = ['testhar/src/main/ets/test']; - arkTsEvolutionModuleMap.set('har', { + arkTSEvolutionModuleMap.set('har', { language: '1.2', packageName: 'testhar', moduleName: 'testhar', @@ -284,7 +286,7 @@ mocha.describe('test ets_checker file api', function () { }) const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/${DEFAULT_ENTRY}/src/main/entryability/test.ets`; const arktsEvoTestFilePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/src/main/ets/test.ets`; - const arktsEvoTestDeclFilePath: string = `${arkTsEvolutionModuleMap.get('har').declgenV1OutPath}/testhar/src/main/ets/test.d.ets`; + const arktsEvoTestDeclFilePath: string = `${arkTSEvolutionModuleMap.get('har').declgenV1OutPath}/testhar/src/main/ets/test.d.ets`; const resolveModuleNameStub = sinon.stub(ts, 'resolveModuleName').returns({ resolvedModule: { resolvedFileName: arktsEvoTestFilePath, diff --git a/compiler/test/ark_compiler_ut/mock/rollup_mock/common.ts b/compiler/test/ark_compiler_ut/mock/rollup_mock/common.ts index aa0c7c34e..123f315d9 100644 --- a/compiler/test/ark_compiler_ut/mock/rollup_mock/common.ts +++ b/compiler/test/ark_compiler_ut/mock/rollup_mock/common.ts @@ -82,4 +82,5 @@ export const TEST: string = 'test'; export const NEWFILE: string = 'newFile'; export const DECLFILESPATH: string = '/entry/build/default/intermediates/loader_out/default/etsFortgz/decl-fileInfo.json'; -export const DECLGENV2OUTPATH: string = '/entry/build/default/intermediates/declgen/default/declgenV2'; \ No newline at end of file +export const DECLGENV2OUTPATH: string = '/entry/build/default/intermediates/declgen/default/declgenV2'; +export const HAR_DECLGENV2OUTPATH: string = '/har/build/default/intermediates/declgen/default/declgenV2'; \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/mock/rollup_mock/project_config.ts b/compiler/test/ark_compiler_ut/mock/rollup_mock/project_config.ts index 243038c36..fc63322da 100644 --- a/compiler/test/ark_compiler_ut/mock/rollup_mock/project_config.ts +++ b/compiler/test/ark_compiler_ut/mock/rollup_mock/project_config.ts @@ -39,7 +39,7 @@ import { OHPM, RELEASE } from "../../../../lib/fast_build/ark_compiler/common/ark_define"; -import { ArkTsEvolutionModule } from "../../../../lib/ark_utils"; +import { ArkTSEvolutionModule } from "../../../../lib/process_arkts_evolution"; interface IArkProjectConfig { projectRootPath: string, @@ -133,7 +133,7 @@ class ProjectConfig { widgetCompile: boolean; arkRouterMap: Array; declarationEntry: Array; - dependentModuleMap: Map; + dependentModuleMap: Map; constructor(buildMode: string) { this.watchMode = 'false'; @@ -268,7 +268,7 @@ class ProjectConfig { } private setDependentModuleMap() { - const arkTsEvolutionModuleInfo = { + const arkTSEvolutionModuleInfo = { language: '1.1', pkgName: this.entryModuleName, moduleName: this.entryModuleName, @@ -276,7 +276,7 @@ class ProjectConfig { declgenV2OutPath: DECLGENV2OUTPATH, declFilesPath: DECLFILESPATH } - this.dependentModuleMap.set(this.entryModuleName, arkTsEvolutionModuleInfo) + this.dependentModuleMap.set(this.entryModuleName, arkTSEvolutionModuleInfo) } } diff --git a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts index 62d679b49..53df1a2e7 100644 --- a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts +++ b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts @@ -32,7 +32,6 @@ import { projectConfig as mainProjectConfig } from '../../../../main'; import RollUpPluginMock from '../../mock/rollup_mock/rollup_plugin_mock'; import { GEN_ABC_PLUGIN_NAME } from '../../../../lib/fast_build/ark_compiler/common/ark_define'; import { ModuleSourceFile } from '../../../../lib/fast_build/ark_compiler/module/module_source_file'; -import { DECLGENV2OUTPATH, INDEX_SOURCE_PATH } from '../../mock/rollup_mock/common'; import { ArkTSErrorDescription, ArkTSInternalErrorDescription, @@ -1475,38 +1474,4 @@ mocha.describe('generate ohmUrl', function () { this.rollup.share.getHvigorConsoleLogger = getHvigorConsoleLogger; loggerStub.restore(); }); - - mocha.it('generate declFilesInfo in mixed compilation', function () { - this.rollup.build(); - pkgDeclFilesConfig['entry'] = { - packageName: 'entry', - files: {} - }; - const pkgParams = { - pkgName: 'entry', - moduleName: 'entry', - pkgPath: `${projectConfig.projectRootPath}/entry`, - isRecordName: true, - isArkTsEvolution: false - }; - this.rollup.share.projectConfig.pkgContextInfo = { - 'entry': { - 'packageName': 'entry', - 'bundleName': '', - 'moduleName': '', - 'version': '', - 'entryPath': 'Index.ets', - 'isSO': false - } - }; - const filePath: string = `${projectConfig.projectRootPath}/${INDEX_SOURCE_PATH}`; - const logger = this.rollup.share.getLogger(GEN_ABC_PLUGIN_NAME); - const expectDeclPath: string = `${DECLGENV2OUTPATH}/src/main/pages/Index.d.ets`; - const expectOhmUrl: string = `@normalized:N&entry&com.example.app&entry/src/main/pages/Index&`; - getNormalizedOhmUrlByFilepath(filePath, this.rollup.share.projectConfig, logger, pkgParams); - expect(pkgDeclFilesConfig['entry'].files.length !== 0).to.be.true; - expect(pkgDeclFilesConfig['entry'].files['src/main/pages/Index'].length !== 0).to.be.true; - expect(pkgDeclFilesConfig['entry'].files['src/main/pages/Index'].declPath === expectDeclPath).to.be.true; - expect(pkgDeclFilesConfig['entry'].files['src/main/pages/Index'].ohmUrl === expectOhmUrl).to.be.true; - }); }); \ No newline at end of file -- Gitee From b4ceaf1b126eea0fae99fedf69567be7a7709961 Mon Sep 17 00:00:00 2001 From: zenghang Date: Thu, 10 Apr 2025 22:35:21 +0800 Subject: [PATCH 111/140] adjust to oh_modules compile Issue: IC072W Signed-off-by: zenghang Change-Id: Idf12853eab729a9cbb4a2f2741510b61821eee62 --- compiler/main.js | 35 +++++++++++++++++-- compiler/src/ets_checker.ts | 10 +++--- .../ark_compiler/module/module_mode.ts | 24 ++++++------- .../ark_compiler/module/module_source_file.ts | 2 +- compiler/src/process_arkts_evolution.ts | 33 ++++++++--------- .../common/process_arkts_evolution.test.ts | 2 +- 6 files changed, 68 insertions(+), 38 deletions(-) diff --git a/compiler/main.js b/compiler/main.js index fe52a7825..e70ee162b 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -150,6 +150,7 @@ function loadEntryObj(projectConfig) { initProjectConfig(projectConfig); loadMemoryTrackingConfig(projectConfig); loadBuildJson(); + initMixCompileHar(projectConfig); if (process.env.aceManifestPath && aceCompileMode === 'page') { setEntryFile(projectConfig); setFaTestRunnerFile(projectConfig); @@ -160,7 +161,9 @@ function loadEntryObj(projectConfig) { setStageTestRunnerFile(projectConfig); loadNavigationConfig(aceBuildJson); } - + if (projectConfig.mixCompile) { + return; + } if (staticPreviewPage) { projectConfig.entryObj['./' + staticPreviewPage] = projectConfig.projectPath + path.sep + staticPreviewPage + '.ets?entry'; @@ -265,7 +268,23 @@ function buildManifest(manifest, aceConfigPath) { } function getPackageJsonEntryPath() { - const rootPackageJsonPath = path.resolve(projectConfig.projectPath, '../../../' + projectConfig.packageJson); + /** + * adapt to oh_modules compile + * origin local module => project/library/src/main/ets + * oh_module => project/library/src/main + * bcs some oh_module don't contain ets dir + */ + + const candidatePaths = [ + path.resolve(projectConfig.projectPath, '../../../', projectConfig.packageJson), + path.resolve(projectConfig.projectPath, '../../', projectConfig.packageJson), + ]; + + const rootPackageJsonPath = + candidatePaths.find(fs.existsSync) ?? + (() => { + throw new Error('package.json not found in ../../../ or ../../'); + })(); if (fs.existsSync(rootPackageJsonPath)) { let rootPackageJsonContent; try { @@ -394,6 +413,9 @@ function setIntentEntryPages(projectConfig) { } function setAbilityPages(projectConfig) { + if (projectConfig.isRemoteModule) { + return; + } let abilityPages = []; if (projectConfig.aceModuleJsonPath && fs.existsSync(projectConfig.aceModuleJsonPath)) { const moduleJson = JSON.parse(fs.readFileSync(projectConfig.aceModuleJsonPath).toString()); @@ -1154,6 +1176,15 @@ function initMain() { abilityConfig.abilityType = process.env.abilityType || 'page'; } +function initMixCompileHar(projectConfig) { + projectConfig.isRemoteModule = process.env.isRemoteModule === 'true'; + projectConfig.mixCompile = process.env.mixCompile === 'true'; + if (projectConfig.isRemoteModule && projectConfig.mixCompile) { + projectConfig.compileHar = true; + getPackageJsonEntryPath(); + } +} + exports.globalProgram = globalProgram; exports.projectConfig = projectConfig; exports.loadEntryObj = loadEntryObj; diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index fe242f6ee..63ee2bb16 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -604,7 +604,7 @@ export function serviceChecker(rootFileNames: string[], newLogger: Object = null MemoryMonitor.stopRecordStage(runArkTSLinterRecordInfo); ts.PerformanceDotting.stopAdvanced('runArkTSLinterTime'); - if (process.env.watchMode !== 'true') { + if (process.env.watchMode !== 'true' && !projectConfig.isRemoteModule) { const processBuildHaprrecordInfo = MemoryMonitor.recordStage(MemoryDefine.PROCESS_BUILD_HAP); processBuildHap(cacheFile, rootFileNames, parentEvent, rollupShareObject); MemoryMonitor.stopRecordStage(processBuildHaprrecordInfo); @@ -1908,7 +1908,6 @@ export function generateDeclarationFileForSTS(rootFileNames: string[]) { return toUnixPath(path); }); - const regex = new RegExp(projectConfig.packageDir); const uniqueFiles = Array.from(new Set([ ...unixRootFileNames, /** @@ -1916,14 +1915,14 @@ export function generateDeclarationFileForSTS(rootFileNames: string[]) { * otherwise an error will be reported during the tsc compilation of declgen */ ...readDeaclareFiles() - ])).filter(file => !regex.test(file)); + ])); const config: RunnerParms = { inputDirs: [], inputFiles: uniqueFiles, - outDir: projectConfig.dependentModuleMap.get(projectConfig.moduleName).declgenV2OutPath, + outDir: projectConfig.dependentModuleMap.get(projectConfig.entryPackageName).declgenV2OutPath, // use package name as folder name - rootDir: projectConfig.moduleRootPath, + rootDir: projectConfig.modulePath, customResolveModuleNames: resolveModuleNames, customCompilerOptions: compilerOptions, includePaths: [projectConfig.modulePath] @@ -1933,4 +1932,5 @@ export function generateDeclarationFileForSTS(rootFileNames: string[]) { } fs.mkdirSync(config.outDir, { recursive: true }); generateInteropDecls(config); + processInteropUI(projectConfig.dependentModuleMap?.get(projectConfig.entryPackageName)?.declgenV2OutPath); } \ No newline at end of file diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index a9edcb3b8..dad96646b 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -261,7 +261,7 @@ export class ModuleMode extends CommonMode { } const isArkTSEvolution: boolean = metaInfo.language === ARKTS_1_2; const pkgPath: string = isArkTSEvolution ? - path.join(getDeclgenBridgeCodePath(metaInfo.moduleName), metaInfo.moduleName) : metaInfo.pkgPath; + path.join(getDeclgenBridgeCodePath(metaInfo.pkgName), metaInfo.moduleName) : metaInfo.pkgPath; const pkgParams = { pkgName: metaInfo.pkgName, pkgPath, @@ -322,23 +322,21 @@ export class ModuleMode extends CommonMode { const eventPrepareForCompilation = createAndStartEvent(parentEvent, 'preparation for compilation'); this.collectModuleFileList(rollupObject, rollupObject.getModuleIds()); if (rollupObject.share.projectConfig.dependentModuleMap) { - this.writeDeclFilesConfigJson(rollupObject.share.projectConfig.dependentModuleMap); + this.writeDeclFilesConfigJson(rollupObject.share.projectConfig.entryPackageName); } this.removeCacheInfo(rollupObject); stopEvent(eventPrepareForCompilation); } // Write the declaration file information of the 1.1 module file to the disk of the corresponding module - writeDeclFilesConfigJson(dependentModuleMap: Map): void { - for (const pkgName in pkgDeclFilesConfig) { - const arkTSEvolutionModuleInfo = dependentModuleMap.get(pkgName); - if (!arkTSEvolutionModuleInfo?.declFilesPath) { - return; - } - const declFilesConfigFile: string = toUnixPath(arkTSEvolutionModuleInfo.declFilesPath); - mkdirsSync(path.dirname(declFilesConfigFile)); - fs.writeFileSync(declFilesConfigFile, JSON.stringify(pkgDeclFilesConfig[pkgName], null, 2), 'utf-8'); + writeDeclFilesConfigJson(pkgName: string): void { + if (!arkTSModuleMap.size) { + return; } + const arkTSEvolutionModuleInfo: ArkTSEvolutionModule = arkTSModuleMap.get(pkgName); + const declFilesConfigFile: string = toUnixPath(arkTSEvolutionModuleInfo.declFilesPath); + mkdirsSync(path.dirname(declFilesConfigFile)); + fs.writeFileSync(declFilesConfigFile, JSON.stringify(pkgDeclFilesConfig[pkgName], null, 2), 'utf-8'); } collectModuleFileList(module: Object, fileList: IterableIterator): void { @@ -538,7 +536,7 @@ export class ModuleMode extends CommonMode { packageName = metaInfo.pkgName; const isArkTSEvolution: boolean = metaInfo.language === ARKTS_1_2; const pkgPath: string = isArkTSEvolution ? - path.join(getDeclgenBridgeCodePath(metaInfo.moduleName), metaInfo.moduleName) : metaInfo.pkgPath; + path.join(getDeclgenBridgeCodePath(packageName), metaInfo.moduleName) : metaInfo.pkgPath; const pkgParams = { pkgName: packageName, pkgPath, @@ -546,7 +544,7 @@ export class ModuleMode extends CommonMode { }; recordName = getNormalizedOhmUrlByFilepath(filePath, this.projectConfig, this.logger, pkgParams, undefined); if (!isArkTSEvolution) { - addDeclFilesConfig(originalFilePath, metaInfo.moduleName, this.projectConfig, this.logger, pkgPath, packageName); + addDeclFilesConfig(originalFilePath, this.projectConfig, this.logger, pkgPath, packageName); } } else { recordName = getOhmUrlByFilepath(filePath, this.projectConfig, this.logger, moduleName); diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 65a6e4d6f..c7b779e53 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -518,7 +518,7 @@ export class ModuleSourceFile { private static spliceNormalizedOhmurl(moduleInfo: Object, filePath: string, importerFile?: string): string { const isArkTSEvolution: boolean = moduleInfo.meta.language === ARKTS_1_2; const pkgPath: string = isArkTSEvolution ? - path.join(getDeclgenBridgeCodePath(moduleInfo.meta.moduleName), moduleInfo.meta.moduleName) : moduleInfo.meta.pkgPath; + path.join(getDeclgenBridgeCodePath(moduleInfo.meta.pkgName), moduleInfo.meta.moduleName) : moduleInfo.meta.pkgPath; const pkgParams = { pkgName: moduleInfo.meta.pkgName, pkgPath, diff --git a/compiler/src/process_arkts_evolution.ts b/compiler/src/process_arkts_evolution.ts index a3a56b193..a2f57711f 100644 --- a/compiler/src/process_arkts_evolution.ts +++ b/compiler/src/process_arkts_evolution.ts @@ -69,10 +69,10 @@ export let arkTSEvolutionModuleMap: Map = new Map( export let arkTSHybridModuleMap: Map = new Map(); -export function addDeclFilesConfig(filePath: string, moduleName: string, projectConfig: Object, - logger: Object, pkgPath: string, pkgName: string): void { +export function addDeclFilesConfig(filePath: string, projectConfig: Object, logger: Object, + pkgPath: string, pkgName: string): void { const { projectFilePath, pkgInfo } = getPkgInfo(filePath, projectConfig, logger, pkgPath, pkgName); - const declgenV2OutPath: string = getDeclgenV2OutPath(moduleName); + const declgenV2OutPath: string = getDeclgenV2OutPath(pkgName); if (!declgenV2OutPath) { return; } @@ -95,9 +95,10 @@ export function addDeclFilesConfig(filePath: string, moduleName: string, project export function getArkTSEvoDeclFilePath(resolvedFileInfo: ResolvedFileInfo): string { const { moduleRequest, resolvedFileName } = resolvedFileInfo; let arktsEvoDeclFilePath: string = moduleRequest; - for (const [moduleName, arkTSEvolutionModuleInfo] of arkTSEvolutionModuleMap) { + for (const [pkgName, arkTSEvolutionModuleInfo] of arkTSEvolutionModuleMap) { const declgenV1OutPath: string = toUnixPath(arkTSEvolutionModuleInfo.declgenV1OutPath); const modulePath: string = toUnixPath(arkTSEvolutionModuleInfo.modulePath); + const moduleName: string = arkTSEvolutionModuleInfo.moduleName; const declgenBridgeCodePath: string = toUnixPath(arkTSEvolutionModuleInfo.declgenBridgeCodePath); if (resolvedFileName && resolvedFileName.startsWith(modulePath + '/') && !resolvedFileName.startsWith(declgenBridgeCodePath + '/')) { @@ -130,23 +131,23 @@ export function collectArkTSEvolutionModuleInfo(share: Object): void { // dependentModuleMap Contents eg. // 1.2 hap -> 1.1 har: It contains the information of 1.1 har // 1.1 hap -> 1.2 har -> 1.1 har : There is information about 3 modules. - for (const [moduleName, dependentModuleInfo] of share.projectConfig.dependentModuleMap) { + for (const [pkgName, dependentModuleInfo] of share.projectConfig.dependentModuleMap) { if (dependentModuleInfo.language === ARKTS_1_2) { if (dependentModuleInfo.declgenV1OutPath && dependentModuleInfo.declgenBridgeCodePath) { - arkTSEvolutionModuleMap.set(moduleName, dependentModuleInfo); + arkTSEvolutionModuleMap.set(pkgName, dependentModuleInfo); } else { share.throwArkTsCompilerError(red, 'ArkTS:INTERNAL ERROR: Failed to collect arkTs evolution module info.\n' + - `Error Message: Failed to collect arkTs evolution module "${moduleName}" info from rollup.`, reset); + `Error Message: Failed to collect arkTs evolution module "${pkgName}" info from rollup.`, reset); } } else if (dependentModuleInfo.language === ARKTS_1_1) { if (dependentModuleInfo.declgenV2OutPath && dependentModuleInfo.declFilesPath) { - arkTSModuleMap.set(moduleName, dependentModuleInfo); + arkTSModuleMap.set(pkgName, dependentModuleInfo); } else { share.throwArkTsCompilerError(red, 'ArkTS:INTERNAL ERROR: Failed to collect arkTs evolution module info.\n' + - `Error Message: Failed to collect arkTs evolution module "${moduleName}" info from rollup.`, reset); + `Error Message: Failed to collect arkTs evolution module "${pkgName}" info from rollup.`, reset); } } else { - arkTSHybridModuleMap.set(moduleName, dependentModuleInfo); + arkTSHybridModuleMap.set(pkgName, dependentModuleInfo); } } } @@ -168,17 +169,17 @@ export async function writeBridgeCodeFileSyncByNode(node: ts.SourceFile, moduleI fs.writeFileSync(moduleId, writer.getText()); } -export function getDeclgenBridgeCodePath(moduleName: string): string { - if (arkTSEvolutionModuleMap.size && arkTSEvolutionModuleMap.get(moduleName)) { - const arkTSEvolutionModuleInfo: ArkTSEvolutionModule = arkTSEvolutionModuleMap.get(moduleName); +export function getDeclgenBridgeCodePath(pkgName: string): string { + if (arkTSEvolutionModuleMap.size && arkTSEvolutionModuleMap.get(pkgName)) { + const arkTSEvolutionModuleInfo: ArkTSEvolutionModule = arkTSEvolutionModuleMap.get(pkgName); return arkTSEvolutionModuleInfo.declgenBridgeCodePath; } return ''; } -function getDeclgenV2OutPath(moduleName: string): string { - if (arkTSModuleMap.size && arkTSModuleMap.get(moduleName)) { - const arkTsModuleInfo: ArkTSEvolutionModule = arkTSModuleMap.get(moduleName); +function getDeclgenV2OutPath(pkgName: string): string { + if (arkTSModuleMap.size && arkTSModuleMap.get(pkgName)) { + const arkTsModuleInfo: ArkTSEvolutionModule = arkTSModuleMap.get(pkgName); return arkTsModuleInfo.declgenV2OutPath; } return ''; diff --git a/compiler/test/ark_compiler_ut/common/process_arkts_evolution.test.ts b/compiler/test/ark_compiler_ut/common/process_arkts_evolution.test.ts index cde7e4eae..42a538d80 100644 --- a/compiler/test/ark_compiler_ut/common/process_arkts_evolution.test.ts +++ b/compiler/test/ark_compiler_ut/common/process_arkts_evolution.test.ts @@ -106,7 +106,7 @@ mocha.describe('process arkts evolution tests', function () { pkgName: 'har', declgenV2OutPath: HAR_DECLGENV2OUTPATH }) - addDeclFilesConfig(filePath, 'har', projectConfig, undefined, '/har', 'har'); + addDeclFilesConfig(filePath, projectConfig, undefined, '/har', 'har'); const expectDeclPath: string = `${HAR_DECLGENV2OUTPATH}/Index.d.ets`; const expectOhmUrl: string = `@normalized:N&entry&${BUNDLE_NAME_DEFAULT}&har/Index&1.0.0`; expect(pkgDeclFilesConfig['har'].files.length !== 0).to.be.true; -- Gitee From 12e2a48ebafbafa828d279c6f25d032adcab8b43 Mon Sep 17 00:00:00 2001 From: zenghang Date: Fri, 25 Apr 2025 16:28:12 +0800 Subject: [PATCH 112/140] fix bug for oh_modules Issue: IC3ZEW Signed-off-by: zenghang Change-Id: I0af780413e368c67182af88805af6f74395d600c --- compiler/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/main.js b/compiler/main.js index e70ee162b..e72d8e9a4 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -161,7 +161,7 @@ function loadEntryObj(projectConfig) { setStageTestRunnerFile(projectConfig); loadNavigationConfig(aceBuildJson); } - if (projectConfig.mixCompile) { + if (projectConfig.mixCompile && projectConfig.isRemoteModule) { return; } if (staticPreviewPage) { @@ -1181,6 +1181,7 @@ function initMixCompileHar(projectConfig) { projectConfig.mixCompile = process.env.mixCompile === 'true'; if (projectConfig.isRemoteModule && projectConfig.mixCompile) { projectConfig.compileHar = true; + process.env.compileMode = 'moduleJson'; getPackageJsonEntryPath(); } } -- Gitee From 48797a0eb96bd4743ce72b92084c98ae973f0d57 Mon Sep 17 00:00:00 2001 From: zenghang Date: Wed, 14 May 2025 10:27:18 +0800 Subject: [PATCH 113/140] fix compile oh_modules mixed Issue: IC7PSG Signed-off-by: zenghang Change-Id: I81bca159044a0999aeffde139f30e8c341377a01 --- compiler/main.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compiler/main.js b/compiler/main.js index e72d8e9a4..0a19d638c 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -1176,6 +1176,10 @@ function initMain() { abilityConfig.abilityType = process.env.abilityType || 'page'; } +/** + * due to some oh_modules is different with the original arkTs module. + * Some branches were not reached, causing some information to be uninitialized. + */ function initMixCompileHar(projectConfig) { projectConfig.isRemoteModule = process.env.isRemoteModule === 'true'; projectConfig.mixCompile = process.env.mixCompile === 'true'; @@ -1183,6 +1187,13 @@ function initMixCompileHar(projectConfig) { projectConfig.compileHar = true; process.env.compileMode = 'moduleJson'; getPackageJsonEntryPath(); + /** + * ets-loader will generate decl file from projectConfig.intentEntry which init in setIntentEntryPages. + * aceModuleJsonPath->ark_modules.json + * when compile oh_module with ets-loader, aceModuleJsonPath will be undefined. + * so projectConfig.intentEntry is empty. + */ + setIntentEntryPages(projectConfig); } } -- Gitee From c0e7018e580b111ebc2c08fac304bd47c466ddc9 Mon Sep 17 00:00:00 2001 From: oh_ci Date: Sat, 14 Jun 2025 14:02:23 +0000 Subject: [PATCH 114/140] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20?= =?UTF-8?q?!4891=20:=20fix=20$r=20$rawfile=20``'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compiler/src/process_ui_syntax.ts | 2 +- .../resource/resourceTest.js.sample | 58 ------------------- .../resource/resourceTest.ets | 25 -------- .../test/transform_ut/helpers/pathConfig.ts | 2 - 4 files changed, 1 insertion(+), 86 deletions(-) delete mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample delete mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index cada4b755..745b53a78 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -736,7 +736,7 @@ export function isAnimateToOrImmediately(node: ts.Node): boolean { export function processResourceData(node: ts.CallExpression, filePath: string, previewLog: {isAcceleratePreview: boolean, log: LogInfo[]} = {isAcceleratePreview: false, log: []}): ts.Node { - if (ts.isStringLiteral(node.arguments[0]) || ts.isNoSubstitutionTemplateLiteral(node.arguments[0])) { + if (ts.isStringLiteral(node.arguments[0])) { const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.'); const isResourceModule: boolean = resourceData.length && /^\[.*\]$/g.test(resourceData[0]); if (node.expression.getText() === RESOURCE_RAWFILE) { diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample deleted file mode 100644 index f3d898bf4..000000000 --- a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022-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. - */ -"use strict"; -if (!("finalizeConstruction" in ViewPU.prototype)) { - Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); -} -class Index extends ViewPU { - constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { - super(parent, __localStorage, elmtId, extraInfo); - if (typeof paramsLambda === "function") { - this.paramsGenerator_ = paramsLambda; - } - this.setInitiallyProvidedValue(params); - this.finalizeConstruction(); - } - setInitiallyProvidedValue(params) { - } - updateStateVars(params) { - } - purgeVariableDependenciesOnElmtId(rmElmtId) { - } - aboutToBeDeleted() { - SubscriberManager.Get().delete(this.id__()); - this.aboutToBeDeletedInternal(); - } - initialRender() { - this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); - }, Row); - this.observeComponentCreation2((elmtId, isInitialRender) => { - Image.create({ "id": 0, "type": 30000, params: ['foreground.png'], "bundleName": "com.example.application", "moduleName": "application" }); - }, Image); - this.observeComponentCreation2((elmtId, isInitialRender) => { - Image.create({ "id": 0, "type": 30000, params: [`foreground.png`], "bundleName": "com.example.application", "moduleName": "application" }); - }, Image); - Row.pop(); - } - rerender() { - this.updateDirtyElements(); - } - static getEntryName() { - return "Index"; - } -} -registerNamedRoute(() => new Index(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/resource/resourceTest", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest", integratedHsp: "false", moduleType: "followWithHap" }); -//# sourceMappingURL=resourceTest.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets deleted file mode 100644 index 57402fbdb..000000000 --- a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022-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. - */ -// Reusable test -@Entry -@Component -struct Index { - build() { - Row() { - Image($rawfile('foreground.png')) - Image($rawfile(`foreground.png`)) - } - } -} \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/pathConfig.ts b/compiler/test/transform_ut/helpers/pathConfig.ts index 14a3de177..936ccfdc3 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -213,8 +213,6 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'v2_component_decorator/reusableV2/reusableV2_initialRender', 'v2_component_decorator/reusableV2/reusableV2_members', 'v2_component_decorator/reusableV2/reusableV2_component_nesting', - - 'resource/resourceTest', ]; export const UT_VALIDATE_PAGES_PREVIEW: string[] = []; -- Gitee From 6577329aa04604f601b0cbf1eaa0363cb0df4f4d Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Sun, 15 Jun 2025 00:00:50 +0800 Subject: [PATCH 115/140] =?UTF-8?q?=E6=84=8F=E5=9B=BE=E6=A1=86=E6=9E=B6ent?= =?UTF-8?q?ity=E8=A3=85=E9=A5=B0=E5=99=A8=E5=92=8Cform=E8=A3=85=E9=A5=B0?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../ets_ui/rollup-plugin-ets-typescript.ts | 1 - compiler/src/pre_define.ts | 2 + compiler/src/process_ui_syntax.ts | 4 +- .../src/userIntents_parser/intentLogger.ts | 27 +- compiler/src/userIntents_parser/intentType.ts | 47 +- .../userIntents_parser/parseUserIntents.ts | 1110 +++++++++++++---- .../@InsightIntentEntity.js.sample | 26 + .../@InsightIntentForm.js.sample | 49 + .../@InsightIntentEntity.ets | 44 + .../@InsightIntentForm/@InsightIntentForm.ets | 92 ++ .../transform_ut/helpers/insightUTPath.ts | 4 +- 11 files changed, 1116 insertions(+), 290 deletions(-) create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntity/@InsightIntentEntity.js.sample create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentForm/@InsightIntentForm.js.sample create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntity/@InsightIntentEntity.ets create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentForm/@InsightIntentForm.ets diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index f1e30ae7b..3c11e1d89 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -231,7 +231,6 @@ export function etsTransform() { const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsTransform', 'afterBuildEnd'); const eventEtsTransformAfterBuildEnd = createAndStartEvent(hookEventFactory, 'etsTransformafterBuildEnd'); if (parseIntent.intentData.length > 0 || parseIntent.isUpdateCompile) { - parseIntent.verifyInheritanceChain(); parseIntent.writeUserIntentJsonFile(); } // Copy the cache files in the compileArkTS directory to the loader_out directory diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 7b041ad59..82109acda 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -98,6 +98,8 @@ export const COMPONENT_USER_INTENTS_DECORATOR_ENTRY: string = '@InsightIntentEnt export const COMPONENT_USER_INTENTS_DECORATOR_FUNCTION: string = '@InsightIntentFunction'; export const COMPONENT_USER_INTENTS_DECORATOR_METHOD: string = '@InsightIntentFunctionMethod'; export const COMPONENT_USER_INTENTS_DECORATOR_PAGE: string = '@InsightIntentPage'; +export const COMPONENT_USER_INTENTS_DECORATOR_ENTITY: string = '@InsightIntentEntity'; +export const COMPONENT_USER_INTENTS_DECORATOR_FORM: string = '@InsightIntentForm'; export const CHECK_COMPONENT_EXTEND_DECORATOR: string = 'Extend'; export const STRUCT_CONTEXT_METHOD_DECORATORS: Set = new Set([COMPONENT_BUILDER_DECORATOR, COMPONENT_STYLES_DECORATOR, COMPONENT_LOCAL_BUILDER_DECORATOR]); diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index cada4b755..878b2b929 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -301,7 +301,7 @@ export function processUISyntax(program: ts.Program, ut = false, } if (ts.isStructDeclaration(node)) { // This processing aims to parse InsightIntentDecorator. - node = parseIntent.detectInsightIntent(node, metaInfo, filePath, eventProcessUISyntax); + node = parseIntent.detectInsightIntent(node, metaInfo, filePath, eventProcessUISyntax, transformLog.errors); hasStruct = true; componentCollection.currentClassName = node.name.getText(); componentCollection.entryComponent === componentCollection.currentClassName && entryKeyNode(node); @@ -412,7 +412,7 @@ export function processUISyntax(program: ts.Program, ut = false, } } else if (ts.isClassDeclaration(node)) { // This processing aims to parse InsightIntentDecorator. - node = parseIntent.detectInsightIntent(node, metaInfo, filePath, eventProcessUISyntax); + node = parseIntent.detectInsightIntent(node, metaInfo, filePath, eventProcessUISyntax, transformLog.errors); if (hasDecorator(node, COMPONENT_SENDABLE_DECORATOR)) { if (projectConfig.compileHar && !projectConfig.useTsHar) { let warnMessage: string = 'If you use @Sendable in js har, an exception will occur during runtime.\n' + diff --git a/compiler/src/userIntents_parser/intentLogger.ts b/compiler/src/userIntents_parser/intentLogger.ts index 40848c1c8..23545f70c 100644 --- a/compiler/src/userIntents_parser/intentLogger.ts +++ b/compiler/src/userIntents_parser/intentLogger.ts @@ -83,29 +83,4 @@ export class IntentLogger { const message: string = typeof error === 'string' ? error : error.toString(); throw new Error(message); } -} - -export const ENTRYPATH_ERROR: LogData = LogDataFactory.newInstance('1001', '[InsightIntent] IntentDecorator needs to be in the .ets file'); -export const DECORATOR_STATEMENT_ERROR: LogData = LogDataFactory.newInstance('1002', '[InsightIntent] decorator is not CallExpression'); -export const DYNAMIC_PARAM_ERROR: LogData = LogDataFactory.newInstance('1003', '[InsightIntent] Dynamic variable cannot be resolved'); -export const DISALLOWED_PARAM_ERROR: LogData = LogDataFactory.newInstance('1004', '[InsightIntent] param is disallowed'); -export const UNSUPPORTED_PARSE_ERROR: LogData = LogDataFactory.newInstance('1005', '[InsightIntent] unsupported parameter type cannot be parsed'); -export const INCORRECT_PARAM_TYPE_ERROR: LogData = LogDataFactory.newInstance('1006', '[InsightIntent] param parsing occurs error param type'); -export const REQUIRED_PARAM_DISMISS_ERROR: LogData = LogDataFactory.newInstance('1007', '[InsightIntent] decorator args missing required param'); -export const INTERNAL_ERROR: LogData = LogDataFactory.newInstance('1008', '[InsightIntent] internal error'); -export const SCHEMA_VALIDATE_ONE_OF_ERROR: LogData = LogDataFactory.newInstance('1009', '[InsightIntent] Not meeting the one of schema verification rules'); -export const SCHEMA_VALIDATE_ANY_OF_ERROR: LogData = LogDataFactory.newInstance('1010', '[InsightIntent] Not meeting the any of schema verification rules'); -export const SCHEMA_VALIDATE_TYPE_ERROR: LogData = LogDataFactory.newInstance('1011', '[InsightIntent] schema verification parameter type error'); -export const SCHEMA_VALIDATE_REQUIRED_ERROR: LogData = LogDataFactory.newInstance('1012', - '[InsightIntent] schema verification required parameter does not exist'); -export const SCHEMA_ROOT_TYPE_MISMATCH_ERROR: LogData = LogDataFactory.newInstance('1013', '[InsightIntent] Schema root type must be \'object\''); -export const INVALID_BASE_CLASS_ERROR: LogData = LogDataFactory.newInstance('1014', - '[InsightIntent] decorated with @InsightIntentEntry has an invalid inheritance hierarchy.'); -export const PARAM_CIRCULAR_REFERENCE_ERROR: LogData = LogDataFactory.newInstance('1015', - '[InsightIntent] Circular reference detected in param'); -export const INVALID_PAGEPATH_ERROR: LogData = LogDataFactory.newInstance('1016', - '[InsightIntent] @InsightIntentPage Resolved \'pagePath\' path not found in project directory'); -export const DECORATOR_ILLEGAL_USE: LogData = LogDataFactory.newInstance('1017', - '[InsightIntent] @InsightIntentFunctionMethod must be declared under the @InsightIntentFunction decorator'); -export const DECORATOR_DUPLICATE_INTENTNAME: LogData = LogDataFactory.newInstance('1018', - '[InsightIntent] user intents has duplicate intentName param'); +} \ No newline at end of file diff --git a/compiler/src/userIntents_parser/intentType.ts b/compiler/src/userIntents_parser/intentType.ts index bfe00c16e..a29d16a24 100644 --- a/compiler/src/userIntents_parser/intentType.ts +++ b/compiler/src/userIntents_parser/intentType.ts @@ -60,6 +60,15 @@ export interface IntentPageInfo extends IntentInfo { navDestinationName: string; } +export interface IntentEntityDecoratorInfo { + entityCategory: string; + parameters?: object; +} + +export interface FormIntentDecoratorInfo extends IntentInfo { + formName: string; +} + export class ParamChecker { private _requiredFields: (keyof T)[]; private _allowFields: Set; @@ -193,7 +202,7 @@ IntentLinkInfoChecker.paramValidators = { intentVersion: validateRequiredString, displayName: validateRequiredString, displayDescription: validateOptionalString, - schema: validateRequiredString, + schema: validateOptionalString, icon: validateIcon, llmDescription: validateOptionalString, uri: validateRequiredString @@ -209,7 +218,7 @@ intentEntryInfoChecker.paramValidators = { parameters: validateParameters, icon: validateIcon, keywords: validateKeywords, - schema: validateRequiredString, + schema: validateOptionalString, abilityName: validateRequiredString, displayDescription: validateRequiredString, displayName: validateRequiredString, @@ -243,7 +252,7 @@ intentMethodInfoChecker.paramValidators = { parameters: validateParameters, icon: validateIcon, keywords: validateKeywords, - schema: validateRequiredString, + schema: validateOptionalString, intentName: validateRequiredString, domain: validateRequiredString, intentVersion: validateRequiredString, @@ -268,7 +277,7 @@ IntentPageInfoChecker.paramValidators = { parameters: validateParameters, icon: validateIcon, keywords: validateKeywords, - schema: validateRequiredString, + schema: validateOptionalString, intentName: validateRequiredString, domain: validateRequiredString, intentVersion: validateRequiredString, @@ -280,3 +289,33 @@ IntentPageInfoChecker.paramValidators = { navigationId: validateOptionalString, navDestinationName: validateOptionalString }; + +export const IntentEntityInfoChecker: ParamChecker = new ParamChecker(); +IntentEntityInfoChecker.requiredFields = ['entityCategory']; +IntentEntityInfoChecker.allowFields = new Set(['entityCategory', 'parameters']); + +IntentEntityInfoChecker.paramValidators = { + entityCategory: validateOptionalString, + parameters: validateParameters +}; + +export const intentFormInfoChecker = new ParamChecker(); +intentFormInfoChecker.requiredFields = [...BASE_REQUIRED as Array, 'formName']; +intentFormInfoChecker.allowFields = new Set([ + ...BASE_ALLOW as Array, 'formName' +]); +intentFormInfoChecker.paramValidators = { + formName: validateOptionalString, + example: validateOptionalString, + result: validateParameters, + parameters: validateParameters, + icon: validateIcon, + keywords: validateKeywords, + schema: validateRequiredString, + intentName: validateRequiredString, + domain: validateRequiredString, + intentVersion: validateRequiredString, + displayName: validateRequiredString, + displayDescription: validateOptionalString, + llmDescription: validateOptionalString +}; diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index b45f4dec0..b98525db1 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -18,48 +18,32 @@ import { IntentEntryInfo, intentEntryInfoChecker, IntentLinkInfo, - IntentLinkInfoChecker, intentMethodInfoChecker, + IntentLinkInfoChecker, + intentMethodInfoChecker, LinkIntentParamMapping, IntentPageInfoChecker, - ParamChecker + ParamChecker, + IntentEntityInfoChecker, + intentFormInfoChecker } from './intentType'; -import { - DECORATOR_DUPLICATE_INTENTNAME, - DECORATOR_ILLEGAL_USE, - DECORATOR_STATEMENT_ERROR, - DISALLOWED_PARAM_ERROR, - DYNAMIC_PARAM_ERROR, - ENTRYPATH_ERROR, - INCORRECT_PARAM_TYPE_ERROR, - IntentLogger, - INTERNAL_ERROR, - INVALID_BASE_CLASS_ERROR, INVALID_PAGEPATH_ERROR, - PARAM_CIRCULAR_REFERENCE_ERROR, - REQUIRED_PARAM_DISMISS_ERROR, - SCHEMA_ROOT_TYPE_MISMATCH_ERROR, - SCHEMA_VALIDATE_ANY_OF_ERROR, - SCHEMA_VALIDATE_ONE_OF_ERROR, - SCHEMA_VALIDATE_REQUIRED_ERROR, - SCHEMA_VALIDATE_TYPE_ERROR, - UNSUPPORTED_PARSE_ERROR -} from './intentLogger'; +import { IntentLogger } from './intentLogger'; import path from 'path'; import { getNormalizedOhmUrlByFilepath } from '../ark_utils'; import { globalModulePaths, projectConfig } from '../../main'; import fs from 'fs'; +import json5 from 'json5'; import { ProjectCollections } from 'arkguard'; import { COMPONENT_USER_INTENTS_DECORATOR, + COMPONENT_USER_INTENTS_DECORATOR_ENTITY, COMPONENT_USER_INTENTS_DECORATOR_ENTRY, COMPONENT_USER_INTENTS_DECORATOR_FUNCTION, COMPONENT_USER_INTENTS_DECORATOR_METHOD, - COMPONENT_USER_INTENTS_DECORATOR_PAGE + COMPONENT_USER_INTENTS_DECORATOR_PAGE, + COMPONENT_USER_INTENTS_DECORATOR_FORM } from '../pre_define'; -import { - CompileEvent, - createAndStartEvent, - stopEvent -} from '../performance'; +import { CompileEvent, createAndStartEvent, stopEvent } from '../performance'; +import { LogInfo, LogType } from '../utils'; type StaticValue = string | number | boolean | null | undefined | StaticValue[] | { [key: string]: StaticValue }; @@ -70,23 +54,36 @@ interface methodParametersInfo { } class ParseIntent { + private checker: ts.TypeChecker; + public intentData: object[]; + private currentFilePath: string; + private heritageClassSet: Set; + private updatePageIntentObj: Map; + public isUpdateCompile: boolean = true; + private isInitCache: boolean = false; + private entityMap: Map; + private entityOwnerMap: Map; + private moduleJsonInfo: Map; + private EntityHeritageClassSet: Set; + private EntityExtendsMap: Map; + private transformLog: LogInfo[]; + private currentNode: ts.Node; + constructor() { this.intentData = []; this.currentFilePath = ''; this.heritageClassSet = new Set(); + this.heritageClassSet.add('IntentEntity_sdk'); this.heritageClassSet.add('InsightIntentEntryExecutor_sdk'); this.updatePageIntentObj = new Map(); + this.entityMap = new Map(); + this.entityOwnerMap = new Map(); + this.moduleJsonInfo = new Map(); + this.EntityHeritageClassSet = new Set(); + this.EntityExtendsMap = new Map(); } - checker: ts.TypeChecker; - intentData: object[]; - currentFilePath: string; - heritageClassSet: Set; - updatePageIntentObj: Map; - isUpdateCompile: boolean = false; - isInitCache : boolean = false; - - hasDecorator(node: ts.Node, decorators: string[]): boolean { + private hasDecorator(node: ts.Node, decorators: string[]): boolean { if (!node.modifiers) { return false; } @@ -96,37 +93,32 @@ class ParseIntent { } let decoratorName: string | undefined; if (ts.isCallExpression(decorator.expression)) { - decoratorName = '@' + decorator.expression.expression.getText(); + decoratorName = `@${decorator.expression.expression.getText()}`; } return decoratorName !== undefined && decorators.includes(decoratorName); }); } - detectInsightIntent(node: ts.ClassDeclaration, metaInfo: object, filePath: string, eventOrEventFactory: CompileEvent | undefined): ts.Node { + public detectInsightIntent( + node: ts.ClassDeclaration, metaInfo: object, filePath: string, eventOrEventFactory: CompileEvent | undefined, transformLog: LogInfo[]): ts.Node { + this.initInsightIntent(node, metaInfo, transformLog, filePath); const eventParseIntentTime: CompileEvent | undefined = createAndStartEvent(eventOrEventFactory, 'parseIntentTime'); - if (!this.isInitCache && projectConfig.cachePath) { - const cacheSourceMapPath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); // The user's intents configuration file - this.isUpdateCompile = fs.existsSync(cacheSourceMapPath); - this.isInitCache = true; - } - if (this.isUpdateCompile) { - const pkgParams: object = { - pkgName: metaInfo.pkgName, - pkgPath: metaInfo.pkgPath - }; - const Logger: IntentLogger = IntentLogger.getInstance(); - const recordName: string = getNormalizedOhmUrlByFilepath(filePath, projectConfig, Logger, pkgParams, null); - if (!this.updatePageIntentObj.has(`@normalized:${recordName}`)) { - this.updatePageIntentObj.set(`@normalized:${recordName}`, []); - } - } const definedDecorators: string[] = [COMPONENT_USER_INTENTS_DECORATOR, COMPONENT_USER_INTENTS_DECORATOR_ENTRY, - COMPONENT_USER_INTENTS_DECORATOR_FUNCTION, COMPONENT_USER_INTENTS_DECORATOR_PAGE]; + COMPONENT_USER_INTENTS_DECORATOR_FUNCTION, COMPONENT_USER_INTENTS_DECORATOR_PAGE, COMPONENT_USER_INTENTS_DECORATOR_ENTITY, + COMPONENT_USER_INTENTS_DECORATOR_FORM]; if (ts.isClassDeclaration(node) && !this.hasDecorator(node, [COMPONENT_USER_INTENTS_DECORATOR_FUNCTION])) { node.members.forEach((member) => { if (ts.isMethodDeclaration(member) && this.hasModifier(member, ts.SyntaxKind.StaticKeyword) && this.hasDecorator(member, [COMPONENT_USER_INTENTS_DECORATOR_METHOD])) { - throw Error(`${DECORATOR_ILLEGAL_USE.toString()}, className: ${node.name.getText()}`); + const errorMessage: string = '@InsightIntentFunctionMethod must be declared under the @InsightIntentFunction decorator'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: node.getStart(), + code: '10105110', + description: 'ArkTs InsightIntent Error' + }); + return; } }); } @@ -139,60 +131,195 @@ class ParseIntent { return node; } - handleIntent(node: ts.ClassDeclaration, checker: ts.TypeChecker, filepath: string, metaInfo: Object = {}): void { + private initInsightIntent(node: ts.ClassDeclaration, metaInfo: object, transformLog: LogInfo[], filePath: string): void { + this.transformLog = transformLog; + this.currentNode = node; + if (!this.isInitCache) { + if (projectConfig.cachePath) { + const cacheSourceMapPath: string = + path.join(projectConfig.cachePath, 'insight_compile_cache.json'); // The user's intents configuration file + this.isUpdateCompile = fs.existsSync(cacheSourceMapPath); + this.isInitCache = true; + } else { + this.isUpdateCompile = false; + } + } + if (this.isUpdateCompile) { + const pkgParams: object = { + pkgName: metaInfo.pkgName, + pkgPath: metaInfo.pkgPath + }; + const Logger: IntentLogger = IntentLogger.getInstance(); + const recordName: string = getNormalizedOhmUrlByFilepath(filePath, projectConfig, Logger, pkgParams, null); + if (!this.updatePageIntentObj.has(`@normalized:${recordName}`)) { + this.updatePageIntentObj.set(`@normalized:${recordName}`, []); + } + } + } + + private handleIntent(node: ts.ClassDeclaration, checker: ts.TypeChecker, filepath: string, metaInfo: Object = {}): void { this.checker = checker; this.currentFilePath = filepath; if (!filepath.endsWith('.ets')) { - throw Error(`${ENTRYPATH_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = 'IntentDecorator needs to be in the .ets file'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101002', + description: 'ArkTs InsightIntent Error' + }); + return; } const pkgParams: object = { pkgName: metaInfo.pkgName, pkgPath: metaInfo.pkgPath }; node.modifiers.forEach(decorator => { - const expr: ts.Expression = decorator.expression; - if (!expr || !ts.isCallExpression(expr)) { - return; + this.handleDecorator(node, decorator, filepath, pkgParams); + }); + } + + private handleDecorator(node: ts.ClassDeclaration, decorator: ts.Decorator, filepath: string, pkgParams: object): void { + const expr: ts.Expression = decorator.expression; + if (!expr || !ts.isCallExpression(expr)) { + return; + } + const argumentKind: ts.SyntaxKind | undefined = expr.arguments[0]?.kind; + if (argumentKind && argumentKind === ts.SyntaxKind.NullKeyword || argumentKind && argumentKind === ts.SyntaxKind.UndefinedKeyword) { + return; + } + const symbol: ts.Symbol = this.checker.getTypeAtLocation(decorator.expression.expression)?.getSymbol(); + const declarations: ts.Declaration[] | undefined = symbol?.getDeclarations(); + if (!declarations || declarations.length === 0) { + return; + } + const decoratorSourceFile: string = declarations[0].getSourceFile().fileName; + const isGlobalPathFlag: boolean = this.isGlobalPath(decoratorSourceFile); + if (!isGlobalPathFlag) { + return; + } + const Logger: IntentLogger = IntentLogger.getInstance(); + const recordName: string = getNormalizedOhmUrlByFilepath(filepath, projectConfig, Logger, pkgParams, null); + const intentObj: object = { + 'decoratorFile': `@normalized:${recordName}`, + 'decoratorClass': node.name.text + }; + const originalDecorator: string = '@' + decorator.expression.expression.getText(); + if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR) { + this.handleLinkDecorator(intentObj, node, decorator); + } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_ENTRY) { + this.handleEntryDecorator(intentObj, node, decorator, pkgParams); + } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_FUNCTION) { + this.handleMethodDecorator(intentObj, node, decorator); + } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_PAGE) { + this.handlePageDecorator(intentObj, node, decorator, pkgParams); + } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_ENTITY) { + this.handleEntityDecorator(intentObj, node, decorator, pkgParams); + } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_FORM) { + this.handleFormDecorator(intentObj, node, decorator, pkgParams); + } + } + + private handleFormDecorator(intentObj: object, node: ts.ClassDeclaration, decorator: ts.Decorator, + pkgParams: object): void { + const expr: ts.Expression = decorator.expression; + if (ts.isCallExpression(expr)) { + const args: ts.NodeArray = expr.arguments; + Object.assign(intentObj, { + 'bundleName': projectConfig.bundleName, + 'moduleName': projectConfig.moduleName, + 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_FORM + }); + this.analyzeDecoratorArgs(args, intentObj, intentFormInfoChecker); + const properties: Record = this.parseClassNode(node, intentObj.intentName); + this.processFormInfo(node, this.currentFilePath, pkgParams, intentObj); + this.schemaValidateSync(properties, intentObj.parameters); + this.createObfuscation(node); + if (this.isUpdateCompile) { + this.updatePageIntentObj.get(intentObj.decoratorFile).push(intentObj); } - const argumentKind: ts.SyntaxKin | undefined = expr.arguments[0]?.kind; - if (argumentKind && argumentKind === ts.SyntaxKind.NullKeyword || argumentKind && argumentKind === ts.SyntaxKind.UndefinedKeyword) { - return; + this.intentData.push(intentObj); + } else { + const errorMessage: string = 'Decorator is not CallExpression'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101003', + description: 'ArkTs InsightIntent Error' + }); + return; + } + } + + private handleEntityDecorator(intentObj: object, node: ts.ClassDeclaration, decorator: ts.Decorator, + pkgParams: object): void { + const entityClassName: string = this.checker.getTypeAtLocation(node).getSymbol().getName(); + const expr: ts.Expression = decorator.expression; + if (ts.isCallExpression(expr)) { + const args: ts.NodeArray = expr.arguments; + Object.assign(intentObj, { + 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_ENTITY, + 'className': intentObj.decoratorClass + }); + delete intentObj.decoratorClass; + this.analyzeDecoratorArgs(args, intentObj, IntentEntityInfoChecker); + const properties: Record = this.parseClassNode(node, undefined); + const entityId: string = this.getEntityId(node); + Object.assign(properties, { + 'entityId': entityId + }); + Object.assign(intentObj, { + 'entityId': entityId + }); + this.schemaValidateSync(properties, intentObj.parameters); + this.analyzeBaseClass(node, pkgParams, intentObj, COMPONENT_USER_INTENTS_DECORATOR_ENTITY); + this.createObfuscation(node); + if (this.isUpdateCompile) { + this.updatePageIntentObj.get(intentObj.decoratorFile).push(intentObj); } - const symbol: ts.Symbol = checker.getTypeAtLocation(decorator.expression.expression)?.getSymbol(); - const declarations: ts.Declaration[] | undefined = symbol?.getDeclarations(); - if (!declarations || declarations.length === 0) { + if (this.entityMap.has(entityClassName)) { + const errorMessage: string = 'class can be decorated with at most one @InsightIntentEntity'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101004', + description: 'ArkTs InsightIntent Error' + }); return; + } else { + this.entityMap.set(entityClassName, intentObj); } - const decoratorSourceFile: string = declarations[0].getSourceFile().fileName; - const isGlobalPath: boolean = globalModulePaths?.some(globalPath => { - const normalizedParent: string = path.normalize(decoratorSourceFile).replace(/\\/g, '/'); - const normalizedGlobalPath: string = path.normalize(globalPath).replace(/\\/g, '/'); - return normalizedParent.startsWith(normalizedGlobalPath); + } else { + const errorMessage: string = '10101003 ArkTs InsightIntent Error\n' + + 'Decorator is not CallExpression'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101003' }); - if (!isGlobalPath) { - return; - } - const Logger: IntentLogger = IntentLogger.getInstance(); - const recordName: string = getNormalizedOhmUrlByFilepath(filepath, projectConfig, Logger, pkgParams, null); - const intentObj: object = { - 'decoratorFile': `@normalized:${recordName}`, - 'decoratorClass': node.name.text - }; - const originalDecorator: string = '@' + decorator.expression.expression.getText(); - if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR) { - this.handleLinkDecorator(intentObj, node, decorator); - } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_ENTRY) { - this.handleEntryDecorator(intentObj, node, decorator, pkgParams); - } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_FUNCTION) { - this.handleMethodDecorator(intentObj, node, decorator); - } else if (originalDecorator === COMPONENT_USER_INTENTS_DECORATOR_PAGE) { - this.handlePageDecorator(intentObj, node, decorator, pkgParams); - } - }); + return; + } } - handlePageDecorator(intentObj: object, node: ts.Node, decorator: ts.Decorator, pkgParams: object): void { + private handlePageDecorator(intentObj: object, node: ts.ClassDeclaration, decorator: ts.Decorator, + pkgParams: object): void { const expr: ts.Expression = decorator.expression; + if (ts.isClassDeclaration(node)) { + const errorMessage: string = `@InsightIntentPage must be decorated on struct` + + `, className: ${node.name.getText()}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101003', + description: 'ArkTs InsightIntent Error' + }); + return; + } if (ts.isCallExpression(expr)) { const args: ts.NodeArray = expr.arguments; Object.assign(intentObj, { @@ -201,18 +328,26 @@ class ParseIntent { 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_PAGE }); this.analyzeDecoratorArgs(args, intentObj, IntentPageInfoChecker); + this.validatePagePath(intentObj, pkgParams); this.createObfuscation(node); - this.transformPagePath(intentObj, pkgParams); if (this.isUpdateCompile) { this.updatePageIntentObj.get(intentObj.decoratorFile).push(intentObj); } this.intentData.push(intentObj); } else { - throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = 'Decorator is not CallExpression'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101003', + description: 'ArkTs InsightIntent Error' + }); + return; } } - handleMethodDecorator(intentObj: object, node: ts.Node, decorator: ts.Decorator): void { + private handleMethodDecorator(intentObj: object, node: ts.ClassDeclaration, decorator: ts.Decorator): void { const expr: ts.Expression = decorator.expression; if (ts.isCallExpression(expr)) { Object.assign(intentObj, { @@ -227,13 +362,15 @@ class ParseIntent { args: ts.NodeArray, } - const methodParameters: methodParametersInfo[] = this.parseClassMethods(node, COMPONENT_USER_INTENTS_DECORATOR_METHOD); + const methodParameters: methodParametersInfo[] = + this.parseClassMethods(node, COMPONENT_USER_INTENTS_DECORATOR_METHOD); methodParameters.forEach(methodDecorator => { const functionName: string = methodDecorator.functionName; const methodArgs: ts.NodeArray = methodDecorator.args; const properties: Record = methodDecorator.parameters; const functionParamList: Array = Object.keys(properties); - const methodObj: object = Object.assign({}, intentObj, {functionName, 'functionParamList': functionParamList}); + const methodObj: object = + Object.assign({}, intentObj, { functionName, 'functionParamList': functionParamList }); this.analyzeDecoratorArgs(methodArgs, methodObj, intentMethodInfoChecker); if (this.isUpdateCompile) { this.updatePageIntentObj.get(methodObj.decoratorFile).push(methodObj); @@ -242,11 +379,19 @@ class ParseIntent { }); this.createObfuscation(node); } else { - throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = 'Decorator is not CallExpression'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101003', + description: 'ArkTs InsightIntent Error' + }); + return; } } - handleLinkDecorator(intentObj: object, node: ts.Node, decorator: ts.Decorator): void { + private handleLinkDecorator(intentObj: object, node: ts.ClassDeclaration, decorator: ts.Decorator): void { const expr: ts.Expression = decorator.expression; if (ts.isCallExpression(expr)) { const args: ts.NodeArray = expr.arguments; @@ -262,11 +407,20 @@ class ParseIntent { } this.intentData.push(intentObj); } else { - throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = 'Decorator is not CallExpression'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101003', + description: 'ArkTs InsightIntent Error' + }); + return; } } - handleEntryDecorator(intentObj: object, node: ts.Node, decorator: ts.Decorator, pkgParams: object): void { + private handleEntryDecorator(intentObj: object, node: ts.ClassDeclaration, decorator: ts.Decorator, + pkgParams: object): void { const expr: ts.Expression = decorator.expression; if (ts.isCallExpression(expr)) { const args: ts.NodeArray = expr.arguments; @@ -276,9 +430,9 @@ class ParseIntent { 'decoratorType': COMPONENT_USER_INTENTS_DECORATOR_ENTRY }); this.analyzeDecoratorArgs(args, intentObj, intentEntryInfoChecker); - const properties: Record = this.parseClassNode(node); + const properties: Record = this.parseClassNode(node, intentObj.intentName); this.schemaValidateSync(properties, intentObj.parameters); - this.analyzeBaseClass(node, pkgParams, intentObj); + this.analyzeBaseClass(node, pkgParams, intentObj, COMPONENT_USER_INTENTS_DECORATOR_ENTRY); this.createObfuscation(node); this.processExecuteModeParam(intentObj); if (this.isUpdateCompile) { @@ -286,62 +440,224 @@ class ParseIntent { } this.intentData.push(intentObj); } else { - throw Error(`${DECORATOR_STATEMENT_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = 'Decorator is not CallExpression'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101003', + description: 'ArkTs InsightIntent Error' + }); + return; + } + } + + private processFormInfo(node: ts.ClassDeclaration, formClassPath: string, pkgParams: object, + intentObj: object): void { + if (this.moduleJsonInfo.size === 0 && pkgParams.pkgPath) { + this.readModuleJsonInfo(pkgParams); + } + const extensionAbilities: object[] = this.moduleJsonInfo.get('extensionAbilities'); + const bindFormInfo: object = extensionAbilities.find(extensionInfo => { + const formSrcEntryPath: string = path.join(pkgParams.pkgPath, 'src', 'main', extensionInfo.srcEntry); + return formSrcEntryPath === formClassPath && extensionInfo.type === 'form'; + }); + this.verifyFormName(bindFormInfo, intentObj); + const isExported: boolean = node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword); + const isDefault: boolean = node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.DefaultKeyword); + if (!(bindFormInfo && isExported && isDefault)) { + const errorMessage: string = '@InsightIntentForm must be decorated on a formExtensionAbility'; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101006', + description: 'ArkTs InsightIntent Error' + }); + return; + } + } + + private verifyFormName(bindFormInfo: object, intentObj: object): void { + if (!bindFormInfo) { + return; + } + let formNameFound: boolean = false; + intentObj.abilityName = bindFormInfo.name; + bindFormInfo.metadata?.forEach(metaData => { + const formConfigName = `${metaData.resource.split(':').pop()}.json`; + const formConfigPath = path.join(projectConfig.aceProfilePath, formConfigName); + if (!fs.existsSync(formConfigPath)) { + return; + } + const formData = fs.readFileSync(formConfigPath, 'utf8'); + const formConfigs = JSON.parse(formData).forms; + if (formConfigs?.some(form => form.name === intentObj.formName)) { + formNameFound = true; + } + }); + if (!formNameFound) { + const errorMessage: string = '@InsightIntentForm param formName must match the card name. ' + + `Provided name: ${intentObj.formName}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101006', + description: 'ArkTs InsightIntent Error' + }); + return; + } + } + + private readModuleJsonInfo(pkgParams: object): void { + const moduleJsonPath: string = path.join(pkgParams.pkgPath, 'src', 'main', 'module.json5'); + if (fs.existsSync(moduleJsonPath)) { + const jsonStr: string = fs.readFileSync(moduleJsonPath, 'utf8'); + const obj: object = json5.parse(jsonStr); + if (obj.module?.abilities) { + this.moduleJsonInfo.set('abilities', obj.module.abilities); + } + if (obj.module?.extensionAbilities) { + this.moduleJsonInfo.set('extensionAbilities', obj.module.extensionAbilities); + } + } else { + const errorMessage: string = ` module.json5 not found, expect moduleJsonPath: ${moduleJsonPath}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101007', + description: 'ArkTs InsightIntent Error' + }); + return; } } - transformPagePath(intentObj: object, pkgParams: object): void { + private validatePagePath(intentObj: object, pkgParams: object): void { if (pkgParams.pkgPath) { - const normalPagePath: string = path.join(pkgParams.pkgPath, 'src/main', intentObj.pagePath + '.ets'); + const normalPagePath: string = path.join(pkgParams.pkgPath, 'src', 'main', intentObj.pagePath + '.ets'); if (!fs.existsSync(normalPagePath)) { - throw Error(`${INVALID_PAGEPATH_ERROR.toString()}, ${normalPagePath} does not exist, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `@InsightIntentPage pagePath incorrect,` + + `${normalPagePath} does not exist, invalidDecoratorPath: ${this.currentFilePath}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101008', + description: 'ArkTs InsightIntent Error' + }); + return; } else { const Logger: IntentLogger = IntentLogger.getInstance(); - intentObj.pagePath = '@normalized:' + getNormalizedOhmUrlByFilepath(normalPagePath, projectConfig, Logger, pkgParams, null); + intentObj.pagePath = + '@normalized:' + getNormalizedOhmUrlByFilepath(normalPagePath, projectConfig, Logger, pkgParams, null); } } } - analyzeBaseClass(node: ts.ClassDeclaration, pkgParams: object, intentObj: object): void { + private isGlobalPath(parentFilePath: string): boolean { + return globalModulePaths?.some(globalPath => { + const normalizedParent: string = path.normalize(parentFilePath).replace(/\\/g, '/'); + const normalizedGlobalPath: string = path.normalize(globalPath).replace(/\\/g, '/'); + return normalizedParent.startsWith(normalizedGlobalPath); + }); + } + + private analyzeBaseClass(node: ts.ClassDeclaration, pkgParams: object, intentObj: object, + decoratorFlag: string): void { const interfaces: ts.ExpressionWithTypeArguments[] = []; - node.heritageClauses?.forEach(clause => { - if (clause.token === ts.SyntaxKind.ImplementsKeyword || clause.token === ts.SyntaxKind.ExtendsKeyword) { - interfaces.push(...clause.types); + if (decoratorFlag === COMPONENT_USER_INTENTS_DECORATOR_ENTRY) { + node.heritageClauses?.forEach(clause => { + if (clause.token === ts.SyntaxKind.ExtendsKeyword) { + interfaces.push(...clause.types); + } + }); + this.processEntryBaseClass(interfaces, intentObj, pkgParams); + } else if (decoratorFlag === COMPONENT_USER_INTENTS_DECORATOR_ENTITY) { + node.heritageClauses?.forEach(clause => { + if (clause.token === ts.SyntaxKind.ImplementsKeyword || clause.token === ts.SyntaxKind.ExtendsKeyword) { + interfaces.push(...clause.types); + } + }); + if (interfaces.length > 0) { + const parentNode: ts.ExpressionWithTypeArguments = interfaces[0]; + this.analyzeClassHeritage(parentNode, node, pkgParams, intentObj); + } else { + const errorMessage: string = + `decorated with @InsightIntentEntity must be ultimately inherited to insightIntent.IntentEntity`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101009', + description: 'ArkTs InsightIntent Error' + }); + return; } - }); + } + } + + private processEntryBaseClass(interfaces: ts.ExpressionWithTypeArguments[], intentObj: object, + pkgParams: object): void { if (interfaces.length > 0) { const parentNode: ts.ExpressionWithTypeArguments = interfaces[0]; - if (parentNode) { - this.analyzeClassHeritage(parentNode, node, pkgParams, intentObj); + const parentClassName: string = parentNode.expression.getText(); + const parentNodeSymbol: ts.Symbol = this.checker.getTypeAtLocation(parentNode).getSymbol(); + const parentFilePath: string = parentNodeSymbol.getDeclarations()?.[0].getSourceFile().fileName; + const isGlobalPathFlag: boolean = this.isGlobalPath(parentFilePath); + if (!(isGlobalPathFlag && parentClassName === 'InsightIntentEntryExecutor')) { + const errorMessage: string = + `decorated with @InsightIntentEntry must be inherited to InsightIntentEntryExecutor`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101010', + description: 'ArkTs InsightIntent Error' + }); + return; } + const logger: IntentLogger = IntentLogger.getInstance(); + const parentRecordName: string = + getNormalizedOhmUrlByFilepath(parentFilePath, projectConfig, logger, pkgParams, null); + const recordPath: string = isGlobalPathFlag ? `sdk` : `@normalized:${parentRecordName}`; + this.collectClassInheritanceInfo(parentNode, intentObj, parentClassName, recordPath); } else { - throw Error(`${INVALID_BASE_CLASS_ERROR.toString()}, - The user's custom intents must be ultimately inherited to InsightIntentEntryExecutor, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `decorated with @InsightIntentEntry must be inherited to InsightIntentEntryExecutor`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101010', + description: 'ArkTs InsightIntent Error' + }); + return; } } - hasModifier(node: ts.Node, modifier: ts.SyntaxKind): boolean { + private hasModifier(node: ts.Node, modifier: ts.SyntaxKind): boolean { return (node.modifiers || []).some(m => m.kind === modifier); } - parseClassMethods(classNode: ts.ClassDeclaration, decoratorType: string): methodParametersInfo[] { + private parseClassMethods(classNode: ts.ClassDeclaration, decoratorType: string): methodParametersInfo[] { const methodsArr: methodParametersInfo[] = []; for (const member of classNode.members) { if (!ts.isMethodDeclaration(member) || !this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { continue; } - const decorator: boolean = member.modifiers?.find(m => { + const decorator: ts.ModifierLike = member.modifiers?.find(m => { if (!ts.isDecorator(m)) { return false; } let decoratorName: string | undefined; if (ts.isCallExpression(m.expression)) { - decoratorName = '@' + m.expression.expression.getText(); + decoratorName = `@${decorator.expression.expression.getText()}`; } return decoratorName === decoratorType; }); if (decorator && ts.isCallExpression(decorator.expression)) { - const parameters: Record = {}; + let parameters: Record = {}; member.parameters.forEach(param => { const paramName: string = param.name.getText(); parameters[paramName] = this.checker.typeToString( @@ -361,7 +677,7 @@ class ParseIntent { return methodsArr; } - analyzeClassHeritage( + private analyzeClassHeritage( parentNode: ts.ExpressionWithTypeArguments, node: ts.ClassDeclaration, pkgParams: object, intentObj: object ): void { const parentSymbol: ts.Symbol = this.checker.getTypeAtLocation(parentNode).getSymbol(); @@ -373,29 +689,37 @@ class ParseIntent { parentClassName = parentSymbol.getName(); } }); + intentObj.parentClassName = parentClassName; const parentFilePath: string = parentSymbol.getDeclarations()?.[0].getSourceFile().fileName; const logger: IntentLogger = IntentLogger.getInstance(); - const parentRecordName: string = getNormalizedOhmUrlByFilepath(parentFilePath, projectConfig, logger, pkgParams, null); const baseClassName: string = this.checker.getTypeAtLocation(node).getSymbol().getName(); const baseFilePath: string = node.getSourceFile().fileName; const baseRecordName: string = getNormalizedOhmUrlByFilepath(baseFilePath, projectConfig, logger, pkgParams, null); - const isGlobalPath: boolean = globalModulePaths?.some(globalPath => { - const normalizedParent: string = path.normalize(parentFilePath).replace(/\\/g, '/'); - const normalizedGlobalPath: string = path.normalize(globalPath).replace(/\\/g, '/'); - return normalizedParent.startsWith(normalizedGlobalPath); - }); - const recordPath: string = isGlobalPath ? `sdk` : `@normalized:${parentRecordName}`; - if (isGlobalPath) { - if (parentClassName !== 'InsightIntentEntryExecutor') { - throw Error(`${INVALID_BASE_CLASS_ERROR.toString()}, - The user's custom intents must be ultimately inherited to InsightIntentEntryExecutor, invalidDecoratorPath: ${this.currentFilePath}`); + const isGlobalPathFlag: boolean = this.isGlobalPath(parentFilePath); + const parentRecordName: string = + getNormalizedOhmUrlByFilepath(parentFilePath, projectConfig, logger, pkgParams, null); + if (isGlobalPathFlag) { + if (parentClassName !== 'IntentEntity') { + const errorMessage: string = + `decorated with @InsightIntentEntity must be ultimately inherited to insightIntent.IntentEntity`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101009', + description: 'ArkTs InsightIntent Error' + }); + return; } + this.EntityHeritageClassSet.add(parentClassName + '_' + `sdk`); + } else { + this.EntityHeritageClassSet.add(parentClassName + '_' + `@normalized:${parentRecordName}`); + this.EntityExtendsMap.set(baseClassName, parentClassName); } this.heritageClassSet.add(baseClassName + '_' + `@normalized:${baseRecordName}`); - this.collectClassInheritanceInfo(parentNode, intentObj, parentClassName, recordPath); } - collectClassInheritanceInfo( + private collectClassInheritanceInfo( parentNode: ts.ExpressionWithTypeArguments, intentObj: object, parentClassName: string, recordPath: string ): void { const ClassInheritanceInfo: object = { @@ -405,7 +729,7 @@ class ParseIntent { }; if (parentNode.typeArguments?.length > 0) { parentNode.typeArguments.forEach((arg): void => { - this.getInheritanceInfoByTypeNode(arg, ClassInheritanceInfo); + this.getInheritanceInfoByTypeNode(arg, ClassInheritanceInfo, intentObj); }); } Object.assign(intentObj, { @@ -413,12 +737,12 @@ class ParseIntent { }); } - getInheritanceInfoByTypeNode(arg: ts.TypeNode, ClassInheritanceInfo: object): void { + private getInheritanceInfoByTypeNode(arg: ts.TypeNode, ClassInheritanceInfo: object, intentObj: object): void { const generic = {}; const genericType: ts.Type = this.checker.getTypeAtLocation(arg); let genericName: string; let genericSource: string | undefined; - let recordGenericSource : string; + let recordGenericSource: string; const genericSymbol: ts.Symbol | undefined = genericType.getSymbol(); if (genericSymbol) { genericName = genericSymbol.getName(); @@ -441,51 +765,111 @@ class ParseIntent { 'typeName': genericName, 'definitionFilePath': recordGenericSource }); + if (this.entityOwnerMap.has(intentObj.intentName)) { + const entityNames: string[] = this.entityOwnerMap.get(intentObj.intentName); + entityNames.push(genericName); + this.entityOwnerMap.set(intentObj.intentName, entityNames); + } else { + this.entityOwnerMap.set(intentObj.intentName, [genericName]); + } ClassInheritanceInfo.generics.push(generic); } - isPrimitiveType(type: ts.Type): boolean { + private isPrimitiveType(type: ts.Type): boolean { return ( (type.flags & ts.TypeFlags.StringLike) || - (type.flags & ts.TypeFlags.NumberLike) || - (type.flags & ts.TypeFlags.BooleanLike) + (type.flags & ts.TypeFlags.NumberLike) || + (type.flags & ts.TypeFlags.BooleanLike) ) !== 0; } - parseClassNode(node: ts.ClassDeclaration): Record { + private parseClassNode(node: ts.ClassDeclaration, intentName: string): Record { const mergedObject: Record = {}; - node.members - .filter((member): member is ts.PropertyDeclaration => { - return ts.isPropertyDeclaration(member) && - member.parent === node; - }) - .forEach(propertyNode => { - const propSymbol = this.checker.getSymbolAtLocation(propertyNode.name); - if (!propSymbol) { - return; - } - const objItem: Record = this.processProperty(propSymbol); - Object.assign(mergedObject, objItem); - }); + const type: ts.Type = this.checker.getTypeAtLocation(node); + const propertiesOfType: ts.Symbol[] = this.checker.getPropertiesOfType(type); + propertiesOfType.forEach((prop) => { + const objItem: Record = this.processProperty(prop, intentName); + Object.assign(mergedObject, objItem); + }); return mergedObject; } - processProperty(prop: ts.Symbol): Record { + private getEntityId(node: ts.ClassDeclaration): string { + let entityId: string; + const type: ts.Type = this.checker.getTypeAtLocation(node); + const propertiesOfType: ts.Symbol[] = this.checker.getPropertiesOfType(type); + propertiesOfType.forEach((prop) => { + if (prop.getName() === 'entityId') { + const declaration: ts.Declaration = prop.getDeclarations()?.[0]; + if (declaration) { + const initializer = ts.isIdentifier(declaration.initializer) ? + this.checker.getSymbolAtLocation(declaration.initializer)?.valueDeclaration?.initializer : + declaration.initializer; + entityId = initializer.text; + } + } + }); + return entityId; + } + + private processProperty(prop: ts.Symbol, intentName: string): Record { const propType: ts.Type = this.checker.getTypeOfSymbol(prop); - const {category} = this.getTypeCategory(propType); + const { category } = this.getTypeCategory(propType); const obj: Record = {}; const propName: string = prop.getName(); if (category === 'object') { - obj[propName] = 'object'; + if (this.isEntity(propType, intentName)) { + obj[propName] = 'object'; + } } else if (category === 'array') { - obj[propName] = 'array'; + if (this.isEntity(propType, intentName)) { + obj[propName] = 'array'; + } } else { obj[propName] = this.checker.typeToString(propType); } return obj; } - getTypeCategory(type: ts.Type): { category: 'array' | 'object'; } { + private isEntity(propType: ts.Type, intentName: string): boolean { + let propDeclaration: ts.Declaration; + let elementType: ts.Type | undefined; + const typeSymbol: ts.Symbol = propType.getSymbol(); + const propertyClassName: string = typeSymbol.getName(); + if (this.isArrayType(propType)) { + elementType = (propType as ts.TypeReference).typeArguments?.[0]; + propDeclaration = elementType.getSymbol().getDeclarations()[0]; + } else { + propDeclaration = typeSymbol.getDeclarations()?.[0]; + } + if (!propDeclaration) { + return false; + } + return propDeclaration.modifiers?.some(decorator => { + if (!ts.isDecorator(decorator)) { + return false; + } + let decoratorName: string | undefined; + if (ts.isCallExpression(decorator.expression)) { + decoratorName = `@${decorator.expression.expression.getText()}`; + } + if (decoratorName === '@InsightIntentEntity') { + const typeSymbol: ts.Symbol = propType.getSymbol(); + const propertyClassName: string = typeSymbol.getName(); + if (this.entityOwnerMap.has(intentName)) { + const entityNames: string[] = this.entityOwnerMap.get(intentName); + entityNames.push(propertyClassName); + this.entityOwnerMap.set(intentName, entityNames); + } else { + this.entityOwnerMap.set(intentName, [propertyClassName]); + } + return true; + } + return false; + }); + } + + private getTypeCategory(type: ts.Type): { category: 'array' | 'object'; } { const flags: ts.TypeFlags = type.getFlags(); const isPrimitive: boolean = !!(flags & ts.TypeFlags.StringLike) || @@ -494,15 +878,7 @@ class ParseIntent { !!(flags & ts.TypeFlags.Null) || !!(flags & ts.TypeFlags.Undefined); - let isArray: boolean; - const symbol: ts.Symbol | undefined = type.getSymbol(); - if (symbol) { - isArray = symbol.getName() === 'Array'; - } else { - isArray = !!(flags & ts.TypeFlags.Object) && - !!(type as ts.ObjectType).objectFlags && ts.ObjectFlags.Reference && - ((type as ts.TypeReference).target.getSymbol()?.getName() === 'Array'); - } + const isArray: boolean = this.isArrayType(type); const isObject: boolean = !isPrimitive && !isArray && !!(flags & ts.TypeFlags.Object); @@ -512,17 +888,31 @@ class ParseIntent { } else if (isObject) { category = 'object'; } - return {category}; + return { category }; + } + + private isArrayType(type: ts.Type): boolean { + let isArray: boolean; + const symbol: ts.Symbol | undefined = type.getSymbol(); + const flags: ts.TypeFlags = type.getFlags(); + if (symbol) { + isArray = symbol.getName() === 'Array'; + } else { + isArray = !!(flags & ts.TypeFlags.Object) && + !!(type as ts.ObjectType).objectFlags && ts.ObjectFlags.Reference && + ((type as ts.TypeReference).target.getSymbol()?.getName() === 'Array'); + } + return isArray; } - removeDecorator(node: ts.ClassDeclaration, decoratorNames: string[]): ts.ClassDeclaration { + private removeDecorator(node: ts.ClassDeclaration, decoratorNames: string[]): ts.ClassDeclaration { const filteredModifiers: ts.ModifierLike[] = node.modifiers.filter(decorator => { if (!ts.isDecorator(decorator)) { return true; } let decoratorName: string | undefined; if (ts.isCallExpression(decorator.expression)) { - decoratorName = '@' + decorator.expression.expression.getText(); + decoratorName = `@${decorator.expression.expression.getText()}`; } return !decoratorNames.includes(decoratorName); }); @@ -539,7 +929,7 @@ class ParseIntent { ); } - reduceMembers(member : ts.ClassElement): ts.ClassElement { + private reduceMembers(member: ts.ClassElement): ts.ClassElement { if (ts.isMethodDeclaration(member) && this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { const memberModifiers: ts.ModifierLike[] = (member.modifiers ?? []).filter(decorator => { if (!ts.isDecorator(decorator)) { @@ -547,7 +937,7 @@ class ParseIntent { } let decoratorName: string | undefined; if (ts.isCallExpression(decorator.expression)) { - decoratorName = '@' + decorator.expression.expression.getText(); + decoratorName = `@${decorator.expression.expression.getText()}`; } return decoratorName !== COMPONENT_USER_INTENTS_DECORATOR_METHOD; }); @@ -568,7 +958,7 @@ class ParseIntent { return member; } - isSymbolConstant(symbol: ts.Symbol): boolean { + private isSymbolConstant(symbol: ts.Symbol): boolean { const declaration: Declaration = symbol.valueDeclaration; if (!this.isConstVariable(declaration)) { @@ -579,7 +969,7 @@ class ParseIntent { return initializer ? this.isConstantExpression(initializer) : false; } - isConstVariable(node: ts.Node | undefined): node is ts.VariableDeclaration { + private isConstVariable(node: ts.Node | undefined): node is ts.VariableDeclaration { if (!node || !ts.isVariableDeclaration(node)) { return false; } @@ -589,9 +979,10 @@ class ParseIntent { (varList.flags & ts.NodeFlags.Const) !== 0; } - isConstantExpression(node: ts.Node): boolean { + private isConstantExpression(node: ts.Node): boolean { let flag: boolean = true; - if (ts.isLiteralExpression(node) || node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword) { + if (ts.isLiteralExpression(node) || node.kind === ts.SyntaxKind.TrueKeyword || + node.kind === ts.SyntaxKind.FalseKeyword) { flag = true; } @@ -621,12 +1012,20 @@ class ParseIntent { }); } if (!flag) { - throw Error(`${DYNAMIC_PARAM_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Dynamic variable cannot be resolved`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101011', + description: 'ArkTs InsightIntent Error' + }); + return false; } return flag; } - validateRequiredIntentLinkInfo( + private validateRequiredIntentLinkInfo( node: ts.ObjectLiteralExpression, paramCheckFields: ParamChecker ): void { @@ -644,11 +1043,20 @@ class ParseIntent { } const missingFields: (keyof T)[] = requiredFields.filter(f => !existingParams.has(f)); if (missingFields.length > 0) { - throw Error(`${REQUIRED_PARAM_DISMISS_ERROR.toString()}, cause params: ${missingFields.join(', ')}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Decorator args missing required param, cause params: ${missingFields.join(', ')}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101012', + description: 'ArkTs InsightIntent Error' + }); + return; } } - validateSelfParamFields(prop: ts.Node, nestedCheckers: Map>): void { + private validateSelfParamFields(prop: ts.Node, + nestedCheckers: Map>): void { const checker: ParamChecker = nestedCheckers.get(prop.name.text); if (ts.isArrayLiteralExpression(prop.initializer)) { prop.initializer.elements.every(elem => { @@ -669,30 +1077,56 @@ class ParseIntent { } } - validateFields( + private validateFields( prop: ts.Node, allowedFields: Set, paramValidators: Record boolean> ): void { const paramName: keyof T = prop.name.text; if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) { if (!allowedFields.has(paramName)) { - throw Error(`${DISALLOWED_PARAM_ERROR}, cause undeclared param: '${paramName.toString()}', invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = + `Decorator args missing required param, cause undeclared param: ${paramName.toString()}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101012', + description: 'ArkTs InsightIntent Error' + }); + return; } const validator: Function = paramValidators[paramName]; if (ts.isIdentifier(prop.initializer)) { const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(prop.initializer); const declaration: ts.Declaration = symbol?.valueDeclaration; if (validator && !validator(declaration?.initializer)) { - throw Error(`${INCORRECT_PARAM_TYPE_ERROR.toString()}, cause param: '${paramName.toString()}', invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Param parsing occurs error param type, cause param: ${paramName.toString()}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101013', + description: 'ArkTs InsightIntent Error' + }); + return; } } else { if (validator && !validator(prop.initializer)) { - throw Error(`${INCORRECT_PARAM_TYPE_ERROR.toString()}, cause param: '${paramName.toString()}', invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Param parsing occurs error param type, cause param: ${paramName.toString()}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101013', + description: 'ArkTs InsightIntent Error' + }); + return; } } } } - analyzeDecoratorArgs(args: ts.NodeArray, intentObj: object, paramChecker: ParamChecker): void { + private analyzeDecoratorArgs(args: ts.NodeArray, intentObj: object, + paramChecker: ParamChecker): void { args.forEach(arg => { if (ts.isIdentifier(arg)) { const symbol: ts.Symbol | undefined = this.checker.getSymbolAtLocation(arg); @@ -707,43 +1141,38 @@ class ParseIntent { }); } - createObfuscation(classNode: ts.Node): void { - ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.globalNames.add(classNode.symbol.name); + private createObfuscation(classNode: ts.Node): void { + ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.globalNames.add(classNode.name.text); const isExported: boolean = classNode.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword); if (isExported) { - ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.propertyNames.add(classNode.symbol.name); + ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.propertyNames.add(classNode.name.text); } classNode.members.forEach(member => { - if (ts.isPropertyDeclaration(member) && member.name || ts.isFunctionDeclaration(member) || ts.isMethodDeclaration(member) || - ts.isGetAccessor(member) || ts.isSetAccessor(member)) { + if (ts.isPropertyDeclaration(member) && member.name || ts.isFunctionDeclaration(member) || + ts.isMethodDeclaration(member) || + ts.isGetAccessor(member) || ts.isSetAccessor(member)) { const propName: string = member.name.getText(); ProjectCollections.projectWhiteListManager?.fileWhiteListInfo.fileKeepInfo.arkUIKeepInfo.propertyNames.add(propName); } }); } - parseStaticObject(node: ts.Node, visited: Set = new Set()): StaticValue | undefined { + private parseStaticObject(node: ts.Node, visited: Set = new Set()): StaticValue | undefined { if (visited.has(node)) { - throw Error(`${PARAM_CIRCULAR_REFERENCE_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Circular reference detected in param`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101023', + description: 'ArkTs InsightIntent Error' + }); + return undefined; } visited.add(node); - if (ts.isStringLiteral(node)) { - return node.text; - } - if (ts.isNumericLiteral(node)) { - return parseFloat(node.text); - } - if (node.kind === ts.SyntaxKind.TrueKeyword) { - return true; - } - if (node.kind === ts.SyntaxKind.FalseKeyword) { - return false; - } - if (node.kind === ts.SyntaxKind.NullKeyword) { - return null; - } - if (node.kind === ts.SyntaxKind.UndefinedKeyword) { - return undefined; + const literalValue: StaticValue | undefined = this.parseLiteralValue(node); + if (literalValue !== undefined) { + return literalValue; } if (ts.isIdentifier(node)) { const isStatic: boolean = this.isConstantExpression(node); @@ -769,10 +1198,40 @@ class ParseIntent { if (ts.isPropertyAccessExpression(node)) { return this.processEnumElement(node); } - throw Error(`${UNSUPPORTED_PARSE_ERROR.toString()}, cause param: '${node.text}', invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Unsupported parameter type cannot be parsed, cause param: ${node.text}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101014', + description: 'ArkTs InsightIntent Error' + }); + return undefined; + } + + private parseLiteralValue(node: ts.Node): StaticValue | undefined { + if (ts.isStringLiteral(node)) { + return node.text; + } + if (ts.isNumericLiteral(node)) { + return parseFloat(node.text); + } + if (node.kind === ts.SyntaxKind.TrueKeyword) { + return true; + } + if (node.kind === ts.SyntaxKind.FalseKeyword) { + return false; + } + if (node.kind === ts.SyntaxKind.NullKeyword) { + return null; + } + if (node.kind === ts.SyntaxKind.UndefinedKeyword) { + return undefined; + } + return undefined; } - processEnumElement(node: ts.PropertyAccessExpression): string { + private processEnumElement(node: ts.PropertyAccessExpression): string { const enumValue: string = node?.getText().split('.').pop(); const executeModeEnum: Map = new Map(); executeModeEnum.set('UI_ABILITY_FOREGROUND', '0'); @@ -787,11 +1246,19 @@ class ParseIntent { } else if (paramCategoryEnum.has(enumValue)) { return paramCategoryEnum.get(enumValue); } else { - throw Error(`${UNSUPPORTED_PARSE_ERROR.toString()}, cause param: '${node.text}', invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Unsupported parameter type cannot be parsed, cause param: ${node.text}`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101014', + description: 'ArkTs InsightIntent Error' + }); + return ''; } } - processObjectElements(elements: ts.ObjectLiteralExpression): { [key: string]: StaticValue } { + private processObjectElements(elements: ts.ObjectLiteralExpression): { [key: string]: StaticValue } { const obj: { [key: string]: StaticValue } = {}; for (const prop of elements.properties) { if (ts.isPropertyAssignment(prop)) { @@ -812,7 +1279,7 @@ class ParseIntent { return obj; } - processArrayElements(elements: readonly ts.Node[]): StaticValue[] { + private processArrayElements(elements: readonly ts.Node[]): StaticValue[] { const parsedElements: StaticValue[] = []; elements.forEach((element) => { @@ -830,7 +1297,7 @@ class ParseIntent { return parsedElements; } - parsePropertyKey(node: ts.PropertyName): string | undefined { + private parsePropertyKey(node: ts.PropertyName): string | undefined { if (ts.isLiteralExpression(node)) { return node.text; } @@ -841,7 +1308,7 @@ class ParseIntent { return undefined; } - processExecuteModeParam(intentObj: object): void { + private processExecuteModeParam(intentObj: object): void { if (intentObj.executeMode) { intentObj.executeMode.forEach((item: string, index: number) => { if (item === '0') { @@ -860,7 +1327,7 @@ class ParseIntent { } } - collectSchemaInfo(intentObj: object): void { + private collectSchemaInfo(intentObj: object): void { if (intentObj.schema) { const schemaPath: string = path.join( __dirname, 'schema', @@ -879,21 +1346,24 @@ class ParseIntent { } } - verifyInheritanceChain(): void { - this.intentData.forEach((element): void => { - if (element.ClassInheritanceInfo) { - const parentClassName: string = element.ClassInheritanceInfo.parentClassName; - const definitionFilePath: string = element.ClassInheritanceInfo.definitionFilePath; - const verifiedString: string = parentClassName + '_' + definitionFilePath; - if (!this.heritageClassSet.has(verifiedString)) { - throw Error(`${INVALID_BASE_CLASS_ERROR.toString()} - , Subclass must inherit from a class decorated with @InsightIntentEntry, invalidDecoratorPath: ${this.currentFilePath}\``); - } + private verifyInheritanceChain(): void { + this.EntityHeritageClassSet.forEach(entityClassInfo => { + if (!this.heritageClassSet.has(entityClassInfo)) { + const errorMessage: string = + `decorated with @InsightIntentEntity must be ultimately inherited to insightIntent.IntentEntity`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101009', + description: 'ArkTs InsightIntent Error' + }); + return; } }); } - schemaValidationRequiredRule(schemaData: Record, schemaObj: object): void { + private schemaValidationRequiredRule(schemaData: Record, schemaObj: object): void { const reqData: Map = new Map(); schemaObj.required.forEach(key => reqData.set(key, true)); if (schemaObj.properties) { @@ -901,17 +1371,33 @@ class ParseIntent { const keyArr: string[] = Object.keys(paramsSchema); keyArr.forEach(key => { if (!schemaData[key] && reqData.get(key)) { - throw Error(`${SCHEMA_VALIDATE_REQUIRED_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Schema verification required parameter does not exist`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101016', + description: 'ArkTs InsightIntent Error' + }); + return; } }); } } - schemaPropertiesValidation(schemaData: Record, schemaObj: object): void { + private schemaPropertiesValidation(schemaData: Record, schemaObj: object): void { if (schemaObj.properties) { Object.entries(schemaObj.properties).forEach(([key, value]) => { if (schemaData[key] && value.type !== schemaData[key]) { - throw Error(`${SCHEMA_VALIDATE_TYPE_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Schema verification parameter type error`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101017', + description: 'ArkTs InsightIntent Error' + }); + return; } }); } @@ -931,7 +1417,15 @@ class ParseIntent { } }); if (count !== 1) { - throw Error(`${SCHEMA_VALIDATE_ONE_OF_ERROR.toString()} , invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Not meeting the one of schema verification rules`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101024', + description: 'ArkTs InsightIntent Error' + }); + return; } } if (schemaObj.anyOf) { @@ -946,12 +1440,20 @@ class ParseIntent { } }); if (count === 0) { - throw Error(`${SCHEMA_VALIDATE_ANY_OF_ERROR.toString()} , invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Not meeting the any of schema verification rules`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101018', + description: 'ArkTs InsightIntent Error' + }); + return; } } } - schemaValidateSync(schemaData: Record, schemaObj: object): void { + private schemaValidateSync(schemaData: Record, schemaObj: object): void { if (!schemaObj) { return; } @@ -962,7 +1464,15 @@ class ParseIntent { this.schemaValidateSync(schemaData, schemaObj.items.items); } if (schemaObj.type !== 'object') { - throw Error(`${SCHEMA_ROOT_TYPE_MISMATCH_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Schema root type must be object`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101019', + description: 'ArkTs InsightIntent Error' + }); + return; } if (schemaObj.properties) { const items: string[] = Object.keys(schemaObj.properties); @@ -978,22 +1488,78 @@ class ParseIntent { this.schemaValidateRules(schemaData, schemaObj); } - schemaAdditionalPropertiesValidation(schemaData, schemaProps): void { + private schemaAdditionalPropertiesValidation(schemaData, schemaProps): void { for (const key of Object.keys(schemaData)) { if (!schemaProps[key]) { - throw Error(`${SCHEMA_VALIDATE_TYPE_ERROR.toString()}, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Schema does not allow more parameters`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101025', + description: 'ArkTs InsightIntent Error' + }); + return; + } + } + } + + private processEntityOwnerMap(): void { + for (const [intentName, entityClassNames] of this.entityOwnerMap.entries()) { + const expandedClassNames = new Set(entityClassNames); + entityClassNames.forEach(className => { + this.visitEntityHeritage(className, expandedClassNames); + }); + if (expandedClassNames.size > entityClassNames.length) { + this.entityOwnerMap.set(intentName, Array.from(expandedClassNames)); + } + } + } + + private visitEntityHeritage(className: string, expandedClassNames: Set): void { + const parentClassName: string = this.EntityExtendsMap.get(className); + if (parentClassName && !expandedClassNames.has(parentClassName)) { + expandedClassNames.add(parentClassName); + this.visitEntityHeritage(parentClassName, expandedClassNames); + } + } + + private matchEntities(): void { + if (this.entityMap.size === 0) { + return; + } + this.processEntityOwnerMap(); + const intentNameMappingMap = new Map(); + this.intentData.forEach(data => { + intentNameMappingMap.set(data.intentName, data); + }); + for (const [intentName, entityIds] of this.entityOwnerMap.entries()) { + const targetIntent: object = intentNameMappingMap.get(intentName); + if (!targetIntent) { + continue; + } + const matchedEntities: object[] = []; + entityIds.forEach(id => { + if (this.entityMap.has(id)) { + matchedEntities.push(this.entityMap.get(id)); + } + }); + if (matchedEntities.length !== 0) { + targetIntent.entities = matchedEntities; } } } - writeUserIntentJsonFile(): void { + public writeUserIntentJsonFile(): void { + this.verifyInheritanceChain(); const writeJsonData: object = this.processIntentData(); - const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'insight_intent.json'); // The user's intents configuration file + const cacheSourceMapPath: string = + path.join(projectConfig.aceProfilePath, 'insight_intent.json'); // The user's intents configuration file const cachePath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); // Compiled cache file try { if (this.intentData.length > 0) { fs.writeFileSync(cacheSourceMapPath, JSON.stringify(writeJsonData, null, 2), 'utf-8'); - fs.writeFileSync(cachePath, JSON.stringify({'extractInsightIntents': this.intentData}, null, 2), 'utf-8'); + fs.writeFileSync(cachePath, JSON.stringify({ 'extractInsightIntents': this.intentData }, null, 2), 'utf-8'); } else if (fs.existsSync(cacheSourceMapPath)) { fs.unlinkSync(cacheSourceMapPath); } @@ -1009,20 +1575,38 @@ class ParseIntent { fs.writeFileSync(fullPath, updatedJson, 'utf8'); } } catch (e) { - throw Error(`${INTERNAL_ERROR}, writeFile failed: ${e}`); + const errorMessage: string = `Internal error writeFile error`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101020', + description: 'ArkTs InsightIntent Error' + }); + return; } } - processIntentData(): object { + private processIntentData(): object { + this.matchEntities(); if (!projectConfig.aceProfilePath) { - throw Error(`${INTERNAL_ERROR.toString()}, aceProfilePath not found, invalidDecoratorPath: ${this.currentFilePath}`); + const errorMessage: string = `Internal error aceProfilePath not found`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101020', + description: 'ArkTs InsightIntent Error' + }); + return null; } - const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'insight_intent.json'); // The user's intents configuration file + const cacheSourceMapPath: string = + path.join(projectConfig.aceProfilePath, 'insight_intent.json'); // The user's intents configuration file const cachePath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); // Compiled cache file if (!fs.existsSync(projectConfig.aceProfilePath)) { - fs.mkdirSync(projectConfig.aceProfilePath, {recursive: true}); + fs.mkdirSync(projectConfig.aceProfilePath, { recursive: true }); } - if (this.isUpdateCompile) { + if (this.isUpdateCompile && fs.existsSync(cachePath)) { const cacheData: string = fs.readFileSync(cachePath, 'utf8'); const cacheDataObj: object = JSON.parse(cacheData); const insightIntents: object[] = cacheDataObj.extractInsightIntents.filter(insightIntent => { @@ -1050,29 +1634,43 @@ class ParseIntent { return writeJsonData; } - validateIntentIntentName(writeJsonData: object): void { + private validateIntentIntentName(writeJsonData: object): void { const duplicates = new Set(); writeJsonData.insightIntents?.forEach(insightIntent => { duplicates.add(insightIntent.intentName); }); writeJsonData.extractInsightIntents.forEach(item => { if (duplicates.has(item.intentName)) { - throw Error(`${DECORATOR_DUPLICATE_INTENTNAME.toString()}, value : ${item.intentName}`); - } else { + const errorMessage: string = `User intents has duplicate intentName param`; + this.transformLog.push({ + type: LogType.ERROR, + message: errorMessage, + pos: this.currentNode.getStart(), + code: '10101021', + description: 'ArkTs InsightIntent Error' + }); + return; + } else if (item.intentName !== undefined) { duplicates.add(item.intentName); } }); } - clear(): void { + public clear(): void { this.intentData = []; this.checker = null; this.currentFilePath = ''; this.heritageClassSet = new Set(); + this.heritageClassSet.add('IntentEntity_sdk'); this.heritageClassSet.add('InsightIntentEntryExecutor_sdk'); this.isInitCache = false; - this.isUpdateCompile = false; + this.isUpdateCompile = true; this.updatePageIntentObj = new Map(); + this.entityMap = new Map(); + this.entityOwnerMap = new Map(); + this.moduleJsonInfo = new Map(); + this.EntityHeritageClassSet = new Set(); + this.EntityExtendsMap = new Map(); } } diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntity/@InsightIntentEntity.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntity/@InsightIntentEntity.js.sample new file mode 100644 index 000000000..1896d0476 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntity/@InsightIntentEntity.js.sample @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 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. + */ + +let __generate__Id = 0; +function generateId() { + return "@InsightIntentEntity_" + ++__generate__Id; +} +export class ArtistClassDef { + constructor() { + this.entityId = "id"; + this.name = ''; + } +} +//# sourceMappingURL=@InsightIntentEntity.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentForm/@InsightIntentForm.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentForm/@InsightIntentForm.js.sample new file mode 100644 index 000000000..53c9c02e0 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentForm/@InsightIntentForm.js.sample @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 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. + */ + +let __generate__Id = 0; +function generateId() { + return "@InsightIntentForm_" + ++__generate__Id; +} +export default class EntryFormAbilityaa extends FormExtensionAbility { + constructor() { + super(...arguments); + this.songName = ""; + } + onAddForm(want) { + // Called to return a FormBindingData object. + let formData = ''; + return formBindingData.createFormBindingData(formData); + } + onCastToNormalForm(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + onUpdateForm(formId) { + // Called to notify the form provider to update a specified form. + } + onFormEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + onRemoveForm(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +} +; +//# sourceMappingURL=@InsightIntentForm.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntity/@InsightIntentEntity.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntity/@InsightIntentEntity.ets new file mode 100644 index 000000000..b6184f987 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentEntity/@InsightIntentEntity.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 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. + */ + +@InsightIntentEntity({ + entityCategory: 'artist entity category', + parameters: { + "$id": "/schemas/ArtistClassDef", + "type": "object", + "description": "Information about the artist", + "properties": { + "country": { + "type": "string", + "description": "The artist's country of origin", + "default": "zh" + }, + "city": { + "type": "string", + "description": "The artist's city of origin" + }, + "name": { + "type": "string", + "description": "The name of the artist", + "minLength": 1 + } + }, + "required": ["name"] + } +}) +export class ArtistClassDef implements insightIntent.IntentEntity { + entityId: string = "id"; + name: string = '' +} \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentForm/@InsightIntentForm.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentForm/@InsightIntentForm.ets new file mode 100644 index 000000000..77e236242 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForInsightDecorator/@InsightIntentForm/@InsightIntentForm.ets @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2025 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. + */ + +@InsightIntentForm({ + intentName: 'PlayMusic78', + domain: 'MusicDomain', + intentVersion: '1.0.1', + displayName: '播放歌曲', + displayDescription: '播放音乐意图', + icon: "", + llmDescription: '支持传递歌曲名称,播放音乐', + keywords: ['音乐播放', '播放歌曲', 'PlayMusic'], + parameters: { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "Song Schema", + "description": "A schema for describing songs and their artists", + "properties": { + "songName": { + "type": "string", + "description": "The name of the song", + "minLength": 1 + }, + "artist": { + "type": "object", + "description": "Information about the artist", + "properties": { + "country": { + "type": "string", + "description": "The artist's country of origin", + "default": "zh" + }, + "city": { + "type": "object", + "description": "The artist's city of origin" + }, + "name": { + "type": "string", + "description": "The name of the artist", + "minLength": 1 + } + }, + "required": ["name"] + } + }, + "required": ["songName"] + }, + formName: 'widget' +}) +export default class EntryFormAbilityaa extends FormExtensionAbility { + songName: string = "" + + onAddForm(want: Want) { + // Called to return a FormBindingData object. + let formData = ''; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormalForm(formId: string) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdateForm(formId: string) { + // Called to notify the form provider to update a specified form. + } + + onFormEvent(formId: string, message: string) { + // Called when a specified message event defined by the form provider is triggered. + } + + onRemoveForm(formId: string) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want: Want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; diff --git a/compiler/test/transform_ut/helpers/insightUTPath.ts b/compiler/test/transform_ut/helpers/insightUTPath.ts index 2b5cba81d..3e5826abc 100644 --- a/compiler/test/transform_ut/helpers/insightUTPath.ts +++ b/compiler/test/transform_ut/helpers/insightUTPath.ts @@ -17,7 +17,9 @@ export const UT_PAGES: string[] = [ '@InsightIntentLink/@InsightIntentLink', '@InsightIntentEntry/@InsightIntentEntry', '@InsightIntentFunction/@InsightIntentFunction', - '@InsightIntentPage/@InsightIntentPage' + '@InsightIntentPage/@InsightIntentPage', + '@InsightIntentForm/@InsightIntentForm', + '@InsightIntentEntity/@InsightIntentEntity' ] export const CACHE_PATH: string = 'default/cache/default/default@CompileArkTS/esmodule/debug'; \ No newline at end of file -- Gitee From 66f80650c584346519da8f97492d9a1a37cffa7a Mon Sep 17 00:00:00 2001 From: wuhailong Date: Tue, 13 May 2025 20:48:55 +0800 Subject: [PATCH 116/140] Fix TSC_SYSTEM_CODE not imported Issue: #IC7K6B Signed-off-by: wuhailong Change-Id: I07092b70d16f2d3543e7021b5ba88e02fa6f9009 --- compiler/main.js | 2 +- compiler/script/install_declgen.sh | 58 ++++++++++++++ compiler/src/ets_checker.ts | 5 +- .../ark_compiler/common/ark_define.ts | 4 +- .../ark_compiler/generate_sourcemap.ts | 14 ++++ .../ark_compiler/module/module_mode.ts | 5 +- .../ark_compiler/run_es2abc_standalone.ts | 39 +++++---- .../ets_ui/rollup-plugin-ets-checker.ts | 2 +- compiler/src/pre_define.ts | 3 +- compiler/src/process_arkts_evolution.ts | 3 +- .../test/ark_compiler_ut/ets_checker.test.ts | 79 ------------------- 11 files changed, 108 insertions(+), 106 deletions(-) create mode 100644 compiler/script/install_declgen.sh diff --git a/compiler/main.js b/compiler/main.js index 0a19d638c..1b6cb7ef3 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -283,7 +283,7 @@ function getPackageJsonEntryPath() { const rootPackageJsonPath = candidatePaths.find(fs.existsSync) ?? (() => { - throw new Error('package.json not found in ../../../ or ../../'); + throw new Error('package.json not found'); })(); if (fs.existsSync(rootPackageJsonPath)) { let rootPackageJsonContent; diff --git a/compiler/script/install_declgen.sh b/compiler/script/install_declgen.sh new file mode 100644 index 000000000..ca35365e4 --- /dev/null +++ b/compiler/script/install_declgen.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Copyright (c) 2025 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. + +#!/bin/bash +set -e + +if [ ! -d "../compiler" ]; then + echo "Error: must run this script in ace_ets2bundle/compiler root directory" + exit 1 +fi + +oriDir=$(pwd) + +DECLGEN_ROOT_DIR="../../../arkcompiler/runtime_core/static_core/plugins/ets/tools/declgen_ts2sts" + +cd "$DECLGEN_ROOT_DIR" || { echo "Failed to change directory to $DECLGEN_ROOT_DIR"; exit 1; } + +npm install +npm run build + +# Generate the npm package using `npm pack` +if npm pack; then + tarball=$(ls *.tgz) # Get the generated tarball file name + if [ -f "$tarball" ]; then + # Move the tarball to the original directory + mv "$tarball" "$oriDir/" + + # Go back to the original directory and extract the tarball + cd "$oriDir" + tar -xvzf "$tarball" + + # Rename the extracted directory (assuming it is named after the package) + extracted_dir=$(tar -tf "$tarball" | head -n 1 | cut -f1 -d"/") # Get the extracted folder name + mv "$extracted_dir" "./node_modules/declgen" # Rename to 'declgen' + + # Optionally, remove the tarball after extraction + rm "$tarball" + + echo "Build successfully packed, extracted, and renamed to 'declgen' in $oriDir" + else + echo "Error: No tarball found, cannot proceed" + exit 1 + fi +else + echo "Error: npm pack failed" + exit 1 +fi diff --git a/compiler/src/ets_checker.ts b/compiler/src/ets_checker.ts index 63ee2bb16..a5f4a63e7 100644 --- a/compiler/src/ets_checker.ts +++ b/compiler/src/ets_checker.ts @@ -1140,7 +1140,7 @@ export function resolveModuleNames(moduleNames: string[], containingFile: string // When result has a value and the path parsed is the source code file path of module 1.2, // the parsing result needs to be modified to the glue code path of module 1.2 let arktsEvoDeclFilePathExist: boolean = false; - const resolvedFileName: string = toUnixPath(result.resolvedModule.resolvedFileName); + const resolvedFileName: string = toUnixPath(result.resolvedModule.resolvedFileName); const resultDETSPath: string = getArkTSEvoDeclFilePath({ moduleRequest: '', resolvedFileName }); if (ts.sys.fileExists(resultDETSPath)) { resolvedModules.push(getResolveModule(resultDETSPath, EXTNAME_D_ETS)); @@ -1900,7 +1900,7 @@ export function resetEtsCheck(): void { maxMemoryInServiceChecker = 0; } -export function generateDeclarationFileForSTS(rootFileNames: string[]) { +export function generateDeclarationFileForSTS(rootFileNames: string[]): void { if (!(projectConfig.compileHar || projectConfig.compileShared)) { return; } @@ -1932,5 +1932,4 @@ export function generateDeclarationFileForSTS(rootFileNames: string[]) { } fs.mkdirSync(config.outDir, { recursive: true }); generateInteropDecls(config); - processInteropUI(projectConfig.dependentModuleMap?.get(projectConfig.entryPackageName)?.declgenV2OutPath); } \ No newline at end of file diff --git a/compiler/src/fast_build/ark_compiler/common/ark_define.ts b/compiler/src/fast_build/ark_compiler/common/ark_define.ts index 9bbbb62fc..9a1e6f62d 100644 --- a/compiler/src/fast_build/ark_compiler/common/ark_define.ts +++ b/compiler/src/fast_build/ark_compiler/common/ark_define.ts @@ -123,8 +123,8 @@ export const SEPARATOR_BITWISE_AND: string = '&'; export const SEPARATOR_AT: string = '@'; export const SEPARATOR_SLASH: string = '/'; -export const GEN_ABC_CMD: string = "genAbcCmd"; -export const GEN_ABC_CMD_FILE_PATH: string = "genAbcCmd.json"; +export const GEN_ABC_CMD: string = 'genAbcCmd'; +export const GEN_ABC_CMD_FILE_PATH: string = 'genAbcCmd.json'; export const ES_ANNOTATIONS = [ '_ESConcurrentModuleRequestsAnnotation', diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index 28862e9c0..d54489ae1 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -72,6 +72,7 @@ export class SourceMapGenerator { private sourceMapPath: string; private sourceMapPathTmp: string; private cacheSourceMapPath: string; + private sourceMapForMergePath: string; private triggerAsync: Object; private triggerEndSignal: Object; private sourceMaps: Object = {}; @@ -91,6 +92,7 @@ export class SourceMapGenerator { this.sourceMapPath = this.getSourceMapSavePath(); this.sourceMapPathTmp = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON + '.tmp'); this.cacheSourceMapPath = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON); + this.sourceMapForMergePath = this.cacheSourceMapPath + '.merge'; this.triggerAsync = rollupObject.async; this.triggerEndSignal = rollupObject.signal; this.logger = CommonLogger.getInstance(rollupObject); @@ -340,6 +342,12 @@ export class SourceMapGenerator { this.writeTemp(''); } this.closeFd(); + if (fs.existsSync(this.sourceMapForMergePath)) { + fs.unlinkSync(this.sourceMapForMergePath); + } + if (fs.existsSync(this.sourceMapPath)) { + fs.copyFileSync(this.sourceMapPath, this.sourceMapForMergePath); + } if (fs.existsSync(this.cacheSourceMapPath)) { fs.unlinkSync(this.cacheSourceMapPath); } @@ -438,6 +446,12 @@ export class SourceMapGenerator { this.logger.printErrorAndExit(errInfo); } fs.copyFileSync(this.sourceMapPath, this.cacheSourceMapPath); + if (fs.existsSync(this.sourceMapForMergePath)) { + fs.unlinkSync(this.sourceMapForMergePath); + } + if (fs.existsSync(this.sourceMapPath)) { + fs.copyFileSync(this.sourceMapPath, this.sourceMapForMergePath); + } stopEvent(eventWriteFile, true); this.triggerEndSignal(); }); diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index dad96646b..0048ff302 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -109,7 +109,8 @@ import { addDeclFilesConfig, ArkTSEvolutionModule, getDeclgenBridgeCodePath, - pkgDeclFilesConfig + pkgDeclFilesConfig, + arkTSModuleMap } from '../../../process_arkts_evolution'; import { MemoryMonitor } from '../../meomry_monitor/rollup-plugin-memory-monitor'; import { MemoryDefine } from '../../meomry_monitor/memory_define'; @@ -528,7 +529,7 @@ export class ModuleMode extends CommonMode { let moduleName: string = metaInfo.moduleName; let recordName: string = ''; - let cacheFilePath: string = metaInfo.language === ARKTS_1_2 ? originalFilePath : + let cacheFilePath: string = metaInfo.language === ARKTS_1_2 ? originalFilePath : this.genFileCachePath(filePath, this.projectConfig.projectRootPath, this.projectConfig.cachePath, metaInfo); let packageName: string = ''; diff --git a/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts b/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts index 8ec011349..b1e77c3fe 100644 --- a/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts +++ b/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts @@ -41,8 +41,8 @@ import { * @returns erro.toString() */ export function run(cachePathList: string[], targetCachePath: string, aceModuleBuild: string): void { - if (!cachePathList || cachePathList.length == 0) { - return + if (!cachePathList || cachePathList.length === 0) { + return; } mergeCacheData(cachePathList, targetCachePath, FILESINFO_TXT); mergeCacheData(cachePathList, targetCachePath, MODULES_CACHE); @@ -57,22 +57,29 @@ export function run(cachePathList: string[], targetCachePath: string, aceModuleB export function mergeCacheData(cachePathList: string[], targetCachePath: string, fileName: string): void { const dataSet: Set = new Set(); cachePathList.forEach(cachePath => { - const inputFilePath: string = path.join(cachePath, fileName); - if (fs.existsSync(inputFilePath)) { - const fileData: string = fs.readFileSync(inputFilePath).toString(); - fileData.split('\n').forEach(data => { - //eat blank line - if (data) { - dataSet.add(data); - } - }); - } + processCachePath(cachePath, fileName, dataSet); }); const outputFilePath: string = path.join(targetCachePath, fileName); fs.writeFileSync(outputFilePath, Array.from(dataSet).join('\n')); } +function processCachePath(cachePath: string, fileName: string, dataSet: Set): void { + const inputFilePath = path.join(cachePath, fileName); + if (!fs.existsSync(inputFilePath)) { + return; + } + + const fileData = fs.readFileSync(inputFilePath).toString(); + const lines = fileData.split('\n'); + + for (const data of lines) { + if (data) { + dataSet.add(data); + } + } +} + function execCmd(cmd: string[]): string { try { const result = childProcess.execSync(cmd.join(' '), { @@ -85,9 +92,9 @@ function execCmd(cmd: string[]): string { } } -export function updateCmd(cmd: string[], targetCachePath: string, aceModuleBuild: string) { +export function updateCmd(cmd: string[], targetCachePath: string, aceModuleBuild: string): void { for (let i = 0; i < cmd.length; i++) { - if (cmd[i].indexOf("filesInfo.txt") != -1) { + if (cmd[i].indexOf('filesInfo.txt') !== -1) { const filesInfoPath: string = path.join(targetCachePath, FILESINFO_TXT); cmd[i] = `"@${filesInfoPath}"`; continue; @@ -126,7 +133,7 @@ function deepMerge(target: Object, source: Object): Object { return target; } -export function mergeCompileContextInfo(cachePathList: string[], targetCachePath: string) { +export function mergeCompileContextInfo(cachePathList: string[], targetCachePath: string): void { const mergedData = { hspPkgNames: [], compileEntries: [], @@ -150,7 +157,7 @@ export function mergeCompileContextInfo(cachePathList: string[], targetCachePath fs.writeFileSync(targetPath, JSON.stringify(mergedData, null, 2)); } -export function mergeSourceMap(cachePathList: string[], targetCachePath: string) { +export function mergeSourceMap(cachePathList: string[], targetCachePath: string): void { const mergedMap: Record = {}; cachePathList.forEach((item) => { /** diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts index 68c96ec36..8ada482f3 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-checker.ts @@ -29,7 +29,7 @@ import { emitBuildInfo, runArkTSLinter, targetESVersionChanged, - collectFileToIgnoreDiagnostics + collectFileToIgnoreDiagnostics, TSC_SYSTEM_CODE, traverseProgramSourceFiles, arkTsEvolutionModuleMap, diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index d153bf444..9582f6068 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -668,4 +668,5 @@ export const COLD_RELOAD_MODE: string = 'coldReload'; export const INTEGRATED_HSP: string = 'integratedHsp'; export const ARKTS_1_2: string = '1.2'; -export const ARKTS_1_1: string = '1.1'; \ No newline at end of file +export const ARKTS_1_1: string = '1.1'; +export const ARKTS_1_0: string = '1.0'; \ No newline at end of file diff --git a/compiler/src/process_arkts_evolution.ts b/compiler/src/process_arkts_evolution.ts index a2f57711f..c28a477d9 100644 --- a/compiler/src/process_arkts_evolution.ts +++ b/compiler/src/process_arkts_evolution.ts @@ -20,6 +20,7 @@ import ts from 'typescript'; import { EXTNAME_ETS, EXTNAME_D_ETS, + ARKTS_1_0, ARKTS_1_1, ARKTS_1_2 } from './pre_define'; @@ -139,7 +140,7 @@ export function collectArkTSEvolutionModuleInfo(share: Object): void { share.throwArkTsCompilerError(red, 'ArkTS:INTERNAL ERROR: Failed to collect arkTs evolution module info.\n' + `Error Message: Failed to collect arkTs evolution module "${pkgName}" info from rollup.`, reset); } - } else if (dependentModuleInfo.language === ARKTS_1_1) { + } else if (dependentModuleInfo.language === ARKTS_1_1 || dependentModuleInfo.language === ARKTS_1_0) { if (dependentModuleInfo.declgenV2OutPath && dependentModuleInfo.declFilesPath) { arkTSModuleMap.set(pkgName, dependentModuleInfo); } else { diff --git a/compiler/test/ark_compiler_ut/ets_checker.test.ts b/compiler/test/ark_compiler_ut/ets_checker.test.ts index 68443f478..9c7f5ae71 100644 --- a/compiler/test/ark_compiler_ut/ets_checker.test.ts +++ b/compiler/test/ark_compiler_ut/ets_checker.test.ts @@ -233,85 +233,6 @@ mocha.describe('test ets_checker file api', function () { fs.unlinkSync(arktsEvoTestDeclFilePath); cleanUpProcessArkTSEvolutionObj(); }); - - mocha.it('2-2: test resolveModuleNames parse the 1.2 module declaration file that the 1.1 module depends on (packageName)', function () { - const moduleNames: string[] = ['testhar']; - arkTSEvolutionModuleMap.set('har', { - language: '1.2', - packageName: 'testhar', - moduleName: 'testhar', - modulePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar`, - declgenV1OutPath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/build/default/intermediates/declgen/default/declgenV1`, - declgenBridgeCodePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/build/default/intermediates/declgen/default/bridgecode` - }) - const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/${DEFAULT_ENTRY}/src/main/entryability/test.ets`; - const arktsEvoIndexFilePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/Index.ets`; - const arktsEvoIndexDeclFilePath: string = `${arkTSEvolutionModuleMap.get('har').declgenV1OutPath}/testhar/Index.d.ets`; - const resolveModuleNameStub = sinon.stub(ts, 'resolveModuleName').returns({ - resolvedModule: { - resolvedFileName: arktsEvoIndexFilePath, - extension: '.ets', - isExternalLibraryImport: false, - } - }); - const mockedTs = { - ...require('typescript'), - resolveModuleName: resolveModuleNameStub - }; - let resolveModuleNames; - ({ resolveModuleNames } = proxyquire('../../lib/ets_checker', { - 'typescript': mockedTs - })); - fs.writeFileSync(filePath, ''); - mkdirsSync(path.dirname(arktsEvoIndexFilePath)); - mkdirsSync(path.dirname(arktsEvoIndexDeclFilePath)); - fs.writeFileSync(arktsEvoIndexFilePath, ''); - fs.writeFileSync(arktsEvoIndexDeclFilePath, ''); - const resolvedModules = resolveModuleNames(moduleNames, filePath); - expect(resolvedModules[0].resolvedFileName === arktsEvoIndexDeclFilePath); - fs.unlinkSync(filePath); - fs.unlinkSync(arktsEvoIndexDeclFilePath); - resolveModuleNameStub.restore(); - }); - - mocha.it('2-3: test resolveModuleNames parse the 1.2 module declaration file that the 1.1 module depends on', function () { - const moduleNames: string[] = ['testhar/src/main/ets/test']; - arkTSEvolutionModuleMap.set('har', { - language: '1.2', - packageName: 'testhar', - moduleName: 'testhar', - modulePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar`, - declgenV1OutPath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/build/default/intermediates/declgen/default/declgenV1`, - declgenBridgeCodePath: `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/build/default/intermediates/declgen/default/bridgecode` - }) - const filePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/${DEFAULT_ENTRY}/src/main/entryability/test.ets`; - const arktsEvoTestFilePath: string = `${PROJECT_ROOT}/${DEFAULT_PROJECT}/testhar/src/main/ets/test.ets`; - const arktsEvoTestDeclFilePath: string = `${arkTSEvolutionModuleMap.get('har').declgenV1OutPath}/testhar/src/main/ets/test.d.ets`; - const resolveModuleNameStub = sinon.stub(ts, 'resolveModuleName').returns({ - resolvedModule: { - resolvedFileName: arktsEvoTestFilePath, - extension: '.ets', - isExternalLibraryImport: false, - } - }); - const mockedTs = { - ...require('typescript'), - resolveModuleName: resolveModuleNameStub - }; - let resolveModuleNames; - ({ resolveModuleNames } = proxyquire('../../lib/ets_checker', { 'typescript': mockedTs })); - - fs.writeFileSync(filePath, ''); - mkdirsSync(path.dirname(arktsEvoTestFilePath)); - mkdirsSync(path.dirname(arktsEvoTestDeclFilePath)); - fs.writeFileSync(arktsEvoTestFilePath, ''); - fs.writeFileSync(arktsEvoTestDeclFilePath, ''); - const resolvedModules = resolveModuleNames(moduleNames, filePath); - expect(resolvedModules[0].resolvedFileName === arktsEvoTestDeclFilePath); - fs.unlinkSync(filePath); - fs.unlinkSync(arktsEvoTestDeclFilePath); - resolveModuleNameStub.restore(); - }); }); mocha.describe('getMaxFlowDepth', () => { -- Gitee From dbcfa0d6f1d0f7ecdfec908711ed7babd16a7ba6 Mon Sep 17 00:00:00 2001 From: wuhailong Date: Sat, 7 Jun 2025 20:04:12 +0800 Subject: [PATCH 117/140] Fix symbols info loss in AST Issue: #ICDDSY Signed-off-by: wuhailong Change-Id: Idfa825b1530d2aae2f45e2c931167651f04209f8 --- .../src/fast_build/ark_compiler/logger.ts | 28 ++++--- .../ark_compiler/module/module_mode.ts | 2 +- .../ark_compiler/module/module_source_file.ts | 4 +- compiler/src/process_lazy_import.ts | 11 +-- .../common/process_lazy_import.test.ts | 77 ++++++++++++++++++- 5 files changed, 98 insertions(+), 24 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/logger.ts b/compiler/src/fast_build/ark_compiler/logger.ts index abdf135c1..1d5ce0f60 100644 --- a/compiler/src/fast_build/ark_compiler/logger.ts +++ b/compiler/src/fast_build/ark_compiler/logger.ts @@ -20,6 +20,15 @@ import { ES2ABC_ERROR_MAPPING } from './error_code'; +interface ErrorInfo { + code: ErrorCode; + description: string; + cause: string; + position: string; + solutions: string[]; + details: string; +} + export class CommonLogger { private static instance: CommonLogger; private logger: Object; @@ -142,29 +151,18 @@ export class LogDataFactory { if (!trimmedOutput) { return LogDataFactory.newInstance( ErrorCode.BYTECODE_OBFUSCATION_COMMON_ERROR, - 'Bytecode program terminated abnormally', - `Status code: ${statusCode}` - ); + 'Bytecode program terminated abnormally', `Status code: ${statusCode}`); } const parseErrorLines = (output: string): Record => - output - .split('\n') - .reduce((acc: Record, line) => { + output.split('\n').reduce((acc: Record, line) => { const [key, ...values] = line.split(':').map(part => part.trim()); return key && values.length ? { ...acc, [key]: values.join(':').trim() } : acc; }, {}); const parsedErrors = parseErrorLines(trimmedOutput); - const getErrorInfo = (): { - code: ErrorCode; - description: string; - cause: string; - position: string; - solutions: string[]; - details: string; - } => { + const getErrorInfo = (): ErrorInfo => { if (Object.keys(parsedErrors).length === 0) { return { code: ErrorCode.BYTECODE_OBFUSCATION_COMMON_ERROR, @@ -186,7 +184,7 @@ export class LogDataFactory { }; }; - const { code, description, cause, position, solutions, details } = getErrorInfo(); + const { code, description, cause, position, solutions, details }: ErrorInfo = getErrorInfo(); return LogDataFactory.newInstance( code, description, diff --git a/compiler/src/fast_build/ark_compiler/module/module_mode.ts b/compiler/src/fast_build/ark_compiler/module/module_mode.ts index a619cb2ef..d0c7dfe15 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_mode.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_mode.ts @@ -667,7 +667,7 @@ export class ModuleMode extends CommonMode { this.generateNpmEntriesInfo(); } this.generateAbcCacheFilesInfo(); - stopEvent(eventEenDescriptionsForMergedEs2abc) + stopEvent(eventEenDescriptionsForMergedEs2abc); } generateMergedAbcOfEs2Abc(parentEvent: CompileEvent): void { diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 2152ebdfe..3694f43a7 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -229,7 +229,7 @@ export class ModuleSourceFile { pkgName: rollupObject.share.projectConfig.entryPackageName, pkgPath: rollupObject.share.projectConfig.modulePath } - } + }; } static isMockFile(file: string, rollupObject: Object): boolean { @@ -328,7 +328,7 @@ export class ModuleSourceFile { return ModuleSourceFile.sourceFiles; } - static async processSingleModuleSourceFile(rollupObject: Object, moduleId: string, parentEvent: CompileEvent| undefined): Promise { + static async processSingleModuleSourceFile(rollupObject: Object, moduleId: string, parentEvent: CompileEvent | undefined): Promise { if (!ModuleSourceFile.isEnvInitialized) { this.initPluginEnv(rollupObject); ModuleSourceFile.setProcessMock(rollupObject); diff --git a/compiler/src/process_lazy_import.ts b/compiler/src/process_lazy_import.ts index 5e87a2e4f..a7004df8a 100644 --- a/compiler/src/process_lazy_import.ts +++ b/compiler/src/process_lazy_import.ts @@ -90,8 +90,8 @@ function updateImportDecl(node: ts.ImportDeclaration, resolver: Object): ts.Impo // eliminate the type symbol // eg: import { type t, x } from '...' --> import { x } from '...' const newNameBindings: ts.ImportSpecifier[] = eliminateTypeSymbol(namedBindings, resolver); - newImportClause = ts.factory.createImportClause(false, importClause.name, - ts.factory.createNamedImports(newNameBindings)); + newImportClause = ts.factory.updateImportClause(importClause, false, importClause.name, + ts.factory.updateNamedImports(namedBindings, newNameBindings)); } else { newImportClause = importClause; } @@ -113,10 +113,11 @@ function eliminateTypeSymbol(namedBindings: ts.NamedImportBindings, resolver: Ob // import { x } from './y' --> propertyName is undefined // import { x as a } from './y' --> propertyName is x newNameBindings.push( - ts.factory.createImportSpecifier( + ts.factory.updateImportSpecifier( + element, false, - element.propertyName ? ts.factory.createIdentifier(element.propertyName.text) : undefined, - ts.factory.createIdentifier(element.name.text) + element.propertyName, + element.name ) ); } diff --git a/compiler/test/ark_compiler_ut/common/process_lazy_import.test.ts b/compiler/test/ark_compiler_ut/common/process_lazy_import.test.ts index ca4b2e72a..2fc025d0b 100644 --- a/compiler/test/ark_compiler_ut/common/process_lazy_import.test.ts +++ b/compiler/test/ark_compiler_ut/common/process_lazy_import.test.ts @@ -25,7 +25,8 @@ import { processJsCodeLazyImport, reExportNoCheckMode, reExportCheckLog, - resetReExportCheckLog + resetReExportCheckLog, + transformLazyImport } from '../../../lib/process_lazy_import'; import { RELEASE } from '../../../lib/fast_build/ark_compiler/common/ark_define'; import { ModuleSourceFile } from '../../../lib/fast_build/ark_compiler/module/module_source_file'; @@ -389,4 +390,78 @@ mocha.describe('process Lazy Imports tests', function () { const result: string = processJsCodeLazyImport('index.js', code, true, 'strict'); expect(result === expectCode).to.be.true; }); + + mocha.it('3-1: test transformLazyImport: the symbol exist after conversion', function () { + const files: Record = { + 'main.ts': ` + import { foo } from './lib'; + console.log(foo); + `, + 'lib.ts': ` + export const foo = 42; + ` + }; + + const fileNames = Object.keys(files); + + const compilerHost = ts.createCompilerHost({}, true); + const getFileKey = (filePath: string) => path.basename(filePath); + + compilerHost.getSourceFile = (filePath, languageVersion) => { + const key = getFileKey(filePath); + const sourceText = files[key]; + return sourceText !== undefined + ? ts.createSourceFile(filePath, sourceText, languageVersion, true) + : undefined; + }; + + compilerHost.readFile = (filePath) => { + const key = getFileKey(filePath); + return files[key]; + }; + + compilerHost.fileExists = (filePath) => { + const key = getFileKey(filePath); + return key in files; + }; + + compilerHost.getCanonicalFileName = fileName => + ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); + + const program = ts.createProgram(['main.ts'], { + target: ts.ScriptTarget.ESNext, + module: ts.ModuleKind.ESNext + }, compilerHost); + + const checker = program.getTypeChecker(); + + const originalSource = program.getSourceFile('main.ts')!; + const libSource = program.getSourceFile('lib.ts')!; + + const libFooSymbol = (() => { + for (const stmt of libSource.statements) { + if (ts.isVariableStatement(stmt)) { + const decl = stmt.declarationList.declarations[0]; + if (ts.isIdentifier(decl.name) && decl.name.text === 'foo') { + return checker.getSymbolAtLocation(decl.name)!; + } + } + } + })(); + const mockResolver = { + isReferencedAliasDeclaration() { + return true; + } + }; + + const transformed = transformLazyImport(originalSource, mockResolver); + + const importDecl = transformed.statements.find(ts.isImportDeclaration)!; + const specifiers = (importDecl.importClause!.namedBindings as ts.NamedImports).elements; + + for (const spec of specifiers) { + const transformedSymbol = checker.getSymbolAtLocation(spec.name); + expect(transformedSymbol).to.exist; + } + }); }); \ No newline at end of file -- Gitee From 1be518670da7fbfbba613b25a1cc84fb6e0bd244 Mon Sep 17 00:00:00 2001 From: wuhailong Date: Thu, 12 Jun 2025 11:16:53 +0800 Subject: [PATCH 118/140] Fix the mock bug Issue: #ICELKD Signed-off-by: wuhailong Change-Id: Ib761d477f055cabf4a4924161d03a20f7da7af9f --- .../ark_compiler/module/module_source_file.ts | 21 +++- .../module/module_source_file.test.ts | 115 ++++++++++++------ 2 files changed, 95 insertions(+), 41 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 2152ebdfe..993f1893b 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -125,6 +125,7 @@ export class ModuleSourceFile { // "etsSourceRootPath": "path of ets source root", // "mockConfigPath": "path of mock configuration file" // "mockConfigKey2ModuleInfo": "moduleInfo of mock-config key" + // "source2ModuleIdMap": "moduleId of mock-config source value" // } ModuleSourceFile.needProcessMock = (rollupObject.share.projectConfig.mockParams && rollupObject.share.projectConfig.mockParams.etsSourceRootPath && @@ -203,12 +204,17 @@ export class ModuleSourceFile { let mockFile: string = ModuleSourceFile.transformedHarOrHspMockConfigInfo[transKey] ? ModuleSourceFile.transformedHarOrHspMockConfigInfo[transKey].source : ModuleSourceFile.mockConfigInfo[originKey].source; - let mockFilePath: string = `${toUnixPath(rollupObject.share.projectConfig.modulePath)}/${mockFile}`; + let source2ModuleIdMap: Map = new Map; + if (rollupObject.share.projectConfig.mockParams?.source2ModuleIdMap && + rollupObject.share.projectConfig.mockParams?.source2ModuleIdMap.size > 0) { + source2ModuleIdMap = rollupObject.share.projectConfig.mockParams?.source2ModuleIdMap; + } + let mockFilePath: string = source2ModuleIdMap.size > 0 ? + source2ModuleIdMap.get(mockFile) : + `${toUnixPath(rollupObject.share.projectConfig.modulePath)}/${mockFile}`; let mockFileOhmUrl: string = ''; if (useNormalizedOHMUrl) { - // When using mock for related compilation in module A, only the mock file under module A can be used, - // so the moduleInfo of the mock file is the moduleInfo of module A (that is, the main moduleInfo in the compilation process) - const targetModuleInfo: Object = ModuleSourceFile.generateModuleInfoOfMockFile(rollupObject); + const targetModuleInfo: Object = ModuleSourceFile.getModuleInfoOfMockFile(mockFilePath, rollupObject, source2ModuleIdMap); mockFileOhmUrl = ModuleSourceFile.spliceNormalizedOhmurl(targetModuleInfo, mockFilePath, importerFile); } else { mockFileOhmUrl = getOhmUrlByFilepath(mockFilePath, @@ -223,13 +229,16 @@ export class ModuleSourceFile { ModuleSourceFile.addMockConfig(ModuleSourceFile.newMockConfigInfo, transKey, mockFileOhmUrl); } - static generateModuleInfoOfMockFile(rollupObject: Object): Object { + static getModuleInfoOfMockFile(filePath: string, rollupObject: Object, source2ModuleIdMap: Map): Object { + if (source2ModuleIdMap.size > 0) { + return rollupObject.getModuleInfo(filePath); + } return { meta: { pkgName: rollupObject.share.projectConfig.entryPackageName, pkgPath: rollupObject.share.projectConfig.modulePath } - } + }; } static isMockFile(file: string, rollupObject: Object): boolean { diff --git a/compiler/test/ark_compiler_ut/module/module_source_file.test.ts b/compiler/test/ark_compiler_ut/module/module_source_file.test.ts index d0b3cd0e7..100481cdd 100644 --- a/compiler/test/ark_compiler_ut/module/module_source_file.test.ts +++ b/compiler/test/ark_compiler_ut/module/module_source_file.test.ts @@ -967,7 +967,42 @@ mocha.describe('test module_source_file file api', function () { expect(ModuleSourceFile.newMockConfigInfo).to.deep.equal(EXPECT_NEW_MOCK_INFO); }); - mocha.it('5-5: test generateNewMockInfo under LocalTest mode (useNormalizedOHMUrl is true)', function () { + mocha.it('5-5: test generateMockConfigFile under LocalTest mode', function () { + this.rollup.share.projectConfig.isLocalTest = true; + ModuleSourceFile.newMockConfigInfo = { + "@ohos:i18n": { + "source": "@bundle:com.example.demo/entry/src/mock/I18nMock" + }, + "@ohos:bluetooth": { + "source": "@bundle:com.example.demo/entry/src/mock/ohos/bluetooth.mock" + }, + "@bundle:com.example.demo/entry/ets/calc": { + "source": "@bundle:com.example.demo/entry/src/mock/module/calc.mock" + }, + "@bundle:/testProjectRootPath/oh_modules/lib/dist/index.js": { + "source": "@bundle:com.example.demo/entry/src/mock/module/bigInt.mock" + }, + "@app:UtTestApplication/entry/entry": { + "source": "@bundle:com.example.demo/entry/src/mock/native/libentry.mock" + } + } + this.rollup.share.projectConfig.mockParams = { + decorator: "@MockSetup", + packageName: "@ohos/hamock", + etsSourceRootPath: "src/main", + mockConfigPath: this.rollup.share.projectConfig.aceModuleRoot + '/mock/mock-config.json5', + } + ModuleSourceFile.generateMockConfigFile(this.rollup); + let EXPECT_MOCK_CONFIG_FILE = path.resolve(this.rollup.share.projectConfig.aceModuleJsonPath, `../mock-config.json`); + expect(fs.existsSync(EXPECT_MOCK_CONFIG_FILE)).to.be.true; + let EXPECT_MOCK_CONFIG_CONTENT = JSON.stringify(ModuleSourceFile.newMockConfigInfo); + let ACTUAL_MOCK_CONFIG_CONTENT = JSON.stringify(require(EXPECT_MOCK_CONFIG_FILE)); + expect(EXPECT_MOCK_CONFIG_CONTENT).to.equal(ACTUAL_MOCK_CONFIG_CONTENT); + fs.unlinkSync(this.rollup.share.projectConfig.cachePath + '/mock-config.json'); + fs.unlinkSync(this.rollup.share.projectConfig.cachePath + '/mock-config.json5'); + }); + + mocha.it('5-6: test generateNewMockInfo under LocalTest mode (useNormalizedOHMUrl is true)', function () { this.rollup.share.projectConfig.isLocalTest = true; this.rollup.share.projectConfig.useNormalizedOHMUrl = true; ModuleSourceFile.projectConfig.pkgContextInfo = { @@ -994,48 +1029,50 @@ mocha.describe('test module_source_file file api', function () { ModuleSourceFile.projectConfig.pkgContextInfo = {}; }); - - mocha.it('5-5: test isMockFile under LocalTest mode', function () { - ModuleSourceFile.needProcessMock = true; - ModuleSourceFile.mockFiles = ["src/mock/ohos/I18nMock.ts"]; - let file = this.rollup.share.projectConfig.aceModuleRoot +'/mock/ohos/I18nMock.ts'; - expect(ModuleSourceFile.isMockFile(file, this.rollup)).to.be.true; - ModuleSourceFile.needProcessMock = false; - }); - - mocha.it('5-6: test generateMockConfigFile under LocalTest mode', function () { + mocha.it('5-7: test generateNewMockInfo under LocalTest mode (has source2ModuleIdMap)', function () { this.rollup.share.projectConfig.isLocalTest = true; - ModuleSourceFile.newMockConfigInfo = { - "@ohos:i18n": { - "source": "@bundle:com.example.demo/entry/src/mock/I18nMock" - }, - "@ohos:bluetooth": { - "source": "@bundle:com.example.demo/entry/src/mock/ohos/bluetooth.mock" - }, - "@bundle:com.example.demo/entry/ets/calc": { - "source": "@bundle:com.example.demo/entry/src/mock/module/calc.mock" - }, - "@bundle:/testProjectRootPath/oh_modules/lib/dist/index.js": { - "source": "@bundle:com.example.demo/entry/src/mock/module/bigInt.mock" - }, - "@app:UtTestApplication/entry/entry": { - "source": "@bundle:com.example.demo/entry/src/mock/native/libentry.mock" + this.rollup.share.projectConfig.useNormalizedOHMUrl = true; + const mockFilePath = `${this.rollup.share.projectConfig.modulePath}/src/mock/utilsMock.ts`; + const moduleInfo = { + mockFilePath: { + meta: { + pkgName: 'entry', + pkgPath: this.rollup.share.projectConfig.modulePath + } } - } + }; + this.rollup.moduleInfos.push(moduleInfo); this.rollup.share.projectConfig.mockParams = { decorator: "@MockSetup", packageName: "@ohos/hamock", etsSourceRootPath: "src/main", mockConfigPath: this.rollup.share.projectConfig.aceModuleRoot + '/mock/mock-config.json5', + source2ModuleIdMap: { + "src/mock/utilsMock.ts": mockFilePath + } } - ModuleSourceFile.generateMockConfigFile(this.rollup); - let EXPECT_MOCK_CONFIG_FILE = path.resolve(this.rollup.share.projectConfig.aceModuleJsonPath, `../mock-config.json`); - expect(fs.existsSync(EXPECT_MOCK_CONFIG_FILE)).to.be.true; - let EXPECT_MOCK_CONFIG_CONTENT = JSON.stringify(ModuleSourceFile.newMockConfigInfo); - let ACTUAL_MOCK_CONFIG_CONTENT = JSON.stringify(require(EXPECT_MOCK_CONFIG_FILE)); - expect(EXPECT_MOCK_CONFIG_CONTENT).to.equal(ACTUAL_MOCK_CONFIG_CONTENT); - fs.unlinkSync(this.rollup.share.projectConfig.cachePath + '/mock-config.json'); - fs.unlinkSync(this.rollup.share.projectConfig.cachePath + '/mock-config.json5'); + ModuleSourceFile.projectConfig.pkgContextInfo = { + 'entry': { + 'packageName': 'entry', + 'bundleName': '', + 'moduleName': '', + 'version': '', + 'entryPath': 'Index.ets', + 'isSO': false + } + } + ModuleSourceFile.mockConfigInfo = { + "@ohos.utils": { + "source": "src/mock/utilsMock.ts" + }, + } + let originKey = "@ohos.utils"; + let transKey = "@ohos:utils"; + ModuleSourceFile.generateNewMockInfo(originKey, transKey, this.rollup, ''); + let expectOHMUrl: string = "@normalized:N&&&entry/src/mock/utilsMock&"; + expect(ModuleSourceFile.newMockConfigInfo[transKey].source === expectOHMUrl).to.be.true; + this.rollup.share.projectConfig.useNormalizedOHMUrl = false; + ModuleSourceFile.projectConfig.pkgContextInfo = {}; }); mocha.it('6-1: test removePotentialMockConfigCache delete mock-config', function () { @@ -1093,4 +1130,12 @@ mocha.describe('test module_source_file file api', function () { this.rollup.share.getHvigorConsoleLogger = getHvigorConsoleLogger; stub.restore(); }); + + mocha.it('8-1: test isMockFile under LocalTest mode', function () { + ModuleSourceFile.needProcessMock = true; + ModuleSourceFile.mockFiles = ["src/mock/ohos/I18nMock.ts"]; + let file = this.rollup.share.projectConfig.aceModuleRoot +'/mock/ohos/I18nMock.ts'; + expect(ModuleSourceFile.isMockFile(file, this.rollup)).to.be.true; + ModuleSourceFile.needProcessMock = false; + }); }); \ No newline at end of file -- Gitee From 712704dda2736cbba27b3123ba130971f48097ce Mon Sep 17 00:00:00 2001 From: lihao Date: Sun, 15 Jun 2025 17:08:51 +0800 Subject: [PATCH 119/140] cherryPick0411 to master Issue: https://gitee.com/openharmony/developtools_ace_ets2bundle/issues/IC8XYV Signed-off-by: lihao Change-Id: If6987416cb7a669996edad32318fc9e99eb2cd14 --- compiler/main.js | 6 ++++++ compiler/src/fast_build/ark_compiler/common/ark_define.ts | 1 + compiler/src/fast_build/ark_compiler/generate_sourcemap.ts | 2 +- .../src/fast_build/ark_compiler/run_es2abc_standalone.ts | 4 ++-- .../{sourceMaps.json => sourceMapsMerge.json} | 0 5 files changed, 10 insertions(+), 3 deletions(-) rename compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/{sourceMaps.json => sourceMapsMerge.json} (100%) diff --git a/compiler/main.js b/compiler/main.js index 1b6cb7ef3..bdbe6e8f9 100644 --- a/compiler/main.js +++ b/compiler/main.js @@ -150,6 +150,7 @@ function loadEntryObj(projectConfig) { initProjectConfig(projectConfig); loadMemoryTrackingConfig(projectConfig); loadBuildJson(); + // Initialize hybrid compilation related configuration initMixCompileHar(projectConfig); if (process.env.aceManifestPath && aceCompileMode === 'page') { setEntryFile(projectConfig); @@ -161,6 +162,11 @@ function loadEntryObj(projectConfig) { setStageTestRunnerFile(projectConfig); loadNavigationConfig(aceBuildJson); } + + /** + * In the case of hybrid compilation mode and remote modules + * do not perform operations such as page path parsing + */ if (projectConfig.mixCompile && projectConfig.isRemoteModule) { return; } diff --git a/compiler/src/fast_build/ark_compiler/common/ark_define.ts b/compiler/src/fast_build/ark_compiler/common/ark_define.ts index 9a1e6f62d..9ddf9d91d 100644 --- a/compiler/src/fast_build/ark_compiler/common/ark_define.ts +++ b/compiler/src/fast_build/ark_compiler/common/ark_define.ts @@ -23,6 +23,7 @@ export const WIDGETS_ABC: string = 'widgets.abc'; export const MODULELIST_JSON: string = 'moduleList.json'; export const PREBUILDMODE_JSON: string = 'preBuildMode.json'; export const SOURCEMAPS_JSON: string = 'sourceMaps.json'; +export const SOURCEMAPS_JSON_MERGE: string = 'sourceMapsMerge.json'; export const SOURCEMAPS: string = 'sourceMaps.map'; export const SYMBOLMAP: string = 'symbolMap.map'; export const PROTO_FILESINFO_TXT: string = 'protoFilesInfo.txt'; diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index d54489ae1..3b9d3e092 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -92,7 +92,7 @@ export class SourceMapGenerator { this.sourceMapPath = this.getSourceMapSavePath(); this.sourceMapPathTmp = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON + '.tmp'); this.cacheSourceMapPath = path.join(this.projectConfig.cachePath, SOURCEMAPS_JSON); - this.sourceMapForMergePath = this.cacheSourceMapPath + '.merge'; + this.sourceMapForMergePath = this.cacheSourceMapPath.replace('.json', 'Merge.json'); this.triggerAsync = rollupObject.async; this.triggerEndSignal = rollupObject.signal; this.logger = CommonLogger.getInstance(rollupObject); diff --git a/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts b/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts index b1e77c3fe..71efd4975 100644 --- a/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts +++ b/compiler/src/fast_build/ark_compiler/run_es2abc_standalone.ts @@ -24,7 +24,7 @@ import { MODULES_CACHE, NPMENTRIES_TXT, SOURCEMAPS, - SOURCEMAPS_JSON + SOURCEMAPS_JSON_MERGE } from './common/ark_define'; /** @@ -166,7 +166,7 @@ export function mergeSourceMap(cachePathList: string[], targetCachePath: string) */ const possiblePaths = [ path.join(item, SOURCEMAPS), - path.join(item, SOURCEMAPS_JSON), + path.join(item, SOURCEMAPS_JSON_MERGE), ]; const sourceMapPath = possiblePaths.find(fs.existsSync); diff --git a/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/sourceMaps.json b/compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/sourceMapsMerge.json similarity index 100% rename from compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/sourceMaps.json rename to compiler/test/ark_compiler_ut/testdata/testcase_def/mergeCacheData/originCacheDir2/sourceMapsMerge.json -- Gitee From 2ff79be888f1ffe0dd2dd1d779c773cea248e9ed Mon Sep 17 00:00:00 2001 From: chengongping Date: Tue, 17 Jun 2025 00:51:12 +0800 Subject: [PATCH 120/140] add the ut for case Signed-off-by: chengongping --- .../src/main/ets/pages/utForCase/builder.ts | 162 ++++++++ .../main/ets/pages/utForCase/makeObserved.ts | 389 ++++++++++++++++++ .../main/ets/pages/utForCase/persistencev2.ts | 376 +++++++++++++++++ .../src/main/ets/pages/utForCase/repeat.ts | 350 ++++++++++++++++ .../main/ets/pages/utForCase/reusablev2.ts | 248 +++++++++++ .../src/main/ets/pages/utForCase/state.ts | 248 +++++++++++ 6 files changed, 1773 insertions(+) create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/builder.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/makeObserved.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/persistencev2.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/repeat.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/reusablev2.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/state.ts diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/builder.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/builder.ts new file mode 100644 index 000000000..7286b8044 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/builder.ts @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +@Entry +@Component +struct PrivateBuilder { + @State builder_value: string = 'Hello'; + + @Builder + builder() { + Column() { + Text(this.builder_value) + .width(230) + .height(40) + .backgroundColor('#ffeae5e5') + .borderRadius(20) + .margin(12) + .textAlign(TextAlign.Center) + } + } + + aboutToAppear(): void { + setTimeout(() => { + this.builder_value = 'Hello World'; + }, 2000); + } + + build() { + Row() { + Column() { + Text(this.builder_value) + .width(230) + .height(40) + .backgroundColor('#ffeae5e5') + .borderRadius(20) + .textAlign(TextAlign.Center) + this.builder() + Button('点击改变builder_value内容') + .onClick(() => { + this.builder_value = 'builder_value被点击了'; + }) + } + .height('100%') + .width('100%') + } + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +interface PrivateBuilder_Params { + builder_value?: string; +} +class PrivateBuilder extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__builder_value = new ObservedPropertySimplePU('Hello', this, "builder_value"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: PrivateBuilder_Params) { + if (params.builder_value !== undefined) { + this.builder_value = params.builder_value; + } + } + updateStateVars(params: PrivateBuilder_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__builder_value.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__builder_value.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __builder_value: ObservedPropertySimplePU; + get builder_value() { + return this.__builder_value.get(); + } + set builder_value(newValue: string) { + this.__builder_value.set(newValue); + } + builder(parent = null) { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.builder_value); + Text.width(230); + Text.height(40); + Text.backgroundColor('#ffeae5e5'); + Text.borderRadius(20); + Text.margin(12); + Text.textAlign(TextAlign.Center); + }, Text); + Text.pop(); + Column.pop(); + } + aboutToAppear(): void { + setTimeout(() => { + this.builder_value = 'Hello World'; + }, 2000); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.height('100%'); + Column.width('100%'); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.builder_value); + Text.width(230); + Text.height(40); + Text.backgroundColor('#ffeae5e5'); + Text.borderRadius(20); + Text.textAlign(TextAlign.Center); + }, Text); + Text.pop(); + this.builder.bind(this)(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('点击改变builder_value内容'); + Button.onClick(() => { + this.builder_value = 'builder_value被点击了'; + }); + }, Button); + Button.pop(); + Column.pop(); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "PrivateBuilder"; + } +} +registerNamedRoute(() => new PrivateBuilder(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/makeObserved.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/makeObserved.ts new file mode 100644 index 000000000..335b7f7fc --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/makeObserved.ts @@ -0,0 +1,389 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +import { collections } from '@kit.ArkTS'; +import { UIUtils } from '@kit.ArkUI'; + +@Sendable +class Info { + id: number = 0; + name: string = 'cc'; + + constructor(id: number) { + this.id = id; + } +} + + +@Entry +@ComponentV2 +struct Index { + scroller: Scroller = new Scroller(); + @Local arrCollect: collections.Array = + UIUtils.makeObserved(new collections.Array(new Info(1), new Info(2))); + + build() { + Column() { + // ForEach接口仅支持Array,不支持collections.Array。 + // 但ForEach的实现用到的Array的API,collections.Array都有提供。所以可以使用as类型断言Array。 + // 需要注意断言并不会改变原本的数据类型。 + ForEach(this.arrCollect as object as Array, (item: Info) => { + Text('' + item.id).onClick(() => { + item.id++; + }) + }, (item: Info, index) => item.id.toString() + index.toString()) + Divider() + .color('blue') + if (this.arrCollect.length > 0) { + Text('the first one ' + this.arrCollect[this.arrCollect.length - this.arrCollect.length].id) + Text('the last one ' + this.arrCollect[this.arrCollect.length - 1].id) + } + Divider() + .color('blue') + + /****************************改变数据长度的api**************************/ + Scroll(this.scroller) { + Column({space: 10}) { + // push: 新增新元素 + Button('push').onClick(() => { + this.arrCollect.push(new Info(30)); + }) + // pop: 删除最后一个 + Button('pop').onClick(() => { + this.arrCollect.pop(); + }) + // shift: 删除第一个 + Button('shift').onClick(() => { + this.arrCollect.shift(); + }) + // unshift: 在数组的开头插入新项 + Button('unshift').onClick(() => { + this.arrCollect.unshift(new Info(50)); + }) + // splice: 从数组的指定位置删除元素 + Button('splice').onClick(() => { + this.arrCollect.splice(1); + }) + + // shrinkTo: 将数组长度缩小到给定的长度 + Button('shrinkTo').onClick(() => { + this.arrCollect.shrinkTo(1); + }) + // extendTo: 将数组长度扩展到给定的长度 + Button('extendTo').onClick(() => { + this.arrCollect.extendTo(6, new Info(20)); + }) + + Divider() + .color('blue') + + /****************************************改变数组item本身*****************/ + // sort:从大到小排序 + Button('sort').onClick(() => { + this.arrCollect.sort((a: Info, b: Info) => b.id - a.id); + }) + // fill: 用值填充指定部分 + Button('fill').onClick(() => { + this.arrCollect.fill(new Info(5), 0, 2); + }) + + /*****************************不会改变数组本身API***************************/ + // slice:返回新的数组,根据start end对原数组的拷贝,不会改变原数组,所以直接调用slice不会触发UI刷新 + // 可以构建用例为返回的浅拷贝的数据赋值给this.arrCollect,需要注意这里依然要调用makeObserved,否则this.arr被普通变量赋值后,会丧失观察能力 + Button('slice').onClick(() => { + this.arrCollect = UIUtils.makeObserved(this.arrCollect.slice(0, 1)); + }) + // map:原理同上 + Button('map').onClick(() => { + this.arrCollect = UIUtils.makeObserved(this.arrCollect.map((value) => { + value.id += 10; + return value; + })) + }) + // filter:原理同上 + Button('filter').onClick(() => { + this.arrCollect = UIUtils.makeObserved(this.arrCollect.filter((value: Info) => value.id % 2 === 0)); + }) + + // concat:原理同上 + Button('concat').onClick(() => { + let array1 = new collections.Array(new Info(100)) + this.arrCollect = UIUtils.makeObserved(this.arrCollect.concat(array1)); + }) + }.height('200%') + }.height('60%') + } + .height('100%') + .width('100%') + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +import collections from "@ohos:arkts.collections"; +import { UIUtils as UIUtils } from "@ohos:arkui.StateManagement"; +class Info { + id: number = 0; + name: string = 'cc'; + constructor(id: number) { + "use sendable"; + this.id = id; + } +} +class Index extends ViewV2 { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda, extraInfo) { + super(parent, elmtId, extraInfo); + this.scroller = new Scroller(); + this.arrCollect = UIUtils.makeObserved(new collections.Array(new Info(1), new Info(2))); + this.finalizeConstruction(); + } + public resetStateVarsOnReuse(params: Object): void { + this.arrCollect = UIUtils.makeObserved(new collections.Array(new Info(1), new Info(2))); + } + scroller: Scroller; + @Local + arrCollect: collections.Array; + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.height('100%'); + Column.width('100%'); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // ForEach接口仅支持Array,不支持collections.Array。 + // 但ForEach的实现用到的Array的API,collections.Array都有提供。所以可以使用as类型断言Array。 + // 需要注意断言并不会改变原本的数据类型。 + ForEach.create(); + const forEachItemGenFunction = _item => { + const item = _item; + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('' + item.id); + Text.onClick(() => { + item.id++; + }); + }, Text); + Text.pop(); + }; + this.forEachUpdateFunction(elmtId, this.arrCollect as object as Array, forEachItemGenFunction, (item: Info, index) => item.id.toString() + index.toString(), false, true); + }, ForEach); + // ForEach接口仅支持Array,不支持collections.Array。 + // 但ForEach的实现用到的Array的API,collections.Array都有提供。所以可以使用as类型断言Array。 + // 需要注意断言并不会改变原本的数据类型。 + ForEach.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); + Divider.color('blue'); + }, Divider); + this.observeComponentCreation2((elmtId, isInitialRender) => { + If.create(); + if (this.arrCollect.length > 0) { + this.ifElseBranchUpdateFunction(0, () => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('the first one ' + this.arrCollect[this.arrCollect.length - this.arrCollect.length].id); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('the last one ' + this.arrCollect[this.arrCollect.length - 1].id); + }, Text); + Text.pop(); + }); + } + else { + this.ifElseBranchUpdateFunction(1, () => { + }); + } + }, If); + If.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); + Divider.color('blue'); + }, Divider); + this.observeComponentCreation2((elmtId, isInitialRender) => { + /****************************改变数据长度的api**************************/ + Scroll.create(this.scroller); + /****************************改变数据长度的api**************************/ + Scroll.height('60%'); + }, Scroll); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create({ space: 10 }); + Column.height('200%'); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // push: 新增新元素 + Button.createWithLabel('push'); + // push: 新增新元素 + Button.onClick(() => { + this.arrCollect.push(new Info(30)); + }); + }, Button); + // push: 新增新元素 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // pop: 删除最后一个 + Button.createWithLabel('pop'); + // pop: 删除最后一个 + Button.onClick(() => { + this.arrCollect.pop(); + }); + }, Button); + // pop: 删除最后一个 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // shift: 删除第一个 + Button.createWithLabel('shift'); + // shift: 删除第一个 + Button.onClick(() => { + this.arrCollect.shift(); + }); + }, Button); + // shift: 删除第一个 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // unshift: 在数组的开头插入新项 + Button.createWithLabel('unshift'); + // unshift: 在数组的开头插入新项 + Button.onClick(() => { + this.arrCollect.unshift(new Info(50)); + }); + }, Button); + // unshift: 在数组的开头插入新项 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // splice: 从数组的指定位置删除元素 + Button.createWithLabel('splice'); + // splice: 从数组的指定位置删除元素 + Button.onClick(() => { + this.arrCollect.splice(1); + }); + }, Button); + // splice: 从数组的指定位置删除元素 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // shrinkTo: 将数组长度缩小到给定的长度 + Button.createWithLabel('shrinkTo'); + // shrinkTo: 将数组长度缩小到给定的长度 + Button.onClick(() => { + this.arrCollect.shrinkTo(1); + }); + }, Button); + // shrinkTo: 将数组长度缩小到给定的长度 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // extendTo: 将数组长度扩展到给定的长度 + Button.createWithLabel('extendTo'); + // extendTo: 将数组长度扩展到给定的长度 + Button.onClick(() => { + this.arrCollect.extendTo(6, new Info(20)); + }); + }, Button); + // extendTo: 将数组长度扩展到给定的长度 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); + Divider.color('blue'); + }, Divider); + this.observeComponentCreation2((elmtId, isInitialRender) => { + /****************************************改变数组item本身*****************/ + // sort:从大到小排序 + Button.createWithLabel('sort'); + /****************************************改变数组item本身*****************/ + // sort:从大到小排序 + Button.onClick(() => { + this.arrCollect.sort((a: Info, b: Info) => b.id - a.id); + }); + }, Button); + /****************************************改变数组item本身*****************/ + // sort:从大到小排序 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // fill: 用值填充指定部分 + Button.createWithLabel('fill'); + // fill: 用值填充指定部分 + Button.onClick(() => { + this.arrCollect.fill(new Info(5), 0, 2); + }); + }, Button); + // fill: 用值填充指定部分 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + /*****************************不会改变数组本身API***************************/ + // slice:返回新的数组,根据start end对原数组的拷贝,不会改变原数组,所以直接调用slice不会触发UI刷新 + // 可以构建用例为返回的浅拷贝的数据赋值给this.arrCollect,需要注意这里依然要调用makeObserved,否则this.arr被普通变量赋值后,会丧失观察能力 + Button.createWithLabel('slice'); + /*****************************不会改变数组本身API***************************/ + // slice:返回新的数组,根据start end对原数组的拷贝,不会改变原数组,所以直接调用slice不会触发UI刷新 + // 可以构建用例为返回的浅拷贝的数据赋值给this.arrCollect,需要注意这里依然要调用makeObserved,否则this.arr被普通变量赋值后,会丧失观察能力 + Button.onClick(() => { + this.arrCollect = UIUtils.makeObserved(this.arrCollect.slice(0, 1)); + }); + }, Button); + /*****************************不会改变数组本身API***************************/ + // slice:返回新的数组,根据start end对原数组的拷贝,不会改变原数组,所以直接调用slice不会触发UI刷新 + // 可以构建用例为返回的浅拷贝的数据赋值给this.arrCollect,需要注意这里依然要调用makeObserved,否则this.arr被普通变量赋值后,会丧失观察能力 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // map:原理同上 + Button.createWithLabel('map'); + // map:原理同上 + Button.onClick(() => { + this.arrCollect = UIUtils.makeObserved(this.arrCollect.map((value) => { + value.id += 10; + return value; + })); + }); + }, Button); + // map:原理同上 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // filter:原理同上 + Button.createWithLabel('filter'); + // filter:原理同上 + Button.onClick(() => { + this.arrCollect = UIUtils.makeObserved(this.arrCollect.filter((value: Info) => value.id % 2 === 0)); + }); + }, Button); + // filter:原理同上 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // concat:原理同上 + Button.createWithLabel('concat'); + // concat:原理同上 + Button.onClick(() => { + let array1 = new collections.Array(new Info(100)); + this.arrCollect = UIUtils.makeObserved(this.arrCollect.concat(array1)); + }); + }, Button); + // concat:原理同上 + Button.pop(); + Column.pop(); + /****************************改变数据长度的api**************************/ + Scroll.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "Index"; + } +} +registerNamedRoute(() => new Index(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/persistencev2.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/persistencev2.ts new file mode 100644 index 000000000..429427523 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/persistencev2.ts @@ -0,0 +1,376 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +import { PersistenceV2, Type, ConnectOptions } from '@kit.ArkUI'; +import { contextConstant } from '@kit.AbilityKit'; + +// 接受序列化失败的回调 +PersistenceV2.notifyOnError((key: string, reason: string, msg: string) => { + console.error(''); +}); + +@ObservedV2 +class SampleChild { + @Trace childId: number = 0; + groupId: number = 1; +} + +@ObservedV2 +export class Sample { + // 对于复杂对象需要@Type修饰,确保序列化成功 + @Type(SampleChild) + @Trace father: SampleChild = new SampleChild(); +} + +@Entry +@ComponentV2 +struct Page1 { + @Local refresh: number = 0; + // key不传入尝试用为type的name作为key,加密参数不传入默认加密等级为EL2 + @Local p: Sample = PersistenceV2.globalConnect({type: Sample, defaultCreator:() => new Sample()})!; + + // 使用key:global1连接,传入加密等级为EL1 + @Local p1: Sample = PersistenceV2.globalConnect({type: Sample, key:'global1', defaultCreator:() => new Sample(), areaMode: contextConstant.AreaMode.EL1})!; + + // 使用key:global2连接,使用构造函数形式,加密参数不传入默认加密等级为EL2 + options: ConnectOptions = {type: Sample, key: 'global2', defaultCreator:() => new Sample()}; + @Local p2: Sample = PersistenceV2.globalConnect(this.options)!; + + // 使用key:global3连接,直接写加密数值,范围只能在0-4,否则运行会crash,例如加密设置为EL3 + @Local p3: Sample = PersistenceV2.globalConnect({type: Sample, key:'global3', defaultCreator:() => new Sample(), areaMode: 3})!; + + build() { + Column() { + /**************************** 显示数据 **************************/ + // 被@Trace修饰的数据可以自动持久化进磁盘 + Text('Key Sample: ' + this.p.father.childId.toString()) + .onClick(()=> { + this.p.father.childId += 1; + }) + .fontSize(25) + .fontColor(Color.Red) + Text('Key global1: ' + this.p1.father.childId.toString()) + .onClick(()=> { + this.p1.father.childId += 1; + }) + .fontSize(25) + .fontColor(Color.Red) + Text('Key global2: ' + this.p2.father.childId.toString()) + .onClick(()=> { + this.p2.father.childId += 1; + }) + .fontSize(25) + .fontColor(Color.Red) + Text('Key global3: ' + this.p3.father.childId.toString()) + .onClick(()=> { + this.p3.father.childId += 1; + }) + .fontSize(25) + .fontColor(Color.Red) + /**************************** keys接口 **************************/ + // keys 本身不会刷新,需要借助状态变量刷新 + Text('Persist keys: ' + PersistenceV2.keys().toString() + ' refresh: ' + this.refresh) + .onClick(() => { + this.refresh += 1; + }) + .fontSize(25) + + /**************************** remove接口 **************************/ + Text('Remove key Sample: ' + 'refresh: ' + this.refresh) + .onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.remove(Sample); + this.refresh += 1; + }) + .fontSize(25) + Text('Remove key global1: ' + 'refresh: ' + this.refresh) + .onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.remove('global1'); + this.refresh += 1; + }) + .fontSize(25) + Text('Remove key global2: ' + 'refresh: ' + this.refresh) + .onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.remove('global2'); + this.refresh += 1; + }) + .fontSize(25) + Text('Remove key global3: ' + 'refresh: ' + this.refresh) + .onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.remove('global3'); + this.refresh += 1; + }) + .fontSize(25) + /**************************** reConnect **************************/ + // 重新连接也无法和之前的状态变量建立联系,因此无法保存数据 + Text('ReConnect key global2: ' + 'refresh: ' + this.refresh) + .onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.globalConnect(this.options); + this.refresh += 1; + }) + .fontSize(25) + + /**************************** save接口 **************************/ + Text('not save key Sample: ' + this.p.father.groupId.toString() + ' refresh: ' + this.refresh) + .onClick(() => { + // 未被@Trace保存的对象无法自动存储 + this.p.father.groupId += 1; + this.refresh += 1; + }) + .fontSize(25) + Text('save key Sample: ' + this.p.father.groupId.toString() + ' refresh: ' + this.refresh) + .onClick(() => { + // 未被@Trace保存的对象无法自动存储,需要调用key存储 + this.p.father.groupId += 1; + PersistenceV2.save(Sample); + this.refresh += 1; + }) + .fontSize(25) + } + .width('100%') + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +import { PersistenceV2 as PersistenceV2 } from "@ohos:arkui.StateManagement"; +import { Type as Type } from "@ohos:arkui.StateManagement"; +import type { ConnectOptions as ConnectOptions } from "@ohos:arkui.StateManagement"; +import contextConstant from "@ohos:app.ability.contextConstant"; +// 接受序列化失败的回调 +PersistenceV2.notifyOnError((key: string, reason: string, msg: string) => { + console.error(''); +}); +@ObservedV2 +class SampleChild { + @Trace + childId: number = 0; + groupId: number = 1; +} +@ObservedV2 +export class Sample { + // 对于复杂对象需要@Type修饰,确保序列化成功 + @Type(SampleChild) + @Trace + father: SampleChild = new SampleChild(); +} +class Page1 extends ViewV2 { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda, extraInfo) { + super(parent, elmtId, extraInfo); + this.refresh = 0; + this.p = PersistenceV2.globalConnect({ type: Sample, defaultCreator: () => new Sample() })!; + this.p1 = PersistenceV2.globalConnect({ type: Sample, key: 'global1', defaultCreator: () => new Sample(), areaMode: contextConstant.AreaMode.EL1 })!; + this.options = { type: Sample, key: 'global2', defaultCreator: () => new Sample() }; + this.p2 = PersistenceV2.globalConnect(this.options)!; + this.p3 = PersistenceV2.globalConnect({ type: Sample, key: 'global3', defaultCreator: () => new Sample(), areaMode: 3 })!; + this.finalizeConstruction(); + } + public resetStateVarsOnReuse(params: Object): void { + this.refresh = 0; + this.p = PersistenceV2.globalConnect({ type: Sample, defaultCreator: () => new Sample() })!; + this.p1 = PersistenceV2.globalConnect({ type: Sample, key: 'global1', defaultCreator: () => new Sample(), areaMode: contextConstant.AreaMode.EL1 })!; + this.p2 = PersistenceV2.globalConnect(this.options)!; + this.p3 = PersistenceV2.globalConnect({ type: Sample, key: 'global3', defaultCreator: () => new Sample(), areaMode: 3 })!; + } + @Local + refresh: number; + // key不传入尝试用为type的name作为key,加密参数不传入默认加密等级为EL2 + @Local + p: Sample; + // 使用key:global1连接,传入加密等级为EL1 + @Local + p1: Sample; + // 使用key:global2连接,使用构造函数形式,加密参数不传入默认加密等级为EL2 + options: ConnectOptions; + @Local + p2: Sample; + // 使用key:global3连接,直接写加密数值,范围只能在0-4,否则运行会crash,例如加密设置为EL3 + @Local + p3: Sample; + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.width('100%'); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + /**************************** 显示数据 **************************/ + // 被@Trace修饰的数据可以自动持久化进磁盘 + Text.create('Key Sample: ' + this.p.father.childId.toString()); + /**************************** 显示数据 **************************/ + // 被@Trace修饰的数据可以自动持久化进磁盘 + Text.onClick(() => { + this.p.father.childId += 1; + }); + /**************************** 显示数据 **************************/ + // 被@Trace修饰的数据可以自动持久化进磁盘 + Text.fontSize(25); + /**************************** 显示数据 **************************/ + // 被@Trace修饰的数据可以自动持久化进磁盘 + Text.fontColor(Color.Red); + }, Text); + /**************************** 显示数据 **************************/ + // 被@Trace修饰的数据可以自动持久化进磁盘 + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Key global1: ' + this.p1.father.childId.toString()); + Text.onClick(() => { + this.p1.father.childId += 1; + }); + Text.fontSize(25); + Text.fontColor(Color.Red); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Key global2: ' + this.p2.father.childId.toString()); + Text.onClick(() => { + this.p2.father.childId += 1; + }); + Text.fontSize(25); + Text.fontColor(Color.Red); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Key global3: ' + this.p3.father.childId.toString()); + Text.onClick(() => { + this.p3.father.childId += 1; + }); + Text.fontSize(25); + Text.fontColor(Color.Red); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + /**************************** keys接口 **************************/ + // keys 本身不会刷新,需要借助状态变量刷新 + Text.create('Persist keys: ' + PersistenceV2.keys().toString() + ' refresh: ' + this.refresh); + /**************************** keys接口 **************************/ + // keys 本身不会刷新,需要借助状态变量刷新 + Text.onClick(() => { + this.refresh += 1; + }); + /**************************** keys接口 **************************/ + // keys 本身不会刷新,需要借助状态变量刷新 + Text.fontSize(25); + }, Text); + /**************************** keys接口 **************************/ + // keys 本身不会刷新,需要借助状态变量刷新 + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + /**************************** remove接口 **************************/ + Text.create('Remove key Sample: ' + 'refresh: ' + this.refresh); + /**************************** remove接口 **************************/ + Text.onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.remove(Sample); + this.refresh += 1; + }); + /**************************** remove接口 **************************/ + Text.fontSize(25); + }, Text); + /**************************** remove接口 **************************/ + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Remove key global1: ' + 'refresh: ' + this.refresh); + Text.onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.remove('global1'); + this.refresh += 1; + }); + Text.fontSize(25); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Remove key global2: ' + 'refresh: ' + this.refresh); + Text.onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.remove('global2'); + this.refresh += 1; + }); + Text.fontSize(25); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Remove key global3: ' + 'refresh: ' + this.refresh); + Text.onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.remove('global3'); + this.refresh += 1; + }); + Text.fontSize(25); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + /**************************** reConnect **************************/ + // 重新连接也无法和之前的状态变量建立联系,因此无法保存数据 + Text.create('ReConnect key global2: ' + 'refresh: ' + this.refresh); + /**************************** reConnect **************************/ + // 重新连接也无法和之前的状态变量建立联系,因此无法保存数据 + Text.onClick(() => { + // 删除这个key,会导致和p失去联系,之后p无法存储,即使reconnect + PersistenceV2.globalConnect(this.options); + this.refresh += 1; + }); + /**************************** reConnect **************************/ + // 重新连接也无法和之前的状态变量建立联系,因此无法保存数据 + Text.fontSize(25); + }, Text); + /**************************** reConnect **************************/ + // 重新连接也无法和之前的状态变量建立联系,因此无法保存数据 + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + /**************************** save接口 **************************/ + Text.create('not save key Sample: ' + this.p.father.groupId.toString() + ' refresh: ' + this.refresh); + /**************************** save接口 **************************/ + Text.onClick(() => { + // 未被@Trace保存的对象无法自动存储 + this.p.father.groupId += 1; + this.refresh += 1; + }); + /**************************** save接口 **************************/ + Text.fontSize(25); + }, Text); + /**************************** save接口 **************************/ + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('save key Sample: ' + this.p.father.groupId.toString() + ' refresh: ' + this.refresh); + Text.onClick(() => { + // 未被@Trace保存的对象无法自动存储,需要调用key存储 + this.p.father.groupId += 1; + PersistenceV2.save(Sample); + this.refresh += 1; + }); + Text.fontSize(25); + }, Text); + Text.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "Page1"; + } +} +registerNamedRoute(() => new Page1(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/repeat.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/repeat.ts new file mode 100644 index 000000000..0d70ce7f3 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/repeat.ts @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +@Observed +class Article { + id: string; + title: string; + brief: string; + isLiked: boolean; + likesCount: number; + + constructor(id: string, title: string, brief: string, isLiked: boolean, likesCount: number) { + this.id = id; + this.title = title; + this.brief = brief; + this.isLiked = isLiked; + this.likesCount = likesCount; + } +} + +@Entry +@Component +struct ArticleListView { + @State articleList: Array
= [ + new Article('001', '第0篇文章', '文章简介内容', false, 100), + new Article('002', '第1篇文章', '文章简介内容', false, 100), + new Article('003', '第2篇文章', '文章简介内容', false, 100), + new Article('004', '第4篇文章', '文章简介内容', false, 100), + new Article('005', '第5篇文章', '文章简介内容', false, 100), + new Article('006', '第6篇文章', '文章简介内容', false, 100), + ]; + + build() { + List() { + ForEach(this.articleList, (item: Article) => { + ListItem() { + ArticleCard({ + article: item + }) + .margin({ top: 20 }) + } + }, (item: Article) => item.id) + } + .padding(20) + .scrollBar(BarState.Off) + .backgroundColor(0xF1F3F5) + } +} + +@Component +struct ArticleCard { + @ObjectLink article: Article; + + handleLiked() { + this.article.isLiked = !this.article.isLiked; + this.article.likesCount = this.article.isLiked ? this.article.likesCount + 1 : this.article.likesCount - 1; + } + + build() { + Row() { + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image($r('app.media.icon')) + .width(80) + .height(80) + .margin({ right: 20 }) + + Column() { + Text(this.article.title) + .fontSize(20) + .margin({ bottom: 8 }) + Text(this.article.brief) + .fontSize(16) + .fontColor(Color.Gray) + .margin({ bottom: 8 }) + + Row() { + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image(this.article.isLiked ? $r('app.media.iconLiked') : $r('app.media.iconUnLiked')) + .width(24) + .height(24) + .margin({ right: 8 }) + Text(this.article.likesCount.toString()) + .fontSize(16) + } + .onClick(() => this.handleLiked()) + .justifyContent(FlexAlign.Center) + } + .alignItems(HorizontalAlign.Start) + .width('80%') + .height('100%') + } + .padding(20) + .borderRadius(12) + .backgroundColor('#FFECECEC') + .height(120) + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +interface ArticleCard_Params { + article?: Article; +} +interface ArticleListView_Params { + articleList?: Array
; +} +@Observed +class Article { + id: string; + title: string; + brief: string; + isLiked: boolean; + likesCount: number; + constructor(id: string, title: string, brief: string, isLiked: boolean, likesCount: number) { + this.id = id; + this.title = title; + this.brief = brief; + this.isLiked = isLiked; + this.likesCount = likesCount; + } +} +class ArticleListView extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__articleList = new ObservedPropertyObjectPU([ + new Article('001', '第0篇文章', '文章简介内容', false, 100), + new Article('002', '第1篇文章', '文章简介内容', false, 100), + new Article('003', '第2篇文章', '文章简介内容', false, 100), + new Article('004', '第4篇文章', '文章简介内容', false, 100), + new Article('005', '第5篇文章', '文章简介内容', false, 100), + new Article('006', '第6篇文章', '文章简介内容', false, 100), + ], this, "articleList"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: ArticleListView_Params) { + if (params.articleList !== undefined) { + this.articleList = params.articleList; + } + } + updateStateVars(params: ArticleListView_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__articleList.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__articleList.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __articleList: ObservedPropertyObjectPU>; + get articleList() { + return this.__articleList.get(); + } + set articleList(newValue: Array
) { + this.__articleList.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + List.create(); + List.padding(20); + List.scrollBar(BarState.Off); + List.backgroundColor(0xF1F3F5); + }, List); + this.observeComponentCreation2((elmtId, isInitialRender) => { + ForEach.create(); + const forEachItemGenFunction = _item => { + const item = _item; + { + const itemCreation = (elmtId, isInitialRender) => { + ViewStackProcessor.StartGetAccessRecordingFor(elmtId); + ListItem.create(deepRenderFunction, true); + if (!isInitialRender) { + ListItem.pop(); + } + ViewStackProcessor.StopGetAccessRecording(); + }; + const itemCreation2 = (elmtId, isInitialRender) => { + ListItem.create(deepRenderFunction, true); + }; + const deepRenderFunction = (elmtId, isInitialRender) => { + itemCreation(elmtId, isInitialRender); + this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); + __Common__.margin({ top: 20 }); + }, __Common__); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new ArticleCard(this, { + article: item + }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 34, col: 11 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + article: item + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, { + article: item + }); + } + }, { name: "ArticleCard" }); + } + __Common__.pop(); + ListItem.pop(); + }; + this.observeComponentCreation2(itemCreation2, ListItem); + ListItem.pop(); + } + }; + this.forEachUpdateFunction(elmtId, this.articleList, forEachItemGenFunction, (item: Article) => item.id, false, false); + }, ForEach); + ForEach.pop(); + List.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "ArticleListView"; + } +} +class ArticleCard extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__article = new SynchedPropertyNesedObjectPU(params.article, this, "article"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: ArticleCard_Params) { + this.__article.set(params.article); + } + updateStateVars(params: ArticleCard_Params) { + this.__article.set(params.article); + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__article.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__article.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __article: SynchedPropertyNesedObjectPU
; + get article() { + return this.__article.get(); + } + handleLiked() { + this.article.isLiked = !this.article.isLiked; + this.article.likesCount = this.article.isLiked ? this.article.likesCount + 1 : this.article.likesCount - 1; + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + Row.padding(20); + Row.borderRadius(12); + Row.backgroundColor('#FFECECEC'); + Row.height(120); + Row.width('100%'); + Row.justifyContent(FlexAlign.SpaceBetween); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.create({ "id": 16777225, "type": 20000, params: [], "bundleName": "com.example.myapplication", "moduleName": "entry" }); + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.width(80); + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.height(80); + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.margin({ right: 20 }); + }, Image); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.alignItems(HorizontalAlign.Start); + Column.width('80%'); + Column.height('100%'); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.article.title); + Text.fontSize(20); + Text.margin({ bottom: 8 }); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.article.brief); + Text.fontSize(16); + Text.fontColor(Color.Gray); + Text.margin({ bottom: 8 }); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + Row.onClick(() => this.handleLiked()); + Row.justifyContent(FlexAlign.Center); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.create(this.article.isLiked ? { "id": 16777225, "type": 20000, params: [], "bundleName": "com.example.myapplication", "moduleName": "entry" } : { "id": 16777225, "type": 20000, params: [], "bundleName": "com.example.myapplication", "moduleName": "entry" }); + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.width(24); + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.height(24); + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.margin({ right: 8 }); + }, Image); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.article.likesCount.toString()); + Text.fontSize(16); + }, Text); + Text.pop(); + Row.pop(); + Column.pop(); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +registerNamedRoute(() => new ArticleListView(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/reusablev2.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/reusablev2.ts new file mode 100644 index 000000000..15828fbd4 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/reusablev2.ts @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +class Model { + public value: string; + + constructor(value: string) { + this.value = value; + } +} + +@Entry +@Component +struct EntryComponent { + build() { + Column() { + // 此处指定的参数都将在初始渲染时覆盖本地定义的默认值,并不是所有的参数都需要从父组件初始化 + MyComponent({ count: 1, increaseBy: 2 }) + .width(300) + MyComponent({ title: new Model('Hello World 2'), count: 7 }) + } + } +} + +@Component +struct MyComponent { + @State title: Model = new Model('Hello World'); + @State count: number = 0; + increaseBy: number = 1; + + build() { + Column() { + Text('' + this.title.value) + .margin(10) + Button('Click to change title') + .onClick(() => { + // @State变量的更新将触发上面的Text组件内容更新 + this.title.value = this.title.value === 'Hello ArkUI' ? 'Hello World' : 'Hello ArkUI'; + }) + .width(300) + .margin(10) + + Button('Click to increase count =' + this.count) + .onClick(() => { + // @State变量的更新将触发该Button组件的内容更新 + this.count += this.increaseBy; + }) + .width(300) + .margin(10) + } + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +interface MyComponent_Params { + title?: Model; + count?: number; + increaseBy?: number; +} +interface EntryComponent_Params { +} +class Model { + public value: string; + constructor(value: string) { + this.value = value; + } +} +class EntryComponent extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: EntryComponent_Params) { + } + updateStateVars(params: EntryComponent_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); + __Common__.width(300); + }, __Common__); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new + // 此处指定的参数都将在初始渲染时覆盖本地定义的默认值,并不是所有的参数都需要从父组件初始化 + MyComponent(this, { count: 1, increaseBy: 2 }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 15, col: 7 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + count: 1, + increaseBy: 2 + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "MyComponent" }); + } + __Common__.pop(); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new MyComponent(this, { title: new Model('Hello World 2'), count: 7 }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 17, col: 7 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + title: new Model('Hello World 2'), + count: 7 + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "MyComponent" }); + } + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "EntryComponent"; + } +} +class MyComponent extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__title = new ObservedPropertyObjectPU(new Model('Hello World'), this, "title"); + this.__count = new ObservedPropertySimplePU(0, this, "count"); + this.increaseBy = 1; + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: MyComponent_Params) { + if (params.title !== undefined) { + this.title = params.title; + } + if (params.count !== undefined) { + this.count = params.count; + } + if (params.increaseBy !== undefined) { + this.increaseBy = params.increaseBy; + } + } + updateStateVars(params: MyComponent_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__title.purgeDependencyOnElmtId(rmElmtId); + this.__count.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__title.aboutToBeDeleted(); + this.__count.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __title: ObservedPropertyObjectPU; + get title() { + return this.__title.get(); + } + set title(newValue: Model) { + this.__title.set(newValue); + } + private __count: ObservedPropertySimplePU; + get count() { + return this.__count.get(); + } + set count(newValue: number) { + this.__count.set(newValue); + } + private increaseBy: number; + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('' + this.title.value); + Text.margin(10); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Click to change title'); + Button.onClick(() => { + // @State变量的更新将触发上面的Text组件内容更新 + this.title.value = this.title.value === 'Hello ArkUI' ? 'Hello World' : 'Hello ArkUI'; + }); + Button.width(300); + Button.margin(10); + }, Button); + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Click to increase count =' + this.count); + Button.onClick(() => { + // @State变量的更新将触发该Button组件的内容更新 + this.count += this.increaseBy; + }); + Button.width(300); + Button.margin(10); + }, Button); + Button.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +registerNamedRoute(() => new EntryComponent(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/state.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/state.ts new file mode 100644 index 000000000..15828fbd4 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/state.ts @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +class Model { + public value: string; + + constructor(value: string) { + this.value = value; + } +} + +@Entry +@Component +struct EntryComponent { + build() { + Column() { + // 此处指定的参数都将在初始渲染时覆盖本地定义的默认值,并不是所有的参数都需要从父组件初始化 + MyComponent({ count: 1, increaseBy: 2 }) + .width(300) + MyComponent({ title: new Model('Hello World 2'), count: 7 }) + } + } +} + +@Component +struct MyComponent { + @State title: Model = new Model('Hello World'); + @State count: number = 0; + increaseBy: number = 1; + + build() { + Column() { + Text('' + this.title.value) + .margin(10) + Button('Click to change title') + .onClick(() => { + // @State变量的更新将触发上面的Text组件内容更新 + this.title.value = this.title.value === 'Hello ArkUI' ? 'Hello World' : 'Hello ArkUI'; + }) + .width(300) + .margin(10) + + Button('Click to increase count =' + this.count) + .onClick(() => { + // @State变量的更新将触发该Button组件的内容更新 + this.count += this.increaseBy; + }) + .width(300) + .margin(10) + } + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +interface MyComponent_Params { + title?: Model; + count?: number; + increaseBy?: number; +} +interface EntryComponent_Params { +} +class Model { + public value: string; + constructor(value: string) { + this.value = value; + } +} +class EntryComponent extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: EntryComponent_Params) { + } + updateStateVars(params: EntryComponent_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); + __Common__.width(300); + }, __Common__); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new + // 此处指定的参数都将在初始渲染时覆盖本地定义的默认值,并不是所有的参数都需要从父组件初始化 + MyComponent(this, { count: 1, increaseBy: 2 }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 15, col: 7 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + count: 1, + increaseBy: 2 + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "MyComponent" }); + } + __Common__.pop(); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new MyComponent(this, { title: new Model('Hello World 2'), count: 7 }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 17, col: 7 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + title: new Model('Hello World 2'), + count: 7 + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "MyComponent" }); + } + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "EntryComponent"; + } +} +class MyComponent extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__title = new ObservedPropertyObjectPU(new Model('Hello World'), this, "title"); + this.__count = new ObservedPropertySimplePU(0, this, "count"); + this.increaseBy = 1; + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: MyComponent_Params) { + if (params.title !== undefined) { + this.title = params.title; + } + if (params.count !== undefined) { + this.count = params.count; + } + if (params.increaseBy !== undefined) { + this.increaseBy = params.increaseBy; + } + } + updateStateVars(params: MyComponent_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__title.purgeDependencyOnElmtId(rmElmtId); + this.__count.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__title.aboutToBeDeleted(); + this.__count.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __title: ObservedPropertyObjectPU; + get title() { + return this.__title.get(); + } + set title(newValue: Model) { + this.__title.set(newValue); + } + private __count: ObservedPropertySimplePU; + get count() { + return this.__count.get(); + } + set count(newValue: number) { + this.__count.set(newValue); + } + private increaseBy: number; + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('' + this.title.value); + Text.margin(10); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Click to change title'); + Button.onClick(() => { + // @State变量的更新将触发上面的Text组件内容更新 + this.title.value = this.title.value === 'Hello ArkUI' ? 'Hello World' : 'Hello ArkUI'; + }); + Button.width(300); + Button.margin(10); + }, Button); + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Click to increase count =' + this.count); + Button.onClick(() => { + // @State变量的更新将触发该Button组件的内容更新 + this.count += this.increaseBy; + }); + Button.width(300); + Button.margin(10); + }, Button); + Button.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +registerNamedRoute(() => new EntryComponent(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; -- Gitee From f5529852ff52f130502a752efffb52131875f2ba Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 17 Jun 2025 00:46:27 +0800 Subject: [PATCH 121/140] =?UTF-8?q?=E6=84=8F=E5=9B=BE=E4=BF=AE=E5=A4=8Dpag?= =?UTF-8?q?e=E8=A3=85=E9=A5=B0=E5=99=A8=E8=A7=A3=E6=9E=90bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/userIntents_parser/parseUserIntents.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index b98525db1..ef9640e03 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -646,13 +646,13 @@ class ParseIntent { if (!ts.isMethodDeclaration(member) || !this.hasModifier(member, ts.SyntaxKind.StaticKeyword)) { continue; } - const decorator: ts.ModifierLike = member.modifiers?.find(m => { - if (!ts.isDecorator(m)) { + const decorator: ts.ModifierLike = member.modifiers?.find(modifier => { + if (!ts.isDecorator(modifier)) { return false; } let decoratorName: string | undefined; - if (ts.isCallExpression(m.expression)) { - decoratorName = `@${decorator.expression.expression.getText()}`; + if (ts.isCallExpression(modifier.expression)) { + decoratorName = `@${modifier.expression.expression.getText()}`; } return decoratorName === decoratorType; }); -- Gitee From 2bcfa4b3ffa98f06aefd61c42bbf23e3ac3e9860 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Tue, 1 Apr 2025 20:46:35 +0800 Subject: [PATCH 122/140] jiangbo91@huawei.com fix $r $rawfile `` Signed-off-by: Bojiang Change-Id: I3dac930d0e4b71a513a007e3b209f4ca3a26d2aa --- compiler/src/process_ui_syntax.ts | 2 +- .../resource/resourceTest.js.sample | 58 +++++++++++++++++++ .../resource/resourceTest.ets | 25 ++++++++ .../test/transform_ut/helpers/pathConfig.ts | 2 + 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 72ec22d69..878b2b929 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -736,7 +736,7 @@ export function isAnimateToOrImmediately(node: ts.Node): boolean { export function processResourceData(node: ts.CallExpression, filePath: string, previewLog: {isAcceleratePreview: boolean, log: LogInfo[]} = {isAcceleratePreview: false, log: []}): ts.Node { - if (ts.isStringLiteral(node.arguments[0])) { + if (ts.isStringLiteral(node.arguments[0]) || ts.isNoSubstitutionTemplateLiteral(node.arguments[0])) { const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.'); const isResourceModule: boolean = resourceData.length && /^\[.*\]$/g.test(resourceData[0]); if (node.expression.getText() === RESOURCE_RAWFILE) { diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample new file mode 100644 index 000000000..f3d898bf4 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022-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. + */ +"use strict"; +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +class Index extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Image.create({ "id": 0, "type": 30000, params: ['foreground.png'], "bundleName": "com.example.application", "moduleName": "application" }); + }, Image); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Image.create({ "id": 0, "type": 30000, params: [`foreground.png`], "bundleName": "com.example.application", "moduleName": "application" }); + }, Image); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName() { + return "Index"; + } +} +registerNamedRoute(() => new Index(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/resource/resourceTest", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest", integratedHsp: "false", moduleType: "followWithHap" }); +//# sourceMappingURL=resourceTest.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets new file mode 100644 index 000000000..57402fbdb --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-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. + */ +// Reusable test +@Entry +@Component +struct Index { + build() { + Row() { + Image($rawfile('foreground.png')) + Image($rawfile(`foreground.png`)) + } + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/pathConfig.ts b/compiler/test/transform_ut/helpers/pathConfig.ts index 936ccfdc3..14a3de177 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -213,6 +213,8 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'v2_component_decorator/reusableV2/reusableV2_initialRender', 'v2_component_decorator/reusableV2/reusableV2_members', 'v2_component_decorator/reusableV2/reusableV2_component_nesting', + + 'resource/resourceTest', ]; export const UT_VALIDATE_PAGES_PREVIEW: string[] = []; -- Gitee From 6017f0b0af0e88f05eeb5330ec920b0684557fce Mon Sep 17 00:00:00 2001 From: chengongping Date: Tue, 17 Jun 2025 22:15:38 +0800 Subject: [PATCH 123/140] add the ut case ui Signed-off-by: chengongping --- .../main/ets/pages/utForCase/appStorage.ts | 201 ++++++++++ .../src/main/ets/pages/utForCase/foreach.ts | 350 +++++++++++++++++ .../main/ets/pages/utForCase/lazyforeach.ts | 325 +++++++++++++++ .../src/main/ets/pages/utForCase/link.ts | 370 ++++++++++++++++++ .../src/main/ets/pages/utForCase/local.ts | 105 +++++ .../src/main/ets/pages/utForCase/prop.ts | 233 +++++++++++ 6 files changed, 1584 insertions(+) create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/appStorage.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/foreach.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/lazyforeach.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/link.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/local.ts create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/prop.ts diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/appStorage.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/appStorage.ts new file mode 100644 index 000000000..de9fa9fca --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/appStorage.ts @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +class Data { + code: number; + + constructor(code: number) { + this.code = code; + } +} + +AppStorage.setOrCreate('PropA', 47); +AppStorage.setOrCreate('PropB', new Data(50)); +let storage = new LocalStorage(); +storage.setOrCreate('LinkA', 48); +storage.setOrCreate('LinkB', new Data(100)); + +@Entry(storage) +@Component +struct Index { + @StorageLink('PropA') storageLink: number = 1; + @LocalStorageLink('LinkA') localStorageLink: number = 1; + @StorageLink('PropB') storageLinkObject: Data = new Data(1); + @LocalStorageLink('LinkB') localStorageLinkObject: Data = new Data(1); + + build() { + Column({ space: 20 }) { + Text('From AppStorage ' + this.storageLink) + .onClick(() => { + this.storageLink += 1; + }) + + Text('From LocalStorage ' + this.localStorageLink) + .onClick(() => { + this.localStorageLink += 1; + }) + + Text('From AppStorage ' + this.storageLinkObject.code) + .onClick(() => { + this.storageLinkObject.code += 1; + }) + + Text('From LocalStorage ' + this.localStorageLinkObject.code) + .onClick(() => { + this.localStorageLinkObject.code += 1; + }) + } + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +interface Index_Params { + storageLink?: number; + localStorageLink?: number; + storageLinkObject?: Data; + localStorageLinkObject?: Data; +} +class Data { + code: number; + constructor(code: number) { + this.code = code; + } +} +AppStorage.setOrCreate('PropA', 47); +AppStorage.setOrCreate('PropB', new Data(50)); +let storage = new LocalStorage(); +storage.setOrCreate('LinkA', 48); +storage.setOrCreate('LinkB', new Data(100)); +class Index extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__storageLink = this.createStorageLink('PropA', 1, "storageLink"); + this.__storageLinkObject = this.createStorageLink('PropB', new Data(1), "storageLinkObject"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: Index_Params) { + } + updateStateVars(params: Index_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__storageLink.purgeDependencyOnElmtId(rmElmtId); + this.__localStorageLink.purgeDependencyOnElmtId(rmElmtId); + this.__storageLinkObject.purgeDependencyOnElmtId(rmElmtId); + this.__localStorageLinkObject.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__storageLink.aboutToBeDeleted(); + this.__localStorageLink.aboutToBeDeleted(); + this.__storageLinkObject.aboutToBeDeleted(); + this.__localStorageLinkObject.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __storageLink: ObservedPropertyAbstractPU; + get storageLink() { + return this.__storageLink.get(); + } + set storageLink(newValue: number) { + this.__storageLink.set(newValue); + } + private __localStorageLink: ObservedPropertyAbstractPU = this.createLocalStorageLink('LinkA', 1, "localStorageLink"); + get localStorageLink() { + return this.__localStorageLink.get(); + } + set localStorageLink(newValue: number) { + this.__localStorageLink.set(newValue); + } + private __storageLinkObject: ObservedPropertyAbstractPU; + get storageLinkObject() { + return this.__storageLinkObject.get(); + } + set storageLinkObject(newValue: Data) { + this.__storageLinkObject.set(newValue); + } + private __localStorageLinkObject: ObservedPropertyAbstractPU = this.createLocalStorageLink('LinkB', new Data(1), "localStorageLinkObject"); + get localStorageLinkObject() { + return this.__localStorageLinkObject.get(); + } + set localStorageLinkObject(newValue: Data) { + this.__localStorageLinkObject.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create({ space: 20 }); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('From AppStorage ' + this.storageLink); + Text.onClick(() => { + this.storageLink += 1; + }); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('From LocalStorage ' + this.localStorageLink); + Text.onClick(() => { + this.localStorageLink += 1; + }); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('From AppStorage ' + this.storageLinkObject.code); + Text.onClick(() => { + this.storageLinkObject.code += 1; + }); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('From LocalStorage ' + this.localStorageLinkObject.code); + Text.onClick(() => { + this.localStorageLinkObject.code += 1; + }); + }, Text); + Text.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "Index"; + } +} +if (storage && storage.routeName != undefined && storage.storage != undefined) { + registerNamedRoute(() => new Index(undefined, {}, storage.useSharedStorage ? LocalStorage.getShared() : storage.storage), storage.routeName, { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +} +else if (storage && storage.routeName != undefined && storage.storage == undefined) { + registerNamedRoute(() => new Index(undefined, {}, storage.useSharedStorage ? LocalStorage.getShared() : storage.storage), storage.routeName, { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +} +else if (storage && storage.routeName == undefined && storage.storage != undefined) { + registerNamedRoute(() => new Index(undefined, {}, storage.useSharedStorage ? LocalStorage.getShared() : storage.storage), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +} +else if (storage && storage.useSharedStorage != undefined) { + registerNamedRoute(() => new Index(undefined, {}, storage.useSharedStorage ? LocalStorage.getShared() : undefined), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +} +else { + registerNamedRoute(() => new Index(undefined, {}, storage), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +} +`; diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/foreach.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/foreach.ts new file mode 100644 index 000000000..ffb98a429 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/foreach.ts @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +@Observed +class Article { + id: string; + title: string; + brief: string; + isLiked: boolean; + likesCount: number; + + constructor(id: string, title: string, brief: string, isLiked: boolean, likesCount: number) { + this.id = id; + this.title = title; + this.brief = brief; + this.isLiked = isLiked; + this.likesCount = likesCount; + } +} + +@Entry +@Component +struct ArticleListView { + @State articleList: Array
= [ + new Article('001', '第0篇文章', '文章简介内容', false, 100), + new Article('002', '第1篇文章', '文章简介内容', false, 100), + new Article('003', '第2篇文章', '文章简介内容', false, 100), + new Article('004', '第4篇文章', '文章简介内容', false, 100), + new Article('005', '第5篇文章', '文章简介内容', false, 100), + new Article('006', '第6篇文章', '文章简介内容', false, 100), + ]; + + build() { + List() { + ForEach(this.articleList, (item: Article) => { + ListItem() { + ArticleCard({ + article: item + }) + .margin({ top: 20 }) + } + }, (item: Article) => item.id) + } + .padding(20) + .scrollBar(BarState.Off) + .backgroundColor(0xF1F3F5) + } +} + +@Component +struct ArticleCard { + @ObjectLink article: Article; + + handleLiked() { + this.article.isLiked = !this.article.isLiked; + this.article.likesCount = this.article.isLiked ? this.article.likesCount + 1 : this.article.likesCount - 1; + } + + build() { + Row() { + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image($r('app.media.icon')) + .width(80) + .height(80) + .margin({ right: 20 }) + + Column() { + Text(this.article.title) + .fontSize(20) + .margin({ bottom: 8 }) + Text(this.article.brief) + .fontSize(16) + .fontColor(Color.Gray) + .margin({ bottom: 8 }) + + Row() { + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image(this.article.isLiked ? $r('app.media.iconLiked') : $r('app.media.iconUnLiked')) + .width(24) + .height(24) + .margin({ right: 8 }) + Text(this.article.likesCount.toString()) + .fontSize(16) + } + .onClick(() => this.handleLiked()) + .justifyContent(FlexAlign.Center) + } + .alignItems(HorizontalAlign.Start) + .width('80%') + .height('100%') + } + .padding(20) + .borderRadius(12) + .backgroundColor('#FFECECEC') + .height(120) + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +interface ArticleCard_Params { + article?: Article; +} +interface ArticleListView_Params { + articleList?: Array
; +} +@Observed +class Article { + id: string; + title: string; + brief: string; + isLiked: boolean; + likesCount: number; + constructor(id: string, title: string, brief: string, isLiked: boolean, likesCount: number) { + this.id = id; + this.title = title; + this.brief = brief; + this.isLiked = isLiked; + this.likesCount = likesCount; + } +} +class ArticleListView extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__articleList = new ObservedPropertyObjectPU([ + new Article('001', '第0篇文章', '文章简介内容', false, 100), + new Article('002', '第1篇文章', '文章简介内容', false, 100), + new Article('003', '第2篇文章', '文章简介内容', false, 100), + new Article('004', '第4篇文章', '文章简介内容', false, 100), + new Article('005', '第5篇文章', '文章简介内容', false, 100), + new Article('006', '第6篇文章', '文章简介内容', false, 100), + ], this, "articleList"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: ArticleListView_Params) { + if (params.articleList !== undefined) { + this.articleList = params.articleList; + } + } + updateStateVars(params: ArticleListView_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__articleList.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__articleList.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __articleList: ObservedPropertyObjectPU>; + get articleList() { + return this.__articleList.get(); + } + set articleList(newValue: Array
) { + this.__articleList.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + List.create(); + List.padding(20); + List.scrollBar(BarState.Off); + List.backgroundColor(0xF1F3F5); + }, List); + this.observeComponentCreation2((elmtId, isInitialRender) => { + ForEach.create(); + const forEachItemGenFunction = _item => { + const item = _item; + { + const itemCreation = (elmtId, isInitialRender) => { + ViewStackProcessor.StartGetAccessRecordingFor(elmtId); + ListItem.create(deepRenderFunction, true); + if (!isInitialRender) { + ListItem.pop(); + } + ViewStackProcessor.StopGetAccessRecording(); + }; + const itemCreation2 = (elmtId, isInitialRender) => { + ListItem.create(deepRenderFunction, true); + }; + const deepRenderFunction = (elmtId, isInitialRender) => { + itemCreation(elmtId, isInitialRender); + this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); + __Common__.margin({ top: 20 }); + }, __Common__); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new ArticleCard(this, { + article: item + }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 34, col: 11 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + article: item + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, { + article: item + }); + } + }, { name: "ArticleCard" }); + } + __Common__.pop(); + ListItem.pop(); + }; + this.observeComponentCreation2(itemCreation2, ListItem); + ListItem.pop(); + } + }; + this.forEachUpdateFunction(elmtId, this.articleList, forEachItemGenFunction, (item: Article) => item.id, false, false); + }, ForEach); + ForEach.pop(); + List.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "ArticleListView"; + } +} +class ArticleCard extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__article = new SynchedPropertyNesedObjectPU(params.article, this, "article"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: ArticleCard_Params) { + this.__article.set(params.article); + } + updateStateVars(params: ArticleCard_Params) { + this.__article.set(params.article); + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__article.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__article.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __article: SynchedPropertyNesedObjectPU
; + get article() { + return this.__article.get(); + } + handleLiked() { + this.article.isLiked = !this.article.isLiked; + this.article.likesCount = this.article.isLiked ? this.article.likesCount + 1 : this.article.likesCount - 1; + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + Row.padding(20); + Row.borderRadius(12); + Row.backgroundColor('#FFECECEC'); + Row.height(120); + Row.width('100%'); + Row.justifyContent(FlexAlign.SpaceBetween); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.create({ "id": 16777225, "type": 20000, params: [], "bundleName": "com.example.myapplication", "moduleName": "entry" }); + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.width(80); + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.height(80); + // 此处'app.media.icon'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.margin({ right: 20 }); + }, Image); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.alignItems(HorizontalAlign.Start); + Column.width('80%'); + Column.height('100%'); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.article.title); + Text.fontSize(20); + Text.margin({ bottom: 8 }); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.article.brief); + Text.fontSize(16); + Text.fontColor(Color.Gray); + Text.margin({ bottom: 8 }); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + Row.onClick(() => this.handleLiked()); + Row.justifyContent(FlexAlign.Center); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.create(this.article.isLiked ? { "id": 16777225, "type": 20000, params: [], "bundleName": "com.example.myapplication", "moduleName": "entry" } : { "id": 16777225, "type": 20000, params: [], "bundleName": "com.example.myapplication", "moduleName": "entry" }); + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.width(24); + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.height(24); + // 此处app.media.iconLiked','app.media.iconUnLiked'仅作示例,请开发者自行替换,否则imageSource创建失败会导致后续无法正常执行。 + Image.margin({ right: 8 }); + }, Image); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.article.likesCount.toString()); + Text.fontSize(16); + }, Text); + Text.pop(); + Row.pop(); + Column.pop(); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +registerNamedRoute(() => new ArticleListView(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/lazyforeach.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/lazyforeach.ts new file mode 100644 index 000000000..64e3f2791 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/lazyforeach.ts @@ -0,0 +1,325 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +// BasicDataSource实现了IDataSource接口,用于管理listener监听,以及通知LazyForEach数据更新 +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + private originDataArray: string[] = []; + + public totalCount(): number { + return this.originDataArray.length; + } + + public getData(index: number): string { + return this.originDataArray[index]; + } + + // 该方法为框架侧调用,为LazyForEach组件向其数据源处添加listener监听 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + // 该方法为框架侧调用,为对应的LazyForEach组件在数据源处去除listener监听 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + // 通知LazyForEach组件需要重载所有子组件 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }); + } + + // 通知LazyForEach组件需要在index对应索引处添加子组件 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + // 写法2:listener.onDatasetChange([{type: DataOperationType.ADD, index: index}]); + }); + } + + // 通知LazyForEach组件在index对应索引处数据有变化,需要重建该子组件 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + // 写法2:listener.onDatasetChange([{type: DataOperationType.CHANGE, index: index}]); + }); + } + + // 通知LazyForEach组件需要在index对应索引处删除该子组件 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + // 写法2:listener.onDatasetChange([{type: DataOperationType.DELETE, index: index}]); + }); + } + + // 通知LazyForEach组件将from索引和to索引处的子组件进行交换 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + // 写法2:listener.onDatasetChange( + // [{type: DataOperationType.EXCHANGE, index: {start: from, end: to}}]); + }); + } + + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }); + } +} + +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + public moveDataWithoutNotify(from: number, to: number): void { + let tmp = this.dataArray.splice(from, 1); + this.dataArray.splice(to, 0, tmp[0]); + } + + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} + +@Entry +@Component +struct Parent { + private data: MyDataSource = new MyDataSource(); + + aboutToAppear(): void { + for (let i = 0; i < 100; i++) { + this.data.pushData(i.toString()); + } + } + + build() { + Row() { + List() { + LazyForEach(this.data, (item: string) => { + ListItem() { + Text(item.toString()) + .fontSize(16) + .textAlign(TextAlign.Center) + .size({ height: 100, width: "100%" }) + }.margin(10) + .borderRadius(10) + .backgroundColor("#FFFFFFFF") + }, (item: string) => item) + .onMove((from: number, to: number) => { + this.data.moveDataWithoutNotify(from, to); + }) + } + .width('100%') + .height('100%') + .backgroundColor("#FFDCDCDC") + } + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +interface Parent_Params { + data?: MyDataSource; +} +// BasicDataSource实现了IDataSource接口,用于管理listener监听,以及通知LazyForEach数据更新 +class BasicDataSource implements IDataSource { + private listeners: DataChangeListener[] = []; + private originDataArray: string[] = []; + public totalCount(): number { + return this.originDataArray.length; + } + public getData(index: number): string { + return this.originDataArray[index]; + } + // 该方法为框架侧调用,为LazyForEach组件向其数据源处添加listener监听 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + // 该方法为框架侧调用,为对应的LazyForEach组件在数据源处去除listener监听 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + // 通知LazyForEach组件需要重载所有子组件 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }); + } + // 通知LazyForEach组件需要在index对应索引处添加子组件 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + // 写法2:listener.onDatasetChange([{type: DataOperationType.ADD, index: index}]); + }); + } + // 通知LazyForEach组件在index对应索引处数据有变化,需要重建该子组件 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + // 写法2:listener.onDatasetChange([{type: DataOperationType.CHANGE, index: index}]); + }); + } + // 通知LazyForEach组件需要在index对应索引处删除该子组件 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + // 写法2:listener.onDatasetChange([{type: DataOperationType.DELETE, index: index}]); + }); + } + // 通知LazyForEach组件将from索引和to索引处的子组件进行交换 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMove(from, to); + // 写法2:listener.onDatasetChange( + // [{type: DataOperationType.EXCHANGE, index: {start: from, end: to}}]); + }); + } + notifyDatasetChange(operations: DataOperation[]): void { + this.listeners.forEach(listener => { + listener.onDatasetChange(operations); + }); + } +} +class MyDataSource extends BasicDataSource { + private dataArray: string[] = []; + public totalCount(): number { + return this.dataArray.length; + } + public getData(index: number): string { + return this.dataArray[index]; + } + public moveDataWithoutNotify(from: number, to: number): void { + let tmp = this.dataArray.splice(from, 1); + this.dataArray.splice(to, 0, tmp[0]); + } + public pushData(data: string): void { + this.dataArray.push(data); + this.notifyDataAdd(this.dataArray.length - 1); + } +} +class Parent extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.data = new MyDataSource(); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: Parent_Params) { + if (params.data !== undefined) { + this.data = params.data; + } + } + updateStateVars(params: Parent_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private data: MyDataSource; + aboutToAppear(): void { + for (let i = 0; i < 100; i++) { + this.data.pushData(i.toString()); + } + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + List.create(); + List.width('100%'); + List.height('100%'); + List.backgroundColor("#FFDCDCDC"); + }, List); + { + const __lazyForEachItemGenFunction = _item => { + const item = _item; + { + const itemCreation2 = (elmtId, isInitialRender) => { + ListItem.create(() => { }, false); + ListItem.margin(10); + ListItem.borderRadius(10); + ListItem.backgroundColor("#FFFFFFFF"); + }; + const observedDeepRender = () => { + this.observeComponentCreation2(itemCreation2, ListItem); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(item.toString()); + Text.fontSize(16); + Text.textAlign(TextAlign.Center); + Text.size({ height: 100, width: "100%" }); + }, Text); + Text.pop(); + ListItem.pop(); + }; + observedDeepRender(); + } + }; + const __lazyForEachItemIdFunc = (item: string) => item; + LazyForEach.create("1", this, this.data, __lazyForEachItemGenFunction, __lazyForEachItemIdFunc); + LazyForEach.onMove((from: number, to: number) => { + this.data.moveDataWithoutNotify(from, to); + }); + LazyForEach.pop(); + } + List.pop(); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "Parent"; + } +} +registerNamedRoute(() => new Parent(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/link.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/link.ts new file mode 100644 index 000000000..792d0877e --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/link.ts @@ -0,0 +1,370 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +class GreenButtonState { + width: number = 0; + + constructor(width: number) { + this.width = width; + } +} + +@Component +struct GreenButton { + @Link greenButtonState: GreenButtonState; + + build() { + Button('Green Button') + .width(this.greenButtonState.width) + .height(40) + .backgroundColor('#64bb5c') + .fontColor('#FFFFFF') + .onClick(() => { + if (this.greenButtonState.width < 700) { + // 更新class的属性,变化可以被观察到同步回父组件 + this.greenButtonState.width += 60; + } else { + // 更新class,变化可以被观察到同步回父组件 + this.greenButtonState = new GreenButtonState(180); + } + }) + } +} + +@Component +struct YellowButton { + @Link yellowButtonState: number; + + build() { + Button('Yellow Button') + .width(this.yellowButtonState) + .height(40) + .backgroundColor('#f7ce00') + .fontColor('#FFFFFF') + .onClick(() => { + // 子组件的简单类型可以同步回父组件 + this.yellowButtonState += 40.0; + }) + } +} + +@Entry +@Component +struct ShufflingContainer { + @State greenButtonState: GreenButtonState = new GreenButtonState(180); + @State yellowButtonProp: number = 180; + + build() { + Column() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { + // 简单类型从父组件@State向子组件@Link数据同步 + Button('Parent View: Set yellowButton') + .width(this.yellowButtonProp) + .height(40) + .margin(12) + .fontColor('#FFFFFF') + .onClick(() => { + this.yellowButtonProp = (this.yellowButtonProp < 700) ? this.yellowButtonProp + 40 : 100; + }) + // class类型从父组件@State向子组件@Link数据同步 + Button('Parent View: Set GreenButton') + .width(this.greenButtonState.width) + .height(40) + .margin(12) + .fontColor('#FFFFFF') + .onClick(() => { + this.greenButtonState.width = (this.greenButtonState.width < 700) ? this.greenButtonState.width + 100 : 100; + }) + // class类型初始化@Link + GreenButton({ greenButtonState: this.greenButtonState }).margin(12) + // 简单类型初始化@Link + YellowButton({ yellowButtonState: this.yellowButtonProp }).margin(12) + } + } + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +interface ShufflingContainer_Params { + greenButtonState?: GreenButtonState; + yellowButtonProp?: number; +} +interface YellowButton_Params { + yellowButtonState?: number; +} +interface GreenButton_Params { + greenButtonState?: GreenButtonState; +} +class GreenButtonState { + width: number = 0; + constructor(width: number) { + this.width = width; + } +} +class GreenButton extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__greenButtonState = new SynchedPropertyObjectTwoWayPU(params.greenButtonState, this, "greenButtonState"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: GreenButton_Params) { + } + updateStateVars(params: GreenButton_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__greenButtonState.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__greenButtonState.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __greenButtonState: SynchedPropertySimpleOneWayPU; + get greenButtonState() { + return this.__greenButtonState.get(); + } + set greenButtonState(newValue: GreenButtonState) { + this.__greenButtonState.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Green Button'); + Button.width(this.greenButtonState.width); + Button.height(40); + Button.backgroundColor('#64bb5c'); + Button.fontColor('#FFFFFF'); + Button.onClick(() => { + if (this.greenButtonState.width < 700) { + // 更新class的属性,变化可以被观察到同步回父组件 + this.greenButtonState.width += 60; + } + else { + // 更新class,变化可以被观察到同步回父组件 + this.greenButtonState = new GreenButtonState(180); + } + }); + }, Button); + Button.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +class YellowButton extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__yellowButtonState = new SynchedPropertySimpleTwoWayPU(params.yellowButtonState, this, "yellowButtonState"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: YellowButton_Params) { + } + updateStateVars(params: YellowButton_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__yellowButtonState.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__yellowButtonState.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __yellowButtonState: SynchedPropertySimpleTwoWayPU; + get yellowButtonState() { + return this.__yellowButtonState.get(); + } + set yellowButtonState(newValue: number) { + this.__yellowButtonState.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Yellow Button'); + Button.width(this.yellowButtonState); + Button.height(40); + Button.backgroundColor('#f7ce00'); + Button.fontColor('#FFFFFF'); + Button.onClick(() => { + // 子组件的简单类型可以同步回父组件 + this.yellowButtonState += 40.0; + }); + }, Button); + Button.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +class ShufflingContainer extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__greenButtonState = new ObservedPropertyObjectPU(new GreenButtonState(180), this, "greenButtonState"); + this.__yellowButtonProp = new ObservedPropertySimplePU(180, this, "yellowButtonProp"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: ShufflingContainer_Params) { + if (params.greenButtonState !== undefined) { + this.greenButtonState = params.greenButtonState; + } + if (params.yellowButtonProp !== undefined) { + this.yellowButtonProp = params.yellowButtonProp; + } + } + updateStateVars(params: ShufflingContainer_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__greenButtonState.purgeDependencyOnElmtId(rmElmtId); + this.__yellowButtonProp.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__greenButtonState.aboutToBeDeleted(); + this.__yellowButtonProp.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __greenButtonState: ObservedPropertyObjectPU; + get greenButtonState() { + return this.__greenButtonState.get(); + } + set greenButtonState(newValue: GreenButtonState) { + this.__greenButtonState.set(newValue); + } + private __yellowButtonProp: ObservedPropertySimplePU; + get yellowButtonProp() { + return this.__yellowButtonProp.get(); + } + set yellowButtonProp(newValue: number) { + this.__yellowButtonProp.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }); + }, Flex); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // 简单类型从父组件@State向子组件@Link数据同步 + Button.createWithLabel('Parent View: Set yellowButton'); + // 简单类型从父组件@State向子组件@Link数据同步 + Button.width(this.yellowButtonProp); + // 简单类型从父组件@State向子组件@Link数据同步 + Button.height(40); + // 简单类型从父组件@State向子组件@Link数据同步 + Button.margin(12); + // 简单类型从父组件@State向子组件@Link数据同步 + Button.fontColor('#FFFFFF'); + // 简单类型从父组件@State向子组件@Link数据同步 + Button.onClick(() => { + this.yellowButtonProp = (this.yellowButtonProp < 700) ? this.yellowButtonProp + 40 : 100; + }); + }, Button); + // 简单类型从父组件@State向子组件@Link数据同步 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + // class类型从父组件@State向子组件@Link数据同步 + Button.createWithLabel('Parent View: Set GreenButton'); + // class类型从父组件@State向子组件@Link数据同步 + Button.width(this.greenButtonState.width); + // class类型从父组件@State向子组件@Link数据同步 + Button.height(40); + // class类型从父组件@State向子组件@Link数据同步 + Button.margin(12); + // class类型从父组件@State向子组件@Link数据同步 + Button.fontColor('#FFFFFF'); + // class类型从父组件@State向子组件@Link数据同步 + Button.onClick(() => { + this.greenButtonState.width = (this.greenButtonState.width < 700) ? this.greenButtonState.width + 100 : 100; + }); + }, Button); + // class类型从父组件@State向子组件@Link数据同步 + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); + __Common__.margin(12); + }, __Common__); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new + // class类型初始化@Link + GreenButton(this, { greenButtonState: this.__greenButtonState }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 76, col: 9 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + greenButtonState: this.greenButtonState + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "GreenButton" }); + } + __Common__.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); + __Common__.margin(12); + }, __Common__); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new + // 简单类型初始化@Link + YellowButton(this, { yellowButtonState: this.__yellowButtonProp }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 78, col: 9 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + yellowButtonState: this.yellowButtonProp + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, {}); + } + }, { name: "YellowButton" }); + } + __Common__.pop(); + Flex.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "ShufflingContainer"; + } +} +registerNamedRoute(() => new ShufflingContainer(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/local.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/local.ts new file mode 100644 index 000000000..3f336b11a --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/local.ts @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +@ObservedV2 +class Info { + @Trace name: string; + @Trace age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } +} +@Entry +@ComponentV2 +struct Index { + info: Info = new Info("Tom", 25); + @Local localInfo: Info = new Info("Tom", 25); + build() { + Column() { + Text('info: ' + this.info.name + '-' + this.info.age) // Text1 + Text('localInfo: ' + this.localInfo.name + '-' + this.localInfo.age) // Text2 + Button("change info&localInfo") + .onClick(() => { + this.info = new Info("Lucy", 18); // Text1不会刷新 + this.localInfo = new Info("Lucy", 18); // Text2会刷新 + }) + } + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +@ObservedV2 +class Info { + @Trace + name: string; + @Trace + age: number; + constructor(name: string, age: number) { + this.name = name; + this.age = age; + } +} +class Index extends ViewV2 { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda, extraInfo) { + super(parent, elmtId, extraInfo); + this.info = new Info("Tom", 25); + this.localInfo = new Info("Tom", 25); + this.finalizeConstruction(); + } + public resetStateVarsOnReuse(params: Object): void { + this.localInfo = new Info("Tom", 25); + } + info: Info; + @Local + localInfo: Info; + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('info: ' + this.info.name + '-' + this.info.age); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('localInfo: ' + this.localInfo.name + '-' + this.localInfo.age); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel("change info&localInfo"); + Button.onClick(() => { + this.info = new Info("Lucy", 18); // Text1不会刷新 + this.localInfo = new Info("Lucy", 18); // Text2会刷新 + }); + }, Button); + Button.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "Index"; + } +} +registerNamedRoute(() => new Index(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/prop.ts b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/prop.ts new file mode 100644 index 000000000..e2ea93a4e --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForCase/prop.ts @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2025 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. + */ + +exports.source = +` +@Component +struct Child { + @Prop message: Set = new Set([0, 1, 2, 3, 4]); + + build() { + Column() { + ForEach(Array.from(this.message.entries()), (item: [number, string]) => { + Text('' + item[0]).fontSize(30) + Divider() + }) + Button('init set').onClick(() => { + this.message = new Set([0, 1, 2, 3, 4]); + }) + Button('set new one').onClick(() => { + this.message.add(5); + }) + Button('clear').onClick(() => { + this.message.clear(); + }) + Button('delete the first one').onClick(() => { + this.message.delete(0); + }) + } + .width('100%') + } +} + + +@Entry +@Component +struct SetSample { + @State message: Set = new Set([0, 1, 2, 3, 4]); + + build() { + Row() { + Column() { + Child({ message: this.message }) + } + .width('100%') + } + .height('100%') + } +} +`; + +exports.expectResult = +` +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +interface SetSample_Params { + message?: Set; +} +interface Child_Params { + message?: Set; +} +class Child extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__message = new SynchedPropertyObjectOneWayPU(params.message, this, "message"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: Child_Params) { + if (params.message === undefined) { + this.__message.set(new Set([0, 1, 2, 3, 4])); + } + } + updateStateVars(params: Child_Params) { + this.__message.reset(params.message); + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__message.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__message.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __message: SynchedPropertySimpleOneWayPU>; + get message() { + return this.__message.get(); + } + set message(newValue: Set) { + this.__message.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.width('100%'); + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + ForEach.create(); + const forEachItemGenFunction = _item => { + const item = _item; + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('' + item[0]); + Text.fontSize(30); + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); + }, Divider); + }; + this.forEachUpdateFunction(elmtId, Array.from(this.message.entries()), forEachItemGenFunction); + }, ForEach); + ForEach.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('init set'); + Button.onClick(() => { + this.message = new Set([0, 1, 2, 3, 4]); + }); + }, Button); + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('set new one'); + Button.onClick(() => { + this.message.add(5); + }); + }, Button); + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('clear'); + Button.onClick(() => { + this.message.clear(); + }); + }, Button); + Button.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('delete the first one'); + Button.onClick(() => { + this.message.delete(0); + }); + }, Button); + Button.pop(); + Column.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +class SetSample extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.__message = new ObservedPropertyObjectPU(new Set([0, 1, 2, 3, 4]), this, "message"); + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params: SetSample_Params) { + if (params.message !== undefined) { + this.message = params.message; + } + } + updateStateVars(params: SetSample_Params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__message.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__message.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + private __message: ObservedPropertyObjectPU>; + get message() { + return this.__message.get(); + } + set message(newValue: Set) { + this.__message.set(newValue); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + Row.height('100%'); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.width('100%'); + }, Column); + { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + let componentCall = new Child(this, { message: this.message }, undefined, elmtId, () => { }, { page: "entry/src/main/ets/pages/Index.ets", line: 37, col: 9 }); + ViewPU.create(componentCall); + let paramsLambda = () => { + return { + message: this.message + }; + }; + componentCall.paramsGenerator_ = paramsLambda; + } + else { + this.updateStateVarsOfChildByElmtId(elmtId, { + message: this.message + }); + } + }, { name: "Child" }); + } + Column.pop(); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName(): string { + return "SetSample"; + } +} +registerNamedRoute(() => new SetSample(undefined, {}), "", { bundleName: "com.example.myapplication", moduleName: "entry", pagePath: "pages/Index", pageFullPath: "entry/src/main/ets/pages/Index", integratedHsp: "false", moduleType: "followWithHap" }); +`; -- Gitee From c606fd8522ea59e8910ae609d7cdbe651331af29 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Wed, 18 Jun 2025 11:12:49 +0800 Subject: [PATCH 124/140] jiangbo91@huawei.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `` check 等级修改 Signed-off-by: Bojiang Change-Id: Ibdebd0c8bd2a15c950bc55e8f646265220208da7 --- compiler/src/process_ui_syntax.ts | 43 +++++++++++++++++-------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 878b2b929..16202d2da 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -736,18 +736,22 @@ export function isAnimateToOrImmediately(node: ts.Node): boolean { export function processResourceData(node: ts.CallExpression, filePath: string, previewLog: {isAcceleratePreview: boolean, log: LogInfo[]} = {isAcceleratePreview: false, log: []}): ts.Node { - if (ts.isStringLiteral(node.arguments[0]) || ts.isNoSubstitutionTemplateLiteral(node.arguments[0])) { + let isTemplateString: boolean = false; + if (ts.isNoSubstitutionTemplateLiteral(node.arguments[0])) { + isTemplateString = true; + } + if (ts.isStringLiteral(node.arguments[0]) || isTemplateString) { const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.'); const isResourceModule: boolean = resourceData.length && /^\[.*\]$/g.test(resourceData[0]); if (node.expression.getText() === RESOURCE_RAWFILE) { - isResourcefile(node, previewLog, isResourceModule); + isResourcefile(node, previewLog, isResourceModule, isTemplateString); if (resourceData && resourceData[0] && isResourceModule) { return createResourceParam(-1, RESOURCE_TYPE.rawfile, [node.arguments[0]], resourceData[0], true); } else { return createResourceParam(0, RESOURCE_TYPE.rawfile, [node.arguments[0]], '', false); } } else { - return getResourceDataNode(node, previewLog, resourceData, isResourceModule, filePath); + return getResourceDataNode(node, previewLog, resourceData, isResourceModule, filePath, isTemplateString); } } else if (node.expression.getText() === RESOURCE && node.arguments && node.arguments.length) { resourcePreviewMessage(previewLog); @@ -769,14 +773,14 @@ function resourcePreviewMessage(previewLog: {isAcceleratePreview: boolean, log: } } -function getResourceDataNode(node: ts.CallExpression, - previewLog: {isAcceleratePreview: boolean, log: LogInfo[]}, resourceData: string[], isResourceModule: boolean, filePath: string): ts.Node { +function getResourceDataNode(node: ts.CallExpression, previewLog: {isAcceleratePreview: boolean, log: LogInfo[]}, + resourceData: string[], isResourceModule: boolean, filePath: string, isTemplateString: boolean): ts.Node { let resourceValue: number; - if (preCheckResourceData(resourceData, resources, node.arguments[0].getStart(), previewLog, isResourceModule, filePath)) { + if (preCheckResourceData(resourceData, resources, node.arguments[0].getStart(), previewLog, isResourceModule, filePath, isTemplateString)) { let resourceType: number = RESOURCE_TYPE[resourceData[1]]; if (resourceType === undefined && !previewLog.isAcceleratePreview) { transformLog.errors.push({ - type: LogType.ERROR, + type: isTemplateString ? LogType.WARN : LogType.ERROR, message: `The resource type '${resourceData[1]}' is not supported.`, pos: node.getStart(), code: '10906334' @@ -796,11 +800,12 @@ function getResourceDataNode(node: ts.CallExpression, return node; } -function isResourcefile(node: ts.CallExpression, previewLog: {isAcceleratePreview: boolean, log: LogInfo[]}, isResourceModule: boolean): void { +function isResourcefile(node: ts.CallExpression, previewLog: {isAcceleratePreview: boolean, log: LogInfo[]}, isResourceModule: boolean, + isTemplateString: boolean): void { if (!isResourceModule && process.env.rawFileResource && !storedFileInfo.resourcesArr.has(node.arguments[0].text) && !previewLog.isAcceleratePreview && process.env.compileMode === 'moduleJson') { transformLog.errors.push({ - type: LogType.ERROR, + type: isTemplateString ? LogType.WARN : LogType.ERROR, message: `No such '${node.arguments[0].text}' resource in current module.`, pos: node.getStart(), code: '10904333' @@ -906,19 +911,19 @@ function createResourceParam(resourceValue: number, resourceType: number, argsAr } function preCheckResourceData(resourceData: string[], resources: object, pos: number, - previewLog: {isAcceleratePreview: boolean, log: LogInfo[]}, isResourceModule: boolean, filePath: string): boolean { + previewLog: {isAcceleratePreview: boolean, log: LogInfo[]}, isResourceModule: boolean, filePath: string, isTemplateString: boolean): boolean { if (previewLog.isAcceleratePreview) { - return validateResourceData(resourceData, resources, pos, previewLog.log, true, isResourceModule, filePath); + return validateResourceData(resourceData, resources, pos, previewLog.log, true, isResourceModule, filePath, isTemplateString); } else { - return validateResourceData(resourceData, resources, pos, transformLog.errors, false, isResourceModule, filePath); + return validateResourceData(resourceData, resources, pos, transformLog.errors, false, isResourceModule, filePath, isTemplateString); } } function validateResourceData(resourceData: string[], resources: object, pos: number, log: LogInfo[], isAcceleratePreview: boolean, - isResourceModule: boolean, filePath: string): boolean { + isResourceModule: boolean, filePath: string, isTemplateString: boolean): boolean { if (resourceData.length !== 3) { log.push({ - type: LogType.ERROR, + type: isTemplateString ? LogType.WARN : LogType.ERROR, message: `Invalid resource file parameter. Enter a value in the format of 'xxx.yyy.zzz'.`, pos, code: '10905332' @@ -930,20 +935,20 @@ function validateResourceData(resourceData: string[], resources: object, pos: nu if (isResourceModule) { if (/^\[.*\]$/.test(resourceData[0]) && projectConfig.hspResourcesMap) { const resourceDataFirst: string = resourceData[0].replace(/^\[/, '').replace(/\]$/, '').trim(); - return resourceCheck(resourceData, resources, pos, log, true, resourceDataFirst, false); + return resourceCheck(resourceData, resources, pos, log, true, resourceDataFirst, false, isTemplateString); } else { - return resourceCheck(resourceData, resources, pos, log, false, resourceData[0], true); + return resourceCheck(resourceData, resources, pos, log, false, resourceData[0], true, isTemplateString); } } else { - return resourceCheck(resourceData, resources, pos, log, false, resourceData[0], false); + return resourceCheck(resourceData, resources, pos, log, false, resourceData[0], false, isTemplateString); } } return false; } function resourceCheck(resourceData: string[], resources: object, pos: number, log: LogInfo[], isHspResourceModule: boolean, - resourceDataFirst: string, faOrNoHspResourcesMap: boolean): boolean { - const logType: LogType = isHspResourceModule ? LogType.WARN : LogType.ERROR; + resourceDataFirst: string, faOrNoHspResourcesMap: boolean, isTemplateString: boolean): boolean { + const logType: LogType = isHspResourceModule || isTemplateString ? LogType.WARN : LogType.ERROR; if (!faOrNoHspResourcesMap && !resources[resourceDataFirst]) { log.push({ type: logType, -- Gitee From 3759ddcb2ca4df7051c3409b54b5a7c03a953f7f Mon Sep 17 00:00:00 2001 From: shitao Date: Wed, 18 Jun 2025 10:51:25 +0800 Subject: [PATCH 125/140] Time sequence error Issue: ICFYQL Signed-off-by: shitao Change-Id: I1c574453d2a63810fb5349e0511362e1c340f619 --- .../ark_compiler/generate_sourcemap.ts | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts index 3b9d3e092..3af645551 100644 --- a/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts +++ b/compiler/src/fast_build/ark_compiler/generate_sourcemap.ts @@ -117,25 +117,6 @@ export class SourceMapGenerator { SourceMapGenerator.instance.isCompileSingle = SourceMapGenerator.instance.isNewSourceMap && SourceMapGenerator.instance.projectConfig.singleFileEmit && isShouldSourceMap; - if (isShouldSourceMap && SourceMapGenerator.instance.isNewSourceMap) { - if (fs.existsSync(SourceMapGenerator.instance.sourceMapPath)) { - fs.unlinkSync(SourceMapGenerator.instance.sourceMapPath); - } - if (fs.existsSync(SourceMapGenerator.instance.sourceMapPathTmp)) { - fs.unlinkSync(SourceMapGenerator.instance.sourceMapPathTmp); - } - - const sourceMapPathDir: string = path.dirname(SourceMapGenerator.instance.sourceMapPath); - if (!fs.existsSync(sourceMapPathDir)) { - fs.mkdirSync(sourceMapPathDir, { recursive: true }); - } - - const sourceMapPathTmpDir: string = path.dirname(SourceMapGenerator.instance.sourceMapPathTmp); - if (!fs.existsSync(sourceMapPathTmpDir)) { - fs.mkdirSync(sourceMapPathTmpDir, { recursive: true }); - } - } - if (SourceMapGenerator.instance.projectConfig.hotReload) { isShouldSourceMap = false; } @@ -265,6 +246,13 @@ export class SourceMapGenerator { public writeOrigin(content: string): void { if (!this.originFd) { + if (fs.existsSync(this.sourceMapPath)) { + fs.unlinkSync(this.sourceMapPath); + } + const sourceMapPathDir: string = path.dirname(this.sourceMapPath); + if (!fs.existsSync(sourceMapPathDir)) { + fs.mkdirSync(sourceMapPathDir, { recursive: true }); + } this.originFd = fs.openSync(this.sourceMapPath, 'a'); } fs.appendFileSync(this.originFd, content, { encoding: 'utf8' }); @@ -272,6 +260,13 @@ export class SourceMapGenerator { public writeTemp(content: string): void { if (!this.tempFd) { + if (fs.existsSync(this.sourceMapPathTmp)) { + fs.unlinkSync(this.sourceMapPathTmp); + } + const sourceMapPathTmpDir: string = path.dirname(this.sourceMapPathTmp); + if (!fs.existsSync(sourceMapPathTmpDir)) { + fs.mkdirSync(sourceMapPathTmpDir, { recursive: true }); + } this.tempFd = fs.openSync(this.sourceMapPathTmp, 'a'); } fs.appendFileSync(this.tempFd, content, { encoding: 'utf8' }); -- Gitee From 4ba672f831aad09de819bad50752cefdccf089f3 Mon Sep 17 00:00:00 2001 From: zcdqs Date: Thu, 19 Jun 2025 11:12:48 +0800 Subject: [PATCH 126/140] add syncLoad for list grid waterflow Signed-off-by: zcdqs --- compiler/components/grid.json | 2 +- compiler/components/list.json | 2 +- compiler/components/water_flow.json | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/components/grid.json b/compiler/components/grid.json index c7a84af18..4a1c945f4 100644 --- a/compiler/components/grid.json +++ b/compiler/components/grid.json @@ -9,6 +9,6 @@ "onScrollBarUpdate", "enableScrollInteraction", "fadingEdge", "onScrollStart", "onScroll", "onScrollStop", "onWillScroll", "onDidScroll", "cachedCount", "nestedScroll", "friction", "alignItems", "onReachStart", "onReachEnd", "onScrollFrameBegin", "flingSpeedLimit", - "clipContent", "backToTop", "focusWrapMode" + "clipContent", "backToTop", "focusWrapMode", "syncLoad" ] } diff --git a/compiler/components/list.json b/compiler/components/list.json index eaf8e120e..b4736f4ae 100644 --- a/compiler/components/list.json +++ b/compiler/components/list.json @@ -9,6 +9,6 @@ "alignListItem", "nestedScroll", "friction", "contentStartOffset", "contentEndOffset", "childrenMainSize", "maintainVisibleContentPosition", "onScrollFrameBegin", "onScrollStart", "onScrollVisibleContentChange", "flingSpeedLimit", "clipContent", "onWillScroll", "onDidScroll", "scrollBarColor", "scrollBarWidth", "backToTop", - "stackFromEnd", "focusWrapMode" + "stackFromEnd", "focusWrapMode", "syncLoad" ] } diff --git a/compiler/components/water_flow.json b/compiler/components/water_flow.json index cef00d053..6ed544ac3 100644 --- a/compiler/components/water_flow.json +++ b/compiler/components/water_flow.json @@ -31,6 +31,7 @@ "onWillScroll", "onDidScroll", "clipContent", - "backToTop" + "backToTop", + "syncLoad" ] } -- Gitee From d9b41b2f59c65c2bb7a6a31f053623270039fea1 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Thu, 19 Jun 2025 16:06:53 +0800 Subject: [PATCH 127/140] =?UTF-8?q?parameters=E5=8F=82=E6=95=B0=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/userIntents_parser/intentType.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/userIntents_parser/intentType.ts b/compiler/src/userIntents_parser/intentType.ts index a29d16a24..9ac1f7fdf 100644 --- a/compiler/src/userIntents_parser/intentType.ts +++ b/compiler/src/userIntents_parser/intentType.ts @@ -16,6 +16,7 @@ import ts from 'typescript'; import parseIntent from './parseUserIntents'; import Ajv from 'ajv'; +import json5 from 'json5'; const ajv = new Ajv({allErrors: true}); @@ -125,7 +126,7 @@ function validateParameters(v: ts.Expression): boolean { const initializer = ts.isIdentifier(v) ? parseIntent.checker.getSymbolAtLocation(v)?.valueDeclaration?.initializer : v; - return ts.isObjectLiteralExpression(initializer) && ajv.compile(JSON.parse(initializer.getText())); + return ts.isObjectLiteralExpression(initializer) && ajv.compile(json5.parse(initializer.getText())); } catch { return false; } -- Gitee From c56fe01fef5bef56e0029e19e0ce575516270c60 Mon Sep 17 00:00:00 2001 From: oh_ci Date: Fri, 20 Jun 2025 01:57:55 +0000 Subject: [PATCH 128/140] update .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md. Signed-off-by: oh_ci --- .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md index 352170fc9..cb1268e32 100644 --- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -25,3 +25,8 @@ ##### **四、补充测试** 请说明已执行的其他测试项及其结果。 + +### L0新增用例自检结果 +- [ ] 是,有新增L0用例,且完成自检 +- [ ] 否 + -- Gitee From da708b5b74d0f6a223100d1f3d59a41d5f4bd92d Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Fri, 13 Jun 2025 16:46:29 +0800 Subject: [PATCH 129/140] =?UTF-8?q?=E4=B8=8B=E6=B2=89=E6=84=8F=E5=9B=BEtop?= =?UTF-8?q?11-47=E6=B7=BB=E5=8A=A0json=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../schema/ContactCustomerService_1.0.1.json | 33 ++++++ .../schema/CreateNewAccount_1.0.1.json | 33 ++++++ .../schema/FindEBicycle_1.0.2.json | 67 ++++++++++++ .../schema/GetDinningNumber_1.0.1.json | 54 ++++++++++ .../schema/OpenScan_1.0.1.json | 65 +++++++++++ .../schema/PlayAudio_1.0.1.json | 51 +++++++++ .../schema/PlayMusicList_1.0.2.json | 77 +++++++++++++ .../schema/ReadBook_1.0.1.json | 46 ++++++++ .../schema/RechargeCallFee_1.0.1.json | 2 +- .../schema/RechargeTraffic_1.0.1.json | 48 +++++++++ .../schema/ReserveDinningTable_1.0.1.json | 69 ++++++++++++ .../SearchChargingStationLocal_1.0.2.json | 43 ++++++++ .../schema/SearchSmartDeviceLocal_1.0.1.json | 102 ++++++++++++++++++ .../schema/SendLogistics_1.0.1.json | 2 +- .../schema/ViewAirportLargeScreen_1.0.1.json | 53 +++++++++ .../schema/ViewAirportStatus_1.0.1.json | 53 +++++++++ .../schema/ViewAnnualAccount_1.0.1.json | 43 ++++++++ .../schema/ViewBlog_1.0.1.json | 48 +++++++++ .../schema/ViewBuyingHouseInfo_1.0.1.json | 49 +++++++++ .../schema/ViewColumn_1.0.1.json | 49 +++++++++ .../schema/ViewCommodity_1.0.2.json | 50 +++++++++ .../schema/ViewHospital_1.0.1.json | 47 ++++++++ .../schema/ViewLogistics_1.0.1.json | 2 +- .../ViewMarriageRegistration_1.0.1.json | 53 +++++++++ .../ViewMedicalInsuranceCode_1.0.1.json | 33 ++++++ .../ViewMedicalinsurancelnfo_1.0.1.json | 33 ++++++ .../schema/ViewMetroCrowdingInfo_1.0.1.json | 33 ++++++ .../schema/ViewPaymentCodes_1.0.1.json | 33 ++++++ .../schema/ViewPayment_1.0.1.json | 95 ++++++++++++++++ .../schema/ViewPhoneBill_1.0.1.json | 43 ++++++++ .../schema/ViewPhoneNumberBenefits_1.0.1.json | 33 ++++++ .../schema/ViewProvidentFundInfo_1.0.1.json | 33 ++++++ .../schema/ViewRankingList_1.0.1.json | 49 +++++++++ .../schema/ViewRealTimeBusRoute_1.0.2.json | 58 ++++++++++ .../schema/ViewRemain_1.0.1.json | 49 +++++++++ .../schema/ViewRentingHouseInfo_1.0.1.json | 49 +++++++++ .../schema/ViewShoppingGuide_1.0.1.json | 44 ++++++++ .../schema/ViewSmartDevice_1.0.1.json | 53 +++++++++ .../schema/ViewSocialSecurityInfo_1.0.2.json | 52 +++++++++ .../ViewSpecialAdditionalDeduction_1.0.1.json | 48 +++++++++ 40 files changed, 1874 insertions(+), 3 deletions(-) create mode 100644 compiler/src/userIntents_parser/schema/ContactCustomerService_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/CreateNewAccount_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/FindEBicycle_1.0.2.json create mode 100644 compiler/src/userIntents_parser/schema/GetDinningNumber_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/OpenScan_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/PlayAudio_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/PlayMusicList_1.0.2.json create mode 100644 compiler/src/userIntents_parser/schema/ReadBook_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/RechargeTraffic_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ReserveDinningTable_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/SearchChargingStationLocal_1.0.2.json create mode 100644 compiler/src/userIntents_parser/schema/SearchSmartDeviceLocal_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewAirportLargeScreen_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewAirportStatus_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewAnnualAccount_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewBlog_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewBuyingHouseInfo_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewColumn_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewCommodity_1.0.2.json create mode 100644 compiler/src/userIntents_parser/schema/ViewHospital_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewMarriageRegistration_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewMedicalInsuranceCode_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewMedicalinsurancelnfo_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewMetroCrowdingInfo_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewPaymentCodes_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewPayment_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewPhoneBill_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewPhoneNumberBenefits_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewProvidentFundInfo_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewRankingList_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewRealTimeBusRoute_1.0.2.json create mode 100644 compiler/src/userIntents_parser/schema/ViewRemain_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewRentingHouseInfo_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewShoppingGuide_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewSmartDevice_1.0.1.json create mode 100644 compiler/src/userIntents_parser/schema/ViewSocialSecurityInfo_1.0.2.json create mode 100644 compiler/src/userIntents_parser/schema/ViewSpecialAdditionalDeduction_1.0.1.json diff --git a/compiler/src/userIntents_parser/schema/ContactCustomerService_1.0.1.json b/compiler/src/userIntents_parser/schema/ContactCustomerService_1.0.1.json new file mode 100644 index 000000000..0f377b127 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ContactCustomerService_1.0.1.json @@ -0,0 +1,33 @@ +{ + "intentName": "ContactCustomerService", + "intentVersion": "1.0.1", + "llmDescription": "联系客服", + "keywords": ["ContactCustomerService"], + "parameters": { + "type": "object", + "properties": {} + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/CreateNewAccount_1.0.1.json b/compiler/src/userIntents_parser/schema/CreateNewAccount_1.0.1.json new file mode 100644 index 000000000..3213795c7 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/CreateNewAccount_1.0.1.json @@ -0,0 +1,33 @@ +{ + "intentName": "CreateNewAccount", + "intentVersion": "1.0.1", + "llmDescription": "创建新账户", + "keywords": ["CreateNewAccount"], + "parameters": { + "type": "object", + "properties": {} + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/FindEBicycle_1.0.2.json b/compiler/src/userIntents_parser/schema/FindEBicycle_1.0.2.json new file mode 100644 index 000000000..8138b9ad2 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/FindEBicycle_1.0.2.json @@ -0,0 +1,67 @@ +{ + "intentName": "FindEBicycle", + "intentVersion": "1.0.2", + "llmDescription": "寻找电动自行车", + "keywords": ["FindEBicycle"], + "parameters": { + "type": "object", + "properties": {} + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result", + "entityId", + "entityName", + "entityLogoURL", + "entityDisplayName", + "entityDescription", + "statusImageUrl" + ] + }, + "required": [ + "code", + "result", + "entityId", + "entityName", + "entityLogoURL", + "entityDisplayName" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + }, + "entityId": { + "description": "本次执行实例ID。", + "type": "string" + }, + "entityName": { + "description": "执行结果实体名称,固定内容。", + "type": "string" + }, + "entityLogoURL": { + "description": "执行结果主图片。", + "type": "string" + }, + "entityDisplayName": { + "description": "执行结果展示名称(主标题)。", + "type": "string" + }, + "entityDescription": { + "description": "执行结果实体描述。", + "type": "string" + }, + "statusImageUrl": { + "description": "执行结果状态图片。", + "type": "string" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/GetDinningNumber_1.0.1.json b/compiler/src/userIntents_parser/schema/GetDinningNumber_1.0.1.json new file mode 100644 index 000000000..444e5a753 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/GetDinningNumber_1.0.1.json @@ -0,0 +1,54 @@ +{ + "intentName": "GetDinningNumber", + "intentVersion": "1.0.1", + "llmDescription": "取用餐号", + "keywords": ["GetDinningNumber"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "number", + "tableType" + ] + }, + "properties": { + "number": { + "description": "用餐的人数。", + "type": "number" + }, + "tableType": { + "description": "餐桌的类型,支持小、中、大。包间类型,1:小桌型,2:中桌型,3:大桌型,4:包间类型。", + "type": "number", + "enum": [ + 1, + 2, + 3, + 4 + ] + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/OpenScan_1.0.1.json b/compiler/src/userIntents_parser/schema/OpenScan_1.0.1.json new file mode 100644 index 000000000..c0fea902c --- /dev/null +++ b/compiler/src/userIntents_parser/schema/OpenScan_1.0.1.json @@ -0,0 +1,65 @@ +{ + "intentName": "OpenScan", + "intentVersion": "1.0.1", + "llmDescription": "扫码", + "keywords": ["OpenScan"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "scanFunction" + ] + }, + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "string", + "maxLength":64 + }, + "scanFunction": { + "description": "扫描里的功能。", + "type": "string", + "enum": [ + "General", + "RecognizeText", + "RecognizeTranslation", + "RecognizeObjects", + "ScanCertificate", + "ScanIDCard", + "ScanHouseholdRegistrationRecord", + "ScanPassport", + "ScanDriverLicense", + "ScanVehicleLicense", + "ScanBankCard", + "ScanHousePropertyCard", + "ScanBusinessLicense", + "EraseHandwriting" + ] + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/PlayAudio_1.0.1.json b/compiler/src/userIntents_parser/schema/PlayAudio_1.0.1.json new file mode 100644 index 000000000..82ff56b7c --- /dev/null +++ b/compiler/src/userIntents_parser/schema/PlayAudio_1.0.1.json @@ -0,0 +1,51 @@ +{ + "intentName": "PlayAudio", + "intentVersion": "1.0.1", + "llmDescription": "播放有声", + "keywords": ["PlayAudio"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "soundId" + ] + }, + "required": [ + "entityId" + ], + "properties": { + "entityId": { + "description": "数据唯一标识,搜索有声时返回的entityId。", + "type": "string" + }, + "soundId": { + "description": "有声节目ID。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/PlayMusicList_1.0.2.json b/compiler/src/userIntents_parser/schema/PlayMusicList_1.0.2.json new file mode 100644 index 000000000..64a430318 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/PlayMusicList_1.0.2.json @@ -0,0 +1,77 @@ +{ + "intentName": "PlayMusicList", + "intentVersion": "1.0.2", + "llmDescription": "播放歌单", + "keywords": ["PlayMusicList"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "entityGroupId", + "sceneType", + "city" + ] + }, + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "string" + }, + "entityGroupId": { + "description": "用于确定歌单的ui形式(每日私享30首、排行榜、新歌推荐,type=公开的歌单,但UI不同)。", + "type": "string" + }, + "sceneType": { + "description": "场景名称。", + "type": "string", + "enum": [ + "MORNING_SCENE", + "MIDDAY_SCENE", + "EVENNING_SCENE", + "NIGHT_SCENE", + "WEEKEND_SCENE", + "FESTIVAL_SCENE", + "BIRTHDAY_SCENE", + "ANNIEVERSARIE_SCENE", + "DRIVE_SCENE", + "SUBWAY_SCENE", + "TRAVEL_SCENE", + "CITY_SCENE" + ] + }, + "city": { + "description": "城市名。", + "type": "string", + "enum": [ + "北京市", + "沈阳市" + ] + } + } + + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ReadBook_1.0.1.json b/compiler/src/userIntents_parser/schema/ReadBook_1.0.1.json new file mode 100644 index 000000000..41f7f8cae --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ReadBook_1.0.1.json @@ -0,0 +1,46 @@ +{ + "intentName": "ReadBook", + "intentVersion": "1.0.1", + "llmDescription": "阅读书籍", + "keywords": ["ReadBook"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId" + ] + }, + "required": [ + "entityId" + ], + "properties": { + "entityId": { + "description": "数据唯一标识,书籍id。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/RechargeCallFee_1.0.1.json b/compiler/src/userIntents_parser/schema/RechargeCallFee_1.0.1.json index a66663a6e..e562ee1d1 100644 --- a/compiler/src/userIntents_parser/schema/RechargeCallFee_1.0.1.json +++ b/compiler/src/userIntents_parser/schema/RechargeCallFee_1.0.1.json @@ -40,7 +40,7 @@ "type": "number" }, "result": { - "description": "返回结果列表对象(列表Key名默认items),如果无内容则返回空。", + "description": "意图调用返回的数据,如果无数据则返回空。", "type": "object" } } diff --git a/compiler/src/userIntents_parser/schema/RechargeTraffic_1.0.1.json b/compiler/src/userIntents_parser/schema/RechargeTraffic_1.0.1.json new file mode 100644 index 000000000..7835dccae --- /dev/null +++ b/compiler/src/userIntents_parser/schema/RechargeTraffic_1.0.1.json @@ -0,0 +1,48 @@ +{ + "intentName": "RechargeTraffic", + "intentVersion": "1.0.1", + "llmDescription": "充值流量", + "keywords": ["RechargeTraffic"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "phoneNumber", + "amount" + ] + }, + "properties": { + "phoneNumber": { + "description": "手机号。", + "type": "number" + }, + "amount": { + "description": "金额。", + "type": "number" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ReserveDinningTable_1.0.1.json b/compiler/src/userIntents_parser/schema/ReserveDinningTable_1.0.1.json new file mode 100644 index 000000000..3ee7c4ae2 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ReserveDinningTable_1.0.1.json @@ -0,0 +1,69 @@ +{ + "intentName": "ReserveDinningTable", + "intentVersion": "1.0.1", + "llmDescription": "预订餐桌", + "keywords": ["ReserveDinningTable"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "number", + "tableType", + "date", + "timeInterval", + "remark" + ] + }, + "properties": { + "number": { + "description": "用餐的人数。", + "type": "number" + }, + "tableType": { + "description": "餐桌的类型,支持小、中、大。包间类型,1:小桌型,2:中桌型,3:大桌型,4:包间类型。", + "type": "number", + "enum": [ + 1, + 2, + 3, + 4 + ] + }, + "date": { + "description": "用餐的日期。", + "type": "string" + }, + "timeInterval": { + "description": "用餐的时间段,包括开始时间和结束时间的时间戳,字段类型number。", + "type": "array" + }, + "remark": { + "description": "一些用餐的备注,比如用餐人的喜好等。", + "type": "srting" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/SearchChargingStationLocal_1.0.2.json b/compiler/src/userIntents_parser/schema/SearchChargingStationLocal_1.0.2.json new file mode 100644 index 000000000..862bd8c07 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/SearchChargingStationLocal_1.0.2.json @@ -0,0 +1,43 @@ +{ + "intentName": "SearchChargingStationLocal", + "intentVersion": "1.0.2", + "llmDescription": "本地搜索充电桩", + "keywords": ["SearchChargingStationLocal"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "location" + ] + }, + "properties": { + "location": { + "description": "位置信息。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/SearchSmartDeviceLocal_1.0.1.json b/compiler/src/userIntents_parser/schema/SearchSmartDeviceLocal_1.0.1.json new file mode 100644 index 000000000..189030851 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/SearchSmartDeviceLocal_1.0.1.json @@ -0,0 +1,102 @@ +{ + "intentName": "SearchSmartDeviceLocal", + "intentVersion": "1.0.1", + "llmDescription": "搜索智能设备", + "keywords": ["SearchSmartDeviceLocal"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "deviceName", + "deviceType", + "deviceLocation", + "keywords" + ] + }, + "properties": { + "deviceName": { + "description": "设备的名称。", + "type": "string" + }, + "deviceType": { + "description": "设备的类型,摄像头,灯具,不传值默认是摄像头。", + "type": "string", + "enum": [ + "摄像头", + "灯具" + ], + "default": "摄像头" + }, + "deviceLocation": { + "description": "设备的位置。", + "type": "string" + }, + "keywords": { + "description": "搜索关键词。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result", + "entityId", + "entityName", + "deviceName", + "deviceType", + "deviceLocation", + "logoURL" + ] + }, + "required": [ + "code", + "result", + "entityId", + "entityName", + "deviceName", + "deviceType", + "deviceLocation", + "logoURL" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + }, + "entityId": { + "description": "实体唯一ID,这里代表设备的唯一标识。", + "type": "string" + }, + "entityName": { + "description": "固定SmartDevice。", + "type": "string" + }, + "deviceName": { + "description": "设备的名称。", + "type": "string" + }, + "deviceType": { + "description": "设备的类型。", + "type": "string", + "enum":[ + "Camera" + ] + }, + "deviceLocation": { + "description": "设备所在位置。", + "type": "string" + }, + "logoURL": { + "description": "图标,用于小艺对话卡片图标的展示。", + "type": "string" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/SendLogistics_1.0.1.json b/compiler/src/userIntents_parser/schema/SendLogistics_1.0.1.json index 2e5b6a7c9..cafaa6cc7 100644 --- a/compiler/src/userIntents_parser/schema/SendLogistics_1.0.1.json +++ b/compiler/src/userIntents_parser/schema/SendLogistics_1.0.1.json @@ -35,7 +35,7 @@ "type": "number" }, "result": { - "description": "返回结果列表对象(列表Key名默认items),如果无内容则返回空。", + "description": "意图调用返回的数据,如果无数据则返回空。", "type": "object" } } diff --git a/compiler/src/userIntents_parser/schema/ViewAirportLargeScreen_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewAirportLargeScreen_1.0.1.json new file mode 100644 index 000000000..fda6309f5 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewAirportLargeScreen_1.0.1.json @@ -0,0 +1,53 @@ +{ + "intentName": "ViewAirportLargeScreen", + "intentVersion": "1.0.1", + "llmDescription": "查看机场大屏", + "keywords": ["ViewAirportLargeScreen"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "airportCode", + "inOutStatus" + ] + }, + "properties": { + "entityId": { + "description": "实体唯一Id。", + "type": "string" + }, + "airportCode": { + "description": "机场三字码。", + "type": "string" + }, + "inOutStatus": { + "description": "进出港状态,缺省出港:Arr:入港;Dep;出港(缺省值)。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewAirportStatus_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewAirportStatus_1.0.1.json new file mode 100644 index 000000000..652aaeaed --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewAirportStatus_1.0.1.json @@ -0,0 +1,53 @@ +{ + "intentName": "ViewAirportStatus", + "intentVersion": "1.0.1", + "llmDescription": "查看机场实时状态", + "keywords": ["ViewAirportStatus"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "airportCode", + "inOutStatus" + ] + }, + "properties": { + "entityId": { + "description": "机场实体唯一ID。", + "type": "string" + }, + "airportCode": { + "description": "机场三字码。", + "type": "string" + }, + "inOutStatus": { + "description": "进出港状态,缺省出港:Arr:入港;Dep;出港(缺省值)。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewAnnualAccount_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewAnnualAccount_1.0.1.json new file mode 100644 index 000000000..266f6e9d3 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewAnnualAccount_1.0.1.json @@ -0,0 +1,43 @@ +{ + "intentName": "ViewAnnualAccount", + "intentVersion": "1.0.1", + "llmDescription": "查看年度会算", + "keywords": ["ViewAnnualAccount"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "annualTime" + ] + }, + "properties": { + "annualTime": { + "description": "年度时间,缺省时默认去年。", + "type": "number" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewBlog_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewBlog_1.0.1.json new file mode 100644 index 000000000..fea417cd5 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewBlog_1.0.1.json @@ -0,0 +1,48 @@ +{ + "intentName": "ViewBlog", + "intentVersion": "1.0.1", + "llmDescription": "查看资讯博客", + "keywords": ["ViewBlog"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "blogCategory" + ] + }, + "properties": { + "entityId": { + "description": "数据唯一标识,限长64个字符。", + "type": "string" + }, + "blogCategory": { + "description": "资讯博客频道分类,如:旅行、生活、军事、科技、文化、美食、汽车。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewBuyingHouseInfo_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewBuyingHouseInfo_1.0.1.json new file mode 100644 index 000000000..dbffe7e26 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewBuyingHouseInfo_1.0.1.json @@ -0,0 +1,49 @@ +{ + "intentName": "ViewBuyingHouseInfo", + "intentVersion": "1.0.1", + "llmDescription": "查看买房信息", + "keywords": ["ViewBuyingHouseInfo"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "extras" + ] + }, + "properties": { + "entityId": { + "description": "租房信息的唯一标识(本地搜索时返回调用)。", + "type": "string", + "maxLength": 64 + }, + "extras": { + "description": "其他信息,具体由接入业务澄清。", + "type": "object" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewColumn_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewColumn_1.0.1.json new file mode 100644 index 000000000..f0f1fd95f --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewColumn_1.0.1.json @@ -0,0 +1,49 @@ +{ + "intentName": "ViewColumn", + "intentVersion": "1.0.1", + "llmDescription": "查看专栏", + "keywords": ["ViewColumn"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "columnTitle" + ] + }, + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "string", + "maxLength": 64 + }, + "columnTitle": { + "description": "专栏标题。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewCommodity_1.0.2.json b/compiler/src/userIntents_parser/schema/ViewCommodity_1.0.2.json new file mode 100644 index 000000000..301629d60 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewCommodity_1.0.2.json @@ -0,0 +1,50 @@ +{ + "intentName": "ViewCommodity", + "intentVersion": "1.0.2", + "llmDescription": "查看商品", + "keywords": ["ViewCommodity"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "shareLink" + ] + }, + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "string", + "maxLength": 64 + }, + "shareLink": { + "description": "商品链接文本(最长1500的字符串),和实体Id参数二选一。", + "type": "string", + "maxLength": 1500 + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewHospital_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewHospital_1.0.1.json new file mode 100644 index 000000000..7cb9cd464 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewHospital_1.0.1.json @@ -0,0 +1,47 @@ +{ + "intentName": "ViewHospital", + "intentVersion": "1.0.1", + "llmDescription": "查看医院", + "keywords": ["ViewHospital"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId" + ], + "required": [ + "entityId" + ], + "properties": { + "entityId": { + "description": "数据唯一标识", + "type": "string", + "maxLength": 64 + } + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewLogistics_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewLogistics_1.0.1.json index efe5fac4d..bc5de6367 100644 --- a/compiler/src/userIntents_parser/schema/ViewLogistics_1.0.1.json +++ b/compiler/src/userIntents_parser/schema/ViewLogistics_1.0.1.json @@ -42,7 +42,7 @@ "type": "number" }, "result": { - "description": "返回结果列表对象(列表Key名默认items),如果无内容则返回空。", + "description": "意图调用返回的数据,如果无数据则返回空。", "type": "object" } } diff --git a/compiler/src/userIntents_parser/schema/ViewMarriageRegistration_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewMarriageRegistration_1.0.1.json new file mode 100644 index 000000000..e2d8a3819 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewMarriageRegistration_1.0.1.json @@ -0,0 +1,53 @@ +{ + "intentName": "ViewMarriageRegistration", + "intentVersion": "1.0.1", + "llmDescription": "查看婚姻登记", + "keywords": ["ViewMarriageRegistration"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "city", + "type" + ] + }, + "properties": { + "city": { + "description": "查询城市信息。", + "type": "string" + }, + "type": { + "description": "婚姻登记类型。", + "type": "string", + "enum": [ + "Marriage", + "Divorce" + ], + "default": "Marriage" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewMedicalInsuranceCode_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewMedicalInsuranceCode_1.0.1.json new file mode 100644 index 000000000..4aa0d4d3a --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewMedicalInsuranceCode_1.0.1.json @@ -0,0 +1,33 @@ +{ + "intentName": "ViewMedicalInsuranceCode", + "intentVersion": "1.0.1", + "llmDescription": "查看医保码", + "keywords": ["ViewMedicalInsuranceCode"], + "parameters": { + "type": "object", + "properties": {} + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewMedicalinsurancelnfo_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewMedicalinsurancelnfo_1.0.1.json new file mode 100644 index 000000000..ab41961bb --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewMedicalinsurancelnfo_1.0.1.json @@ -0,0 +1,33 @@ +{ + "intentName": "ViewMedicalinsurancelnfo", + "intentVersion": "1.0.1", + "llmDescription": "查看医保信息", + "keywords": ["ViewMedicalinsurancelnfo"], + "parameters": { + "type": "object", + "properties": {} + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewMetroCrowdingInfo_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewMetroCrowdingInfo_1.0.1.json new file mode 100644 index 000000000..9a2049e1b --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewMetroCrowdingInfo_1.0.1.json @@ -0,0 +1,33 @@ +{ + "intentName": "ViewMetroCrowdingInfo", + "intentVersion": "1.0.1", + "llmDescription": "查看地铁拥挤度", + "keywords": ["ViewMetroCrowdingInfo"], + "parameters": { + "type": "object", + "properties": {} + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewPaymentCodes_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewPaymentCodes_1.0.1.json new file mode 100644 index 000000000..df8133d02 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewPaymentCodes_1.0.1.json @@ -0,0 +1,33 @@ +{ + "intentName": "ViewPaymentCodes", + "intentVersion": "1.0.1", + "llmDescription": "查看付款码", + "keywords": ["ViewPaymentCodes"], + "parameters": { + "type": "object", + "properties": {} + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewPayment_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewPayment_1.0.1.json new file mode 100644 index 000000000..2c7672966 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewPayment_1.0.1.json @@ -0,0 +1,95 @@ +{ + "intentName": "ViewPayment", + "intentVersion": "1.0.1", + "llmDescription": "查看生活缴费信息", + "keywords": ["ViewPayment"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "entityName", + "accountNumber", + "billType", + "cell", + "company", + "city", + "address", + "belongingAccount" + ] + }, + "required": [ + "entityName", + "belongingAccount" + ], + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "string" + }, + "entityName": { + "description": "实体名称。", + "type": "string" + }, + "accountNumber": { + "description": "缴费户号。", + "type": "number" + }, + "billType": { + "description": "生活缴费费用类型,取值如下,0:水费。1:电费。2:燃气费。3:话费。4:流量。5:暖气费。", + "type": "number", + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5 + ] + }, + "cell": { + "description": "小区。", + "type": "string" + }, + "company": { + "description": "缴费单位。", + "type": "string" + }, + "city": { + "description": "城市。", + "type": "string" + }, + "address": { + "description": "地址。", + "type": "string" + }, + "belongingAccount": { + "description": "华为账号id。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewPhoneBill_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewPhoneBill_1.0.1.json new file mode 100644 index 000000000..af5b11f70 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewPhoneBill_1.0.1.json @@ -0,0 +1,43 @@ +{ + "intentName": "ViewPhoneBill", + "intentVersion": "1.0.1", + "llmDescription": "查看电话账单", + "keywords": ["ViewPhoneBill"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "date" + ] + }, + "properties": { + "date": { + "description": "查询日期。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewPhoneNumberBenefits_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewPhoneNumberBenefits_1.0.1.json new file mode 100644 index 000000000..b29333607 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewPhoneNumberBenefits_1.0.1.json @@ -0,0 +1,33 @@ +{ + "intentName": "ViewPhoneNumberBenefits", + "intentVersion": "1.0.1", + "llmDescription": "查看手机号权益", + "keywords": ["ViewPhoneNumberBenefits"], + "parameters": { + "type": "object", + "properties": {} + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewProvidentFundInfo_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewProvidentFundInfo_1.0.1.json new file mode 100644 index 000000000..672dba4d3 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewProvidentFundInfo_1.0.1.json @@ -0,0 +1,33 @@ +{ + "intentName": "ViewProvidentFundInfo", + "intentVersion": "1.0.1", + "llmDescription": "查看公积金信息", + "keywords": ["ViewProvidentFundInfo"], + "parameters": { + "type": "object", + "properties": {} + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewRankingList_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewRankingList_1.0.1.json new file mode 100644 index 000000000..763d561ae --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewRankingList_1.0.1.json @@ -0,0 +1,49 @@ +{ + "intentName": "ViewRankingList", + "intentVersion": "1.0.1", + "llmDescription": "查看榜单", + "keywords": ["ViewRankingList"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "rankingContentId" + ] + }, + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "string", + "maxLength": 64 + }, + "rankingContentId": { + "description": "榜单内容ID。", + "type": "number" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewRealTimeBusRoute_1.0.2.json b/compiler/src/userIntents_parser/schema/ViewRealTimeBusRoute_1.0.2.json new file mode 100644 index 000000000..06e1cde9b --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewRealTimeBusRoute_1.0.2.json @@ -0,0 +1,58 @@ +{ + "intentName": "ViewRealTimeBusRoute", + "intentVersion": "1.0.2", + "llmDescription": "查看实时公交", + "keywords": ["ViewRealTimeBusRoute"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "lineName", + "province", + "city", + "district" + ] + }, + "properties": { + "lineName": { + "description": "线路名称。", + "type": "string" + }, + "province": { + "description": "省份。", + "type": "string" + }, + "city": { + "description": "城市名称。", + "type": "string" + }, + "district": { + "description": "区或县的名称。", + "type": "string" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewRemain_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewRemain_1.0.1.json new file mode 100644 index 000000000..f9e7d500b --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewRemain_1.0.1.json @@ -0,0 +1,49 @@ +{ + "intentName": "ViewRemain", + "intentVersion": "1.0.1", + "llmDescription": "查看余量", + "keywords": ["ViewRemain"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "category" + ] + }, + "properties": { + "category": { + "description": "余量分类。DataTraffic:数据流量,VoiceTraffic:语音流量,SMSTraffic:短信流量,MobileAccountBalance:话费余额。", + "type": "string", + "enum": [ + "DataTraffic", + "VoiceTraffic", + "SMSTraffic", + "MobileAccountBalance" + ] + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewRentingHouseInfo_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewRentingHouseInfo_1.0.1.json new file mode 100644 index 000000000..ba0d3f2e6 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewRentingHouseInfo_1.0.1.json @@ -0,0 +1,49 @@ +{ + "intentName": "ViewRentingHouseInfo", + "intentVersion": "1.0.1", + "llmDescription": "查看租房信息", + "keywords": ["ViewRentingHouseInfo"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "extras" + ] + }, + "properties": { + "entityId": { + "description": "租房信息的唯一标识(本地搜索时返回调用)。", + "type": "string", + "maxLength": 64 + }, + "extras": { + "description": "其他信息,具体由接入业务澄清。", + "type": "object" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewShoppingGuide_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewShoppingGuide_1.0.1.json new file mode 100644 index 000000000..51daab7b3 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewShoppingGuide_1.0.1.json @@ -0,0 +1,44 @@ +{ + "intentName": "ViewShoppingGuide", + "intentVersion": "1.0.1", + "llmDescription": "查看购物攻略", + "keywords": ["ViewShoppingGuide"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId" + ] + }, + "properties": { + "entityId": { + "description": "数据唯一标识。", + "type": "string", + "maxLength": 64 + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewSmartDevice_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewSmartDevice_1.0.1.json new file mode 100644 index 000000000..1c305e0c6 --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewSmartDevice_1.0.1.json @@ -0,0 +1,53 @@ +{ + "intentName": "ViewSmartDevice", + "intentVersion": "1.0.1", + "llmDescription": "查看智能设备详情", + "keywords": ["ViewSmartDevice"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "entityId", + "functionType" + ] + }, + "properties": { + "entityId": { + "description": "设备的唯一标识。", + "type": "string" + }, + "functionType": { + "description": "设备功能类型,回放/实时画面等,枚举定义。Playbafk:回看录像,LiveVideo:实时画面。", + "type": "string", + "enum": [ + "Playback", + "LiveVideo" + ], + "default": "LiveVideo" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewSocialSecurityInfo_1.0.2.json b/compiler/src/userIntents_parser/schema/ViewSocialSecurityInfo_1.0.2.json new file mode 100644 index 000000000..70baa80ef --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewSocialSecurityInfo_1.0.2.json @@ -0,0 +1,52 @@ +{ + "intentName": "ViewSocialSecurityInfo", + "intentVersion": "1.0.2", + "llmDescription": "查看社保信息", + "keywords": ["ViewSocialSecurityInfo"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "type" + ] + }, + "properties": { + "type": { + "description": "扫描里的功能。养老金收入证明:ProofOfPension,养老待遇发放明细:PensionPaymentDetails,社保缴纳记录:SocialSecurityPaymentRecord,社保余额:SocialSecurityBalance,养老金补缴:SupplementaryPension,养老保险(首页):PensionInsurance,参保证明:SocialSecurityCertificate。", + "type": "string", + "enum": [ + "ProofOfPension", + "PensionPaymentDetails", + "SocialSecurityPaymentRecord", + "SocialSecurityBalance", + "SupplementaryPension", + "Pensionlnsurance", + "SocialSecurityCertificate" + ] + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} diff --git a/compiler/src/userIntents_parser/schema/ViewSpecialAdditionalDeduction_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewSpecialAdditionalDeduction_1.0.1.json new file mode 100644 index 000000000..2dd32099e --- /dev/null +++ b/compiler/src/userIntents_parser/schema/ViewSpecialAdditionalDeduction_1.0.1.json @@ -0,0 +1,48 @@ +{ + "intentName": "ViewSpecialAdditionalDeduction", + "intentVersion": "1.0.1", + "llmDescription": "查看专项附加扣除", + "keywords": ["ViewSpecialAdditionalDeduction"], + "parameters": { + "type": "object", + "propertyNames": { + "enum": [ + "category", + "annualTime" + ] + }, + "properties": { + "category": { + "description": "专项附加扣除类型。", + "type": "string" + }, + "annualTime": { + "description": "年度时间缺省时默认今年。", + "type": "number" + } + } + }, + "result": { + "type": "object", + "propertyNames": { + "enum": [ + "code", + "result" + ] + }, + "required": [ + "code", + "result" + ], + "properties": { + "code": { + "description": "意图调用返回的结果码,0代表成功。", + "type": "number" + }, + "result": { + "description": "意图调用返回的数据,如果无数据则返回空。", + "type": "object" + } + } + } +} -- Gitee From 6c6db9bdbec66c9f9cb1f1aac4781d99aaa8e0e8 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Thu, 19 Jun 2025 22:13:10 +0800 Subject: [PATCH 130/140] =?UTF-8?q?har=E5=8C=85=E6=94=B6=E9=9B=86=E6=84=8F?= =?UTF-8?q?=E5=9B=BE=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../ets_ui/rollup-plugin-ets-typescript.ts | 5 +- .../userIntents_parser/parseUserIntents.ts | 60 +++++++++++++++++-- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index 3c11e1d89..d3a4238c7 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -230,8 +230,9 @@ export function etsTransform() { afterBuildEnd() { const hookEventFactory: CompileEvent = getHookEventFactory(this.share, 'etsTransform', 'afterBuildEnd'); const eventEtsTransformAfterBuildEnd = createAndStartEvent(hookEventFactory, 'etsTransformafterBuildEnd'); - if (parseIntent.intentData.length > 0 || parseIntent.isUpdateCompile) { - parseIntent.writeUserIntentJsonFile(); + const harIntentDataObj: object = parseIntent.getHarData(); + if (parseIntent.intentData.length > 0 || parseIntent.isUpdateCompile || Object.keys(harIntentDataObj).length !== 0) { + parseIntent.writeUserIntentJsonFile(harIntentDataObj); } // Copy the cache files in the compileArkTS directory to the loader_out directory if (projectConfig.compileHar && !projectConfig.byteCodeHar) { diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index b98525db1..614f2bb36 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -1550,15 +1550,20 @@ class ParseIntent { } } - public writeUserIntentJsonFile(): void { + // This method writes the parsed data to a file. + public writeUserIntentJsonFile(harIntentDataObj: object): void { + const cachePath: string = + path.join(projectConfig.cachePath, 'insight_compile_cache.json'); // Compiled cache file + if (!(fs.existsSync(cachePath) || this.intentData.length > 0 || Object.keys(harIntentDataObj).length !== 0)) { + return; + } this.verifyInheritanceChain(); - const writeJsonData: object = this.processIntentData(); + const mergedData: object = this.processIntentData(harIntentDataObj); const cacheSourceMapPath: string = path.join(projectConfig.aceProfilePath, 'insight_intent.json'); // The user's intents configuration file - const cachePath: string = path.join(projectConfig.cachePath, 'insight_compile_cache.json'); // Compiled cache file try { if (this.intentData.length > 0) { - fs.writeFileSync(cacheSourceMapPath, JSON.stringify(writeJsonData, null, 2), 'utf-8'); + fs.writeFileSync(cacheSourceMapPath, JSON.stringify(mergedData, null, 2), 'utf-8'); fs.writeFileSync(cachePath, JSON.stringify({ 'extractInsightIntents': this.intentData }, null, 2), 'utf-8'); } else if (fs.existsSync(cacheSourceMapPath)) { fs.unlinkSync(cacheSourceMapPath); @@ -1587,7 +1592,7 @@ class ParseIntent { } } - private processIntentData(): object { + private processIntentData(harIntentDataObj: object): object { this.matchEntities(); if (!projectConfig.aceProfilePath) { const errorMessage: string = `Internal error aceProfilePath not found`; @@ -1630,8 +1635,51 @@ class ParseIntent { 'extractInsightIntents': this.intentData }); } + const mergedData: object = this.mergeHarData(writeJsonData, harIntentDataObj); this.validateIntentIntentName(writeJsonData); - return writeJsonData; + return mergedData; + } + + private mergeHarData(writeJsonData: object, harIntentDataObj: object): object { + let mergedData: object = {}; + if (writeJsonData) { + mergedData = JSON.parse(JSON.stringify(writeJsonData)); + } + Object.keys(harIntentDataObj || {})?.forEach(harName => { + if (harIntentDataObj[harName].extractInsightIntents) { + harIntentDataObj[harName].extractInsightIntents.forEach(intentObj => { + intentObj.moduleName = projectConfig.moduleName; + intentObj.bundleName = projectConfig.bundleName; + }); + if (harIntentDataObj[harName].extractInsightIntents) { + mergedData.extractInsightIntents?.push(...harIntentDataObj[harName].extractInsightIntents); + } + } + }); + return mergedData; + } + + // This method get the user's intents from the bytecode HAR package. + public getHarData(): object { + const harIntentDataObj: object = {}; + if (fs.existsSync(projectConfig.aceBuildJson)) { + const loaderJson: string = fs.readFileSync(projectConfig.aceBuildJson, 'utf8'); + const { byteCodeHarInfo } = JSON.parse(loaderJson); + Object.keys(byteCodeHarInfo || {})?.forEach((harName) => { + const harAbcFilePath = byteCodeHarInfo[harName].abcPath as string; + const harModulePath: string = harAbcFilePath.split('ets')[0]; + const harSourcePath: string = path.join(harModulePath, 'src', 'main', 'resources', 'base', 'profile'); + const intentDataSourcePath: string = path.join(harSourcePath, 'insight_intent.json'); + let harIntentData: object = {}; + if (fs.existsSync(intentDataSourcePath)) { + harIntentData = JSON.parse(fs.readFileSync(intentDataSourcePath, 'utf8')) as object; + } + Object.assign(harIntentDataObj, { + harName: harIntentData + }); + }); + } + return harIntentDataObj; } private validateIntentIntentName(writeJsonData: object): void { -- Gitee From c5fb13004ecf63367f2656b409922f7c77074caa Mon Sep 17 00:00:00 2001 From: wuhailong Date: Wed, 18 Jun 2025 17:43:57 +0800 Subject: [PATCH 131/140] add import path expand Issue: #ICGX8X Signed-off-by: wuhailong Change-Id: Iee96c73a856412745693f9ebd936b50332fc8bbb --- .../ets_ui/rollup-plugin-ets-typescript.ts | 3 + compiler/src/import_path_expand.ts | 344 ++++++++++++++++ .../common/import_path_expand.test.ts | 377 ++++++++++++++++++ 3 files changed, 724 insertions(+) create mode 100644 compiler/src/import_path_expand.ts create mode 100644 compiler/test/ark_compiler_ut/common/import_path_expand.test.ts diff --git a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts index d3a4238c7..f4cf60e59 100644 --- a/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts +++ b/compiler/src/fast_build/ets_ui/rollup-plugin-ets-typescript.ts @@ -117,6 +117,7 @@ import { ARKUI_SUBSYSTEM_CODE } from '../../../lib/hvigor_error_code/hvigor_erro import { ProjectCollections } from 'arkguard'; import parseIntent from '../../userIntents_parser/parseUserIntents'; import { concatenateEtsOptions, getExternalComponentPaths } from '../../external_component_map'; +import { expandAllImportPaths } from '../../import_path_expand'; let switchTsAst: boolean = true; @@ -501,6 +502,7 @@ async function transform(code: string, id: string) { { before: [ processUISyntax(null, false, eventEmit, id, this.share, metaInfo), + expandAllImportPaths(tsProgram.getTypeChecker(), this), processKitImport(id, metaInfo, eventEmit, true, lazyImportOptions), collectReservedNameForObf(this.share.arkProjectConfig?.obfuscationMergedObConfig, shouldETSOrTSFileTransformToJSWithoutRemove(id, projectConfig, metaInfo)) @@ -518,6 +520,7 @@ async function transform(code: string, id: string) { transformResult = ts.transformNodes(emitResolver, tsProgram.getEmitHost?.(), ts.factory, tsProgram.getCompilerOptions(), [targetSourceFile], [processUISyntax(null, false, eventTransformNodes, id, this.share, metaInfo), + expandAllImportPaths(tsProgram.getTypeChecker(), this), processKitImport(id, metaInfo, eventTransformNodes, false, lazyImportOptions), collectReservedNameForObf(this.share.arkProjectConfig?.obfuscationMergedObConfig, shouldETSOrTSFileTransformToJSWithoutRemove(id, projectConfig, metaInfo))], false); diff --git a/compiler/src/import_path_expand.ts b/compiler/src/import_path_expand.ts new file mode 100644 index 000000000..d869d8172 --- /dev/null +++ b/compiler/src/import_path_expand.ts @@ -0,0 +1,344 @@ +/* + * Copyright (c) 2025 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 * as ts from 'typescript'; +import path from 'path'; + +import { toUnixPath } from './utils'; +import { + projectConfig as mainProjectConfig, + sdkConfigPrefix +} from '../main'; +import { compilerOptions } from './ets_checker'; + +interface ImportInfo { + defaultImport?: { + name: ts.Identifier; + isTypeOnly: boolean; + }; + namedImports: ts.ImportSpecifier[]; +} + +interface SymbolInfo { + filePath: string, + isDefault: boolean +} + +interface SeparatedImportInfos { + typeOnly: Map; + value: Map; +}; + +export function expandAllImportPaths(checker: ts.TypeChecker, rollupObejct: Object): Function { + const expandImportPath: Object = rollupObejct.share.projectConfig?.expandImportPath; + const modulePathMap: Map = mainProjectConfig.modulePathMap; + if (!(expandImportPath && Object.entries(expandImportPath).length !== 0) || !expandImportPath.enable) { + return () => sourceFile => sourceFile; + } + const exclude: string[] = expandImportPath?.exclude ? expandImportPath?.exclude : []; + return (context: ts.TransformationContext) => { + // @ts-ignore + const visitor: ts.Visitor = (node: ts.Node): ts.VisitResult => { + if (ts.isImportDeclaration(node)) { + const result: ts.ImportDeclaration[] = transformImportDecl(node, checker, exclude, modulePathMap); + return result.length > 0 ? result : node; + } + return node; + }; + + return (node: ts.SourceFile): ts.SourceFile => { + return ts.visitEachChild(node, visitor, context); + }; + }; +} + +function transformImportDecl(node: ts.ImportDeclaration, checker: ts.TypeChecker, exclude: string[], + modulePathMap: Map): ts.ImportDeclaration[] { + const moduleSpecifier: ts.StringLiteral = node.moduleSpecifier as ts.StringLiteral; + const moduleRequest: string = moduleSpecifier.text; + const REG_SYSTEM_MODULE: RegExp = new RegExp(`@(${sdkConfigPrefix})\\.(\\S+)`); + const REG_LIB_SO: RegExp = /lib(\S+)\.so/; + if (moduleRequest.startsWith('.') || REG_SYSTEM_MODULE.test(moduleRequest.trim()) || + REG_LIB_SO.test(moduleRequest.trim()) || exclude.indexOf(moduleRequest) !== -1) { + return []; + } + const importClause = node.importClause; + if (!importClause) { + return []; + } + if ((importClause.namedBindings && ts.isNamespaceImport(importClause.namedBindings)) || importClause.isTypeOnly) { + return []; + } + + const importMap = new Map(); + // default import + processDefaultImport(checker, importMap, importClause, moduleSpecifier); + // named imports + processNamedImport(checker, importMap, importClause, moduleSpecifier); + if (importMap.size === 0) { + return []; + } + const { typeOnly, value }: SeparatedImportInfos = separateImportInfos(importMap); + const results: ts.ImportDeclaration[] = []; + + for (const [_, info] of typeOnly.entries()) { + results.push(createImportDeclarationFromInfo(info, node, moduleRequest)); + } + + for (const [filePath, info] of value.entries()) { + const realModuleRequest = genModuleRequst(filePath, moduleSpecifier.text, modulePathMap); + if (!realModuleRequest) { + continue; + } + results.push(createImportDeclarationFromInfo(info, node, realModuleRequest)); + } + + return results; +} + + +function processDefaultImport(checker: ts.TypeChecker, importMap: Map, importClause: ts.ImportClause, + moduleSpecifier: ts.StringLiteral): void { + if (importClause.name) { + const resolved = getRealFilePath(checker, moduleSpecifier, 'default'); + if (!resolved) { + return; + } + const filePath: string = resolved.filePath; + + if (!importMap.has(filePath)) { + importMap.set(filePath, { namedImports: [] }); + } + if (resolved.isDefault) { + importMap.get(filePath)!.defaultImport = { + name: importClause.name, + isTypeOnly: importClause.isTypeOnly + }; + } else { + // fallback: was re-exported as default, but originally named + importMap.get(filePath)!.namedImports.push( + ts.factory.createImportSpecifier(importClause.isTypeOnly, + ts.factory.createIdentifier(importClause.name.text), importClause.name) + ); + } + } +} + +function processNamedImport(checker: ts.TypeChecker, importMap: Map, importClause: ts.ImportClause, + moduleSpecifier: ts.StringLiteral): void { + if (importClause.namedBindings && ts.isNamedImports(importClause.namedBindings)) { + for (const element of importClause.namedBindings.elements) { + const name: string = element.propertyName?.text || element.name.text; + const resolved: SymbolInfo | undefined = getRealFilePath(checker, moduleSpecifier, name); + if (!resolved) { + continue; + } + + const filePath: string = resolved.filePath; + + if (!importMap.has(filePath)) { + importMap.set(filePath, { namedImports: [] }); + } + if (resolved.isDefault) { + importMap.get(filePath)!.defaultImport = { + name: element.name, + isTypeOnly: element.isTypeOnly + }; + } else { + importMap.get(filePath)!.namedImports.push( + ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName, element.name)); + } + } + } +} + +function separateImportInfos(importInfos: Map): SeparatedImportInfos { + const typeOnly = new Map(); + const value = new Map(); + + for (const [filePath, info] of importInfos.entries()) { + const typeInfo: ImportInfo = { namedImports: [] }; + const valueInfo: ImportInfo = { namedImports: [] }; + + if (info.defaultImport) { + if (info.defaultImport.isTypeOnly) { + typeInfo.defaultImport = info.defaultImport; + } else { + valueInfo.defaultImport = info.defaultImport; + } + } + + for (const spec of info.namedImports) { + if (spec.isTypeOnly) { + typeInfo.namedImports.push(spec); + } else { + valueInfo.namedImports.push(spec); + } + } + + if (typeInfo.defaultImport || typeInfo.namedImports.length > 0) { + typeOnly.set(filePath, typeInfo); + } + if (valueInfo.defaultImport || valueInfo.namedImports.length > 0) { + value.set(filePath, valueInfo); + } + } + + return { typeOnly, value }; +} + +function createImportDeclarationFromInfo(importInfo: ImportInfo, originalNode: ts.ImportDeclaration, + modulePath: string): ts.ImportDeclaration { + const importClause = ts.factory.createImportClause(false, importInfo.defaultImport?.name, + importInfo.namedImports.length > 0 ? ts.factory.createNamedImports(importInfo.namedImports) : undefined); + + // @ts-ignore + importClause.isLazy = originalNode.importClause?.isLazy; + + return ts.factory.updateImportDeclaration(originalNode, originalNode.modifiers, importClause, + ts.factory.createStringLiteral(modulePath), originalNode.assertClause); +} + +function genModuleRequst(filePath: string, moduleRequest: string, modulePathMap: Map): string { + const unixFilePath: string = toUnixPath(filePath); + for (const [_, moduleRootPath] of Object.entries(modulePathMap)) { + const unixModuleRootPath: string = toUnixPath(moduleRootPath); + if (unixFilePath.startsWith(unixModuleRootPath + '/')) { + return unixFilePath.replace(unixModuleRootPath, moduleRequest).replace(/\.(d\.ets|ets|d\.ts|ts|js)$/, ''); + } + } + return ''; +} + +function getRealFilePath(checker: ts.TypeChecker, moduleSpecifier: ts.StringLiteral, + exportName: string): SymbolInfo | undefined { + const symbol: ts.Symbol | undefined = resolveImportedSymbol(checker, moduleSpecifier, exportName); + if (!symbol) { + return undefined; + } + + const finalSymbol: ts.Symbol = resolveAliasedSymbol(symbol, checker); + if (!finalSymbol || !finalSymbol.declarations || finalSymbol.declarations.length === 0) { + return undefined; + } + + const decl: ts.Declaration = finalSymbol.declarations?.[0]; + const filePath = path.normalize(decl.getSourceFile().fileName); + const isDefault: boolean = isActuallyDefaultExport(finalSymbol); + + return { filePath, isDefault }; +} + +function resolveImportedSymbol(checker: ts.TypeChecker, moduleSpecifier: ts.StringLiteral, + exportName: string): ts.Symbol | undefined { + const moduleSymbol: ts.Symbol = checker.getSymbolAtLocation(moduleSpecifier); + if (!moduleSymbol) { + return undefined; + } + + const exports: ts.Symbol[] = checker.getExportsOfModule(moduleSymbol); + if (!exports) { + return undefined; + } + + for (const sym of exports) { + const name: string = sym.escapedName.toString(); + if (name === exportName) { + return sym; + } + } + return undefined; +} + +function resolveAliasedSymbol(symbol: ts.Symbol, checker: ts.TypeChecker): ts.Symbol { + const visited = new Set(); + let finalSymbol: ts.Symbol | undefined = symbol; + + while (finalSymbol && finalSymbol.flags & ts.SymbolFlags.Alias) { + if (visited.has(finalSymbol)) { + break; + } + visited.add(finalSymbol); + const aliased = checker.getAliasedSymbol(finalSymbol); + if (!aliased) { + break; + } + finalSymbol = aliased; + } + + // fallback: skip symbols with no declarations + while (finalSymbol && (!finalSymbol.declarations || finalSymbol.declarations.length === 0)) { + if (visited.has(finalSymbol)) { + break; + } + visited.add(finalSymbol); + const aliased = checker.getAliasedSymbol(finalSymbol); + if (!aliased || aliased === finalSymbol) { + break; + } + finalSymbol = aliased; + } + + return finalSymbol; +} + +function isActuallyDefaultExport(symbol: ts.Symbol): boolean { + const decl = symbol.valueDeclaration ?? symbol.declarations?.[0]; + if (!decl) { + return false; + } + const sourceFile = decl.getSourceFile(); + for (const stmt of sourceFile.statements) { + if (isDefaultExportAssignment(stmt, symbol)) { + return true; + } + if (isNamedDefaultExport(stmt, symbol)) { + return true; + } + if (isNamedDefaultDecl(stmt, decl, symbol)) { + return true; + } + } + return false; +} + +function isDefaultExportAssignment(stmt: ts.Statement, symbol: ts.Symbol): boolean { + return ts.isExportAssignment(stmt) && + !stmt.isExportEquals && + ts.isIdentifier(stmt.expression) && + stmt.expression.text === symbol.name; +} + +function isNamedDefaultExport(stmt: ts.Statement, symbol: ts.Symbol): boolean { + if (!ts.isExportDeclaration(stmt) || !stmt.exportClause || !ts.isNamedExports(stmt.exportClause)) { + return false; + } + for (const specifier of stmt.exportClause.elements) { + if (specifier.name.text === 'default' && specifier.propertyName?.text === symbol.name) { + return true; + } + if (specifier.name.text === 'default' && !specifier.propertyName) { + return false; + } + } + return false; +} + +function isNamedDefaultDecl(stmt: ts.Statement, decl: ts.Declaration, symbol: ts.Symbol): boolean { + return symbol.name === 'default' && + (ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) && + stmt.modifiers?.some(m => m.kind === ts.SyntaxKind.DefaultKeyword) && + stmt.name?.text === decl.name?.getText(); +} \ No newline at end of file diff --git a/compiler/test/ark_compiler_ut/common/import_path_expand.test.ts b/compiler/test/ark_compiler_ut/common/import_path_expand.test.ts new file mode 100644 index 000000000..b6a90d836 --- /dev/null +++ b/compiler/test/ark_compiler_ut/common/import_path_expand.test.ts @@ -0,0 +1,377 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use rollupObject 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 mocha from 'mocha'; +import { expect } from 'chai'; +import path from 'path'; +import * as ts from 'typescript'; + +import { expandAllImportPaths } from '../../../lib/import_path_expand'; +import { projectConfig } from '../../../main'; + +const compilerOptions = ts.readConfigFile( + path.resolve(__dirname, '../../../tsconfig.json'), ts.sys.readFile).config.compilerOptions; +compilerOptions['moduleResolution'] = 'nodenext'; +compilerOptions['module'] = 'es2020'; + +function createMultiSymbolProgram(testContent: string, symbolToFileMap: Record, + indexContent: string, rootDir: string = '/TestProject'): { program: ts.Program; testSourceFile: ts.SourceFile } { + const moduleRootPath: string = `${rootDir}/testPkg`; + const fileMap = new Map(); + + for (const [relativePath, code] of Object.entries(symbolToFileMap)) { + const fullFilePath = `${moduleRootPath}/${relativePath}`; + const sourceFile = ts.createSourceFile(fullFilePath, code, ts.ScriptTarget.ES2020, true); + Object.defineProperty(sourceFile, 'fileName', { value: fullFilePath }); + fileMap.set(fullFilePath, sourceFile); + } + + const testFileName = `${rootDir}/test/testFile.ets`; + const testSourceFile = ts.createSourceFile(testFileName, testContent, ts.ScriptTarget.ES2020, true); + Object.defineProperty(testSourceFile, 'fileName', { value: testFileName }); + + const compilerHost = ts.createCompilerHost({ target: ts.ScriptTarget.ES2020 }); + const allSourceFiles = new Map([...fileMap.entries(), [testFileName, testSourceFile]]); + + compilerHost.getSourceFile = (fileName) => allSourceFiles.get(fileName); + + compilerHost.resolveModuleNames = (moduleNames: string[], containingFile: string) => { + return moduleNames.map(name => { + if (name === 'testPkg') { + return { + resolvedFileName: `${moduleRootPath}/Index.ts`, + isExternalLibraryImport: false + }; + } + const candidate = path.resolve(path.dirname(containingFile), name); + const resolved = [...fileMap.keys()].find(filePath => + filePath === candidate || filePath === candidate + '.ts'); + + if (resolved) { + return { + resolvedFileName: resolved, + isExternalLibraryImport: false + }; + } + return undefined; + }); + }; + + const indexFilePath = `${moduleRootPath}/Index.ts`; + const indexSourceFile = ts.createSourceFile(indexFilePath, indexContent, ts.ScriptTarget.ESNext, true); + Object.defineProperty(indexSourceFile, 'fileName', { value: indexFilePath }); + allSourceFiles.set(indexFilePath, indexSourceFile); + + return { + program: ts.createProgram({ + rootNames: [...allSourceFiles.keys()], + options: compilerOptions, + host: compilerHost, + }), + testSourceFile + }; +} + +const CASE_1_1_TEST = `import def, { A as AA, B, type C } from 'testPkg'; +def(); +let a: AA = new AA(); +B(); +const c: C = 'c';`; +const CASE_1_1_FILES = { + 'testDir/test.ts': ` + function def() {} + export class A {} + export function B() {} + export type C = string; + export default def; + ` +}; +const CASE_1_1_INDEX = ` +import def from './testDir/test'; +export { A, B, type C } from './testDir/test'; +export default def; +`; +const EXPECT_1_1 = `import { type C } from "testPkg"; +import def, { A as AA, B } from "testPkg/testDir/test"; +def(); +let a: AA = new AA(); +B(); +const c: C = 'c'; +`; + + +const CASE_1_2_TEST = `import { A, B, C } from 'testPkg'; +A(); +B(); +C();`; +const CASE_1_2_FILES = { + 'a.ts': `export function A() {}`, + 'b.ts': `export function B() {}`, + 'c.ts': `export function C() {}` +}; +const CASE_1_2_INDEX = ` +export { A } from './a'; +export { B } from './b'; +export { C } from './c'; +`; +const EXPECT_1_2 = `import { A } from "testPkg/a"; +import { B } from "testPkg/b"; +import { C } from "testPkg/c"; +A(); +B(); +C(); +`; + +const CASE_1_3_TEST = `import { x, y as y1 } from 'testPkg'; +console.log(x, y1);`; +const CASE_1_3_FILES = { + 'final.ts': `const x = 1; export const y = 2; export default x;` +}; +const CASE_1_3_INDEX = `import x, { y } from './final'; +export { x, y };`; +const EXPECT_1_3 = `import x, { y as y1 } from "testPkg/final"; +console.log(x, y1); +`; + +const CASE_1_4_TEST = `import { y as y1 } from 'excludePkg'; +import { x } from 'testPkg'; +console.log(x, y1);`; +const CASE_1_4_FILES = { + 'final.ts': `const x = 1; export default x;` +}; +const CASE_1_4_INDEX = `import x from './final'; +export { x };`; +const EXPECT_1_4 = `import { y as y1 } from 'excludePkg'; +import x from "testPkg/final"; +console.log(x, y1); +`; + +const CASE_1_5_TEST = `import fallback from 'testPkg'; +console.log(fallback);`; +const CASE_1_5_FILES = { + 'test.ts': `export const fallback = 1;` +}; +const CASE_1_5_INDEX = `export { fallback as default } from './test';`; +const EXPECT_1_5 = `import { fallback as fallback } from "testPkg/test"; +console.log(fallback); +`; + +const CASE_1_6_TEST = `import type { T1 } from 'testPkg'; +const a: T1 = 'a';`; +const CASE_1_6_FILES = { + 'test.ts': `export type T1 = string;` +}; +const CASE_1_6_INDEX = `export type { T1 } from './test';`; +const EXPECT_1_6 = `import type { T1 } from 'testPkg'; +const a: T1 = 'a'; +`; + +const CASE_2_1_TEST = `import { x } from 'testPkg'; +console.log(x);`; +const CASE_2_1_FILES = { + 'test.ts': `export const x = 1;` +}; +const CASE_2_1_INDEX = `export { x } from './test';`; +const EXPECT_2_1 = `import { x } from 'testPkg'; +console.log(x); +`; + +const CASE_2_2_TEST = `import { def } from 'testPkg'; +def();`; +const CASE_2_2_FILES = { + 'test.ts': `export default function def() {};` +}; +const CASE_2_2_INDEX = ` import def from './test'; +export { def };`; +const EXPECT_2_2 = `import def from "testPkg/test"; +def(); +`; + +const CASE_3_1_TEST = `import * as test from 'testPkg'; +test.fn();`; +const CASE_3_1_FILES = { + 'test.ts': `export function fn() {}` +}; +const CASE_3_1_INDEX = `export * from './test';`; +const EXPECT_3_1 = `import * as test from 'testPkg'; +test.fn(); +`; + +const CASE_3_2_IMPORT = `import 'testPkg';`; +const CASE_3_2_FILES = { + 'test.ts': `console.log('loaded');` +}; +const CASE_3_2_INDEX = `export * from './test';`; +const EXPECT_3_2 = `import 'testPkg'; +`; + +const baseConfig = { enable: true, exclude: [] }; +const rollupObejct = { share: { projectConfig: { expandImportPath: baseConfig } } }; + +mocha.describe('test import_path_expand file api', () => { + mocha.it('1-1: split default + named + type imports', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_1_1_TEST, CASE_1_1_FILES, CASE_1_1_INDEX); + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed); + + expect(result === EXPECT_1_1).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + }); + + mocha.it('1-2: resolve multi-symbol to different files', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_1_2_TEST, CASE_1_2_FILES, CASE_1_2_INDEX); + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed); + + expect(result === EXPECT_1_2).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + }); + + mocha.it('1-3: resolve re-export chain to final file', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_1_3_TEST, CASE_1_3_FILES, CASE_1_3_INDEX); + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed); + + expect(result === EXPECT_1_3).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + }); + + mocha.it('1-4: exclude import path from transform', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_1_4_TEST, CASE_1_4_FILES, CASE_1_4_INDEX); + rollupObejct.share.projectConfig.expandImportPath.exclude = ['excludePkg']; + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed); + + expect(result === EXPECT_1_4).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + rollupObejct.share.projectConfig.expandImportPath.exclude = []; + }); + + mocha.it('1-5: fallback default import to named', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_1_5_TEST, CASE_1_5_FILES, CASE_1_5_INDEX); + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed); + + expect(result === EXPECT_1_5).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + }); + + mocha.it('1-6: transform type-only named import', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_1_6_TEST, CASE_1_6_FILES, CASE_1_6_INDEX); + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed); + + expect(result === EXPECT_1_6).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + }); + + mocha.it('2-1: should not transform when config is disabled', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + rollupObejct.share.projectConfig.expandImportPath.enable = false; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_2_1_TEST, CASE_2_1_FILES, CASE_2_1_INDEX); + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed); + + expect(result === EXPECT_2_1).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + rollupObejct.share.projectConfig.expandImportPath.enable = true; + }); + + mocha.it('2-2: transform the variable name is default', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_2_2_TEST, CASE_2_2_FILES, CASE_2_2_INDEX); + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed); + + expect(result === EXPECT_2_2).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + }); + + mocha.it('3-1: should preserve namespace import', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_3_1_TEST, CASE_3_1_FILES, CASE_3_1_INDEX); + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed); + + expect(result === EXPECT_3_1).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + }); + + mocha.it('3-2: should preserve side-effect import', () => { + const tmpModulePathMap = projectConfig.modulePathMap; + projectConfig.modulePathMap = { + 'testPkg': '/TestProject/testPkg' + }; + const { program, testSourceFile } = createMultiSymbolProgram(CASE_3_2_IMPORT, CASE_3_2_FILES, CASE_3_2_INDEX); + const transformed = ts.transform(testSourceFile, [expandAllImportPaths(program.getTypeChecker(), rollupObejct)], + program.getCompilerOptions()).transformed[0]; + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); + const result = printer.printFile(transformed) + + expect(result === EXPECT_3_2).to.be.true; + projectConfig.modulePathMap = tmpModulePathMap; + }); +}); -- Gitee From 015ecb81ec6943d2fb535d352d6991d3e8bc4504 Mon Sep 17 00:00:00 2001 From: yp9522 Date: Tue, 10 Jun 2025 17:45:04 +0800 Subject: [PATCH 132/140] Collect import so list Issue: ICE338 Signed-off-by: yp9522 --- compiler/src/ark_utils.ts | 38 ++-- .../src/fast_build/ark_compiler/error_code.ts | 3 +- .../ark_compiler/generate_module_abc.ts | 4 +- .../module/module_preload_file_utils.ts | 198 ++++++++++++++++++ .../ark_compiler/module/module_source_file.ts | 20 +- .../ark_compiler/rollup-plugin-gen-abc.ts | 6 +- .../module/ohmUrl/ohmUrl.test.ts | 99 ++++++++- 7 files changed, 340 insertions(+), 28 deletions(-) create mode 100644 compiler/src/fast_build/ark_compiler/module/module_preload_file_utils.ts diff --git a/compiler/src/ark_utils.ts b/compiler/src/ark_utils.ts index 901755076..261b87a56 100644 --- a/compiler/src/ark_utils.ts +++ b/compiler/src/ark_utils.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -99,6 +99,9 @@ import { LogDataFactory } from './fast_build/ark_compiler/logger'; import * as ts from 'typescript'; +import { + PreloadFileModules +} from './fast_build/ark_compiler/module/module_preload_file_utils'; export const SRC_MAIN: string = 'src/main'; @@ -283,13 +286,19 @@ function processPackageDir(params: Object): string { return originalFilePath; } - -export function getOhmUrlBySystemApiOrLibRequest(moduleRequest: string, config?: Object, logger?: Object, - importerFile?: string, useNormalizedOHMUrl: boolean = false): string { +export type OhmUrlParams = { + moduleRequest: string; + moduleId: string; + config?: Object; + logger?: Object; + importerFile?: string; +}; +export function getOhmUrlBySystemApiOrLibRequest(params: OhmUrlParams, + useNormalizedOHMUrl: boolean = false, needPreloadSo: boolean = false): string { // 'arkui-x' represents cross platform related APIs, processed as 'ohos' const REG_SYSTEM_MODULE: RegExp = new RegExp(`@(${sdkConfigPrefix})\\.(\\S+)`); const REG_LIB_SO: RegExp = /lib(\S+)\.so/; - + const moduleRequest = params.moduleRequest; if (REG_SYSTEM_MODULE.test(moduleRequest.trim())) { return moduleRequest.replace(REG_SYSTEM_MODULE, (_, moduleType, systemKey) => { let moduleRequestStr = ''; @@ -297,30 +306,35 @@ export function getOhmUrlBySystemApiOrLibRequest(moduleRequest: string, config?: moduleRequestStr = moduleRequestCallback(moduleRequest, _, moduleType, systemKey); } if (moduleRequestStr !== '') { + needPreloadSo && PreloadFileModules.updatePreloadFileDataByItems( + moduleRequest, moduleRequestStr, params.moduleId); return moduleRequestStr; } + let resultOhmUrl: string = ''; const systemModule: string = `${moduleType}.${systemKey}`; if (NATIVE_MODULE.has(systemModule)) { - return `@native:${systemModule}`; + resultOhmUrl = `@native:${systemModule}`; } else if (moduleType === ARKTS_MODULE_NAME) { // @arkts.xxx -> @ohos:arkts.xxx - return `@ohos:${systemModule}`; + resultOhmUrl = `@ohos:${systemModule}`; } else { - return `@ohos:${systemKey}`; - }; + resultOhmUrl = `@ohos:${systemKey}`; + } + needPreloadSo && PreloadFileModules.updatePreloadFileDataByItems(moduleRequest, resultOhmUrl, params.moduleId); + return resultOhmUrl; }); } if (REG_LIB_SO.test(moduleRequest.trim())) { if (useNormalizedOHMUrl) { - const pkgInfo = config.pkgContextInfo[moduleRequest]; + const pkgInfo = params.config.pkgContextInfo[moduleRequest]; if (!pkgInfo) { const errInfo: LogData = LogDataFactory.newInstance( ErrorCode.ETS2BUNDLE_INTERNAL_UNABLE_TO_GET_PKG_CONTENT_INFO, ArkTSInternalErrorDescription, `Can not get pkgContextInfo of package '${moduleRequest}' ` + - `which being imported by '${importerFile}'` + `which being imported by '${params.importerFile}'` ); - logger?.printError(errInfo); + params.logger?.printError(errInfo); return moduleRequest; } const isSo = pkgInfo.isSO ? 'Y' : 'N'; diff --git a/compiler/src/fast_build/ark_compiler/error_code.ts b/compiler/src/fast_build/ark_compiler/error_code.ts index 9b1a594a5..1f6928797 100644 --- a/compiler/src/fast_build/ark_compiler/error_code.ts +++ b/compiler/src/fast_build/ark_compiler/error_code.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -45,6 +45,7 @@ export enum ErrorCode { ETS2BUNDLE_INTERNAL_SOURCE_CODE_OBFUSCATION_FAILED = '10310020', ETS2BUNDLE_INTERNAL_ES2ABC_SUBPROCESS_START_FAILED = '10310021', ETS2BUNDLE_INTERNAL_EXECUTE_ES2ABC_WITH_ASYNC_HANDLER_FAILED = '10310022', + ETS2BUNDLE_INTERNAL_WRITE_PERLOAD_SO_FAILED = '10310023', // EXTERNAL ERRORS ETS2BUNDLE_EXTERNAL_FORBIDDEN_IMPORT_ARKTS_FILE = '10311001', diff --git a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts index 1053a7cf9..f24a68778 100644 --- a/compiler/src/fast_build/ark_compiler/generate_module_abc.ts +++ b/compiler/src/fast_build/ark_compiler/generate_module_abc.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -28,6 +28,7 @@ import { createAndStartEvent, stopEvent } from '../../performance'; +import { PreloadFileModules } from './module/module_preload_file_utils'; let moduleMode: ModuleMode = null; @@ -53,6 +54,7 @@ export async function generateModuleAbc(error) { return; } } + PreloadFileModules.finalizeWritePreloadSoList(); generateAbc(this, hookEventFactory); } } diff --git a/compiler/src/fast_build/ark_compiler/module/module_preload_file_utils.ts b/compiler/src/fast_build/ark_compiler/module/module_preload_file_utils.ts new file mode 100644 index 000000000..bfe9b50ad --- /dev/null +++ b/compiler/src/fast_build/ark_compiler/module/module_preload_file_utils.ts @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2025 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 path from 'path'; +import fs from 'fs'; +import { + CommonLogger, + LogData, + LogDataFactory +} from '../logger'; +import { + ArkTSInternalErrorDescription, + ErrorCode +} from '../error_code'; + +interface PreloadEntry { + name: string; + srcEntry: string; + ohmurl: string; + moduleId: string; +} + +interface PreloadFileStructure { + systemPreloadHintStartupTasks: PreloadEntry[]; +} + +export class PreloadFileModules { + private static needPreloadSo: boolean = true; + private static preloadEntries: Array<{ name: string; srcEntry: string; ohmurl: string }> = []; + private static preloadEntriesBack: Array<{ name: string; srcEntry: string; ohmurl: string; moduleId: string }> = []; + private static preloadFilePath: string; + private static preloadFilePathBack: string; + private static projectConfig: Object; + private static logger: CommonLogger; + private static moduleIds: string[] = []; + + public static initialize(rollupObject: Object): void { + this.projectConfig = Object.assign(rollupObject.share.arkProjectConfig, rollupObject.share.projectConfig); + this.logger = CommonLogger.getInstance(rollupObject); + if (this.projectConfig.widgetCompile) { + this.needPreloadSo = false; + return; + } + if (!this.projectConfig.preloadSoFilePath) { + this.needPreloadSo = false; + return; + } + this.needPreloadSo = true; + this.preloadFilePath = this.projectConfig.preloadSoFilePath; + this.preloadFilePathBack = this.preloadFilePath.replace('.json', '.backup.json'); + } + + public static updatePreloadFileDataByItems(moduleRequest: string, ohmurl: string, moduleId: string): void { + if (!this.needPreloadSo) { + return; + } + + const newEntryBack = { name: moduleRequest, srcEntry: moduleRequest, ohmurl: ohmurl, moduleId: moduleId }; + // One file is only need record once so + const backExists = this.preloadEntriesBack.some( + entry => entry.moduleId === moduleId && entry.name === moduleRequest + ); + if (!backExists) { + this.preloadEntriesBack.push(newEntryBack); + } + } + + public static removePreloadSoDataByModuleIds(): void { + if (!this.needPreloadSo) { + return; + } + + const backupFilePath = this.preloadFilePathBack; + if (!fs.existsSync(backupFilePath)) { + this.preloadEntries = [...this.deduplicateByName(this.preloadEntriesBack)]; + return; + } + + try { + const rawData = fs.readFileSync(backupFilePath, 'utf8'); + const parsed: PreloadFileStructure = JSON.parse(rawData); + + if (!parsed || !Array.isArray(parsed.systemPreloadHintStartupTasks)) { + const errInfo = LogDataFactory.newInstance( + ErrorCode.ETS2BUNDLE_INTERNAL_WRITE_PERLOAD_SO_FAILED, + ArkTSInternalErrorDescription, + 'Invalid JSON structure in preload so backup file.' + ); + this.logger?.printError?.(errInfo); + } + + const filtered = parsed.systemPreloadHintStartupTasks.filter( + entry => !this.moduleIds.includes(entry.moduleId) + ); + + const merged = [...this.preloadEntriesBack, ...filtered]; + const uniqueEntries = Array.from( + merged.reduce((map, entry) => { + const key = `${entry.moduleId}-${entry.name}`; + if (!map.has(key)) { + map.set(key, entry); + } + return map; + }, new Map()).values() + ); + this.preloadEntriesBack = uniqueEntries; + this.preloadEntries = [...this.deduplicateByName(this.preloadEntriesBack)]; + } catch (e) { + const errInfo = LogDataFactory.newInstance( + ErrorCode.ETS2BUNDLE_INTERNAL_WRITE_PERLOAD_SO_FAILED, + ArkTSInternalErrorDescription, + `Failed to update preload so backup file: ${e.message}` + ); + this.logger?.printError?.(errInfo); + } + } + + private static deduplicateByName(entries: T[]): T[] { + const seenNames = new Set(); + return entries + .map(({ moduleId, ...rest }) => rest) + .filter(entry => { + if (seenNames.has(entry.name)) { + return false; + } + seenNames.add(entry.name); + return true; + }); + } + + public static finalizeWritePreloadSoList(): void { + if (!this.needPreloadSo) { + return; + } + + try { + this.removePreloadSoDataByModuleIds(); + + const PRELOAD_FILE_STRUCTURE = { + systemPreloadHintStartupTasks: this.preloadEntries + }; + + const PRELOAD_FILE_STRUCTURE_BACK = { + systemPreloadHintStartupTasks: this.preloadEntriesBack + }; + + this.ensureDirectoryExistence(this.preloadFilePath); + fs.writeFileSync(this.preloadFilePath, JSON.stringify(PRELOAD_FILE_STRUCTURE, null, 2), 'utf8'); + + this.ensureDirectoryExistence(this.preloadFilePathBack); + fs.writeFileSync(this.preloadFilePathBack, JSON.stringify(PRELOAD_FILE_STRUCTURE_BACK, null, 2), 'utf8'); + } catch (error) { + const errInfo = LogDataFactory.newInstance( + ErrorCode.ETS2BUNDLE_INTERNAL_WRITE_PERLOAD_SO_FAILED, + ArkTSInternalErrorDescription, + `Failed to write preload so file: ${error.message}` + ); + this.logger?.printError?.(errInfo); + } + } + + static collectModuleIds(moduleId: string): void { + if (!this.needPreloadSo) { + return; + } + this.moduleIds.push(moduleId); + } + + private static ensureDirectoryExistence(filePath: string): void { + const dir = path.dirname(filePath); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }); + } + } + + public static cleanUpPreloadSoObjects(): void { + this.preloadEntries = []; + this.preloadEntriesBack = []; + this.preloadFilePath = ''; + this.preloadFilePathBack = ''; + this.logger = undefined; + this.projectConfig = undefined; + this.moduleIds = []; + this.needPreloadSo = true; + } +} \ No newline at end of file diff --git a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts index 900b195c6..78f5bf1db 100644 --- a/compiler/src/fast_build/ark_compiler/module/module_source_file.ts +++ b/compiler/src/fast_build/ark_compiler/module/module_source_file.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use rollupObject file except in compliance with the License. * You may obtain a copy of the License at @@ -28,7 +28,8 @@ import { getOhmUrlByByteCodeHar, getOhmUrlByFilepath, getOhmUrlByExternalPackage, - getOhmUrlBySystemApiOrLibRequest + getOhmUrlBySystemApiOrLibRequest, + OhmUrlParams } from '../../../ark_utils'; import { writeFileSyncByNode } from '../../../process_module_files'; import { @@ -83,6 +84,7 @@ import { getDeclgenBridgeCodePath, writeBridgeCodeFileSyncByNode } from '../../../process_arkts_evolution'; +import { PreloadFileModules } from './module_preload_file_utils'; const ROLLUP_IMPORT_NODE: string = 'ImportDeclaration'; const ROLLUP_EXPORTNAME_NODE: string = 'ExportNamedDeclaration'; @@ -371,6 +373,7 @@ export class ModuleSourceFile { if (!rollupObject.share.projectConfig.compileHar || ModuleSourceFile.projectConfig.byteCodeHar) { //compileHar: compile closed source har of project, which convert .ets to .d.ts and js, doesn't transform module request. const eventBuildModuleSourceFile = createAndStartEvent(parentEvent, 'build module source files'); + PreloadFileModules.collectModuleIds(moduleId); await moduleSourceFile.processModuleRequest(rollupObject, eventBuildModuleSourceFile); stopEvent(eventBuildModuleSourceFile); } @@ -410,6 +413,7 @@ export class ModuleSourceFile { if (!rollupObject.share.projectConfig.compileHar || byteCodeHar) { // compileHar: compile closed source har of project, which convert .ets to .d.ts and js, doesn't transform module request. const eventBuildModuleSourceFile = createAndStartEvent(parentEvent, 'build module source files'); + PreloadFileModules.collectModuleIds(source.getModuleId()); await source.processModuleRequest(rollupObject, eventBuildModuleSourceFile); stopEvent(eventBuildModuleSourceFile); } @@ -457,8 +461,16 @@ export class ModuleSourceFile { if (!!rollupObject.share.projectConfig.useNormalizedOHMUrl) { useNormalizedOHMUrl = rollupObject.share.projectConfig.useNormalizedOHMUrl; } - let systemOrLibOhmUrl = getOhmUrlBySystemApiOrLibRequest(moduleRequest, ModuleSourceFile.projectConfig, - ModuleSourceFile.logger, importerFile, useNormalizedOHMUrl); + const metaModuleInfo: Object = rollupObject.getModuleInfo(this.moduleId); + const isNeedPreloadSo = metaModuleInfo?.meta?.needPreloadSo ? metaModuleInfo?.meta?.needPreloadSo : false; + const params: OhmUrlParams = { + moduleRequest, + moduleId: this.moduleId, + config: ModuleSourceFile.projectConfig, + logger: ModuleSourceFile.logger, + importerFile, + }; + let systemOrLibOhmUrl = getOhmUrlBySystemApiOrLibRequest(params, useNormalizedOHMUrl, isNeedPreloadSo); if (systemOrLibOhmUrl !== undefined) { if (ModuleSourceFile.needProcessMock) { ModuleSourceFile.generateNewMockInfo(moduleRequest, systemOrLibOhmUrl, rollupObject, importerFile); diff --git a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts index 32df152df..8c666e634 100644 --- a/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts +++ b/compiler/src/fast_build/ark_compiler/rollup-plugin-gen-abc.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -34,6 +34,7 @@ import { CompileEvent } from '../../performance'; import { BytecodeObfuscator } from './bytecode_obfuscator'; +import { PreloadFileModules } from './module/module_preload_file_utils'; export function genAbc() { return { @@ -44,6 +45,8 @@ export function genAbc() { //Because calling the method of SourceMapGenerator may not retrieve the rollupObject //it is necessary to assign the rollupObject to SourceMapGenerator in the early stages of build SourceMapGenerator.init(this); + // Check proload path exist or not, initialize preloadBack path + PreloadFileModules.initialize(this); }, shouldInvalidCache: shouldInvalidCache, transform: transformForModule, @@ -85,6 +88,7 @@ export function genAbc() { cleanUpAsyncEvents(); BytecodeObfuscator.cleanBcObfuscatorObject(); cleanUpProcessArkTSEvolutionObj(); + PreloadFileModules.cleanUpPreloadSoObjects(); } }; } diff --git a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts index 53df1a2e7..6c4d4d769 100644 --- a/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts +++ b/compiler/test/ark_compiler_ut/module/ohmUrl/ohmUrl.test.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use rollupObject file except in compliance with the License. * You may obtain a copy of the License at @@ -16,6 +16,7 @@ import { expect } from 'chai'; import mocha from 'mocha'; import sinon from 'sinon'; +import fs from 'fs'; import { getOhmUrlByFilepath, @@ -24,7 +25,8 @@ import { getNormalizedOhmUrlByFilepath, getNormalizedOhmUrlByAliasName, getNormalizedOhmUrlByModuleRequest, - pkgDeclFilesConfig + pkgDeclFilesConfig, + OhmUrlParams } from '../../../../lib/ark_utils'; import { PACKAGES } from '../../../../lib/pre_define'; import projectConfig from '../../utils/processProjectConfig'; @@ -42,6 +44,7 @@ import { LogData, LogDataFactory } from '../../../../lib/fast_build/ark_compiler/logger'; +import { PreloadFileModules } from '../../../../lib/fast_build/ark_compiler/module/module_preload_file_utils'; const PRVIEW_MOCK_CONFIG : Object = { // system api mock @@ -108,9 +111,30 @@ mocha.describe('generate ohmUrl', function () { const systemModuleRequest: string = '@system.app'; const ohosModuleRequest: string = '@ohos.hilog'; const appSoModuleRequest: string = 'libapplication.so'; - const systemOhmUrl: string = getOhmUrlBySystemApiOrLibRequest(systemModuleRequest); - const ohosOhmUrl: string = getOhmUrlBySystemApiOrLibRequest(ohosModuleRequest); - const appOhmUrl: string = getOhmUrlBySystemApiOrLibRequest(appSoModuleRequest); + const systemParams: OhmUrlParams = { + moduleRequest:systemModuleRequest, + moduleId: '', + config: ModuleSourceFile.projectConfig, + logger: ModuleSourceFile.logger, + importerFile: undefined, + }; + const systemOhmUrl: string = getOhmUrlBySystemApiOrLibRequest(systemParams); + const ohosParams: OhmUrlParams = { + moduleRequest: ohosModuleRequest, + moduleId: '', + config: ModuleSourceFile.projectConfig, + logger: ModuleSourceFile.logger, + importerFile: undefined, + }; + const ohosOhmUrl: string = getOhmUrlBySystemApiOrLibRequest(ohosParams); + const appSoParams: OhmUrlParams = { + moduleRequest: appSoModuleRequest, + moduleId: '', + config: ModuleSourceFile.projectConfig, + logger: ModuleSourceFile.logger, + importerFile: undefined, + }; + const appOhmUrl: string = getOhmUrlBySystemApiOrLibRequest(appSoParams); const expectedSystemOhmUrl: string = '@native:system.app'; const expectedOhosOhmUrl: string = '@ohos:hilog'; const expectedappOhmUrl: string = '@app:UtTestApplication/entry/application'; @@ -1252,8 +1276,14 @@ mocha.describe('generate ohmUrl', function () { '/testHap/oh_modules/.ohpm/pkghar@test+har=/oh_modules/pkghar/src/main/ets/pages/Index.ets'; const appSoModuleRequest: string = 'libapplication.so'; try { - getOhmUrlBySystemApiOrLibRequest(appSoModuleRequest, this.rollup.share.projectConfig, logger, - importerFile, true); + const appSoParams: OhmUrlParams = { + moduleRequest: appSoModuleRequest, + moduleId: '', + config: this.rollup.share.projectConfig, + logger: logger, + importerFile: importerFile, + }; + getOhmUrlBySystemApiOrLibRequest(appSoParams, true); } catch (e) { } expect(loggerStub.calledWith(errInfo)).to.be.true; @@ -1279,8 +1309,14 @@ mocha.describe('generate ohmUrl', function () { '/testHap/oh_modules/.ohpm/pkghar@test+har=/oh_modules/pkghar/src/main/ets/pages/Index.ets'; const appSoModuleRequest: string = 'libapplication.so'; try { - getOhmUrlBySystemApiOrLibRequest(appSoModuleRequest, this.rollup.share.projectConfig, logger, - importerFile, true); + const appSoParams: OhmUrlParams = { + moduleRequest: appSoModuleRequest, + moduleId: '', + config: this.rollup.share.projectConfig, + logger: logger, + importerFile: importerFile, + }; + getOhmUrlBySystemApiOrLibRequest(appSoParams, true); } catch (e) { } expect(loggerStub.calledWith(errInfo.toString())).to.be.true; @@ -1474,4 +1510,49 @@ mocha.describe('generate ohmUrl', function () { this.rollup.share.getHvigorConsoleLogger = getHvigorConsoleLogger; loggerStub.restore(); }); + + mocha.it('Collect. so libraries referenced in the project and generate JSON files', function () { + this.rollup.build(); + this.rollup.share.projectConfig.useNormalizedOHMUrl = false; + this.rollup.share.projectConfig.preloadSoFilePath = 'build/default/intermediates/preload/default/preload.json'; + const filePath: string = '/testHsp/hsp/src/main/ets/utils/Calc.ets'; + const outFilePath: string = 'build/default/intermediates/preload/default/preload.json'; + const moduleRequest: string = '@ohos.router'; + const moduleInfo = { + id: filePath, + meta: { + needPreloadSo: true + }, + importedIdMaps: [filePath] + } + this.rollup.moduleInfos.push(moduleInfo); + const importerFile: string = '/testHsp/hsp/src/main/ets/pages/Index.ets' + const moduleSourceFile: string = new ModuleSourceFile(); + moduleSourceFile.moduleId = filePath; + ModuleSourceFile.initPluginEnv(this.rollup); + PreloadFileModules.initialize(this.rollup); + ModuleSourceFile.PreloadEntryNames = []; + ModuleSourceFile.preloadEntries = []; + + const resultOhmUrl: string = moduleSourceFile.getOhmUrl(this.rollup, moduleRequest, filePath, importerFile); + + PreloadFileModules.finalizeWritePreloadSoList(); + + const fileContent = fs.readFileSync(outFilePath, 'utf8'); + const expectedJson = { + "systemPreloadHintStartupTasks": [ + { + "name": "@ohos.router", + "ohmurl": "@ohos:router", + "srcEntry": "@ohos.router" + } + ] + }; + + // Remove trailing ',' if exists + const parsedFileContent = JSON.parse(fileContent.trim().replace(/,$/, '')); + expect(resultOhmUrl === '@ohos:router').to.be.true; + expect(fs.existsSync(outFilePath)).to.be.true; + expect(parsedFileContent).to.deep.equal(expectedJson); + }); }); \ No newline at end of file -- Gitee From 07e849a7d7b597bac868db3c305c18e6c92df4b7 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Mon, 23 Jun 2025 16:07:47 +0800 Subject: [PATCH 133/140] jsonSchema fix Signed-off-by: zhangzezhong --- .../schema/FindEBicycle_1.0.2.json | 2 +- .../schema/ViewCommodity_1.0.2.json | 14 +++++++++++++- .../schema/ViewHospital_1.0.1.json | 8 ++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/compiler/src/userIntents_parser/schema/FindEBicycle_1.0.2.json b/compiler/src/userIntents_parser/schema/FindEBicycle_1.0.2.json index 8138b9ad2..98205ef3b 100644 --- a/compiler/src/userIntents_parser/schema/FindEBicycle_1.0.2.json +++ b/compiler/src/userIntents_parser/schema/FindEBicycle_1.0.2.json @@ -1,7 +1,7 @@ { "intentName": "FindEBicycle", "intentVersion": "1.0.2", - "llmDescription": "寻找电动自行车", + "llmDescription": "寻找电动车", "keywords": ["FindEBicycle"], "parameters": { "type": "object", diff --git a/compiler/src/userIntents_parser/schema/ViewCommodity_1.0.2.json b/compiler/src/userIntents_parser/schema/ViewCommodity_1.0.2.json index 301629d60..0a217d0f3 100644 --- a/compiler/src/userIntents_parser/schema/ViewCommodity_1.0.2.json +++ b/compiler/src/userIntents_parser/schema/ViewCommodity_1.0.2.json @@ -22,7 +22,19 @@ "type": "string", "maxLength": 1500 } - } + }, + "oneOf": [ + { + "required": [ + "entityId" + ] + }, + { + "required": [ + "shareLink" + ] + } + ] }, "result": { "type": "object", diff --git a/compiler/src/userIntents_parser/schema/ViewHospital_1.0.1.json b/compiler/src/userIntents_parser/schema/ViewHospital_1.0.1.json index 7cb9cd464..babbb3797 100644 --- a/compiler/src/userIntents_parser/schema/ViewHospital_1.0.1.json +++ b/compiler/src/userIntents_parser/schema/ViewHospital_1.0.1.json @@ -9,9 +9,6 @@ "enum": [ "entityId" ], - "required": [ - "entityId" - ], "properties": { "entityId": { "description": "数据唯一标识", @@ -19,7 +16,10 @@ "maxLength": 64 } } - } + }, + "required": [ + "entityId" + ] }, "result": { "type": "object", -- Gitee From 21fc143fec812d6b3d507e21d9b473d37701a7e2 Mon Sep 17 00:00:00 2001 From: tomkl123 Date: Mon, 23 Jun 2025 18:37:48 +0800 Subject: [PATCH 134/140] Scrollable component support onWillStopDragging Signed-off-by: tomkl123 Change-Id: Icbfeda466c50a79ea76de8b67fa0d5d14d2af265 --- compiler/components/grid.json | 2 +- compiler/components/list.json | 2 +- compiler/components/scroll.json | 2 +- compiler/components/water_flow.json | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/components/grid.json b/compiler/components/grid.json index 4a1c945f4..19559328e 100644 --- a/compiler/components/grid.json +++ b/compiler/components/grid.json @@ -9,6 +9,6 @@ "onScrollBarUpdate", "enableScrollInteraction", "fadingEdge", "onScrollStart", "onScroll", "onScrollStop", "onWillScroll", "onDidScroll", "cachedCount", "nestedScroll", "friction", "alignItems", "onReachStart", "onReachEnd", "onScrollFrameBegin", "flingSpeedLimit", - "clipContent", "backToTop", "focusWrapMode", "syncLoad" + "clipContent", "backToTop", "focusWrapMode", "syncLoad", "onWillStopDragging" ] } diff --git a/compiler/components/list.json b/compiler/components/list.json index b4736f4ae..aff74ca6d 100644 --- a/compiler/components/list.json +++ b/compiler/components/list.json @@ -9,6 +9,6 @@ "alignListItem", "nestedScroll", "friction", "contentStartOffset", "contentEndOffset", "childrenMainSize", "maintainVisibleContentPosition", "onScrollFrameBegin", "onScrollStart", "onScrollVisibleContentChange", "flingSpeedLimit", "clipContent", "onWillScroll", "onDidScroll", "scrollBarColor", "scrollBarWidth", "backToTop", - "stackFromEnd", "focusWrapMode", "syncLoad" + "stackFromEnd", "focusWrapMode", "syncLoad", "onWillStopDragging" ] } diff --git a/compiler/components/scroll.json b/compiler/components/scroll.json index 209dba43f..998f0c979 100644 --- a/compiler/components/scroll.json +++ b/compiler/components/scroll.json @@ -6,6 +6,6 @@ "scrollBarWidth", "edgeEffect", "enableScrollInteraction", "onScrollBegin", "scrollSnap", "nestedScroll", "friction", "enablePaging", "initialOffset", "onScrollFrameBegin", "onWillScroll", "onDidScroll", "onScrollStart", "onScrollStop", "flingSpeedLimit", - "fadingEdge", "clipContent", "onReachStart", "onReachEnd", "backToTop" + "fadingEdge", "clipContent", "onReachStart", "onReachEnd", "backToTop", "onWillStopDragging" ] } diff --git a/compiler/components/water_flow.json b/compiler/components/water_flow.json index 6ed544ac3..300375772 100644 --- a/compiler/components/water_flow.json +++ b/compiler/components/water_flow.json @@ -32,6 +32,7 @@ "onDidScroll", "clipContent", "backToTop", - "syncLoad" + "syncLoad", + "onWillStopDragging" ] } -- Gitee From 7c1d1b18558edbc1ae634305a684dae4a26699c0 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 24 Jun 2025 09:52:46 +0800 Subject: [PATCH 135/140] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dschema=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- compiler/src/userIntents_parser/parseUserIntents.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/userIntents_parser/parseUserIntents.ts b/compiler/src/userIntents_parser/parseUserIntents.ts index 7d4b99dfc..2a0fc035e 100644 --- a/compiler/src/userIntents_parser/parseUserIntents.ts +++ b/compiler/src/userIntents_parser/parseUserIntents.ts @@ -838,7 +838,7 @@ class ParseIntent { const propertyClassName: string = typeSymbol.getName(); if (this.isArrayType(propType)) { elementType = (propType as ts.TypeReference).typeArguments?.[0]; - propDeclaration = elementType.getSymbol().getDeclarations()[0]; + propDeclaration = elementType.getSymbol()?.getDeclarations()[0]; } else { propDeclaration = typeSymbol.getDeclarations()?.[0]; } @@ -871,6 +871,8 @@ class ParseIntent { private getTypeCategory(type: ts.Type): { category: 'array' | 'object'; } { const flags: ts.TypeFlags = type.getFlags(); + const valueDeclaration: ts.Declaration | undefined = type.getSymbol()?.valueDeclaration; + const isEnum: boolean = valueDeclaration ? ts.isEnumDeclaration(valueDeclaration) : false; const isPrimitive: boolean = !!(flags & ts.TypeFlags.StringLike) || !!(flags & ts.TypeFlags.NumberLike) || @@ -881,7 +883,7 @@ class ParseIntent { const isArray: boolean = this.isArrayType(type); const isObject: boolean = !isPrimitive && !isArray && - !!(flags & ts.TypeFlags.Object); + (!!(flags & ts.TypeFlags.Object) || isEnum); let category: 'array' | 'object'; if (isArray) { category = 'array'; -- Gitee From 3deaaa94b3c45ad240b59cd70f1623510ccdaa6a Mon Sep 17 00:00:00 2001 From: Keerecles Date: Thu, 12 Jun 2025 09:53:34 +0800 Subject: [PATCH 136/140] code clean: assert Signed-off-by: Keerecles Change-Id: I9b146e27c08f6a46d636f25802a1727203389506 --- .../interop/src/cpp/DeserializerBase.h | 3 +- .../koalaui/interop/src/cpp/SerializerBase.h | 11 +++-- .../koalaui/interop/src/cpp/interop-logging.h | 17 +++++-- .../interop/src/cpp/jsc/convertors-jsc.cc | 23 +++++----- .../interop/src/cpp/jsc/convertors-jsc.h | 44 ++++++++++--------- .../interop/src/cpp/wasm/convertors-wasm.h | 12 +++-- 6 files changed, 63 insertions(+), 47 deletions(-) diff --git a/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h index e09c40524..669d16f9f 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h +++ b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h @@ -16,7 +16,6 @@ #define _DESERIALIZER_BASE_H_ #include -#include #include #include #include @@ -343,7 +342,7 @@ public: { if (position + count > length) { fprintf(stderr, "Incorrect serialized data, check for %d, buffer %d position %d\n", count, length, position); - assert(false); + ASSERT(false); abort(); } } diff --git a/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h index f6cce0fae..f99efca14 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h +++ b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h @@ -21,13 +21,13 @@ #include #include #include -#include #include #include #include "callback-resource.h" #include "interop-types.h" #include "koala-types.h" +#include "interop-logging.h" #ifdef __arm__ #define KOALA_NO_UNALIGNED_ACCESS 1 @@ -55,7 +55,7 @@ T* allocArray(const std::array& ref) { std::size_t space = sizeof(buffer) - offset; void* ptr = buffer + offset; void* aligned_ptr = std::align(alignof(T), sizeof(T) * size, ptr, space); - assert(aligned_ptr != nullptr && "Insufficient space or alignment failed!"); + ASSERT(aligned_ptr != nullptr && "Insufficient space or alignment failed!"); offset = (char*)aligned_ptr + sizeof(T) * size - buffer; T* array = reinterpret_cast(aligned_ptr); for (size_t i = 0; i < size; ++i) { @@ -72,8 +72,8 @@ private: bool ownData; CallbackResourceHolder* resourceHolder; void resize(uint32_t newLength) { - assert(ownData); - assert(newLength > dataLength); + ASSERT(ownData); + ASSERT(newLength > dataLength); auto* newData = reinterpret_cast(malloc(newLength)); memcpy(newData, data, position); free(data); @@ -112,8 +112,7 @@ public: if (ownData) { resize(dataLength * 3 / 2 + 2); } else { - fprintf(stderr, "Buffer overrun: %d > %d\n", position + more, dataLength); - assert(false); + INTEROP_FATAL("Buffer overrun: %d > %d\n", position + more, dataLength); } } } diff --git a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.h b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.h index 4d1b7bc0f..493799010 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.h +++ b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.h @@ -15,8 +15,15 @@ #ifndef _INTEROP_LGGING_H #define _INTEROP_LGGING_H -#include -#include +#ifdef __cplusplus + #include + #include + #include +#else + #include + #include + #include +#endif #if defined(KOALA_OHOS) #include "oh_sk_log.h" @@ -37,6 +44,10 @@ #define INTEROP_API_EXPORT __attribute__((visibility("default"))) #endif +#ifndef ASSERT + #define ASSERT(expression) assert(expression) +#endif + // Grouped logs. Keep consistent with type in ServiceGroupLogger typedef struct GroupLogger { void (*startGroupedLog)(int kind); @@ -46,6 +57,6 @@ typedef struct GroupLogger { int (*needGroupedLog)(int kind); } GroupLogger; -const GroupLogger* GetDefaultLogger(); +extern "C" INTEROP_API_EXPORT const GroupLogger* GetDefaultLogger(); #endif // _INTEROP_LOGGING_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc index b1edbde65..1ae964f27 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc @@ -16,11 +16,12 @@ #include #include <_types/_uint32_t.h> #include <_types/_uint8_t.h> -#include #include #include "convertors-jsc.h" +#include "interop-logging.h" + // See https://github.com/BabylonJS/BabylonNative/blob/master/Dependencies/napi/napi-direct/source/js_native_api_javascriptcore.cc // for convertors logic. @@ -59,7 +60,7 @@ int32_t getInt32(JSContextRef context, JSValueRef value) { return 0; } if (JSValueIsUndefined(context, value)) { - assert(false); + ASSERT(false); return 0; } double result = JSValueToNumber(context, value, &exception); @@ -72,7 +73,7 @@ uint32_t getUInt32(JSContextRef context, JSValueRef value) { return 0; } if (JSValueIsUndefined(context, value)) { - assert(false); + ASSERT(false); return 0; } double result = JSValueToNumber(context, value, &exception); @@ -85,7 +86,7 @@ uint8_t getUInt8(JSContextRef context, JSValueRef value) { return 0; } if (JSValueIsUndefined(context, value)) { - assert(false); + ASSERT(false); return 0; } double result = JSValueToNumber(context, value, &exception); @@ -158,10 +159,10 @@ static uint64_t bigIntToU64(JSContextRef ctx, JSValueRef value) { JSStringRef strRef = JSValueToStringCopy(ctx, value, nullptr); size_t len = JSStringGetUTF8CString(strRef, buf, sizeof(buf)); JSStringRelease(strRef); - assert(len < sizeof(buf)); + ASSERT(len < sizeof(buf)); char* suf; uint64_t numValue = std::strtoull(buf, &suf, 10); - assert(*suf == '\0'); + ASSERT(*suf == '\0'); return numValue; } @@ -175,8 +176,8 @@ KNativePointerArray getPointerElements(JSContextRef context, JSValueRef value) { return nullptr; } - assert(JSValueIsObject(context, value)); - assert(JSValueGetTypedArrayType(context, value, nullptr) == kJSTypedArrayTypeBigUint64Array); + ASSERT(JSValueIsObject(context, value)); + ASSERT(JSValueGetTypedArrayType(context, value, nullptr) == kJSTypedArrayTypeBigUint64Array); JSObjectRef typedArray = JSValueToObject(context, value, nullptr); return reinterpret_cast(JSObjectGetTypedArrayBytesPtr(context, typedArray, nullptr)); @@ -188,7 +189,7 @@ KFloat getFloat(JSContextRef context, JSValueRef value) { return 0; } if (JSValueIsUndefined(context, value)) { - assert(false); + ASSERT(false); return 0; } double result = JSValueToNumber(context, value, &exception); @@ -201,7 +202,7 @@ KShort getShort(JSContextRef context, JSValueRef value) { return 0; } if (JSValueIsUndefined(context, value)) { - assert(false); + ASSERT(false); return 0; } double result = JSValueToNumber(context, value, &exception); @@ -214,7 +215,7 @@ KUShort getUShort(JSContextRef context, JSValueRef value) { return 0; } if (JSValueIsUndefined(context, value)) { - assert(false); + ASSERT(false); return 0; } double result = JSValueToNumber(context, value, &exception); diff --git a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h index b100dff7d..860ccae7e 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h +++ b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h @@ -13,7 +13,8 @@ * limitations under the License. */ -#pragma once +#ifndef CONVERTORS_JSC_H +#define CONVERTORS_JSC_H #if defined(linux) #include // For IDE completion @@ -25,9 +26,8 @@ #include #include -#include - #include "koala-types.h" +#include "interop-logging.h" template inline ElemType* getTypedElements(JSContextRef context, const JSValueRef arguments) { @@ -35,7 +35,7 @@ inline ElemType* getTypedElements(JSContextRef context, const JSValueRef argumen return nullptr; } if (JSValueIsUndefined(context, arguments)) { - assert(false); + ASSERT(false); return nullptr; } JSValueRef exception {}; @@ -46,7 +46,7 @@ inline ElemType* getTypedElements(JSContextRef context, const JSValueRef argumen template inline ElemType* getTypedElements(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getTypedElements(context, arguments[index]); } @@ -74,85 +74,85 @@ inline Type getArgument(JSContextRef context, size_t argumentCount, const JSValu template <> inline int32_t getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getInt32(context, arguments[index]); } template <> inline uint32_t getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getUInt32(context, arguments[index]); } template <> inline uint8_t getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getUInt8(context, arguments[index]); } template <> inline KNativePointer getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getPointer(context, arguments[index]); } template <> inline KFloat getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getFloat(context, arguments[index]); } template <> inline KStringPtr getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getString(context, arguments[index]); } template <> inline KBoolean getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getBoolean(context, arguments[index]); } template <> inline KInt* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getInt32Elements(context, arguments[index]); } template <> inline float* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getFloat32Elements(context, arguments[index]); } template <> inline KByte* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getByteElements(context, arguments[index]); } template <> inline KStringArray getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getKStringArray(context, arguments[index]); } template <> inline KUShort* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getUShortElements(context, arguments[index]); } template <> inline KNativePointerArray getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getPointerElements(context, arguments[index]); } template <> inline KShort* getArgument(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - assert(index < argumentCount); + ASSERT(index < argumentCount); return getShortElements(context, arguments[index]); } @@ -711,12 +711,14 @@ void InitExports(JSGlobalContextRef globalContext); #define KOALA_INTEROP_THROW(vmContext, object, ...) \ do { \ - /* TODO: implement*/ assert(false); \ + /* TODO: implement*/ ASSERT(false); \ return __VA_ARGS__; \ } while (0) #define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ do { \ - assert(false); /* TODO: implement*/ \ + ASSERT(false); /* TODO: implement*/ \ return __VA_ARGS__; \ } while (0) + +#endif // CONVERTORS_JSC_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/wasm/convertors-wasm.h b/koala-wrapper/koalaui/interop/src/cpp/wasm/convertors-wasm.h index eea97a98e..c0fffffa1 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/wasm/convertors-wasm.h +++ b/koala-wrapper/koalaui/interop/src/cpp/wasm/convertors-wasm.h @@ -13,14 +13,16 @@ * limitations under the License. */ -#pragma once +#ifndef CONVERTORS_WASM_H +#define CONVERTORS_WASM_H #include "koala-types.h" -#include #include #define KOALA_INTEROP_EXPORT EMSCRIPTEN_KEEPALIVE extern "C" +#include "interop-logging.h" + template struct InteropTypeConverter { using InteropType = T; @@ -767,12 +769,14 @@ KOALA_INTEROP_EXPORT void name( \ #define KOALA_INTEROP_THROW(vmContext, object, ...) \ do { \ - assert(false); /* TODO: implement*/ \ + ASSERT(false); /* TODO: implement*/ \ return __VA_ARGS__; \ } while (0) #define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ do { \ - assert(false); /* TODO: implement*/ \ + ASSERT(false); /* TODO: implement*/ \ return __VA_ARGS__; \ } while (0) + +#endif // CONVERTORS_WASM_H \ No newline at end of file -- Gitee From 3673525008d83aa1ad8353b20d8d281982968bf5 Mon Sep 17 00:00:00 2001 From: Keerecles Date: Thu, 12 Jun 2025 11:25:48 +0800 Subject: [PATCH 137/140] clean code: safe memcpy Signed-off-by: Keerecles Change-Id: I20a092605a2e41d579489f51a46e8070f33924be --- .../interop/src/cpp/DeserializerBase.h | 63 +++++++++++++++---- .../koalaui/interop/src/cpp/SerializerBase.h | 42 ++++++++++--- .../interop/src/cpp/ani/convertors-ani.cc | 21 ------- .../interop/src/cpp/ani/convertors-ani.h | 50 --------------- .../interop/src/cpp/callback-resource.cc | 22 +++++-- .../interop/src/cpp/cangjie/convertors-cj.h | 11 ++-- .../koalaui/interop/src/cpp/common-interop.cc | 23 +++++-- .../interop/src/cpp/ets/convertors-ets.cc | 2 - .../interop/src/cpp/ets/convertors-ets.h | 6 +- .../interop/src/cpp/interop-logging.cc | 13 ++-- .../koalaui/interop/src/cpp/interop-types.h | 6 +- .../interop/src/cpp/jni/convertors-jni.h | 26 +++++--- .../interop/src/cpp/jsc/convertors-jsc.cc | 6 +- .../interop/src/cpp/napi/convertors-napi.h | 14 +---- .../interop/src/cpp/napi/win-dynamic-node.cc | 11 +++- .../koalaui/interop/src/cpp/ohos/hilog/log.h | 9 ++- .../koalaui/interop/src/cpp/ohos/oh_sk_log.cc | 17 +++-- .../koalaui/interop/src/cpp/ohos/oh_sk_log.h | 5 +- .../koalaui/interop/src/cpp/profiler.h | 6 +- .../interop/src/cpp/types/koala-types.h | 8 ++- .../interop/src/cpp/types/signatures.cc | 34 +++++----- .../koalaui/interop/src/cpp/vmloader.cc | 1 - .../src/interop/java/CallbackRegistry.java | 12 ++-- 23 files changed, 239 insertions(+), 169 deletions(-) diff --git a/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h index 669d16f9f..4ff7a986c 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h +++ b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h @@ -23,6 +23,7 @@ #include "interop-types.h" #include "interop-logging.h" +#include "koala-types.h" void holdManagedCallbackResource(InteropInt32); void releaseManagedCallbackResource(InteropInt32); @@ -198,7 +199,11 @@ template <> inline void WriteToString(std::string *result, const InteropMaterialized *value) { char hex[20]; - std::snprintf(hex, sizeof(hex), "0x%llx", (long long)value->ptr); + #ifdef __STDC_LIB_EXT1__ + std::snprintf_s(hex, sizeof(hex), "0x%llx", (long long)value->ptr); + #else + std::snprintf(hex, sizeof(hex), "0x%llx", (long long)value->ptr); + #endif result->append("\""); result->append("Materialized "); result->append(hex); @@ -309,7 +314,11 @@ public: if (length > 0) { value = malloc(length * sizeof(E)); - memset(value, 0, length * sizeof(E)); + #ifdef __STDC_LIB_EXT1__ + memset_s(value, length * sizeof(E), 0, length * sizeof(E)); + #else + memset(value, 0, length * sizeof(E)); + #endif toClean.push_back(value); } array->length = length; @@ -324,11 +333,19 @@ public: if (length > 0) { keys = malloc(length * sizeof(K)); - memset(keys, 0, length * sizeof(K)); + #ifdef __STDC_LIB_EXT1__ + memset_s(keys, length * sizeof(K), 0, length * sizeof(K)); + #else + memset(keys, 0, length * sizeof(K)); + #endif toClean.push_back(keys); values = malloc(length * sizeof(V)); - memset(values, 0, length * sizeof(V)); + #ifdef __STDC_LIB_EXT1__ + memset_s(values, length * sizeof(V), 0, length * sizeof(V)); + #else + memset(values, 0, length * sizeof(V)); + #endif toClean.push_back(values); } map->size = length; @@ -397,7 +414,11 @@ public: check(4); #ifdef KOALA_NO_UNALIGNED_ACCESS InteropInt32 value; - memcpy(&value, data + position, 4); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 4, data + position, 4); + #else + memcpy(&value, data + position, 4); + #endif #else auto value = *(InteropInt32 *)(data + position); #endif @@ -409,7 +430,11 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS InteropInt64 value; - memcpy(&value, data + position, 4); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 4, data + position, 4); + #else + memcpy(&value, data + position, 4); + #endif #else auto value = *(InteropInt64 *)(data + position); #endif @@ -421,7 +446,11 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS InteropInt64 value; - memcpy(&value, data + position, 4); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 4, data + position, 4); + #else + memcpy(&value, data + position, 4); + #endif #else auto value = *(InteropUInt64 *)(data + position); #endif @@ -433,7 +462,11 @@ public: check(4); #ifdef KOALA_NO_UNALIGNED_ACCESS InteropFloat32 value; - memcpy(&value, data + position, 4); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 4, data + position, 4); + #else + memcpy(&value, data + position, 4); + #endif #else auto value = *(InteropFloat32 *)(data + position); #endif @@ -445,12 +478,16 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS int64_t value = 0; - memcpy(&value, data + position, 8); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 8, data + position, 8); + #else + memcpy(&value, data + position, 8); + #endif #else int64_t value = *(int64_t *)(data + position); #endif position += 8; - return reinterpret_cast(value); + return reinterpret_cast(static_cast(value)); } InteropNativePointer readPointerOrDefault(InteropNativePointer defaultValue) { @@ -578,7 +615,11 @@ inline void WriteToString(std::string *result, InteropFloat32 value) #if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 130300L)) // to_chars() is not available on older macOS. char buf[20]; - snprintf(buf, sizeof buf, "%f", value); + #ifdef __STDC_LIB_EXT1__ + snprintf_s(buf, sizeof buf, "%f", value); + #else + snprintf(buf, sizeof buf, "%f", value); + #endif result->append(buf); #else std::string storage; diff --git a/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h index f99efca14..f28c46252 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h +++ b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h @@ -75,7 +75,11 @@ private: ASSERT(ownData); ASSERT(newLength > dataLength); auto* newData = reinterpret_cast(malloc(newLength)); - memcpy(newData, data, position); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(newData, newLength, data, position); + #else + memcpy(newData, data, position); + #endif free(data); data = newData; } @@ -126,7 +130,11 @@ public: void writeInt32(InteropInt32 value) { check(4); #ifdef KOALA_NO_UNALIGNED_ACCESS - memcpy(data + position, &value, 4); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value, 4); + #else + memcpy(data + position, &value, 4); + #endif #else *((InteropInt32*)(data + position)) = value; #endif @@ -136,7 +144,11 @@ public: void writeInt64(InteropInt64 value) { check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS - memcpy(data + position, &value, 8); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value, 8); + #else + memcpy(data + position, &value, 8); + #endif #else *((InteropInt64*)(data + position)) = value; #endif @@ -146,7 +158,11 @@ public: void writeUInt64(InteropUInt64 value) { check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS - memcpy(data + position, &value, 8); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value, 8); + #else + memcpy(data + position, &value, 8); + #endif #else *((InteropUInt64*)(data + position)) = value; #endif @@ -156,7 +172,11 @@ public: void writeFloat32(InteropFloat32 value) { check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS - memcpy(data + position, &value, 4); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value, 4); + #else + memcpy(data + position, &value, 4); + #endif #else *((InteropFloat32*)(data + position)) = value; #endif @@ -166,7 +186,11 @@ public: void writePointer(InteropNativePointer value) { check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS - memcpy(data + position, &value, 8); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value64, 8); + #else + memcpy(data + position, &value, 8); + #endif #else *((int64_t*)(data + position)) = reinterpret_cast(value); #endif @@ -220,7 +244,11 @@ public: case 3: suffix = "%"; break; case 4: suffix = "lpx"; break; } - snprintf(buf, 64, "%.8f%s", value.value, suffix.c_str()); + #ifdef __STDC_LIB_EXT1__ + snprintf_s(buf, 64, "%.8f%s", value.value, suffix.c_str()); + #else + snprintf(buf, 64, "%.8f%s", value.value, suffix.c_str()); + #endif InteropString str = { buf, (InteropInt32) strlen(buf) }; writeString(str); break; diff --git a/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.cc b/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.cc index f41a2f5bf..cb9160ed0 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.cc @@ -40,7 +40,6 @@ static bool registerNatives(ani_env *env, const ani_class clazz, const std::vect ani_boolean isError = false; env->ExistUnhandledError(&isError); if (isError) { - //env->ErrorDescribe(); env->ResetError(); } } @@ -73,26 +72,6 @@ bool registerAllModules(ani_env *env) { return true; } -#if 0 -extern "C" ETS_EXPORT ets_int ETS_CALL EtsNapiOnLoad(ets_env *env) { - if (!registerAllModules(env)) { - LOGE("Failed to register ets modules"); - return ETS_ERR; - } - auto interopClasspath = AniExports::getInstance()->getClasspath("InteropNativeModule"); - auto interopClass = env->FindClass(interopClasspath.c_str()); - if (interopClass == nullptr) { - LOGE("Can not find InteropNativeModule classpath to set callback dispatcher"); - return ETS_ERR; - } - if (!setKoalaEtsNapiCallbackDispatcher(env, interopClass, callCallbackFromNative, callCallbackFromNativeSig)) { - LOGE("Failed to set koala ets callback dispatcher"); - return ETS_ERR; - } - return ETS_NAPI_VERSION_1_0; -} -#endif - AniExports* AniExports::getInstance() { static AniExports *instance = nullptr; if (instance == nullptr) { diff --git a/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.h b/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.h index 3be74d311..c3b678273 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.h +++ b/koala-wrapper/koalaui/interop/src/cpp/ani/convertors-ani.h @@ -16,7 +16,6 @@ #ifndef KOALA_ANI #define KOALA_ANI -#include #include #include #include @@ -1319,60 +1318,11 @@ bool setKoalaEtsNapiCallbackDispatcher( ); void getKoalaEtsNapiCallbackDispatcher(ani_class* clazz, ani_method* method); -#if 0 -#define KOALA_INTEROP_CALL_VOID(venv, id, length, args) \ -{ \ - ani_class clazz = nullptr; \ - ani_method method = nullptr; \ - getKoalaEtsNapiCallbackDispatcher(&clazz, &method); \ - ani_env* ani_env = reinterpret_cast(vmContext); \ - ani_env->PushLocalFrame(1); \ - ani_fixedarray_byte args_ets = ani_env->NewByteArray(length); \ - ani_env->SetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ - ani_env->CallStaticIntMethod(clazz, method, id, args_ets, length); \ - ani_env->GetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ - ani_env->PopLocalFrame(nullptr); \ -} - -#define KOALA_INTEROP_CALL_INT(venv, id, length, args) \ -{ \ - ani_class clazz = nullptr; \ - ani_method method = nullptr; \ - getKoalaEtsNapiCallbackDispatcher(&clazz, &method); \ - ani_env* ani_env = reinterpret_cast(venv); \ - ani_env->PushLocalFrame(1); \ - ani_fixedarray_byte args_ets = ani_env->NewByteArray(length); \ - ani_env->SetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ - int32_t rv = ani_env->CallStaticIntMethod(clazz, method, id, args_ets, length); \ - ani_env->GetByteArrayRegion(args_ets, 0, length, reinterpret_cast(args)); \ - ani_env->PopLocalFrame(nullptr); \ - return rv; \ -} - -#define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_VOID(venv, id, (argc) * sizeof(int32_t), args) -#define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) KOALA_INTEROP_CALL_INT(venv, id, (argc) * sizeof(int32_t), args) - -#define KOALA_INTEROP_THROW(vmContext, object, ...) \ - do { \ - ani_env* env = reinterpret_cast(vmContext); \ - env->ThrowError(object); \ - return __VA_ARGS__; \ - } while (0) - -#define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ - do { \ - ani_env* env = reinterpret_cast(vmContext); \ - const static ani_class errorClass = env->FindClass("std/core/Error"); \ - env->ThrowErrorNew(errorClass, message); \ - } while (0) -#else - #define KOALA_INTEROP_CALL_VOID(venv, id, length, args) #define KOALA_INTEROP_CALL_INT(venv, id, length, args) { return 0; } #define KOALA_INTEROP_CALL_VOID_INTS32(venv, id, argc, args) { return; } #define KOALA_INTEROP_CALL_INT_INTS32(venv, id, argc, args) { return 0; } #define KOALA_INTEROP_THROW(vmContext, object, ...) { return __VA_ARGS__; } #define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) { return __VA_ARGS__; } -#endif #endif // KOALA_ETS_NAPI diff --git a/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc index d7851e405..f10eacf58 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc @@ -41,7 +41,8 @@ void releaseManagedCallbackResource(InteropInt32 resourceId) { callbackResourceSubqueue.push_back(resourceId); } -KInt impl_CheckCallbackEvent(KByte* result, KInt size) { +KInt impl_CheckCallbackEvent(KByte* buffer, KInt size) { + KByte* result = (KByte*)buffer; if (needReleaseFront) { switch (callbackEventsQueue.front()) @@ -64,16 +65,29 @@ KInt impl_CheckCallbackEvent(KByte* result, KInt size) { return 0; } const CallbackEventKind frontEventKind = callbackEventsQueue.front(); - memcpy(result, &frontEventKind, 4); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(result, size, &frontEventKind, 4); + #else + memcpy(result, &frontEventKind, 4); + #endif + switch (frontEventKind) { case Event_CallCallback: - memcpy(result + 4, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(result + 4, size, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); + #else + memcpy(result + 4, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); + #endif break; case Event_HoldManagedResource: case Event_ReleaseManagedResource: { const InteropInt32 resourceId = callbackResourceSubqueue.front(); - memcpy(result + 4, &resourceId, 4); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(result + 4, size, &frontEventKind, 4); + #else + memcpy(result + 4, &resourceId, 4); + #endif break; } default: diff --git a/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.h b/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.h index 17949006b..e3fbc8a20 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.h +++ b/koala-wrapper/koalaui/interop/src/cpp/cangjie/convertors-cj.h @@ -13,15 +13,16 @@ * limitations under the License. */ -#pragma once +#ifndef CONVERTORS_CJ_H +#define CONVERTORS_CJ_H #include -#include #include #include #include #include "koala-types.h" +#include "interop-logging.h" #define KOALA_INTEROP_EXPORT extern "C" @@ -864,12 +865,14 @@ KOALA_INTEROP_EXPORT void name(InteropTypeConverter::InteropType _p0, \ #define KOALA_INTEROP_THROW(vmContext, object, ...) \ do { \ - /* TODO: implement*/ assert(false); \ + /* TODO: implement*/ ASSERT(false); \ return __VA_ARGS__; \ } while (0) #define KOALA_INTEROP_THROW_STRING(vmContext, message, ...) \ do { \ - /* TODO: implement*/ assert(false); \ + /* TODO: implement*/ ASSERT(false); \ return __VA_ARGS__; \ } while (0) + +#endif // CONVERTORS_CJ_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc b/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc index ec6572c6d..5d4d5b43e 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc @@ -127,7 +127,13 @@ KOALA_INTEROP_1(StringLength, KInt, KNativePointer) void impl_StringData(KNativePointer ptr, KByte* bytes, KUInt size) { string* s = reinterpret_cast(ptr); - if (s) memcpy(bytes, s->c_str(), size); + if (s) { + #ifdef __STDC_LIB_EXT1__ + memcpy_s(bytes, size, s->c_str(), size); + #else + memcpy(bytes, s->c_str(), size); + #endif + } } KOALA_INTEROP_V3(StringData, KNativePointer, KByte*, KUInt) @@ -149,7 +155,11 @@ KOALA_INTEROP_1(StringMake, KNativePointer, KStringPtr) // For slow runtimes w/o fast encoders. KInt impl_ManagedStringWrite(const KStringPtr& string, KByte* buffer, KInt offset) { - memcpy(buffer + offset, string.c_str(), string.length() + 1); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(buffer + offset, string.length() + 1, string.c_str(), string.length() + 1); + #else + memcpy(buffer + offset, string.c_str(), string.length() + 1); + #endif return string.length() + 1; } KOALA_INTEROP_3(ManagedStringWrite, KInt, KStringPtr, KByte*, KInt) @@ -373,8 +383,7 @@ KInt impl_CallForeignVM(KNativePointer foreignContextRaw, KInt function, KByte* KOALA_INTEROP_4(CallForeignVM, KInt, KNativePointer, KInt, KByte*, KInt) -#define __QUOTE(x) #x -#define QUOTE(x) __QUOTE(x) +#define QUOTE(x) #x void impl_NativeLog(const KStringPtr& str) { #ifdef KOALA_OHOS @@ -461,7 +470,11 @@ KOALA_INTEROP_CTX_1(StdStringToString, KStringPtr, KNativePointer) #if defined(KOALA_JNI) || defined(KOALA_NAPI) || defined(KOALA_CJ) KInteropReturnBuffer impl_RawReturnData(KVMContext vmContext, KInt v1, KInt v2) { void* data = new int8_t[v1]; - memset(data, v2, v1); + #ifdef __STDC_LIB_EXT1__ + memset_s(data, v1, v2, v1); + #else + memset(data, v2, v1); + #endif KInteropReturnBuffer buffer = { v1, data, [](KNativePointer ptr, KInt) { delete[] (int8_t*)ptr; }}; return buffer; } diff --git a/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.cc b/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.cc index 450804338..103c8c7de 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.cc @@ -38,7 +38,6 @@ static bool registerNatives(ets_env *env, const ets_class clazz, const std::vect if (registerByOne) { result &= env->RegisterNatives(clazz, &method, 1) >= 0; if (env->ErrorCheck()) { - //env->ErrorDescribe(); env->ErrorClear(); } } @@ -131,7 +130,6 @@ void EtsExports::setClasspath(const char* module, const char *classpath) { static std::map g_defaultClasspaths = { {"InteropNativeModule", "@koalaui/interop/InteropNativeModule/InteropNativeModule"}, - // todo leave just InteropNativeModule, define others via KOALA_ETS_INTEROP_MODULE_CLASSPATH {"TestNativeModule", "@koalaui/arkts-arkui/generated/arkts/TestNativeModule/TestNativeModule"}, {"ArkUINativeModule", "@koalaui/arkts-arkui/generated/arkts/ArkUINativeModule/ArkUINativeModule"}, {"ArkUIGeneratedNativeModule", "@koalaui/arkts-arkui/generated/arkts/ArkUIGeneratedNativeModule/ArkUIGeneratedNativeModule"}, diff --git a/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.h b/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.h index c03b5af27..b81fc1c81 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.h +++ b/koala-wrapper/koalaui/interop/src/cpp/ets/convertors-ets.h @@ -13,11 +13,11 @@ * limitations under the License. */ -#pragma once +#ifndef CONVERTORS_ETS_H +#define CONVERTORS_ETS_H #ifdef KOALA_ETS_NAPI -#include #include #include #include @@ -1347,3 +1347,5 @@ void getKoalaEtsNapiCallbackDispatcher(ets_class* clazz, ets_method* method); } while (0) #endif // KOALA_ETS_NAPI + +#endif // CONVERTORS_ETS_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc index 073878547..b99493ff6 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc @@ -14,6 +14,7 @@ */ #include #include +#include #include "interop-logging.h" @@ -27,7 +28,7 @@ struct Log { std::vector groupedLogs; void startGroupedLog(int index) { - if (index >= (int)groupedLogs.size()) { + if (index >= static_cast(groupedLogs.size())) { groupedLogs.resize(index + 1); for (int i = 0; i <= index; i++) { if (!groupedLogs[i]) groupedLogs[i] = new Log(); @@ -38,27 +39,27 @@ void startGroupedLog(int index) { } void stopGroupedLog(int index) { - if (index < (int)groupedLogs.size()) { + if (index < static_cast(groupedLogs.size())) { groupedLogs[index]->isActive = false; } } void appendGroupedLog(int index, const char* str) { - if (index < (int)groupedLogs.size()) { + if (index < static_cast(groupedLogs.size())) { groupedLogs[index]->log.append(str); } } const char* getGroupedLog(int index) { - if (index < (int)groupedLogs.size()) { - auto result = groupedLogs[index]->log.c_str(); + if (index < static_cast(groupedLogs.size())) { + const char* result = groupedLogs[index]->log.c_str(); return result; } return ""; } int needGroupedLog(int index) { - if (index < (int)groupedLogs.size()) { + if (index < static_cast(groupedLogs.size())) { return groupedLogs[index]->isActive; } return 0; diff --git a/koala-wrapper/koalaui/interop/src/cpp/interop-types.h b/koala-wrapper/koalaui/interop/src/cpp/interop-types.h index 4c5c26187..1daaaa80a 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/interop-types.h +++ b/koala-wrapper/koalaui/interop/src/cpp/interop-types.h @@ -16,7 +16,11 @@ #ifndef _INTEROP_TYPES_H_ #define _INTEROP_TYPES_H_ -#include +#ifdef __cplusplus + #include +#else + #include +#endif #define INTEROP_FATAL(msg, ...) do { fprintf(stderr, msg "\n", ##__VA_ARGS__); abort(); } while (0) diff --git a/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h index 2ebefafe7..063a86a56 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h +++ b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h @@ -13,12 +13,12 @@ * limitations under the License. */ -#pragma once +#ifndef CONVERTORS_JNI_H +#define CONVERTORS_JNI_H #ifdef KOALA_JNI #include -#include #include #include @@ -145,9 +145,14 @@ struct SlowInteropTypeConverter { return result; } static InteropType convertTo(JNIEnv* env, KInteropBuffer value) { - jarray result = env->NewByteArray(value.length); + int bufferLength = value.length; + jarray result = env->NewByteArray(bufferLength); void* data = env->GetPrimitiveArrayCritical(result, nullptr); - memcpy(data, value.data, value.length); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(data, bufferLength, value.data, bufferLength); + #else + memcpy(data, value.data, bufferLength); + #endif env->ReleasePrimitiveArrayCritical(result, data, 0); return result; } @@ -161,11 +166,16 @@ struct SlowInteropTypeConverter { using InteropType = jarray; static inline KInteropReturnBuffer convertFrom(JNIEnv* env, InteropType value) = delete; static InteropType convertTo(JNIEnv* env, KInteropReturnBuffer value) { - jarray result = env->NewByteArray(value.length); + int bufferLength = value.length; + jarray result = env->NewByteArray(bufferLength); void* data = env->GetPrimitiveArrayCritical(result, nullptr); - memcpy(data, value.data, value.length); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(data, bufferLength, value.data, bufferLength); + #else + memcpy(data, value.data, bufferLength); + #endif env->ReleasePrimitiveArrayCritical(result, data, 0); - value.dispose(value.data, value.length); + value.dispose(value.data, bufferLength); return result; } static inline void release(JNIEnv* env, InteropType value, const KInteropReturnBuffer& converted) = delete; @@ -1463,3 +1473,5 @@ void getKoalaJniCallbackDispatcher(jclass* clazz, jmethodID* method); } while (0) #endif // KOALA_JNI_CALL + +#endif // CONVERTORS_JNI_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc index 1ae964f27..246a1fd1c 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc @@ -146,7 +146,11 @@ static JSValueRef u64ToBigInt(JSContextRef context, uint64_t value) { bigint = JSObjectCallAsFunction(context, bigIntFromParts, nullptr, 2, parts, nullptr); #else char buffer[128] = {0}; - std::snprintf(buffer, sizeof(buffer) - 1, "%zun", (size_t) value); + #ifdef __STDC_LIB_EXT1__ + std::snprintf_s(buffer, sizeof(buffer) - 1, "%zun", static_cast(value)); + #else + std::snprintf(buffer, sizeof(buffer) - 1, "%zun", static_cast(value)); + #endif JSStringRef script = JSStringCreateWithUTF8CString(buffer); bigint = JSEvaluateScript(context, script, nullptr, nullptr, 0, nullptr); JSStringRelease(script); diff --git a/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.h b/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.h index 720d423f1..2446ec3a8 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.h +++ b/koala-wrapper/koalaui/interop/src/cpp/napi/convertors-napi.h @@ -31,7 +31,6 @@ #include "koala-types.h" #include "interop-types.h" -// TODO: switch to more generic convertors eventually. template struct InteropTypeConverter { using InteropType = T; @@ -88,9 +87,6 @@ struct InteropTypeConverter { (void*)copy, &result ); - if (status != napi_ok) { - // do smth here - } return result; }; static void release(napi_env env, InteropType value, KInteropBuffer converted) {} @@ -241,7 +237,6 @@ public: } private: napi_env _env; - // napi_callback_info _info; std::vector args; }; @@ -513,11 +508,6 @@ inline KNativePointerArray getArgument(const CallbackInfo& return getPointerElements(info, index); } -// template <> -// inline napi_value getArgument(const CallbackInfo& info, int index) { -// return getObject(info, index); -// } - template <> inline uint8_t* getArgument(const CallbackInfo& info, int index) { return getUInt8Elements(info, index); @@ -573,7 +563,6 @@ napi_value makeUInt64(napi_env env, uint32_t value); napi_value makeFloat32(napi_env env, float value); napi_value makePointer(napi_env env, void* value); napi_value makeVoid(napi_env env); -// napi_value makeObject(napi_env env, napi_value object); inline napi_value makeVoid(const CallbackInfo& info) { return makeVoid(info.Env()); @@ -656,8 +645,7 @@ public: const std::vector>& getMethods(const std::string& module); }; -#define __QUOTE(x) #x -#define QUOTE(x) __QUOTE(x) +#define QUOTE(x) #x #ifdef _MSC_VER #define MAKE_NODE_EXPORT(module, name) \ diff --git a/koala-wrapper/koalaui/interop/src/cpp/napi/win-dynamic-node.cc b/koala-wrapper/koalaui/interop/src/cpp/napi/win-dynamic-node.cc index 6ec8fcc34..ac0355338 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/napi/win-dynamic-node.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/napi/win-dynamic-node.cc @@ -12,8 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include + +#ifdef __cplusplus + #include + #include +#else + #include + #include +#endif + #include #include "node_api.h" diff --git a/koala-wrapper/koalaui/interop/src/cpp/ohos/hilog/log.h b/koala-wrapper/koalaui/interop/src/cpp/ohos/hilog/log.h index 7452137c2..174564bce 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/ohos/hilog/log.h +++ b/koala-wrapper/koalaui/interop/src/cpp/ohos/hilog/log.h @@ -58,8 +58,13 @@ * * @since 8 */ -#include -#include + +#ifdef __cplusplus + #include +#else + #include + #include +#endif #ifdef __cplusplus extern "C" { diff --git a/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.cc b/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.cc index 6aa01fe5e..0d30f1b58 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.cc @@ -24,9 +24,13 @@ static const char* KOALAUI_OHOS_LOG_ROOT = "/data/storage/el2/base/files/logs"; -#define APPLY_LOG_FILE_PATTERN(buf, t, ms, pid) \ - sprintf(buf, "%s/%d_%d_%d_%ld.pid%d.log", \ - KOALAUI_OHOS_LOG_ROOT, t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, ms.tv_sec, pid) +#define APPLY_LOG_FILE_PATTERN(buf, bufLen, t, ms, pid) \ + #ifdef __STDC_LIB_EXT1__ \ + sprintf_s(buf, bufLen, "%s/%d_%d_%d_%lld.pid%d.log", \ + #else \ + sprintf(buf, "%s/%d_%d_%d_%lld.pid%d.log", \ + #endif \ + KOALAUI_OHOS_LOG_ROOT, (t).tm_year + 1900, (t).tm_mon + 1, (t).tm_mday, (ms).tv_sec, pid) const char* oh_sk_log_type_str(oh_sk_log_type type) { switch (type) { @@ -46,15 +50,16 @@ void oh_sk_file_log(oh_sk_log_type type, const char* msg, ...) { static char* path = nullptr; if (!path) { - path = new char[strlen(KOALAUI_OHOS_LOG_ROOT) + 100]; - APPLY_LOG_FILE_PATTERN(path, lt, ms, getpid()); + size_t len = strlen(KOALAUI_OHOS_LOG_ROOT) + 100; + path = new char[len]; + APPLY_LOG_FILE_PATTERN(path, len, lt, ms, getpid()); mkdir(KOALAUI_OHOS_LOG_ROOT, 0777); } std::unique_ptr file(fopen(path, "a"), fclose); if (!file) return; - fprintf(file.get(), "%02d-%02d %02d:%02d:%02d.%03ld %s koala: ", + fprintf(file.get(), "%02d-%02d %02d:%02d:%02d.%03lld %s koala: ", lt.tm_mon + 1, lt.tm_mday, lt.tm_hour, lt.tm_min, lt.tm_sec, ms.tv_usec / 1000, oh_sk_log_type_str(type)); diff --git a/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.h b/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.h index 961e2c0f1..6544a2e2e 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.h +++ b/koala-wrapper/koalaui/interop/src/cpp/ohos/oh_sk_log.h @@ -13,7 +13,8 @@ * limitations under the License. */ -#pragma once +#ifndef OH_SK_LOG_H +#define OH_SK_LOG_H #include @@ -55,3 +56,5 @@ const char* oh_sk_log_type_str(oh_sk_log_type type); #define OH_SK_LOG_FATAL_A(msg, ...) OH_LOG_Print(LOG_APP, LOG_FATAL, 0xFF00, "Koala", msg, ##__VA_ARGS__) #endif + +#endif // OH_SK_LOG_H \ No newline at end of file diff --git a/koala-wrapper/koalaui/interop/src/cpp/profiler.h b/koala-wrapper/koalaui/interop/src/cpp/profiler.h index a3b9da38c..cdfe518d9 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/profiler.h +++ b/koala-wrapper/koalaui/interop/src/cpp/profiler.h @@ -68,7 +68,11 @@ class InteropProfiler { auto ns = a.second.time; auto count = a.second.count; char buffer[1024]; - snprintf(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), (long long)count, (double)ns / total * 100.0, (long long)ns); + #ifdef __STDC_LIB_EXT1__ + snprintf_s(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), (long long)count, (double)ns / total * 100.0, (long long)ns); + #else + snprintf(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), (long long)count, (double)ns / total * 100.0, (long long)ns); + #endif result += buffer; }); return result; diff --git a/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h b/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h index 2c5e88754..f5d684146 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h +++ b/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h @@ -66,7 +66,11 @@ struct KStringPtrImpl { if (data) { if (_owned) { _value = reinterpret_cast(malloc(len + 1)); - memcpy(_value, data, len); + #ifdef __STDC_LIB_EXT1__ + memcpy_s(_value, len, data, len); + #else + memcpy(_value, data, len); + #endif _value[len] = 0; } else { _value = const_cast(data); @@ -100,7 +104,7 @@ struct KInteropNumber { // TODO: boundary check if (value == std::floor(value)) { result.tag = 102; // ARK_TAG_INT32 - result.i32 = (int)value; + result.i32 = static_cast(value); } else { result.tag = 103; // ARK_TAG_FLOAT32 result.f32 = (float)value; diff --git a/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc b/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc index 7f556adaf..6c4d12e62 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc @@ -13,8 +13,14 @@ * limitations under the License. */ -#include "stdio.h" -#include +#ifdef __cplusplus + #include + #include +#else + #include + #include +#endif + #include #include "signatures.h" @@ -22,15 +28,15 @@ // For types with the same name on ets and jni #define KOALA_INTEROP_TYPEDEF(func, lang, CPP_TYPE, SIG_TYPE, CODE_TYPE) \ - if (std::strcmp(func, "sigType") == 0) if (type == CPP_TYPE) return SIG_TYPE; \ - if (std::strcmp(func, "codeType") == 0) if (type == CPP_TYPE) return CODE_TYPE; + if (std::strcmp(func, "sigType") == 0) if (type == (CPP_TYPE)) return SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0) if (type == (CPP_TYPE)) return CODE_TYPE; // For types with distinct names on ets and jni #define KOALA_INTEROP_TYPEDEF_LS(func, lang, CPP_TYPE, ETS_SIG_TYPE, ETS_CODE_TYPE, JNI_SIG_TYPE, JNI_CODE_TYPE) \ - if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "ets") == 0) if (type == CPP_TYPE) return ETS_SIG_TYPE; \ - if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "ets") == 0) if (type == CPP_TYPE) return ETS_CODE_TYPE; \ - if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "jni") == 0) if (type == CPP_TYPE) return JNI_SIG_TYPE; \ - if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "jni") == 0) if (type == CPP_TYPE) return JNI_CODE_TYPE; + if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "ets") == 0) if (type == (CPP_TYPE)) return ETS_SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "ets") == 0) if (type == (CPP_TYPE)) return ETS_CODE_TYPE; \ + if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "jni") == 0) if (type == (CPP_TYPE)) return JNI_SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "jni") == 0) if (type == (CPP_TYPE)) return JNI_CODE_TYPE; #define KOALA_INTEROP_TYPEDEFS(func, lang) \ KOALA_INTEROP_TYPEDEF(func, lang, "void", "V", "void") \ @@ -107,7 +113,7 @@ std::string convertType(const char* name, const char* koalaType) { #if KOALA_USE_PANDA_VM - for (int i = 1; i < (int)tokens.size(); i++) + for (int i = 1; i < static_cast(tokens.size()); i++) { result.append(sigType(tokens[i])); } @@ -117,7 +123,7 @@ std::string convertType(const char* name, const char* koalaType) { #elif KOALA_USE_JAVA_VM result.append("("); - for (int i = 1; i < (int)tokens.size(); i++) + for (int i = 1; i < static_cast(tokens.size()); i++) { result.append(sigType(tokens[i])); } @@ -129,24 +135,24 @@ std::string convertType(const char* name, const char* koalaType) { #ifdef KOALA_BUILD_FOR_SIGNATURES #ifdef KOALA_USE_PANDA_VM std::string params; - for (int i = 1; i < (int)tokens.size(); i++) + for (int i = 1; i < static_cast(tokens.size()); i++) { params.append("arg"); params.append(std::to_string(i)); params.append(": "); params.append(codeType(tokens[i])); - if (i < (int)(tokens.size() - 1)) + if (i < static_cast(tokens.size() - 1)) params.append(", "); } fprintf(stderr, " static native %s(%s): %s;\n", name, params.c_str(), codeType(tokens[0]).c_str()); #elif KOALA_USE_JAVA_VM std::string params; - for (int i = 1; i < (int)tokens.size(); i++) + for (int i = 1; i < static_cast(tokens.size()); i++) { params.append(codeType(tokens[i])); params.append(" arg"); params.append(std::to_string(i)); - if (i < (int)(tokens.size() - 1)) + if (i < static_cast(tokens.size() - 1)) params.append(", "); } fprintf(stderr, " public static native %s %s(%s);\n", codeType(tokens[0]).c_str(), name, params.c_str()); diff --git a/koala-wrapper/koalaui/interop/src/cpp/vmloader.cc b/koala-wrapper/koalaui/interop/src/cpp/vmloader.cc index 995d2623c..c2f5a08f9 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/vmloader.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/vmloader.cc @@ -259,7 +259,6 @@ extern "C" DLL_EXPORT KInt LoadVirtualMachine(KInt vmKind, const char* appClassP etsVMOptions.push_back({EtsOptionType::ETS_NO_JIT, nullptr}); etsVMOptions.push_back({EtsOptionType::ETS_MOBILE_LOG, (void*)ArkMobileLog}); etsVMOptions.push_back({EtsOptionType::ETS_AOT, nullptr}); - // etsVMOptions.push_back({EtsOptionType::ETS_LOG_LEVEL, "info"}); pandaVMArgs.nOptions = etsVMOptions.size(); pandaVMArgs.options = etsVMOptions.data(); g_vmEntry.vmKind = PANDA_VM_KIND; diff --git a/koala-wrapper/koalaui/interop/src/interop/java/CallbackRegistry.java b/koala-wrapper/koalaui/interop/src/interop/java/CallbackRegistry.java index 59dceae85..b246d133b 100644 --- a/koala-wrapper/koalaui/interop/src/interop/java/CallbackRegistry.java +++ b/koala-wrapper/koalaui/interop/src/interop/java/CallbackRegistry.java @@ -40,15 +40,15 @@ class CallbackRegistry { } public static Integer wrap(CallbackType callback) { - Integer id = CallbackRegistry.id++; - CallbackRegistry.callbacks.put(id, new CallbackRecord(callback, true)); - return id; + Integer tmpId = CallbackRegistry.id++; + CallbackRegistry.callbacks.put(tmpId, new CallbackRecord(callback, true)); + return tmpId; } public static Integer wrap(CallbackType callback, boolean autoDisposable) { - Integer id = CallbackRegistry.id++; - CallbackRegistry.callbacks.put(id, new CallbackRecord(callback, autoDisposable)); - return id; + Integer tmpId = CallbackRegistry.id++; + CallbackRegistry.callbacks.put(tmpId, new CallbackRecord(callback, autoDisposable)); + return tmpId; } public static int call(Integer id, byte[] args, int length) { -- Gitee From e3fd12914d4b8db7bf18895a3b9d22b0acabc3d4 Mon Sep 17 00:00:00 2001 From: Keerecles Date: Thu, 12 Jun 2025 11:31:51 +0800 Subject: [PATCH 138/140] Add CODEOWNERS Signed-off-by: Keerecles Change-Id: I0622299a9c7058a88ab57100bb37e6721107ade2 --- .gitee/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitee/CODEOWNERS b/.gitee/CODEOWNERS index d0600cc8d..53ea029d5 100755 --- a/.gitee/CODEOWNERS +++ b/.gitee/CODEOWNERS @@ -26,6 +26,7 @@ compiler/test/ut/ @lixingchi1 compiler/test/utForPartialUpdate/ @lixingchi1 compiler/test/utForValidate/ @lixingchi1 compiler/test/transform_ut/ @lixingchi1 +koala-wrapper/ @keerecles # Code owners for ArkCompiler ace_ets2bundle -- Gitee From 0f9273ab2635f5561c9365c1ba7acbd80c0c95c6 Mon Sep 17 00:00:00 2001 From: Keerecles Date: Thu, 12 Jun 2025 15:43:12 +0800 Subject: [PATCH 139/140] code clean Signed-off-by: Keerecles Change-Id: Iafbf0fc320dc6e10f48a68d2df671eb30a87077c --- .../interop/src/cpp/DeserializerBase.h | 100 +++++++++--------- .../koalaui/interop/src/cpp/SerializerBase.h | 76 ++++++------- .../interop/src/cpp/callback-resource.cc | 30 +++--- .../koalaui/interop/src/cpp/common-interop.cc | 30 +++--- .../interop/src/cpp/interop-logging.cc | 6 +- .../koalaui/interop/src/cpp/interop-types.h | 2 +- .../interop/src/cpp/jni/convertors-jni.h | 20 ++-- .../interop/src/cpp/jsc/convertors-jsc.cc | 10 +- .../interop/src/cpp/jsc/convertors-jsc.h | 4 +- .../koalaui/interop/src/cpp/profiler.h | 12 ++- .../interop/src/cpp/types/koala-types.h | 10 +- .../interop/src/cpp/types/signatures.cc | 12 ++- koala-wrapper/native/include/common.h | 2 +- 13 files changed, 163 insertions(+), 151 deletions(-) diff --git a/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h index 4ff7a986c..2945f8da8 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h +++ b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h @@ -199,11 +199,11 @@ template <> inline void WriteToString(std::string *result, const InteropMaterialized *value) { char hex[20]; - #ifdef __STDC_LIB_EXT1__ - std::snprintf_s(hex, sizeof(hex), "0x%llx", (long long)value->ptr); - #else - std::snprintf(hex, sizeof(hex), "0x%llx", (long long)value->ptr); - #endif +#ifdef __STDC_LIB_EXT1__ + std::snprintf_s(hex, sizeof(hex), "0x%llx", (long long)value->ptr); +#else + std::snprintf(hex, sizeof(hex), "0x%llx", (long long)value->ptr); +#endif result->append("\""); result->append("Materialized "); result->append(hex); @@ -314,11 +314,11 @@ public: if (length > 0) { value = malloc(length * sizeof(E)); - #ifdef __STDC_LIB_EXT1__ - memset_s(value, length * sizeof(E), 0, length * sizeof(E)); - #else - memset(value, 0, length * sizeof(E)); - #endif +#ifdef __STDC_LIB_EXT1__ + memset_s(value, length * sizeof(E), 0, length * sizeof(E)); +#else + memset(value, 0, length * sizeof(E)); +#endif toClean.push_back(value); } array->length = length; @@ -333,19 +333,19 @@ public: if (length > 0) { keys = malloc(length * sizeof(K)); - #ifdef __STDC_LIB_EXT1__ - memset_s(keys, length * sizeof(K), 0, length * sizeof(K)); - #else - memset(keys, 0, length * sizeof(K)); - #endif +#ifdef __STDC_LIB_EXT1__ + memset_s(keys, length * sizeof(K), 0, length * sizeof(K)); +#else + memset(keys, 0, length * sizeof(K)); +#endif toClean.push_back(keys); values = malloc(length * sizeof(V)); - #ifdef __STDC_LIB_EXT1__ - memset_s(values, length * sizeof(V), 0, length * sizeof(V)); - #else - memset(values, 0, length * sizeof(V)); - #endif +#ifdef __STDC_LIB_EXT1__ + memset_s(values, length * sizeof(V), 0, length * sizeof(V)); +#else + memset(values, 0, length * sizeof(V)); +#endif toClean.push_back(values); } map->size = length; @@ -414,11 +414,11 @@ public: check(4); #ifdef KOALA_NO_UNALIGNED_ACCESS InteropInt32 value; - #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 4, data + position, 4); - #else - memcpy(&value, data + position, 4); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 4, data + position, 4); +#else + memcpy(&value, data + position, 4); +#endif #else auto value = *(InteropInt32 *)(data + position); #endif @@ -430,11 +430,11 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS InteropInt64 value; - #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 4, data + position, 4); - #else - memcpy(&value, data + position, 4); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 4, data + position, 4); +#else + memcpy(&value, data + position, 4); +#endif #else auto value = *(InteropInt64 *)(data + position); #endif @@ -446,11 +446,11 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS InteropInt64 value; - #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 4, data + position, 4); - #else - memcpy(&value, data + position, 4); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 4, data + position, 4); +#else + memcpy(&value, data + position, 4); +#endif #else auto value = *(InteropUInt64 *)(data + position); #endif @@ -462,11 +462,11 @@ public: check(4); #ifdef KOALA_NO_UNALIGNED_ACCESS InteropFloat32 value; - #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 4, data + position, 4); - #else - memcpy(&value, data + position, 4); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 4, data + position, 4); +#else + memcpy(&value, data + position, 4); +#endif #else auto value = *(InteropFloat32 *)(data + position); #endif @@ -478,11 +478,11 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS int64_t value = 0; - #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 8, data + position, 8); - #else - memcpy(&value, data + position, 8); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(&value, 8, data + position, 8); +#else + memcpy(&value, data + position, 8); +#endif #else int64_t value = *(int64_t *)(data + position); #endif @@ -615,11 +615,11 @@ inline void WriteToString(std::string *result, InteropFloat32 value) #if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 130300L)) // to_chars() is not available on older macOS. char buf[20]; - #ifdef __STDC_LIB_EXT1__ - snprintf_s(buf, sizeof buf, "%f", value); - #else - snprintf(buf, sizeof buf, "%f", value); - #endif +#ifdef __STDC_LIB_EXT1__ + snprintf_s(buf, sizeof buf, "%f", value); +#else + snprintf(buf, sizeof buf, "%f", value); +#endif result->append(buf); #else std::string storage; diff --git a/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h index f28c46252..0abea8247 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h +++ b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h @@ -33,6 +33,8 @@ #define KOALA_NO_UNALIGNED_ACCESS 1 #endif +constexpr int BUFFER_MAX_LEN = 64; + template inline InteropRuntimeType runtimeType(const T& value) = delete; @@ -55,7 +57,7 @@ T* allocArray(const std::array& ref) { std::size_t space = sizeof(buffer) - offset; void* ptr = buffer + offset; void* aligned_ptr = std::align(alignof(T), sizeof(T) * size, ptr, space); - ASSERT(aligned_ptr != nullptr && "Insufficient space or alignment failed!"); + ASSERT(aligned_ptr != nullptr); // "Insufficient space or alignment failed!" offset = (char*)aligned_ptr + sizeof(T) * size - buffer; T* array = reinterpret_cast(aligned_ptr); for (size_t i = 0; i < size; ++i) { @@ -75,11 +77,11 @@ private: ASSERT(ownData); ASSERT(newLength > dataLength); auto* newData = reinterpret_cast(malloc(newLength)); - #ifdef __STDC_LIB_EXT1__ - memcpy_s(newData, newLength, data, position); - #else - memcpy(newData, data, position); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(newData, newLength, data, position); +#else + memcpy(newData, data, position); +#endif free(data); data = newData; } @@ -130,11 +132,11 @@ public: void writeInt32(InteropInt32 value) { check(4); #ifdef KOALA_NO_UNALIGNED_ACCESS - #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value, 4); - #else - memcpy(data + position, &value, 4); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value, 4); +#else + memcpy(data + position, &value, 4); +#endif #else *((InteropInt32*)(data + position)) = value; #endif @@ -144,11 +146,11 @@ public: void writeInt64(InteropInt64 value) { check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS - #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value, 8); - #else - memcpy(data + position, &value, 8); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value, 8); +#else + memcpy(data + position, &value, 8); +#endif #else *((InteropInt64*)(data + position)) = value; #endif @@ -158,11 +160,11 @@ public: void writeUInt64(InteropUInt64 value) { check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS - #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value, 8); - #else - memcpy(data + position, &value, 8); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value, 8); +#else + memcpy(data + position, &value, 8); +#endif #else *((InteropUInt64*)(data + position)) = value; #endif @@ -172,11 +174,11 @@ public: void writeFloat32(InteropFloat32 value) { check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS - #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value, 4); - #else - memcpy(data + position, &value, 4); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value, 4); +#else + memcpy(data + position, &value, 4); +#endif #else *((InteropFloat32*)(data + position)) = value; #endif @@ -186,11 +188,11 @@ public: void writePointer(InteropNativePointer value) { check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS - #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value64, 8); - #else - memcpy(data + position, &value, 8); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(data + position, dataLength, &value64, 8); +#else + memcpy(data + position, &value, 8); +#endif #else *((int64_t*)(data + position)) = reinterpret_cast(value); #endif @@ -235,7 +237,7 @@ public: writeInt32(value.resource); break; case INTEROP_RUNTIME_STRING: { - char buf[64]; + char buf[BUFFER_MAX_LEN]; std::string suffix; switch (value.unit) { case 0: suffix = "px"; break; @@ -244,11 +246,11 @@ public: case 3: suffix = "%"; break; case 4: suffix = "lpx"; break; } - #ifdef __STDC_LIB_EXT1__ - snprintf_s(buf, 64, "%.8f%s", value.value, suffix.c_str()); - #else - snprintf(buf, 64, "%.8f%s", value.value, suffix.c_str()); - #endif +#ifdef __STDC_LIB_EXT1__ + snprintf_s(buf, BUFFER_MAX_LEN, "%.8f%s", value.value, suffix.c_str()); +#else + snprintf(buf, BUFFER_MAX_LEN, "%.8f%s", value.value, suffix.c_str()); +#endif InteropString str = { buf, (InteropInt32) strlen(buf) }; writeString(str); break; diff --git a/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc index f10eacf58..0bf2128f0 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc @@ -65,29 +65,29 @@ KInt impl_CheckCallbackEvent(KByte* buffer, KInt size) { return 0; } const CallbackEventKind frontEventKind = callbackEventsQueue.front(); - #ifdef __STDC_LIB_EXT1__ - memcpy_s(result, size, &frontEventKind, 4); - #else - memcpy(result, &frontEventKind, 4); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(result, size, &frontEventKind, 4); +#else + memcpy(result, &frontEventKind, 4); +#endif switch (frontEventKind) { case Event_CallCallback: - #ifdef __STDC_LIB_EXT1__ - memcpy_s(result + 4, size, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); - #else - memcpy(result + 4, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(result + 4, size, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); +#else + memcpy(result + 4, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); +#endif break; case Event_HoldManagedResource: case Event_ReleaseManagedResource: { const InteropInt32 resourceId = callbackResourceSubqueue.front(); - #ifdef __STDC_LIB_EXT1__ - memcpy_s(result + 4, size, &frontEventKind, 4); - #else - memcpy(result + 4, &resourceId, 4); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(result + 4, size, &frontEventKind, 4); +#else + memcpy(result + 4, &resourceId, 4); +#endif break; } default: diff --git a/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc b/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc index 5d4d5b43e..2eb8c428f 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc @@ -128,11 +128,11 @@ KOALA_INTEROP_1(StringLength, KInt, KNativePointer) void impl_StringData(KNativePointer ptr, KByte* bytes, KUInt size) { string* s = reinterpret_cast(ptr); if (s) { - #ifdef __STDC_LIB_EXT1__ - memcpy_s(bytes, size, s->c_str(), size); - #else - memcpy(bytes, s->c_str(), size); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(bytes, size, s->c_str(), size); +#else + memcpy(bytes, s->c_str(), size); +#endif } } KOALA_INTEROP_V3(StringData, KNativePointer, KByte*, KUInt) @@ -155,11 +155,11 @@ KOALA_INTEROP_1(StringMake, KNativePointer, KStringPtr) // For slow runtimes w/o fast encoders. KInt impl_ManagedStringWrite(const KStringPtr& string, KByte* buffer, KInt offset) { - #ifdef __STDC_LIB_EXT1__ - memcpy_s(buffer + offset, string.length() + 1, string.c_str(), string.length() + 1); - #else - memcpy(buffer + offset, string.c_str(), string.length() + 1); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(buffer + offset, string.length() + 1, string.c_str(), string.length() + 1); +#else + memcpy(buffer + offset, string.c_str(), string.length() + 1); +#endif return string.length() + 1; } KOALA_INTEROP_3(ManagedStringWrite, KInt, KStringPtr, KByte*, KInt) @@ -470,11 +470,11 @@ KOALA_INTEROP_CTX_1(StdStringToString, KStringPtr, KNativePointer) #if defined(KOALA_JNI) || defined(KOALA_NAPI) || defined(KOALA_CJ) KInteropReturnBuffer impl_RawReturnData(KVMContext vmContext, KInt v1, KInt v2) { void* data = new int8_t[v1]; - #ifdef __STDC_LIB_EXT1__ - memset_s(data, v1, v2, v1); - #else - memset(data, v2, v1); - #endif +#ifdef __STDC_LIB_EXT1__ + memset_s(data, v1, v2, v1); +#else + memset(data, v2, v1); +#endif KInteropReturnBuffer buffer = { v1, data, [](KNativePointer ptr, KInt) { delete[] (int8_t*)ptr; }}; return buffer; } diff --git a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc index b99493ff6..01178d096 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc @@ -14,7 +14,11 @@ */ #include #include -#include +#ifdef __cplusplus + #include +#else + #include +#endif #include "interop-logging.h" diff --git a/koala-wrapper/koalaui/interop/src/cpp/interop-types.h b/koala-wrapper/koalaui/interop/src/cpp/interop-types.h index 1daaaa80a..911300d6b 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/interop-types.h +++ b/koala-wrapper/koalaui/interop/src/cpp/interop-types.h @@ -22,7 +22,7 @@ #include #endif -#define INTEROP_FATAL(msg, ...) do { fprintf(stderr, msg "\n", ##__VA_ARGS__); abort(); } while (0) +#define INTEROP_FATAL(msg, ...) do { fprintf(stderr, msg "\n", ##__VA_ARGS__);} while (0) typedef enum InteropTag { diff --git a/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h index 063a86a56..cd4a2fca2 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h +++ b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h @@ -148,11 +148,11 @@ struct SlowInteropTypeConverter { int bufferLength = value.length; jarray result = env->NewByteArray(bufferLength); void* data = env->GetPrimitiveArrayCritical(result, nullptr); - #ifdef __STDC_LIB_EXT1__ - memcpy_s(data, bufferLength, value.data, bufferLength); - #else - memcpy(data, value.data, bufferLength); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(data, bufferLength, value.data, bufferLength); +#else + memcpy(data, value.data, bufferLength); +#endif env->ReleasePrimitiveArrayCritical(result, data, 0); return result; } @@ -169,11 +169,11 @@ struct SlowInteropTypeConverter { int bufferLength = value.length; jarray result = env->NewByteArray(bufferLength); void* data = env->GetPrimitiveArrayCritical(result, nullptr); - #ifdef __STDC_LIB_EXT1__ - memcpy_s(data, bufferLength, value.data, bufferLength); - #else - memcpy(data, value.data, bufferLength); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(data, bufferLength, value.data, bufferLength); +#else + memcpy(data, value.data, bufferLength); +#endif env->ReleasePrimitiveArrayCritical(result, data, 0); value.dispose(value.data, bufferLength); return result; diff --git a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc index 246a1fd1c..3b5546f4b 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc @@ -146,11 +146,11 @@ static JSValueRef u64ToBigInt(JSContextRef context, uint64_t value) { bigint = JSObjectCallAsFunction(context, bigIntFromParts, nullptr, 2, parts, nullptr); #else char buffer[128] = {0}; - #ifdef __STDC_LIB_EXT1__ - std::snprintf_s(buffer, sizeof(buffer) - 1, "%zun", static_cast(value)); - #else - std::snprintf(buffer, sizeof(buffer) - 1, "%zun", static_cast(value)); - #endif +#ifdef __STDC_LIB_EXT1__ + std::snprintf_s(buffer, sizeof(buffer) - 1, "%zun", static_cast(value)); +#else + std::snprintf(buffer, sizeof(buffer) - 1, "%zun", static_cast(value)); +#endif JSStringRef script = JSStringCreateWithUTF8CString(buffer); bigint = JSEvaluateScript(context, script, nullptr, nullptr, 0, nullptr); JSStringRelease(script); diff --git a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h index 860ccae7e..aaabacf01 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h +++ b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h @@ -46,8 +46,8 @@ inline ElemType* getTypedElements(JSContextRef context, const JSValueRef argumen template inline ElemType* getTypedElements(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], int index) { - ASSERT(index < argumentCount); - return getTypedElements(context, arguments[index]); + ASSERT(index < argumentCount); + return getTypedElements(context, arguments[index]); } uint8_t* getUInt8Elements(JSContextRef context, const JSValueRef arguments); diff --git a/koala-wrapper/koalaui/interop/src/cpp/profiler.h b/koala-wrapper/koalaui/interop/src/cpp/profiler.h index cdfe518d9..dd2483f10 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/profiler.h +++ b/koala-wrapper/koalaui/interop/src/cpp/profiler.h @@ -68,11 +68,13 @@ class InteropProfiler { auto ns = a.second.time; auto count = a.second.count; char buffer[1024]; - #ifdef __STDC_LIB_EXT1__ - snprintf_s(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), (long long)count, (double)ns / total * 100.0, (long long)ns); - #else - snprintf(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), (long long)count, (double)ns / total * 100.0, (long long)ns); - #endif +#ifdef __STDC_LIB_EXT1__ + snprintf_s(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), + (long long)count, (double)ns / total * 100.0, (long long)ns); +#else + snprintf(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), + (long long)count, (double)ns / total * 100.0, (long long)ns); +#endif result += buffer; }); return result; diff --git a/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h b/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h index f5d684146..2ffa24ba7 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h +++ b/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h @@ -66,11 +66,11 @@ struct KStringPtrImpl { if (data) { if (_owned) { _value = reinterpret_cast(malloc(len + 1)); - #ifdef __STDC_LIB_EXT1__ - memcpy_s(_value, len, data, len); - #else - memcpy(_value, data, len); - #endif +#ifdef __STDC_LIB_EXT1__ + memcpy_s(_value, len, data, len); +#else + memcpy(_value, data, len); +#endif _value[len] = 0; } else { _value = const_cast(data); diff --git a/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc b/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc index 6c4d12e62..75fc13ee6 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/types/signatures.cc @@ -33,10 +33,14 @@ // For types with distinct names on ets and jni #define KOALA_INTEROP_TYPEDEF_LS(func, lang, CPP_TYPE, ETS_SIG_TYPE, ETS_CODE_TYPE, JNI_SIG_TYPE, JNI_CODE_TYPE) \ - if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "ets") == 0) if (type == (CPP_TYPE)) return ETS_SIG_TYPE; \ - if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "ets") == 0) if (type == (CPP_TYPE)) return ETS_CODE_TYPE; \ - if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "jni") == 0) if (type == (CPP_TYPE)) return JNI_SIG_TYPE; \ - if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "jni") == 0) if (type == (CPP_TYPE)) return JNI_CODE_TYPE; + if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "ets") == 0) \ + if (type == (CPP_TYPE)) return ETS_SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "ets") == 0) \ + if (type == (CPP_TYPE)) return ETS_CODE_TYPE; \ + if (std::strcmp(func, "sigType") == 0 && std::strcmp(lang, "jni") == 0) \ + if (type == (CPP_TYPE)) return JNI_SIG_TYPE; \ + if (std::strcmp(func, "codeType") == 0 && std::strcmp(lang, "jni") == 0) \ + if (type == (CPP_TYPE)) return JNI_CODE_TYPE; #define KOALA_INTEROP_TYPEDEFS(func, lang) \ KOALA_INTEROP_TYPEDEF(func, lang, "void", "V", "void") \ diff --git a/koala-wrapper/native/include/common.h b/koala-wrapper/native/include/common.h index 77ed29cf8..4c17074fb 100644 --- a/koala-wrapper/native/include/common.h +++ b/koala-wrapper/native/include/common.h @@ -13,7 +13,7 @@ * limitations under the License. */ - #ifndef COMMON_H +#ifndef COMMON_H #define COMMON_H #include "dynamic-loader.h" -- Gitee From 30fd568486d605b3ee2cee29fa9a3f0958087ae2 Mon Sep 17 00:00:00 2001 From: Keerecles Date: Thu, 12 Jun 2025 16:44:38 +0800 Subject: [PATCH 140/140] code clean: safe function return Signed-off-by: Keerecles Change-Id: Id06f6bdf1d626cbe83293a8eaef13e5c2b6f2955 --- .../interop/src/cpp/DeserializerBase.h | 50 +++++++++++++++---- .../koalaui/interop/src/cpp/SerializerBase.h | 35 ++++++++++--- .../interop/src/cpp/callback-resource.cc | 15 ++++-- .../koalaui/interop/src/cpp/common-interop.cc | 15 ++++-- .../interop/src/cpp/interop-logging.cc | 3 +- .../interop/src/cpp/jni/convertors-jni.h | 10 +++- .../interop/src/cpp/jsc/convertors-jsc.cc | 5 +- .../interop/src/cpp/jsc/convertors-jsc.h | 2 +- .../koalaui/interop/src/cpp/profiler.h | 11 ++-- .../interop/src/cpp/types/koala-types.h | 5 +- 10 files changed, 118 insertions(+), 33 deletions(-) diff --git a/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h index 2945f8da8..c0b7c88c7 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h +++ b/koala-wrapper/koalaui/interop/src/cpp/DeserializerBase.h @@ -200,7 +200,10 @@ inline void WriteToString(std::string *result, const InteropMaterialized *value) { char hex[20]; #ifdef __STDC_LIB_EXT1__ - std::snprintf_s(hex, sizeof(hex), "0x%llx", (long long)value->ptr); + errno_t res = std::snprintf_s(hex, sizeof(hex), "0x%llx", (long long)value->ptr); + if (res != EOK) { + return; + } #else std::snprintf(hex, sizeof(hex), "0x%llx", (long long)value->ptr); #endif @@ -315,7 +318,10 @@ public: { value = malloc(length * sizeof(E)); #ifdef __STDC_LIB_EXT1__ - memset_s(value, length * sizeof(E), 0, length * sizeof(E)); + errno_t res = memset_s(value, length * sizeof(E), 0, length * sizeof(E)); + if (res != EOK) { + return; + } #else memset(value, 0, length * sizeof(E)); #endif @@ -334,7 +340,10 @@ public: { keys = malloc(length * sizeof(K)); #ifdef __STDC_LIB_EXT1__ - memset_s(keys, length * sizeof(K), 0, length * sizeof(K)); + errno_t res = memset_s(keys, length * sizeof(K), 0, length * sizeof(K)); + if (res != EOK) { + return; + } #else memset(keys, 0, length * sizeof(K)); #endif @@ -342,7 +351,10 @@ public: values = malloc(length * sizeof(V)); #ifdef __STDC_LIB_EXT1__ - memset_s(values, length * sizeof(V), 0, length * sizeof(V)); + errno_t res = memset_s(values, length * sizeof(V), 0, length * sizeof(V)); + if (res != EOK) { + return; + } #else memset(values, 0, length * sizeof(V)); #endif @@ -415,7 +427,10 @@ public: #ifdef KOALA_NO_UNALIGNED_ACCESS InteropInt32 value; #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 4, data + position, 4); + errno_t res = memcpy_s(&value, 4, data + position, 4); + if (res != EOK) { + return value; + } #else memcpy(&value, data + position, 4); #endif @@ -431,7 +446,10 @@ public: #ifdef KOALA_NO_UNALIGNED_ACCESS InteropInt64 value; #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 4, data + position, 4); + errno_t res = memcpy_s(&value, 4, data + position, 4); + if (res != EOK) { + return value; + } #else memcpy(&value, data + position, 4); #endif @@ -447,7 +465,10 @@ public: #ifdef KOALA_NO_UNALIGNED_ACCESS InteropInt64 value; #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 4, data + position, 4); + errno_t res = memcpy_s(&value, 4, data + position, 4); + if (res != EOK) { + return value; + } #else memcpy(&value, data + position, 4); #endif @@ -463,7 +484,10 @@ public: #ifdef KOALA_NO_UNALIGNED_ACCESS InteropFloat32 value; #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 4, data + position, 4); + errno_t res = memcpy_s(&value, 4, data + position, 4); + if (res != EOK) { + return value; + } #else memcpy(&value, data + position, 4); #endif @@ -479,7 +503,10 @@ public: #ifdef KOALA_NO_UNALIGNED_ACCESS int64_t value = 0; #ifdef __STDC_LIB_EXT1__ - memcpy_s(&value, 8, data + position, 8); + errno_t res = memcpy_s(&value, 8, data + position, 8); + if (res != EOK) { + return value; + } #else memcpy(&value, data + position, 8); #endif @@ -616,7 +643,10 @@ inline void WriteToString(std::string *result, InteropFloat32 value) // to_chars() is not available on older macOS. char buf[20]; #ifdef __STDC_LIB_EXT1__ - snprintf_s(buf, sizeof buf, "%f", value); + errno_t res = snprintf_s(buf, sizeof buf, "%f", value); + if (res != EOK) { + return; + } #else snprintf(buf, sizeof buf, "%f", value); #endif diff --git a/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h index 0abea8247..321169abf 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h +++ b/koala-wrapper/koalaui/interop/src/cpp/SerializerBase.h @@ -78,7 +78,10 @@ private: ASSERT(newLength > dataLength); auto* newData = reinterpret_cast(malloc(newLength)); #ifdef __STDC_LIB_EXT1__ - memcpy_s(newData, newLength, data, position); + errno_t res = memcpy_s(newData, newLength, data, position); + if (res != EOK) { + return; + } #else memcpy(newData, data, position); #endif @@ -133,7 +136,10 @@ public: check(4); #ifdef KOALA_NO_UNALIGNED_ACCESS #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value, 4); + errno_t res = memcpy_s(data + position, dataLength, &value, 4); + if (res != EOK) { + return; + } #else memcpy(data + position, &value, 4); #endif @@ -147,7 +153,10 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value, 8); + errno_t res = memcpy_s(data + position, dataLength, &value, 8); + if (res != EOK) { + return; + } #else memcpy(data + position, &value, 8); #endif @@ -161,7 +170,10 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value, 8); + errno_t res = memcpy_s(data + position, dataLength, &value, 8); + if (res != EOK) { + return; + } #else memcpy(data + position, &value, 8); #endif @@ -175,7 +187,10 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value, 4); + errno_t res = memcpy_s(data + position, dataLength, &value, 4); + if (res != EOK) { + return; + } #else memcpy(data + position, &value, 4); #endif @@ -189,7 +204,10 @@ public: check(8); #ifdef KOALA_NO_UNALIGNED_ACCESS #ifdef __STDC_LIB_EXT1__ - memcpy_s(data + position, dataLength, &value64, 8); + errno_t res = memcpy_s(data + position, dataLength, &value64, 8); + if (res != EOK) { + return; + } #else memcpy(data + position, &value, 8); #endif @@ -247,7 +265,10 @@ public: case 4: suffix = "lpx"; break; } #ifdef __STDC_LIB_EXT1__ - snprintf_s(buf, BUFFER_MAX_LEN, "%.8f%s", value.value, suffix.c_str()); + errno_t res = snprintf_s(buf, BUFFER_MAX_LEN, "%.8f%s", value.value, suffix.c_str()); + if (res != EOK) { + return; + } #else snprintf(buf, BUFFER_MAX_LEN, "%.8f%s", value.value, suffix.c_str()); #endif diff --git a/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc index 0bf2128f0..6f246712d 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/callback-resource.cc @@ -66,7 +66,10 @@ KInt impl_CheckCallbackEvent(KByte* buffer, KInt size) { } const CallbackEventKind frontEventKind = callbackEventsQueue.front(); #ifdef __STDC_LIB_EXT1__ - memcpy_s(result, size, &frontEventKind, 4); + errno_t res = memcpy_s(result, size, &frontEventKind, 4); + if (res != EOK) { + return 0; + } #else memcpy(result, &frontEventKind, 4); #endif @@ -75,7 +78,10 @@ KInt impl_CheckCallbackEvent(KByte* buffer, KInt size) { { case Event_CallCallback: #ifdef __STDC_LIB_EXT1__ - memcpy_s(result + 4, size, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); + errno_t res = memcpy_s(result + 4, size, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); + if (res != EOK) { + return 0; + } #else memcpy(result + 4, callbackCallSubqueue.front().buffer, sizeof(CallbackBuffer::buffer)); #endif @@ -84,7 +90,10 @@ KInt impl_CheckCallbackEvent(KByte* buffer, KInt size) { case Event_ReleaseManagedResource: { const InteropInt32 resourceId = callbackResourceSubqueue.front(); #ifdef __STDC_LIB_EXT1__ - memcpy_s(result + 4, size, &frontEventKind, 4); + errno_t res = memcpy_s(result + 4, size, &frontEventKind, 4); + if (res != EOK) { + return 0; + } #else memcpy(result + 4, &resourceId, 4); #endif diff --git a/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc b/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc index 2eb8c428f..27f8cf3b6 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/common-interop.cc @@ -129,7 +129,10 @@ void impl_StringData(KNativePointer ptr, KByte* bytes, KUInt size) { string* s = reinterpret_cast(ptr); if (s) { #ifdef __STDC_LIB_EXT1__ - memcpy_s(bytes, size, s->c_str(), size); + errno_t res = memcpy_s(bytes, size, s->c_str(), size); + if (res != EOK) { + return; + } #else memcpy(bytes, s->c_str(), size); #endif @@ -156,7 +159,10 @@ KOALA_INTEROP_1(StringMake, KNativePointer, KStringPtr) // For slow runtimes w/o fast encoders. KInt impl_ManagedStringWrite(const KStringPtr& string, KByte* buffer, KInt offset) { #ifdef __STDC_LIB_EXT1__ - memcpy_s(buffer + offset, string.length() + 1, string.c_str(), string.length() + 1); + errno_t res = memcpy_s(buffer + offset, string.length() + 1, string.c_str(), string.length() + 1); + if (res != EOK) { + return 0; + } #else memcpy(buffer + offset, string.c_str(), string.length() + 1); #endif @@ -471,7 +477,10 @@ KOALA_INTEROP_CTX_1(StdStringToString, KStringPtr, KNativePointer) KInteropReturnBuffer impl_RawReturnData(KVMContext vmContext, KInt v1, KInt v2) { void* data = new int8_t[v1]; #ifdef __STDC_LIB_EXT1__ - memset_s(data, v1, v2, v1); + errno_t res = memset_s(data, v1, v2, v1); + if (res != EOK) { + LOGE("RawReturnData failed"); + } #else memset(data, v2, v1); #endif diff --git a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc index 01178d096..20d47b8bb 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/interop-logging.cc @@ -56,8 +56,7 @@ void appendGroupedLog(int index, const char* str) { const char* getGroupedLog(int index) { if (index < static_cast(groupedLogs.size())) { - const char* result = groupedLogs[index]->log.c_str(); - return result; + return groupedLogs[index]->log.c_str(); } return ""; } diff --git a/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h index cd4a2fca2..2b89aeb46 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h +++ b/koala-wrapper/koalaui/interop/src/cpp/jni/convertors-jni.h @@ -149,7 +149,10 @@ struct SlowInteropTypeConverter { jarray result = env->NewByteArray(bufferLength); void* data = env->GetPrimitiveArrayCritical(result, nullptr); #ifdef __STDC_LIB_EXT1__ - memcpy_s(data, bufferLength, value.data, bufferLength); + errno_t res = memcpy_s(data, bufferLength, value.data, bufferLength); + if (res != EOK) { + return result; + } #else memcpy(data, value.data, bufferLength); #endif @@ -170,7 +173,10 @@ struct SlowInteropTypeConverter { jarray result = env->NewByteArray(bufferLength); void* data = env->GetPrimitiveArrayCritical(result, nullptr); #ifdef __STDC_LIB_EXT1__ - memcpy_s(data, bufferLength, value.data, bufferLength); + errno_t res = memcpy_s(data, bufferLength, value.data, bufferLength); + if (res != EOK) { + return result; + } #else memcpy(data, value.data, bufferLength); #endif diff --git a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc index 3b5546f4b..5d4114829 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc +++ b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.cc @@ -147,7 +147,10 @@ static JSValueRef u64ToBigInt(JSContextRef context, uint64_t value) { #else char buffer[128] = {0}; #ifdef __STDC_LIB_EXT1__ - std::snprintf_s(buffer, sizeof(buffer) - 1, "%zun", static_cast(value)); + errno_t res = std::snprintf_s(buffer, sizeof(buffer) - 1, "%zun", static_cast(value)); + if (res != EOK) { + return bigint; + } #else std::snprintf(buffer, sizeof(buffer) - 1, "%zun", static_cast(value)); #endif diff --git a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h index aaabacf01..022d8e4d6 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h +++ b/koala-wrapper/koalaui/interop/src/cpp/jsc/convertors-jsc.h @@ -711,7 +711,7 @@ void InitExports(JSGlobalContextRef globalContext); #define KOALA_INTEROP_THROW(vmContext, object, ...) \ do { \ - /* TODO: implement*/ ASSERT(false); \ + ASSERT(false); /* TODO: implement*/ \ return __VA_ARGS__; \ } while (0) diff --git a/koala-wrapper/koalaui/interop/src/cpp/profiler.h b/koala-wrapper/koalaui/interop/src/cpp/profiler.h index dd2483f10..d3b7d5106 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/profiler.h +++ b/koala-wrapper/koalaui/interop/src/cpp/profiler.h @@ -25,6 +25,8 @@ #include #include +constexpr double PERCENTAGE_FACTOR = 100.0; + struct InteropProfilerRecord { int64_t time; int64_t count; @@ -69,11 +71,14 @@ class InteropProfiler { auto count = a.second.count; char buffer[1024]; #ifdef __STDC_LIB_EXT1__ - snprintf_s(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), - (long long)count, (double)ns / total * 100.0, (long long)ns); + errno_t res = snprintf_s(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), + (long long)count, (double)ns / total * PERCENTAGE_FACTOR, (long long)ns); + if (res != EOK) { + return ""; + } #else snprintf(buffer, sizeof buffer, "for %s[%lld]: %.01f%% (%lld)\n", a.first.c_str(), - (long long)count, (double)ns / total * 100.0, (long long)ns); + (long long)count, (double)ns / total * PERCENTAGE_FACTOR, (long long)ns); #endif result += buffer; }); diff --git a/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h b/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h index 2ffa24ba7..710e77370 100644 --- a/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h +++ b/koala-wrapper/koalaui/interop/src/cpp/types/koala-types.h @@ -67,7 +67,10 @@ struct KStringPtrImpl { if (_owned) { _value = reinterpret_cast(malloc(len + 1)); #ifdef __STDC_LIB_EXT1__ - memcpy_s(_value, len, data, len); + errno_t res = memcpy_s(_value, len, data, len); + if (res != EOK) { + return; + } #else memcpy(_value, data, len); #endif -- Gitee