Component library calling method and device, computer equipment and storage medium

By listening to the project configuration file to obtain the type definition file of the component library and mapping it to the target data structure, the problem of lagging knowledge updates in the AI ​​programming assistant is solved, enabling real-time conversion and direct calling of the component library, thus improving development efficiency and code quality.

CN121807288APending Publication Date: 2026-04-07BEIJING BAILONG MAYUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-19
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

In existing technologies, AI programming assistants lag behind in updating their knowledge of third-party UI component libraries, causing developers to frequently switch between IDEs and component documentation, manually writing code, which severely slows down the development process.

Method used

This provides a method for calling a component library. By listening to the project configuration file, it obtains the type definition file of the component library and maps its attribute information into data structures of object and array types, generating a target data structure that can be recognized by the AI ​​programming assistant, thus realizing real-time conversion and direct calling of the component library.

Benefits of technology

It enables the real-time conversion of component libraries into standard tools that can be directly called, reducing the need for manual adaptation code writing and improving development efficiency and code quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121807288A_ABST
    Figure CN121807288A_ABST
Patent Text Reader

Abstract

The invention relates to a component library calling method and device, computer equipment and a storage medium. The method comprises the following steps: monitoring a configuration file of a current project, when monitoring that declaration information of a new component library appears in the configuration file of the current project, obtaining a type definition file of the new component library, obtaining attribute information of components in the new component library from the type definition file, and storing the attribute information of the components in the new component library in the configuration file of the current project; and mapping interface definition information in the attribute information of the components in the new component library into a data structure of an object type, mapping values in the attribute information of the components in the new component library into a data structure of an array type to obtain a target data structure, and responding to a calling request of a target component in the new component library. And determining attribute information of the target component according to the target data structure, and calling the target component according to the attribute information of the target component. By adopting the method, the component library can be converted into the standard tool which can be directly called in real time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, and storage medium for invoking a component library. Background Technology

[0002] In the field of software development, a component library is a collection of independent, reusable, and standardized software modules (i.e., components) along with accompanying documentation and calling specifications. Its core value lies in reducing the cost of repetitive development and ensuring the consistency of the interface and functions. It is widely used in front-end UI (User Interface) development, back-end service encapsulation, and other scenarios. According to the scope of use, it can be divided into two main categories: open-source third-party component libraries and enterprise internal private component libraries.

[0003] To address the need for intelligent coding related to component libraries, developers currently widely use AI programming assistants to improve efficiency. However, these AI (Artificial Intelligence) programming assistants lag behind in updating their knowledge of third-party UI component libraries, especially providing extremely poor support for proprietary component libraries within enterprises. Developers are forced to frequently switch between IDEs (Integrated Development Environments) and component documentation, manually writing code, which severely slows down the development process. Summary of the Invention

[0004] Therefore, it is necessary to provide a method, apparatus, computer device, and storage medium for calling a component library that can be converted into a standard tool that can be directly called in real time, in order to address the above-mentioned technical problems.

[0005] Firstly, this application provides a method for calling a component library, including: Listen to the configuration file of the current project. When a new component library declaration is detected in the configuration file of the current project, retrieve the type definition file of the new component library. The property information of the components in the new component library is obtained from the type definition file, and the interface definition information in the property information of the components in the new component library is mapped to the data structure of the object type. The values ​​in the property information of the components in the new component library are mapped to the data structure of the array type to obtain the target data structure. In response to a call request for a target component in a new component library, the target component's attribute information is determined based on the target data structure, and the target component is called based on the target component's attribute information.

[0006] In one embodiment, in response to a call request for a target component in a new component library, before determining the attribute information of the target component based on the target data structure, the component library call method further includes: Extract the component annotation information from the attribute information into the description field in the target data structure.

[0007] In one embodiment, the method for invoking the component library further includes: In response to the installation command for the new component library, the code package of the new component library is downloaded to the dependency installation directory of the current project; Obtain the type definition file for the new component library, including: Locate the dependency installation directory of the current project using the scanner; Obtain the entry file for the new component library from the current project's dependency installation directory; Obtain the type definition file from the entry file.

[0008] In one embodiment, the method for invoking the component library further includes: Parse the type definition files of the new component library into an abstract syntax tree; Retrieve the property information of the new component in the component library from the type definition file, including: Retrieve the property information of the components in the new component library from the abstract syntax tree corresponding to the new component library.

[0009] In one embodiment, the method for invoking the component library further includes: Merge the abstract syntax tree corresponding to the new component library into the abstract syntax tree corresponding to the current project; Retrieve the property information of components in the new component library from the abstract syntax tree corresponding to the new component library, including: Retrieve the property information of components in the new component library from the abstract syntax tree corresponding to the merged current project.

[0010] In one embodiment, in response to a call request for a target component in a new component library, the attribute information of the target component is determined according to the target data structure, and the target component is called according to the attribute information, including: In response to a call request for a target component in a new component library, determine the target component's attribute information based on the target data structure and obtain the current code context in which the target component resides; The target component is invoked based on its property information and the current code context.

[0011] In one embodiment, the configuration file of the current project is monitored, including: Listen for dependency declaration fields in the current project's configuration file; The component library's calling methods also include: Obtain the version information of the component library corresponding to the target data structure; When the version information of the component library in the dependency declaration field is found to be inconsistent with the version information of the component library corresponding to the target data structure, it is determined that a new component library declaration information has appeared in the configuration file of the current project.

[0012] Secondly, this application provides a component library invocation device, comprising: The listening module is used to listen to the configuration file of the current project. When it detects the declaration information of a new component library in the configuration file of the current project, it retrieves the type definition file of the new component library. The mapping module is used to obtain the attribute information of the components in the new component library from the type definition file, and map the interface definition information in the attribute information of the components in the new component library to the data structure of the object type, and map the values ​​in the attribute information of the components in the new component library to the data structure of the array type, so as to obtain the target data structure. The calling module is used to respond to the calling request of the target component in the new component library, determine the attribute information of the target component according to the target data structure, and call the target component according to the attribute information of the target component.

[0013] In a third aspect, this application provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method for invoking a component library provided in any embodiment of the first aspect of this application.

[0014] In a fourth aspect, this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method for invoking a component library provided in any embodiment of the first aspect of this application.

[0015] The aforementioned component library invocation method, device, computer equipment, and storage medium monitor the configuration file of the current project. When a new component library declaration is detected in the configuration file, the type definition file of the new component library is obtained. The attribute information of the components in the new component library is retrieved from the type definition file. The interface definition information of the component attributes is mapped to an object-type data structure, and the values ​​of the component attributes are mapped to an array-type data structure, resulting in a target data structure. In response to a call request from a target component in the new component library, the attribute information of the target component is determined based on the target data structure, and the target component is invoked based on its attribute information. This application, by mapping the interface definition of component attributes to object types and the values ​​to array types, generates a target data structure recognizable by the AI ​​programming assistant. This enables support for various component libraries. Through the monitoring, conversion, and invocation process, the manual writing of component invocation adaptation code is eliminated, and the component library is transformed into a directly invoked standard tool in real time. Attached Figure Description

[0016] Figure 1 This is a flowchart illustrating the method of calling the component library in some embodiments; Figure 2 This is a structural block diagram of the component library invocation device in some embodiments; Figure 3 This is a diagram showing the internal structure of a computer device in some embodiments. Detailed Implementation

[0017] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0018] In the first aspect, this application provides a method for calling a component library, which will be described using an example of its application to a terminal, including the following steps: Step S11: Listen to the configuration file of the current project. When a new component library declaration is detected in the configuration file of the current project, obtain the type definition file of the new component library.

[0019] Calling the component library refers to the process by which developers, in an integrated development environment, follow the pre-defined syntax rules and interface protocols of the component library, and embed the target module in the component library into the current development project by introducing component dependencies, configuring component parameters, and calling component methods. This process is a key step in realizing component reuse, and its execution efficiency and accuracy directly affect the overall development progress and code quality.

[0020] A project refers to a software development vehicle with specific functions built by developers based on an integrated development environment, which includes all development elements such as source code, configuration files, and dependency libraries.

[0021] The configuration file for the current project refers to the file in the current development platform used to define project dependencies, runtime parameters, and build rules.

[0022] The declaration information of a component library refers to the identification information such as the component library name, version number, and dependency path recorded in the configuration file, which is used to clarify the component library and version specifications introduced in the project.

[0023] The new component library declaration information refers to the component library declaration information added to the configuration file that was not previously monitored or captured.

[0024] Type definition files are files used to describe interface information such as component properties, methods, and events in the component library, and can support IDEs to implement functions such as component property hints and syntax validation.

[0025] Specifically, this application can perform continuous monitoring on the configuration file of the current project, such as the package.json file, to monitor changes in the declaration information of the component library within the file in real time.

[0026] When a new component library declaration is detected in the package.json file, the type definition file corresponding to that new component library is retrieved.

[0027] Step S12: Obtain the attribute information of the components in the new component library from the type definition file, map the interface definition information in the attribute information of the components in the new component library to an object type data structure, and map the values ​​in the attribute information of the components in the new component library to an array type data structure to obtain the target data structure.

[0028] Among them, the component's attribute information refers to all the data recorded in the component library type definition file that describes the component's functional characteristics, including the component's interface structure, attribute value range, comments, and other content.

[0029] The target data structure refers to the standardized data carrier obtained by structurally transforming the component attribute information in the new component library type definition file. Specifically, it is the data structure formed by mapping interface definition information to object type structure and attribute values ​​to array type structure.

[0030] This application can be based on the standardized structure, i.e. the target data structure, pre-defined by MCP (Model Context Protocol). Its format and field definitions follow the MCP's specification requirements for tool description data, and can be directly recognized and parsed by AI programming assistants compatible with this protocol.

[0031] Interface definition information refers to descriptive information used to standardize the structure of component input and output parameters.

[0032] An object-type data structure is a structured carrier that organizes data in key-value pairs. It can be used to store associated information such as parameter names and parameter types of component interfaces.

[0033] The values ​​in the attribute information refer to the set of legal values ​​allowed for the component's attributes.

[0034] An array-type data structure is a structured carrier that organizes data in the form of an ordered list and can be used to store the legal value options of component properties.

[0035] Specifically, this application can extract the attribute information corresponding to each component in the new component library from the type definition file of the new component library, covering interface definitions, attribute values, JSDoc comments, etc. It identifies the interface definition information (such as interface Props) in the attribute information and maps it to an object-type data structure to store the interface parameter configuration. It extracts the valid attribute values ​​(such as size: "large" | "small") from the attribute information and maps them to an array-type data structure to form an enumeration list of attribute values.

[0036] For example, this application can map interface Props to object (object type) input parameters. It can also map the literal type size: "large" | "small" to an array-type data structure.

[0037] Step S13: In response to the call request of the target component in the new component library, determine the attribute information of the target component according to the target data structure, and call the target component according to the attribute information of the target component.

[0038] The invocation request refers to the action of a developer entering the identifier of a target component in the integrated development environment (IDE). This action triggers the IDE to send an instruction to the AI ​​coding assistant to retrieve component attribute information and generate invocation code. Both the IDE and the AI ​​programming assistant are deployed on the terminal.

[0039] Specifically, this application can monitor the developer's coding operations in the IDE and capture the call requests of target components within the new component library. It then retrieves the previously generated target data structure. Based on the target data structure, it parses and determines the complete attribute information of the target component, including parameter configurations, valid value ranges, and comments. Based on the parsed attribute information, it generates component call code that conforms to syntax specifications and provides real-time feedback to the IDE for the developer to use, thus completing the call to the target component.

[0040] In one embodiment, in response to a call request for a target component in a new component library, before determining the attribute information of the target component based on the target data structure, the component library call method may further include: extracting component annotation information from the attribute information into a description field in the target data structure.

[0041] Among them, the component annotation information in the attribute information refers to the text information written in the new component library type definition file using standardized annotation syntax, which is used to explain the component's function, attribute purpose, and parameter constraints.

[0042] The description field refers to a pre-defined field in the target data structure specifically used to carry component annotation information. It is the core data source for the AI ​​programming assistant to display component descriptions to developers.

[0043] Specifically, this application can simultaneously identify and extract component annotation information from the attribute information during the process of extracting component attribute information from the type definition file. The target data structure is then retrieved. The extracted component annotation information is filled into the corresponding description field of the target data structure, completing the target data structure. Subsequently, when responding to a target component call request, the component attribute information is determined based on the completed target data structure.

[0044] The beneficial effects of this embodiment are: enabling the target data structure to carry annotation information, providing a data source for component function descriptions for the AI ​​programming assistant, ensuring the integrity of intelligent prompts, and improving coding efficiency.

[0045] In one embodiment, the method for invoking the component library may further include: in response to an installation instruction for the new component library, downloading the code package of the new component library to the dependency installation directory of the current project, and obtaining the type definition file of the new component library, including: locating the dependency installation directory of the current project using a scanner, obtaining the entry file of the new component library from the dependency installation directory of the current project, and obtaining the type definition file based on the entry file.

[0046] Installation instructions refer to the operation commands that developers execute in the integrated development environment or terminal to add new component libraries to the current project's dependencies.

[0047] A code package refers to the complete release package of a new component library, which includes the component source code, type definition files, resource files, and configuration manifests.

[0048] The dependency installation directory refers to a fixed directory that is pre-defined in the current project to store all installed dependency packages.

[0049] The scanner refers to the program module deployed in this technical solution, which has the ability to traverse directories and identify files, and is used to locate target files in the dependent installation directory.

[0050] The entry file refers to the core configuration file specified in the component library code package, which records key information such as the module structure and type definition file paths of the component library.

[0051] Specifically, this application can listen for and respond to installation instructions for new component libraries, download the corresponding component library code package, and store it in the dependency installation directory of the current project. It then starts a scanner to locate the dependency installation directory of the current project. Within the dependency installation directory, it searches for the new component library code package, identifies and obtains the component library's entry file. The entry file is parsed to extract the type definition file path information contained within. Based on this path, the corresponding type definition file is retrieved from the component library code package.

[0052] The advantage of this embodiment is that by locating the type definition file based on the entry file using a scanner, the accuracy of file acquisition is guaranteed.

[0053] In one embodiment, the method for calling the component library may further include: parsing the type definition file of the new component library into an abstract syntax tree, and obtaining the attribute information of the components in the new component library from the type definition file, including: obtaining the attribute information of the components in the new component library from the abstract syntax tree corresponding to the new component library.

[0054] An Abstract Syntax Tree (AST) is a tree-like data structure generated by abstracting the source code of a type definition file according to its syntactic structure. Each node in the tree corresponds to a syntactic unit in the source code and can accurately represent the syntactic logic and semantic information of the code.

[0055] Specifically, after obtaining the type definition file of the new component library, this application can call a syntax parser to parse the file and generate the corresponding abstract syntax tree. The node structure of the abstract syntax tree is traversed to locate and extract target nodes related to component attributes, including interface definition nodes, attribute value nodes, and comment nodes. From these target nodes, the component's interface definition information, attribute value ranges, comment descriptions, and other attribute information are extracted, providing a data source for subsequent data structure mapping.

[0056] The beneficial effect of this embodiment is that, based on the parsing of attribute information using an abstract syntax tree, the syntax logic of the type definition file can be accurately identified.

[0057] In one embodiment, the method for calling the component library may further include: merging the abstract syntax tree corresponding to the new component library into the abstract syntax tree corresponding to the current project, and obtaining the attribute information of the components in the new component library from the abstract syntax tree corresponding to the new component library, including: obtaining the attribute information of the components in the new component library from the merged abstract syntax tree corresponding to the current project.

[0058] The abstract syntax tree corresponding to the current project refers to the tree-shaped data structure generated after parsing all the source code in the current development project. This structure fully represents the code syntax logic, module dependencies, and semantic information of the current project, and is the core data carrier for the IDE to implement code prompts and syntax verification.

[0059] Specifically, this application can perform syntax parsing on the type definition file of the new component library to generate an abstract syntax tree corresponding to the new component library. It then retrieves the project-level abstract syntax tree already built for the current project. Following preset syntax merging rules, it integrates the nodes of the new component library's abstract syntax tree into the corresponding module positions of the current project's abstract syntax tree, forming a merged project abstract syntax tree. Finally, it traverses the merged abstract syntax tree, locates the node area corresponding to the new component library, and extracts attribute data such as the component's interface definition, property values, and comment information.

[0060] The advantages of this embodiment are as follows: Attribute information extracted from the merged abstract syntax tree can be directly associated with existing type definitions and dependencies within the project, improving the accuracy of attribute information and ensuring that the intelligent code suggestions conform to the project's actual coding standards. It eliminates the need to maintain multiple abstract syntax trees separately, reducing memory usage and parsing time, improving the IDE's real-time response speed, and adapting to the low-latency requirements of intelligent coding.

[0061] In one embodiment, in response to a call request for a target component in a new component library, determining the attribute information of the target component based on the target data structure, and calling the target component based on the attribute information of the target component, includes: in response to a call request for a target component in a new component library, determining the attribute information of the target component based on the target data structure, obtaining the current code context in which the target component is located, and calling the target component based on the attribute information of the target component and the current code context.

[0062] The current code context refers to the part of the code that the developer is currently writing.

[0063] Specifically, this application can listen for and capture new component library call requests triggered by developers in the IDE. Based on a preset target data structure, it parses and determines the complete attribute information of the target component. It extracts the current code context corresponding to the target component call location, covering module dependencies, variable declarations, syntax rules, etc. Combining the target component attribute information with the current code context, it generates component call code that conforms to the project's coding standards. The generated call code is then fed back to the IDE's code editing interface in real time, completing the call to the target component.

[0064] The beneficial effect of this embodiment is that by generating component call code in conjunction with the current code context, the compatibility of the generated code with the existing code logic of the project can be guaranteed, and syntax errors or missing dependencies can be avoided.

[0065] In one embodiment, monitoring the configuration file of the current project includes: monitoring the dependency declaration field in the configuration file of the current project. The component library calling method may also include: obtaining the version information of the component library corresponding to the target data structure. When the version information of the component library in the dependency declaration field is inconsistent with the version information of the component library corresponding to the target data structure, it is determined that a new component library declaration information has appeared in the configuration file of the current project.

[0066] Among them, the dependency declaration field refers to the specific field in the current project configuration file used to record the name, version number, and dependency type of the third-party resources such as component libraries and toolkits that the project depends on.

[0067] Specifically, this application can continuously monitor the dependency declaration fields in the current project configuration file to obtain the name and version information of the component library within the fields in real time. It extracts the version information of the corresponding component library already stored in the target data structure and establishes a version information comparison benchmark. The component library version information in the monitored dependency declaration fields is then compared with the version information in the target data structure for consistency verification. When the verification result is inconsistent, it is determined that new component library declaration information has been detected, triggering the subsequent process of obtaining type definition files.

[0068] The advantages of this embodiment are as follows: by triggering the process through version information comparison, the version iteration of the component library can be accurately identified, avoiding the problem of attribute information becoming invalid due to version updates, and ensuring the timeliness of intelligent coding prompts. Developers do not need to manually trigger update operations, achieving automated detection of component library version changes.

[0069] In a second aspect, this application provides a means for calling a component library, such as... Figure 2 As shown, the component library's invocation mechanism includes: a listening module 21, a mapping module 22, and an invocation module 23, wherein: Listening module 21 is used to listen to the configuration file of the current project. When it detects the declaration information of a new component library in the configuration file of the current project, it retrieves the type definition file of the new component library. The mapping module 22 is used to obtain the attribute information of the components in the new component library from the type definition file, and map the interface definition information in the attribute information of the components in the new component library to the data structure of the object type, and map the values ​​in the attribute information of the components in the new component library to the data structure of the array type, so as to obtain the target data structure. Module 23 is invoked in response to a call request for a target component in the new component library. It determines the attribute information of the target component based on the target data structure and invokes the target component based on the attribute information.

[0070] In one embodiment, the listening module 21 can also extract the component annotation information in the attribute information into a description field in the target data structure.

[0071] In one embodiment, the listening module 21 can also respond to the installation command of the new component library by downloading the code package of the new component library to the dependency installation directory of the current project, locating the dependency installation directory of the current project through the scanner, obtaining the entry file of the new component library from the dependency installation directory of the current project, and obtaining the type definition file based on the entry file.

[0072] In one embodiment, the mapping module 22 can also parse the type definition file of the new component library into an abstract syntax tree and obtain the attribute information of the components in the new component library from the abstract syntax tree corresponding to the new component library.

[0073] In one embodiment, the mapping module 22 can also merge the abstract syntax tree corresponding to the new component library into the abstract syntax tree corresponding to the current project, and obtain the attribute information of the components in the new component library from the merged abstract syntax tree corresponding to the current project.

[0074] In one embodiment, the calling module 23 responds to the calling request of the target component in the new component library, determines the attribute information of the target component according to the target data structure, obtains the current code context in which the target component is located, and calls the target component according to the attribute information of the target component and the current code context.

[0075] In one embodiment, the listening module 21 can listen to the dependency declaration field in the configuration file of the current project to obtain the version information of the component library corresponding to the target data structure. When it is found that the version information of the component library in the dependency declaration field is inconsistent with the version information of the component library corresponding to the target data structure, it is determined that a new component library declaration information has appeared in the configuration file of the current project.

[0076] In a third aspect, this application provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method for invoking a component library provided in any embodiment of the first aspect of this application.

[0077] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 3As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for calling a component library. The display screen can be an LCD screen or an e-ink display screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0078] In a fourth aspect, this application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method for invoking a component library provided in any embodiment of the first aspect of this application.

[0079] The computer-readable storage medium may be Figure 3 The computer-readable storage medium in the computer device shown.

[0080] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0081] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0082] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for calling a component library, characterized in that, The method includes: Listen to the configuration file of the current project. When a new component library declaration is detected in the configuration file of the current project, obtain the type definition file of the new component library. Obtain the attribute information of the components in the new component library from the type definition file, map the interface definition information in the attribute information of the components in the new component library to an object type data structure, and map the values ​​in the attribute information of the components in the new component library to an array type data structure to obtain the target data structure; In response to a call request for a target component in the new component library, the attribute information of the target component is determined according to the target data structure, and the target component is called according to the attribute information of the target component.

2. The method according to claim 1, characterized in that, Before determining the attribute information of the target component based on the target data structure in response to a call request for the target component in the new component library, the method further includes: The component annotation information in the attribute information is extracted as a description field in the target data structure.

3. The method according to claim 1, characterized in that, The method further includes: In response to the installation command for the new component library, the code package of the new component library is downloaded to the dependency installation directory of the current project; The step of obtaining the type definition file of the new component library includes: The scanner locates the dependency installation directory of the current project; Obtain the entry file of the new component library from the dependency installation directory of the current project; Obtain the type definition file based on the entry file.

4. The method according to claim 1, characterized in that, The method further includes: The type definition file of the new component library is parsed into an abstract syntax tree; The step of obtaining the attribute information of the components in the new component library from the type definition file includes: Obtain the attribute information of the components in the new component library from the abstract syntax tree corresponding to the new component library.

5. The method according to claim 4, characterized in that, The method further includes: Merge the abstract syntax tree corresponding to the new component library into the abstract syntax tree corresponding to the current project; The step of obtaining the attribute information of the components in the new component library from the abstract syntax tree corresponding to the new component library includes: Obtain the attribute information of the components in the new component library from the abstract syntax tree corresponding to the merged current project.

6. The method according to claim 1, characterized in that, The step of responding to a call request for a target component in the new component library, determining the attribute information of the target component based on the target data structure, and calling the target component based on the attribute information includes: In response to a call request for a target component in the new component library, the attribute information of the target component is determined according to the target data structure, and the current code context in which the target component resides is obtained; The target component is invoked based on its attribute information and the current code context.

7. The method according to claim 1, characterized in that, The configuration file to be monitored for the current project includes: Listen to the dependency declaration fields in the configuration file of the current project; The method further includes: Obtain the version information of the component library corresponding to the target data structure; When the version information of the component library in the dependency declaration field is found to be inconsistent with the version information of the component library corresponding to the target data structure, it is determined that the declaration information of the new component library has appeared in the configuration file of the current project.

8. A component library invocation device, characterized in that, The device includes: The listening module is used to listen to the configuration file of the current project. When it detects the appearance of a new component library declaration in the configuration file of the current project, it retrieves the type definition file of the new component library. The mapping module is used to obtain the attribute information of the components in the new component library from the type definition file, and map the interface definition information in the attribute information of the components in the new component library to the data structure of the object type, and map the values ​​in the attribute information of the components in the new component library to the data structure of the array type, so as to obtain the target data structure. The calling module is used to respond to the calling request of the target component in the new component library, determine the attribute information of the target component according to the target data structure, and call the target component according to the attribute information of the target component.

9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.